Design Entities
Module
interface : input/output, variable, parameter, submodule을 선언한다.
functional composition : 실제 동작을 기술한다.
Module 이름 및 interface
format : module 모듈명(input_name1, input_name2,…, output_name1, outputname2…);
module 4bit_adder(a_in, b_in, sum, carry);
…
endmodule
|
input/output 정의
format : input name1, name2…; → 1bit
format : output [3:0] name1, name2…; → 4bit
input [3:0] ain, bin;
|
output 종류 정의
종류는 wire, reg이고 위에서 정의한 output과 같은 이름, 같은 bit width를 가져야 한다.
wire [2:0] out1, out2;
reg carry;
|
변수 정의
output 종류 정의와 같은 방식으로 정의한다.
parameter 정의
format : parameter 파라미터명 = 상수;
parameter RED = 1, BLUE = 2;
parameter START = 1’b0, STOP = 1’b1;
|
submodule 선언
format : module_name instance_name(input,…,output,…);
adder adder0(ain, bin, sum);
|
Logic Value
Data Type : 01XZ
X : unknown, don’t care
Z : high impedance, don’t care(in casex / casez statements)
Format
30
|
signed number, 32bits
|
-2
|
signed number, 32 bits in 2’s complement
|
2’b10
|
size of 2bits
|
8’h9a = 8’b10011010
| |
4’d11 = 4’b1011
| |
Operator
Logical Bit-wise
|
operator
|
example
|
unary negation Not
|
~
|
a = ~b
|
binary AND
|
&
|
a = b & c
|
binary OR
|
|
|
a = b | c
|
binary XOR
|
^
|
a = b ^ c
|
binary XNOR
|
^~, ~^
|
a = ~^ c
|
Reduction
|
operator
|
example
|
AND
|
&
|
a = &b
|
OR
|
|
|
a = |b
|
NAD
|
~&
|
a =~&b
|
NOR
|
~|
|
a = ~|b
|
XOR
|
^
|
a = ^b
|
XNOR
|
^~, ~^
|
a = ~^b
|
Logical Comparison
|
operator
|
example
|
NOT
|
!
|
if(!a)
|
AND
|
&&
|
if((a > b) && (a > c))
|
OR
|
||
|
if((a > b) || (a > c))
|
Concatenation & Replication
|
operator
|
example
|
concatenation
|
{}
|
a = {b, c, c}
|
replication
|
{{}}
|
a = {b, {2{c}}
|
Shift
|
operator
|
example
|
실제 사용 예
|
logical shift left
|
>>
|
a = b>>2
|
a = {2’b00, b[7:2]}
|
logical shift right
|
<<
|
a = b<<1
|
a = {b[6:0], 1’b0}
|
Conditional
|
operator
|
example
|
conditional
|
? :
|
y = (a > b) ? a : b
|
댓글 없음:
댓글 쓰기