Programming/C Win32 MFC2018. 5. 29. 11:39

갑자기 little endian인 x86 시스템에서

어떤식으로 Shift 연산자가 작동하는지 멘붕..


엔디안은 메모리에 저장하는 것이기에..

혹시 레지스터는 빅 엔디안으로 구현되는건가?

근데 수업 시간 기억으로는.. little endian이라 자릿수 늘어나도 처리가 부담없다고

그렇게 배운거 봐서는 adder도 모두 little endian인거 같긴한데..

블랙박스 부분이라 알수가 없네..


아무튼.. C 언어 레벨에서는 논리적으로는 big endian으로 처리하고

변환할 때 반대로 구현해줄줄 알았는데 그것도 아니고..(그냥 right는 SAR SHR로 구현)

도대체 어떻게 처리하는건지 알수가 없다.. ㅠㅠ


[링크 : https://code.i-harness.com/ko/q/5c375b]

[링크 : https://www.joinc.co.kr/w/Site/Network_Programing/Documents/endian]


[링크 : https://msdn.microsoft.com/ko-kr/library/336xbhcz.aspx?f=255&MSPPError=-2147217396]

[링크 : https://blogs.msdn.microsoft.com/.../hello-arm-exploring-undefined-unspecified-and-implementation-defined-behavior-in-c/]


[링크 : https://stackoverflow.com/questions/7184789/does-bit-shift-depend-on-endianness]

[링크 : https://stackoverflow.com/questions/1041554/bitwise-operators-and-endianness/1041573]


[링크 : https://www.ibm.com/developerworks/aix/library/au-endianc/index.html]


1235 page

Description

 Shifts the bits in the first operand (destination operand) to the left or right by the number of bits specified in the second operand (count operand). Bits shifted beyond the destination operand boundary are first shifted into the CF flag, then discarded. At the end of the shift operation, the CF flag contains the last bit shifted out of the destination operand. The destination operand can be a register or a memory location. The count operand can be an immediate value or the CL register. The count is masked to 5 bits (or 6 bits if in 64-bit mode and REX.W is used). The count range is limited to 0 to 31 (or 63 if 64-bit mode and REX.W is used). A special opcode encoding is provided for a count of 1. The shift arithmetic left (SAL) and shift logical left (SHL) instructions perform the same operation; they shift the bits in the destination operand to the left (toward more significant bit locations). For each shift count, the most significant bit of the destination operand is shifted into the CF flag, and the least significant bit is cleared (see Figure 7-7 in the Intel® 64 and IA-32 Architectures Software Developer’s Manual, Volume 1).

 The shift arithmetic right (SAR) and shift logical right (SHR) instructions shift the bits of the destination operand to the right (toward less significant bit locations). For each shift count, the least significant bit of the destination operand is shifted into the CF flag, and the most significant bit is either set or cleared depending on the instruction type. The SHR instruction clears the most significant bit (see Figure 7-8 in the Intel® 64 and IA-32 Architectures Software Developer’s Manual, Volume 1); the SAR instruction sets or clears the most significant bit to correspond to the sign (most significant bit) of the original value in the destination operand. In effect, the SAR instruction fills the empty bit position’s shifted value with the sign of the unshifted value (see Figure 7-9 in the Intel® 64 and IA-32 Architectures Software Developer’s Manual, Volume 1). 

[링크 : https://www.intel.com/.../64-ia-32-architectures-software-developer-instruction-set-reference-manual-325383.pdf]



case 4:

packet[4] = (val >> 24) & 0xFF;

0115687B  mov         ebx,ecx  

0115687D  sar         ebx,18h  

01156880  mov         byte ptr [edi+4],bl  

packet[5] = (val >> 16) & 0xFF;

01156883  mov         ebx,ecx  

01156885  sar         ebx,10h  

01156888  mov         byte ptr [edi+5],bl  

packet[6] = (val >> 8) & 0xFF;

0115688B  mov         ebx,ecx  

0115688D  sar         ebx,8  

01156890  mov         byte ptr [edi+6],bl  

packet[7] = (val) & 0xFF;

01156893  mov         byte ptr [edi+7],cl  

break;

01156896  jmp         $LN11+54h (11568A8h)  

break; 

흐음... 어렵다...

'Programming > C Win32 MFC' 카테고리의 다른 글

c언어용 JSON 라이브러리 목록  (0) 2018.10.23
uuid in c  (0) 2018.10.22
const char *과 char * const 차이  (0) 2018.01.31
소스 코드 포맷 적용하기  (0) 2018.01.08
win32 시리얼 통신 LPCTSTR / LPCSTR  (0) 2017.12.07
Posted by 구차니
embeded/FPGA - ALTERA2018. 5. 29. 09:47

OV7670 / HDMI / VGA

일단.. VGA 테스트 패턴 해본 다음

OV7670 따라해보고

그 다음에 천천히 HDMI 테스트 패턴 출력해봐야지..


회로도 받아야 하고..

카페 검색해보니 4bit씩 R/G/B에 되어있다고..



회로도는 구매하신분에게 한하서 공개라고 하신거 봐서는

블로그에 회로도 올리면서 무언가 작업하긴 힘들듯..

'embeded > FPGA - ALTERA' 카테고리의 다른 글

PWM 발생기 1개 연결하기  (0) 2018.05.30
signal Tap 2와 talkback?  (0) 2018.05.30
altera signalTap  (0) 2018.05.24
quartus device family 삭제하기  (0) 2018.05.23
책 도착!  (2) 2018.05.21
Posted by 구차니

HDMI 핀 배열 및 신호 관련 정보 검색


[링크 : http://pinouts.ru/visual/gen/hdmi.jpg]

[링크 : http://pinouts.ru/Video/hdmi_pinout.shtml]


TMDS는 0/1/2+CLK로 구성되고

CEC와 DDC 그리고 Hotplug 및 5V 전원이 공급된다.

Pins 1 through 9 carry the three TMDS data channels (Transition Minimized Differential Signaling – the technology that allows DVI and HDMI to send high-speed digital data), three pins per channel. TMDS data includes both video and audio information, and each channel has three separate lines for + values, - values, and a ground or data shield.


Pins 10 through 12 carry data for the TMDS clock channel, which helps keep the signals in synchronization. As with the TMDS data channels, there are separate lines for + values, - values, and a data shield.


Pin 13 is carries the CEC (Consumer Electronics Control) channel, used for sending command and control data between connected devices.


Pin 14 is reserved for future use.


Pins 15 and 16 are dedicated to the DDC (Display Data Channel), used for communicating EDID (Extended Display Identification Channel) information between devices.


Pin 17 is a data shield for the CEC and DDC channels.


Pin 18 carries a low-voltage (+5V) power supply.


Pin 19 is the Hot Plug Detect, dedicated to monitoring power up/down and plug/unplug events. 

[링크 : https://www.hdmi.org/installers/insidehdmicable.aspx]


데이터는 8b/10b로 인코딩 됨

Both HDMI and DVI use TMDS to send 10-bit characters that are encoded using 8b/10b encoding

[링크 : https://en.wikipedia.org/wiki/HDMI]


2.8V~3.3V로 표현.. TMDS니까 디퍼런셜 라인의 경우 어떻게 표현되려나?

디지털이니까 0과 1만 뒤집어 주면 되려나?

Basics

 HDMI leverages on the successful transition minimized differential signaling (TMDS) technology. The differential signals are +3.3 Volts, terminated in 50 Ω with nominal amplitude transitions of 500 mV (+2.8 V to +3.3 V). The voltage swing can vary from 150 mV to 800 mV. The signals have rise times of the order of 100 ps 

[링크 : http://download.tek.com/document/61W_17974_6_HR_Letter_0.pdf]


6.2.2 Video Control Signals : HSYNC, VSYNC

During the Data Island period, HDMI carries HSYNC and VSYNC signals using encoded bits on Channel 0. During Video Data periods, HDMI does not carry HSYNC and VSYNC and the Sink should assume that these signals remain constant. During Control periods, HDMI carries HSYNC and VSYNC signals through the use of four different control characters on TMDS Channel 0. 

[링크 : http://d1.amobbs.com/bbs_upload782111/files_51/ourdev_716302E34B9Q.pdf]


BGR 순서로 채널이 배정되는게 맞는 듯?

[링크 : http://www.wireworldcable.co.uk/hdmi_tech.html]


[링크 : https://www.cablestogo.com/learning/library/digital-signage/intro-to-tmds]

'이론 관련 > 컴퓨터 관련' 카테고리의 다른 글

VGA(RGB) 파형 측정  (0) 2018.05.30
VGA Pattern Generator 관련 검색  (0) 2018.05.30
VGA 관련 자료 검색중  (0) 2018.05.29
I2c smbus slave interrupt  (0) 2018.04.24
haze / defog  (0) 2018.03.19
Posted by 구차니

640*480에 대한 VHDL 코드 인듯?

0.1 + 0.2 + 0.4V 합치면 0.7V 니까.. 3비트 씩 해서 8(2^3)  * 8 * 8 = 512 컬러 인가?

A VGA video signal contains 5 active signals:

• horizontal sync: digital signal, used for synchronisation of the video

• vertical sync: digital signal, used for synchronisation of the video

• red (R): analog signal (0-0.7 v), used to control the color

• green (G): analog signal (0-0.7 v), used to control the color

• blue (B): analog signal (0-0.7 v), used to control the color 

흐음.. 이건 어떻게 해석을 해야 하나?


[링크 : http://lslwww.epfl.ch/pages/teaching/cours_lsl/ca_es/VGA.pdf]



요즘 사용하는건 I2C 들어간 DDC2 방식이라고 해야하나?

[링크 : https://en.wikipedia.org/wiki/Display_Data_Channel]

[링크 : http://pinouts.ru/Video/VGA15_pinout.shtml]

'이론 관련 > 컴퓨터 관련' 카테고리의 다른 글

VGA Pattern Generator 관련 검색  (0) 2018.05.30
hdmi pinout  (0) 2018.05.29
I2c smbus slave interrupt  (0) 2018.04.24
haze / defog  (0) 2018.03.19
USB class - DFU(Device Firmware Upgrade)  (0) 2017.12.26
Posted by 구차니

아내님 병원 검진 때문에 월차냈는데

반차내려다가 오전에 안 끝날꺼 같아서 월차내길 잘한듯


암튼 오후에 시간이 좀 남아서 간만에 드론을 날렸는데

어제는 아파트 공원에서 날리다가 프로펠러 가드 두개 날리고

오늘은 배터리 부족으로 급상승 하려던 중 배터리 부족으로 추락하여

가드 두개 다리 두개 날려먹음

거기다가 배터리 하나는 부풀어 올라서 폐기헤야 할 듯 하고

하나는 아까 급 방전으로 추락한 녀석..


솔찍히 시간 안보고 날려서 얼마나 날린진 모르겠지만

안전을 위해서 배터리는 사야할듯 ㅜㅜ (3만 ㅠㅠ)

프로펠러 가드랑 다리 사려니 속 쓰리네..


+

2018.05.29

배가 댕글떙글 부은 배터리 ㅠㅠ


'개소리 왈왈 > 육아관련 주저리' 카테고리의 다른 글

체력 오링..  (0) 2018.06.06
피곤피곤..  (0) 2018.06.02
주말이 머했는데 끝나냐...  (0) 2018.05.27
대충대충 한쪽벽면 보온벽지 시공  (0) 2018.05.26
아내님의 꿈 프론토 웨건 중고구매  (6) 2018.05.23
Posted by 구차니

아직도 정신이 안들었는데

잠들려고 보니 주말이 끝...


Q: 도대체 무슨일이 일어난거냐...



A : 아내님 뻗고 홀로 애 봄. ㄷㄷㄷ

Posted by 구차니

아내님이 애 데리고 키즈카페 간 동안

낼름 한쪽면 시공!


자전거 타이어 자국남아있던 곳이라 그런지

시공하니 확실히 깨끗해 보인다.



아내님 : 여기도 해줘(난이도 가장 높은 곳)

남편님 : 어... 노력은 해볼게

아내님 : 해 줘.

남편님 : 어....

Posted by 구차니
Posted by 구차니
게임/비시즈2018. 5. 24. 20:44



'게임 > 비시즈' 카테고리의 다른 글

비시즈 비행기 팁  (0) 2018.05.24
be seige - 비시즈  (0) 2018.05.20
Posted by 구차니
embeded/FPGA - ALTERA2018. 5. 24. 16:34

2018.05.30


이전과 거의 같은데 검색이 잘 안나오면

Filter에서 Design Entry(all names) 해주면 제대로 나오고


모니터링할 노드와 클럭을 정상적으로 추가해주면


아래와 같은 모습이 된다

SOF Manager 우측에는 해당 프로젝트의 SOF를 선택해주면 굳이 Programmer 가지 않아도 되니 편리함.

좌측 상단의 Instance를 누르면 Instance Manager에 버튼이 활성화 되고

Run Analysis - F5 버튼을 누르면 


약간의 시간이 지난뒤 아래와 같이 파형이 나온다

(일단 div/2 로 LED를 점멸하게 소스를 수정함)



//=======================================================

//  This code is generated by Terasic System Builder

//=======================================================

module PwmCtrl(RST_N, CLK, LED0);

input RST_N, CLK;

output LED0;

reg[27:0] counter0;

always @(negedge RST_N or posedge CLK)

begin

if(RST_N == 1'b0)

begin

counter0 <= 0;

end else begin

counter0 <= counter0 + 1;

end

end

assign LED0 = counter0[1];


endmodule


module DE0_NANO(

//////////// CLOCK //////////

CLOCK_50,

//////////// LED //////////

LED,

//////////// KEY //////////

KEY 

);


//=======================================================

//  PARAMETER declarations

//=======================================================


//=======================================================

//  PORT declarations

//=======================================================


//////////// CLOCK //////////

input           CLOCK_50;

//////////// LED //////////

output      [7:0] LED;

//////////// KEY //////////

input      [1:0] KEY;


//=======================================================

//  REG/WIRE declarations

//=======================================================


//=======================================================

//  Structural coding

//=======================================================

PwmCtrl pwm0(KEY[0],CLOCK_50,LED[0]);

endmodule 



---

LE와 M4K 이런거 소모해서

내부적으로 로직을 저장하고 디버깅에 도움을 주는 녀석


Tools - Signal Tap Logic Analyzer


우측 상단의 JTAG Chain Configuration 에서 DE0-nano의 USB-Blaster를 선택하면

자동으로 Device는 검색되는데, 정상적으로 안되면 Scan Chain을 눌러주면 된다.


오른쪽 중앙의 Signal Configuration 에서 Clock을 설정해주고

왼쪽의 auto_signaltap_0 에 "Double-click to add nodes"를 더블클릭해 모니터링할 노드를 추가한다.


그럼 상단에 컴파일 하라고 빨간색으로 뜨고


저장하면 stp 확장자(SignalTaP 약자인듯?)로 설정을 저장하게 하고


프로젝트 연동하도록 도와준다.



[링크 : http://pages.hmc.edu/harris/class/e155/SignalTap.pdf]

[링크 : https://www.altera.com/content/dam/altera-www/global/en_US/pdfs/literature/ug/signal.pdf]


+

2018.06.05

간단한 녀석으로 해보니 (hsync + vsync + 20bit 카운터 + 4비트 rgb)

8K 까지는 빌드가 되지만, 16K 부터는 아래와 같은 에러가 발생하며 중단된다.

Error (170048): Selected device has 66 RAM location(s) of type M9K.  However, the current design needs more than 66 to successfully fit

Error (171000): Can't fit design in device 


대신 저장할 항목을 줄이고(hsync + vsync) 32K로는 성공


즉, singaltap의 sample depth는 저장할 신호당 용량이기에

저장할 노드 갯수 * sample depth 만큼의 용량을 필요로 하게 된다.


+

2018.06.05

Signal Tap의 Enable을 꺼주면 빌드시 시간이 줄어든다(말그대로 Signal Tap 비활성화)

'embeded > FPGA - ALTERA' 카테고리의 다른 글

signal Tap 2와 talkback?  (0) 2018.05.30
레몬 라이트 옵션보드 도착  (2) 2018.05.29
quartus device family 삭제하기  (0) 2018.05.23
책 도착!  (2) 2018.05.21
엥.. Quartus II Lite Edition... 라이센스?  (0) 2018.05.18
Posted by 구차니