Verilog HDL
2007/05/31 19:15
http://blog.naver.com/PostPrint.nhn?blogId=babojay&logNo=40038206543#
Capter 2
Hierachical
Modeling Concepts
Objectives
- Top-Down & Bottom-Up ¼³°è¹æ¹ý
-
Module°ú Module instanceÀÇ Â÷ÀÌ
- Behavioral, Data flow, Gate,
SwitchÀÇ ³× °³ÀÇ Ãß»óÈ·¹º§À» ¼³¸íÇÑ´Ù.
- ½Ã¹Ä·¹À̼ǿ¡ ÇÊ¿äÇÑ ¿ä¼Ò¸¦ ¼³¸íÇÏ°í Stimulus block°ú Design
blockÀ» Á¤ÀÇÇÏ°í Stimulus¸¦ Àû¿ëÇÏ´Â µÎ°¡Áö ¹æ¹ý¿¡ ´ëÇØ ¼³¸íÇÑ´Ù.
2.1 ¼³°è ¹æ¹ý·Ð
±×¸² 2.1 Top-Down Design Methodology
±×¸² 2.2 Bottom-Up Design Methodology
ÀϹÝÀûÀ¸·Î ½ÇÁ¦ ¼³°èÇöÀå¿¡¼´Â µÎ °¡Áö ¹æ¹ýÀÌ ÀûÀýÇÏ°Ô ¼¯¿© »ç¿ëµÈ´Ù. Top-level blockÀÇ ½ºÆåÀ» Á¤ÀÇÇÏ°í ±â´ÉÀ» ÀûÀýÈ÷ ³ª´©°í ÂÉ°³¾î Sub-blockÀ¸·Î ¹èÁ¤ÇÏ´Â Àå¾÷ÀÌ ÀÌ·ç¾îÁö´Â µ¿½Ã¿¡ ÇÊ¿ä·ÎÇÏ´Â ±âº»È¸·Î(±âÃÊȸ·Î)µéÀÇ ¼³°è¿Í ÃÖÀûÈ°¡ ÀÌ·ç¾îÁø´Ù. ÀÌ·± ¼³°èÀÇ È帧ÀÌ Áß°£¿¡ ¸¸³ª¸é¼ ÀüüÀûÀ¸·Î µðÀÚÀÎÀÌ ¿Ï¼ºµÈ´Ù.
2.2 4-bit Ripple Carry Counter
±×¸² 2.3 Ripple Carry Counter
À§ ±×¸²ÀÇ Ripple carry counter´Â 4°³ÀÇ negative edge triggered T F/FÀ¸·Î ¸¸µé¾îÁø´Ù. °¢°¢ÀÇ T F/F´Â negative edge triggered D F/F¿Í Inverter·Î ¸¸µé ¼ö ÀÖ´Ù.(±×¸² 2.4)
±×¸² 2.4 T-flipflop
ÀÌ°ÍÀ» °èÃþÀûÀ¸·Î Ç¥ÇöÇÏ¸é ±×¸² 2.5¿Í °°ÀÌ ³ªÅ¸³¾ ¼ö ÀÖ´Ù.
±×¸² 2.5 4-bit ripple carry counterÀÇ °èÃþ±¸Á¶
Top-down ¼³°è ¹æ¹ý : Ripple carry counter ±â´É Á¤ÀÇ > T-F/FÀ¸·Î counter±¸Çö >
D-F/F°ú inverter·Î T-F/F±¸Çö
Bottpm-up ¼³°è ¹æ¹ý : D-F/F°ú Inverter·Î T-F/F±¸Çö >
T-F/FÀ¸·Î counter±¸Çö
D-F/FÀ» OR¿Í AND °ÔÀÌÆ®·Î ±¸ÇöÇϰųª TRÀ» °¡Áö°í ±¸ÇöÇÏ´Â ¹æ¹ýµéµµ Æ÷ÇÔ µÉ ¼ö ÀÖ´Ù.
2.3 Modules
- Module : Basic Building Block. DesignÀÇ elementÀ̱⵵ ÇÏ¸é¼ ÇÏÀ§ blockÀÇ Á¶ÇÕÀ̱⵵ ÇÏ´Ù. Design¿¡¼ ÀÚÁÖ ¹Ýº¹ »ç¿ëµÇ¾îÁö´Â functional blockÀÌ º¸Åë Module·Î ÀÌ·ç¾îÁø´Ù. ¾Õ¿¡ÀÇ ¿¹¿¡¼ ripple carry counter, T FF, D FF µîÀÌ ¸ðµÎ moduleÀÌ´Ù.
±×¸² 2.6 Module Concepts
* Port Interface : »óÀ§¿Í ÇÏÀ§, ³»ºÎ¿Í ¿ÜºÎÀÇ Á¤º¸Àü´Þ¿¡ ´ëÇÑ Á¤ÀÇ
** Internal Net : Àüü
Design¿¡ ¿µÇâÀ» ¹ÌÄ¡Áö ¾Ê°í interface¸¦ ¼öÁ¤ÇÏÁö ¾Ê´Â ¹üÀ§¿¡¼ ¾ðÁ¦³ª ¼öÁ¤
°¡´É
Syntax
module <module_name>
(<module_terminal_list>);
...
<module internals>
...
endmodule
Example of T_FF
module T_FF (q, clock,
reset);
.
<functionality of
T-flipflop>
.
endmodule
ModuleÀÇ ³»ºÎ´Â ´ÙÀ½ 4 °¡Áö ·¹º§·Î ±â¼úÀÌ °¡´ÉÇÏ´Ù.
- Behavioral or algorithmic level
ÃÖ»óÀ§ Ãß»ó°èÃþ. C¿Í À¯»çÇϸç H/W¿¡ ´ëÇÑ
°í·Á ¾øÀÌ ¿øÇÏ°íÀÚ ÇÏ´Â ¾Ë°í¸®ÁòÀû ±â¼ú
- Dataflow level
Register°£ dataÀÇ Àü´Þ°ú
󸮿¡ ´ëÇÑ ±â¼ú
- Gate level(ÃÖÁ¾°á°ú´Ü°è)
Logic gate¿Í ±×µé°£ÀÇ
»óÈ£¿¬°á(interconnection)À» Á¤ÀÇ. °íÀüÀû ³î¸®È¸·Î¼³°è¿Í À¯»ç
- Switch level
ÃÖÇÏÀ§
°èÃþÀ¸·Î Switch, Storage node¸¦°ú ±×µé°£ÀÇ »óÈ£¿¬°á·Î Á¤ÀÇ
2.4 Instances
ModuleÀ» Á¤ÀÇÇÏ°í ¹Ù·Î »ç¿ëÇÒ ¼ö ¾ø´Ù. ModuleÀº ±¸Á¶Àû ±â´ÉÀû Á¤ÀÇÀÏ»ÓÀÌ´Ù.
Á¤ÀÇµÈ ModuleÀ» »ç¿ëÇϱâ À§Çؼ´Â
InstantiationÀÌ ÇÊ¿äÇÏ´Ù.
À§ÀÇ ¿¹¿¡¼ T_FF´Â ¸ðµâÀÇ Á¤ÀǶó°í º¸¸é µÈ´Ù. tff0, tff1, tff2, tff3 ¸ðµÎ
T_FFÀÇ instanceÀÌ´Ù. µðÀÚÀο¡¼ ½ÇÁ¦ µ¿ÀÛÇÏ´Â °ÍµéÀº ¸ðµÎ instancesÀÌ´Ù.
Example 2-1
module ripple_carry_counter(q, clk, reset);
output [3:0] q;
input clk, reset;
T_FF tff0(q[0], clk,
reset);
T_FF tff1(q[1], q[0],
reset);
T_FF tff2(q[2], q[1],
reset);
T_FF tff3(q[3], q[2], reset);
endmodule
module T_FF (q, clk, reset);
output
q;
input clk, reset;
wire
d;
D_FF dff0(q, d, clk,
reset);
not n1(d, q);
endmodule
2.5 Components of a Simulation
Stimulus Block : ½ÃÇèÀ» À§ÇÑ
Stimulus¿Í °á°ú¸¦ ÃøÁ¤Çϱâ À§ÇÑ ºÎºÐÀ» Æ÷ÇÔÇÏ´Â ºí·°
* Design block°ú´Â ºÐ¸®ÇÏ¿© ¼³°èÇÏ´Â ½À°üÀÌ ÇÊ¿äÇÏ´Ù
±×¸² 2.7 2 types of Stimulus Block
2.6 Example
2.6.1 Design Block
module ripple_carry_counter(q, clk, reset);
output [3:0]
q;
input clk, reset;
T_FF tff0(q[0], clk,
reset);
T_FF tff1(q[1], q[0],
reset);
T_FF tff1(q[2], q[1],
reset);
T_FF tff1(q[3], q[2], reset);
endmodule
module T_FF(q, clk, reset);
output
q;
input clk, reset;
wire
d;
D_FF dff0(q, d, clk,
reset);
not n1(d, q);
endmodule
module D_FF(q, d, clk, reset);
output
q;
input d, clk, reset;
reg
q;
always @(posedge
reset or negedge clk)
if
(reset)
q =
1'b0;
else
q
= d;
endmodule
2.6.2 Stimulus Block
±×¸² 2.7°ú °°Àº ÆÄÇüÀ¸·Î Stimulus¸¦ ÀÛ¼ºÇÑ´Ù.
±×¸² 2.7 Stimulus and Output Waveforms
module stimulus;
reg
clk;
reg reset;
wire[3:0]
q;
ripple_carry_counter r1(q, clk, reset);
initial
clk =
1'b0;
always
#5 clk = ~clk;
initial
begin
reset = 1'b1;
#15 reset = 1'b0;
#180
reset = 1'b1;
#10 reset = 1'b0;
#20
$finish;
end
initial
$monitor($time, " Ouput q = %d", q);
endmodule
½Ã¹Ä·¹ÀÌ¼Ç °á°ú
0
output q = 0
20 output q =
1
30 output q = 2
40 output q = 3
50 output q =
4
60 output q = 5
70 output q = 6
80 output q =
7
90 output q = 8
100
output q = 9
110 output q = 10
120 output q = 11
130 output q = 12
140 output q = 13
150 output q = 14
160 output q = 15
170 output q =
0
180 output q = 1
190 output
q = 2
195 output q = 0
210 output q = 1
220 output q = 2