이번 포스팅에서는 내가 사용해보다 보니 헷갈리는 Verilog에서 숫자 표현 방식을 적어보겠다.
HDL이다 보니 10진수 이외의 2,8,16을 상당수 사용하는 부분이 보였다.
💻 Number Specification in Verilog
- 사이즈를 표시한 수 : <size>'<base format><number> ('d/'D, 'h/'H ,'b/B', 'o/'O)
4'b1111 //This is a 4-bit binary number
12'habc // This is a 12-bit hexadecimal number
16'd255 // This is a 16-bit decimal number.
- 사이즈 미표기 수 : <size> 칸이 없고 10진수를 표현한다면 <base format>도 생략이 가능하다.
23456 // This is a 32-bit decimal number by default
'hc3 // This is a 32-bit hexadecimal number
'o21 // This is a 32-bit octal number
- X or Z
X는 알수 없는 값을 의미하고 Z는 임피던스가 높다는 것을 의미한다. 저항이 높다고 받아들이면 된다.
12'h13x // This is a 12-bit hex number; 4 least significant bits unknown
6'hx // This is a 6-bit hex number
32'bz // This is a 32-bit high impedance number
- 음수 : 맨앞에 -를 붙이면 됨.
-6'd3 // 6-bit negative number stored as 2's compleent of 3
-6'sd3 // Used for performing signed integer math
- 가독성을 늘리기 위해서 언더바('_')와 물음표를 사용할 수 있다.
12'b1111_0000_1010
4'b10?? // 4'b10zz와 같다.
이제 잘랭!
'2-2 > 디지털 설계 및 실험' 카테고리의 다른 글
[디지털 설계 및 실험] 8. tasks and functions (0) | 2022.11.17 |
---|---|
[디지털 설계 및 실험] Verilog 기본 vol 6. dataflow modeling (2) | 2022.10.21 |
[디지털 설계 및 실험] Verilog 기본 vol.5 Gate-Level Modeling (0) | 2022.10.12 |
[디지털 설계 및 실험] Verilog 기본 vol4.-모듈과 포트 (1) | 2022.09.25 |
[디지털 설계 및 실험] Verilog 기본 vol.3 - System Tasks (2) | 2022.09.23 |