VHDLÀÇ ±¸¼º
±¹ÀÏÈ£¡¡
1. VHDLÀÇ ±¸¼º
VHDL¿¡ ÀÇÇÑ ¼³°èÀÇ ±âº»ÀûÀÎ ±¸¼ºÀº PACKAGE, ENTITY, ARCHITECTURE, CONFIGURATION ÀÌ´Ù. ±×¸² 1Àº VHDLÀÇ ±âº»ÀûÀÎ ±¸¼ºÀ» ³ªÅ¸³»¾ú´Ù.
±×¸² 1. VHDL¿¡ ÀÇÇÑ ¼³°èÀÇ ±¸Á¶
package ´Â VHDL ¼³°è¿¡¼ ¹Ýµå½Ã ÇÊ¿äÇÑ »çÇ×ÀÌ ¾Æ´Ñ ¼±ÅÃÀûÀ¸·Î »ç¿ëÇÏ´Â °ÍÀÌ´Ù. entity´Â ¼³°èÀÇ ÀÔÃâ·ÂÀ» ±â¼úÇÑ´Ù. ±×¸®°í architecture´Â ¼³°èÀÇ ½ÇÁ¦ ³»¿ëÀ» ´ã°í ÀÖ´Ù. ÇÑ ¼³°è¿¡´Â ´Ù¼öÀÇ package¿Í entity, architecture °¡ ÀÖÀ» ¼ö ÀÖÀ¸³ª ¼³°è¿Í ÇÕ¼ºÀ» À§Çؼ´Â ÇÑ°³ÀÇ entity¿¡ ÇÑ°³ÀÇ architecture°¡ ¦À» ÀÌ·ç´Â °ÍÀ¸·Î ÇÏ¿´´Ù. ¸¸ÀÏ ´Ù¼öÀÇ architecture¸¦ °®´Â entity°¡ ÀÖÀ» °æ¿ì configuration¿¡ ÀÇÇÏ¿© ±× ¿¬°á°ü°è(entity-architecture mapping)¸¦ ¼³Á¤ÇØ ÁÖ¾î¾ß ÇÑ´Ù. ½ÇÁ¦·Î configurationÀÇ »ç¿ëÀº VHDLÀÇ ÇÕ¼ºÈÄ post-simupation ȤÀº gate-simulation°úÁ¤¿¡¼ ¸¹ÀÌ ÀÌ¿ëµÈ´Ù.
architecture¿¡´Â º´·Ä ±¸¹® (concurrent statement)À» °®´Â´Ù. º´·Ä±¸¹®Àº ´Ù¸¥ PLD ¾ð¾î ȤÀº ³×Æ®¸®½ºÆ®¿Í °°Àº Àǹ̷μ µðÀÚÀÎ ³»¿¡¼ ±¸¹®ÀÌ ³õÀÎ À§Ä¡´Â ½Ã¹Ä·¹À̼ÇÀÇ ½ÇÇà½Ã, ȤÀº ȸ·ÎÀÇ ÇÕ¼º½Ã Àǹ̰¡ ¾ø´Ù(ÇÁ·Î±×·¡¹Ö ¾ð¾î¿¡¼´Â ±¸¹®ÀÌ ³õÀÎ ¼ø¼´ë·Î ½ÇÇàµÈ´Ù.). signalµé¿¡ ÀÇÇÏ¿© °¢ ±¸¹®¿¡ °ªÀÌ Àü´ÞµÇ¸ç signal·Î °ªÀÇ ÇÒ´ç(assignment, <= )Àº ±¸µ¿(driver)À» ÀǹÌÇÑ´Ù(ÇÁ·Î±×·¡¹Ö ¾ð¾î¿¡¼´Â ÀúÀåÀ» ÀǹÌÇÑ´Ù.). Çϵå¿þ¾î¸¦ ±â¼úÇÏ´Â ¾ð¾îÀÓ¿¡µµ ºÒ±¸ÇÏ°í VHDLÀº ¹«¾ù º¸´Ùµµ ¼øÂ÷±¸¹®(sequential statement)ÀÌ Àִٴ°ÍÀÌ °¡Àå µ¸º¸ÀÌ´Â Á¡ÀÌ´Ù. ¼øÂ÷ ±¸¹®Àº process ºí·° ³», ȤÀº function, procedure ³»¿¡¼¸¸ ±â¼úµÉ¼ö ÀÖ´Ù. (º¸Åë PLD¾ð¾î³ª ³×Æ®¸®½ºÆ®´Â º´·Ä±¸¹®¸¸ ÀÖÀ¸¸ç, ÇÁ·Î±×·¡¹Ö ¾ð¾î´Â ¸ðµÎ ¼øÂ÷±¸¹®ÀÌ´Ù.)
¼øÂ÷±¸¹®(sequential statement)Àº ÇÁ·Î±×·¡¹Ö ¾ð¾îÀÇ ¹®Àåµé°ú °°´Ù. ÀÌ·± ¼øÂ÷ ±¸¹®µéÀº ÇÁ·Î±×·¥ ³»¿¡¼ ³õ¿©Áø ¼ø¼¿¡ ÀÇ°ÅÇÏ¿© ½ÇÇàµÈ´Ù. ¼øÂ÷±¸¹®³»ÀÇ ¸ðµç °ªµéÀº º¯¼ö(variable)¿Í »ó¼ö(constant)¿¡ ÀÇÇÏ¿© À¯ÁöµÈ´Ù. processºí·° ³»ÀÇ °ªÀ» º´·Ä ±¸¹®À¸·Î Àü´Þ ÇÒ¶§¿¡´Â signalÀ» ÅëÇÏ¿© ÀÌ·ç¾î Áø´Ù.
VHDLÀÇ º´·Ä±¸¹®°ú ¼øÂ÷±¸¹®ÀÇ Â÷À̸¦ ÀÌÇØÇÏ´Â °ÍÀº ¸Å¿ì Áß¿äÇÏ´Ù. ¶ÇÇÑ ÀÌµé µÎ°¡Áö ±¸¹®¿¡¼ °ªµéÀÇ Àü´Þ ¹æ¹ýÀ» ÀÌÇØÇÏ¿©¾ß ÇÑ´Ù. º´·Ä±¸¹®¿¡¼ °ªÀÇ Àü´ÞÀº signal¿¡ ÀÇÇÏ¸ç ¼øÂ÷±¸¹® ³»¿¡¼´Â variableÀ» ÀÌ¿ëÇÑ´Ù. ¸Þ¸ð¸®(memory)³ª Çø³-Ç÷Ó(flip-flop)°°Àº ¼øÂ÷³í¸®È¸·Î(sequential logic)¿¡ ´ëÇÏ¿© ´Ù½Ã ÀÚ¼¼È÷ ³íÀÇÇϱâ·Î ÇÑ´Ù. VHDL¿¡¼ ¼øÂ÷±¸¹®(sequential statement)Àº ¹®ÀåÀÇ ³õ¿©Áø ¼ø¼¿¡ Àǹ̸¦ µÎ´Â ÇüÅÂÀÇ ±â¼ú¹æ¹ýÀ» ¶æÇÒ »ÓÀÌ¸ç ½ÇÁ¦·Î ¼øÂ÷³í¸®È¸·Î(sequential logic)¸¦ ±¸¼ºÇÑ´Ù°í º¼¼ö´Â ¾ø´Ù. ¼øÂ÷±¸¹®(sequential statement)Àº ±â¼úÇÏ´Â ¹æ¹ý¿¡ µû¶ó Á¶ÇÕȸ·Î ȤÀº ¼øÂ÷³í¸®È¸·Î¸¦ ¸¸µé¼ö ÀÖ´Ù. (¸ðµç ¼øÂ÷±¸¹®ÀÌ ¹Ù·Î ¼øÂ÷ȸ·Î¸¦ ÀǹÌÇÏ´Â °ÍÀÌ ¾Æ´Ï´Ù! VHDL¿¡¼ ¼øÂ÷±¸¹®°ú ¼øÂ÷ ³í¸®È¸·Î¿Í´Â ÀǹÌÇÏ´Â ¹Ù°¡ ´Ù¸£´Ù!)
2. ENTITY
½Ã½ºÅÛÀ» ±¸¼ºÇÏ´Â ºÎºÐÇ°À¸·Î¼ ÀÌµé »çÀÌÀÇ »óÈ£ ¿¬°áÀ» À§ÇÑ Åë·Î ¿ªÈ°(interface)À» ÇÏ´Â °ÍÀÌ ENTITYÀÌ´Ù. ¸»ÇÏÀÚ¸é ³»ºÎ ¼³°Ô¿¡ ´ëÇÑ ÀÔÃâ·Â µîÀ» ±â¼úÇÏ´Â ¡°Æ÷À塱ÀÎ ¼ÀÀÌ´Ù. ½Ã½ºÅÛÀÇ ÀÔÀå¿¡¼ º¸¸é ³»ºÎ ¼³°è¿¡ ´ëÇÑ°ÍÀº °¡·ÁÁ® ÀÖ°í ´Ù¸¸ ENTITY¿¡ ±â¼úµÈ ÀÔÃâ·Â Æ÷Æ®¸¸À» º¸°ÔµÇ´Âµ¥ ÀÌ·± Àǹ̿¡¼ ENTITY¸¦ ¡°¾ÏÈæ»óÀÚ¡±(Black Box)¶ó°í Çϱ⵵ ÇÑ´Ù. ENTITY ¼±¾ðÀÇ ¿¹´Â ´ÙÀ½°ú °°´Ù.
ENTITY counter IS PORT ( clk, reset : IN std_logic; datain : IN std_logic_vector(3 DOWNTO 0); buff : BUFFER std_logic_vector(3 DOWNTO 0); output : OUT std_logic_vector(3 DOWNTO 0); inpouput : INOUT std_logic_vector(3 DOWNTO 0) ); END counter; |
ÀÌ ¼³°èÀÇ À̸§Àº "counter" ÀÌ°í, ÀÔÃâ·ÂµéÀº PORT(....)¿¡ ³ª¿ÇÑ °Í°ú °°´Ù. ÀÔÃâ·ÂÀÇ À̸§°ú ¸ðµå, ±×¸®°í ŸÀÔÀ» ÁöÁ¤ µÇ¾î¾ß ÇÑ´Ù. ÀÔÃâ·Â ¸ðµå¿¡´Â IN, OUT, INOUT, BUFFER°¡ ÀÖ´Ù.
IN Àº ÀÔ·Â Æ÷Æ®·Î¼ signal assignÀÇ ¼Ò½º(source)Ãø ( SignalÀÏ°æ¿ì '<=', VariableÀÏ°æ¿ì ':=' ÀÇ ¿À¸¥ÂÊ, R-Value )¿¡¸¸ ¾µ¼ö ÀÖ´Ù. OUTÀº Ãâ·Â Æ÷Æ®·Î¼ signal asignÀÇ ¸ñÀûÁö(destination) ('<=' ¶Ç´Â ':='ÀÇ ¿ÞÂÊ, L-Value)¿¡¸¸ ¾µ¼ö ÀÖ´Ù. INOUTÀº ÀÔÃâ·Â Æ÷Æ®·Î »ç¿ë µÇ¹Ç·Î ¼Ò½º(source) ¶Ç´Â ¸ñÀûÁö(destination)¿¡ ¸ðµÎ ¾µ¼ö ÀÖ´Ù. ±×·¯³ª ÇÑ°³ÀÇ ¹®Àå¿¡ ¸ðµÎ ¾µ¼ö ¾ø´Ù. ÀÔÃâ·Â ¸ðµå°¡ Á¤ÇØÁø °æ¿ì ÇÒ´ç¹®(assign statement)¿¡¼ÀÇ ¾ö°ÝÇÑ ±ÔÁ¤Àº Çϵå¿þ¾î¸¦ ´Ù·ç±â ¶§¹®ÀÌ´Ù. Çϵå¿þ¾î¸¦ ±â¼úÇÒ¶§ assign À̶õ ¿¬°á°ü°è¸¦ Ç¥ÇöÇÑ°Í(netlist)À¸·Î¼ ÇÁ·Î±×·¡¹Ö ¾ð¾î¿¡¼¿Í °°Àº ¿ÀÆÛ·¹À̼Ç(move operation)ÀÌ ¾Æ´Ï´Ù. BUFFER´Â INOUT°ú °°Àº ÀÔÃâ·Â Æ÷Æ®·Î¼ assignÀÇ ¼Ò½º(source)Ãø ¶Ç´Â ¸ñÀûÁö(destination)Ãø¿¡ ¾µ¼ö ÀÖ´Ù. INOUT ¸ðµå¿Í ´Ù¸¥Á¡Àº ´ÜÀÏ ÇÒ´ç¹® ³»¿¡¼ ¼Ò½º¿Í ¸ñÀûÁöÃø ¸ðµÎ µ¿½Ã¿¡ »ç¿ëÇÒ¼ö ÀÖ´Ù´Â °ÍÀÌ´Ù. ÀÌ´Â BUFFER ¸ðµå¿¡ ÀÌ¹Ì F/FÀ» ³»Æ÷ÇÏ°í ÀÖ´Ù´Â Àǹ̸¦ °®´Â´Ù.
´ÙÀ½°ú °°Àº ºñµ¿±â ¸®¼ÂÀ» °®´Â Ä«¿îÅÍÀÇ ¿¹¸¦ ÅëÇؼ Æ÷Æ® ¸ðµåÀÇ »ç¿ë¹æ¹ý¿¡ ´ëÇϼŠ»ìÆ캸±â·Î ÇÏÀÚ. ±×¸² 2´Â ÀÔÃâ·Â Æ÷Æ®ÀÇ ¸ðµå¿¡ µû¸¥ ÇÕ¼ºÀÇ °á°úÀÌ´Ù. ¸ðµÎ ¾ç¹æÇ⼺ ¸ðµåÀÌÁö¸¸ BUFFER ¸ðµåÀÎ °æ¿ì Àç±ÍÀûÀÎ(recursive) ÇüÅÂÀÇ ³×Æ®¸®½ºÆ®°¡ Çü¼ºµÈ °ÍÀ» º¼ ¼ö ÀÖ´Ù.
LIBRARY ieee; ENTITY count IS clk, reset : IN std_logic; ); ARCHITECTURE behave OF count IS PROCESS ( clk,reset ) IF reset='0' THEN buff <= "0000"; ELSIF clk = '1' AND clk'EVENT THEN buff <= buff + "0001"; END IF; END PROCESS; END behave; |
±×¸² 2. ÀÔÃâ·Â ¸ðµå¿¡ µû¸¥ ÇÕ¼º°á°ú
3. ÀÔÃâ·Â Æ÷Æ®ÀÇ Å¸ÀÔ°ú VHDLÀÇ °´Ã¼Çü(Object Types)
ÀÔÃâ·Â Æ÷Æ®ÀÇ Å¸ÀÔÀ» ÁöÁ¤ÇÑ´Ù. µðÁöÅ» ½ÅÈ£°¡ '1' °ú '0' ¸¸À¸·Î ȸ·Î¸¦ ´Ù·ê °ÍÀÎÁö ¾Æ´Ï¸é ÇÏÀÌ ÀÓÇÇ´ø½º(Z)µµÀÖ°í Ç®¾÷(H), Ç®´Ù¿î(L), ±×¸®°í ÇÕ¼º°ú ½Ã¹Ä·¹À̼ÇÀÇ »óŸ¦ ³ªÅ¸³»±â À§Çؼ Don¡¯t care(-), Unknown(U), ¹ö½º Ãæµ¹µî¿¡ ÀÇÇÑ ¿¡·¯»óÅÂ(X) µîµµ ±¸ºÐÇÒ °ÍÀÎÁö °áÁ¤ÇØ¾ß ÇÑ´Ù. ÀüÀÚÀÇ °æ¿ì bit ŸÀÔÀ̶ó°í ÇÏ°í ÈÄÀÚÀÇ °æ¿ì std_logic À̶ó°í Çϱâ·Î ±ÔÁ¤Çß´Ù. VHDL ¾ð¾î ÀÚüÀûÀ¸·Î´Â std_logic¿¡ ´ëÇÑ ±ÔÁ¤Àº ¾ø´Ù. ´Ù¸¸ IEEE 1076À» Á¤ÇÒ¶§ std_logic_1164 ¶ó´Â °ÍÀ» Á¤ÇØ ³õ°í ÀÌ°÷¿¡ bit¶ó´Â °ÍÀº 1 °ú 0À¸·Î ±ÔÁ¤ÇѴٰųª std_logicÀº 1,0,Z,H,L,X µîµîÀ¸·Î ±ÔÁ¤ÇÑ´Ù°í Á¤Çß´Ù.
- VHDLÀÇ °´Ã¼Çü (Object Types)
VHDLÀÇ °´Ã¼ Çü(Object Types)¿¡ ´ëÇؼ »ìÆì º¸±â·Î ÇÏÀÚ. VHDLµµ ´Ù¸¥ ¾ð¾î¿Í °°ÀÌ ´ÙÀ½°ú °°Àº ÀÚ·á Çü(data types)À» °¡Áö°í ÀÖ´Ù.
¡¡ boolean (³í¸®Çü)
¡¡ character (¹®ÀÚÇü)
¡¡ integer (Á¤¼öÇü)
¡¡ real (½Ç¼öÇü)
¡¡ string (¹®ÀÚ¿)
ÀÌ¿Ü¿¡ µðÁöÅ» Çϵå¿þ¾î¸¦ ´Ù·ç´Â ¾ð¾î·Î¼ VHDLÀº ´ÙÀ½°ú °°Àº ÀÚ·á Çü(data type)À» °¡Áø´Ù.
¡¡ bit
¡¡ bit_vector
bit ÇüÀº µðÁöÅ» ½ÅÈ£ ¡®1¡¯ ¶Ç´Â ¡®0¡¯ °ªÀ» °®´Â´Ù. bit_vector´Â bitÀÇ 1Â÷¿ø ¹è¿ÇüÀÌ´Ù. Áï, N-bit ¹ö½º¸¦ ±â¼úÇÏ´Â °ÍÀÌ´Ù. ´ëºÎºÐÀÇ °æ¿ì µðÁöÅ» µ¥ÀÌŸ ŸÀÔÀº bit ȤÀº bit_vector ´ë½Å, IEEE 1164-standard-logic¿¡¼ Á¤ÇسõÀº °´Ã¼ ÇüÀ» »ç¿ëÇÑ´Ù.
¡¡ std_logic
¡¡ std_logic_vector
À̵éÀº IEEE ¶óÀ̺귯¸®ÀÇ std_logic_1164 ÆÐÅ°Áö¿¡ ¼±¾ðµÇ¾î ÀÖ´Ù. ÀÌ·¯ÇÑ ¿ÜºÎ¿¡¼ ÀÛ¼ºµÈ ¶óÀ̺귯¸®µéÀ» »ç¿ëÇÏ·Á¸é, library ¿Í use ¹®À¸·Î ¶óÀ̺귯¸®¸¦ ÁöÁ¤ÇÏ°í »ç¿ëÇÑ´Ù.
library ieee; |
Boolean, character, integer, real, string, bit, bit_vector ¿Í °°Àº ¹Ì¸®Á¤ÀÇµÈ VHDLÀÇ µ¥ÀÌŸ ÇüÀº standard ÆÐÅ°Áö(package)¿¡ ¼±¾ðµÇ¾î ÀÖ´Ù.
variable, signal, constantµîÀ¸·Î ¼±¾ðµÈ °´Ã¼µéÀº ¼±¾ðµÈ ŸÀÔ¿¡ µû¶ó »ç¿ëÇÒ¼ö ÀÖ´Â ¿¬»êÀÚµéÀÌ Á¤ÇØÁø´Ù. (Áï, °´Ã¼µé¿¡ ÀÇÇÏ¿© ¿¬»êÀÚ°¡ °áÁ¤µÇ´Â °ÍÀε¥, ÈçÈ÷ °´Ã¼ ÁöÇâÀûÀ̶ó´Â ÀǹÌÀÌ´Ù. ³ªÁß¿¡ ¾ð±Þ µÇ°ÚÁö¸¸ VHDLÀº °´Ã¼¿¡ µû¶ó ¿¬»êÀÚÀÇ ¿À¹ö·Îµùµµ °¡´ÉÇÏ´Ù.) ¶ÇÇÑ µðÁöÅ» Çϵå¿þ¾î µðÀÚÀο¡¼ °´Ã¼ÀÇ ¼±¾ðÀº »ç¿ëµÉ Çϵå¿þ¾îÀÇ ºñÆ® Æøµµ ÇÔ²² Æ÷ÇԵȴÙ. (¼ÒÇÁÆ®¿þ¾îÀûÀÎ ÇÁ·Î±×·¡¹Ö ¾ð¾î¿¡¼´Â ¼±¾ðÇÏ´Â °´Ã¼ÀÇ Çü¿¡ µû¶ó ÀÏÁ¤ÇÑ ºñÆ®ÆøÀÌ Á¤ÇØÁ® ÀÖÀ½À» ±â¾ïÇغ¸¶ó!)
VHDLÀº ÄÄÆÄÀÏ Çϴµ¿¾È ÀÚ·á Çü¿¡´ëÇÑ Çü-°Ë»ç(type-checking)°¡ ¸Å¿ì ¾ö°ÝÇÏ°Ô ÀÌ·ç¾î Áø´Ù. ½ÉÁö¾î bit ¿Í std_logic »çÀÌ¿¡¼µµ ÀüÇô ȣȯÀÌ ÀÌ·ç¾îÁöÁö ¾Ê´Âµ¥ ±× ÀÌÀ¯¿¡ ´ëÇؼ´Â std_logic_1164 ÆÐÅ°Áö¸¦ ¼³¸íÇÒ¶§ ÀÚ¼¼È÷ »ìÆì º¸µµ·Ï ÇÑ´Ù. ±×¸®°í, ¼ºê ÇÁ·Î±×·¥ÀÇ ¿À¹ö·Îµù(over-loading)À» °áÁ¤ÇÑ´Ù. ¼³°èÀÚ´Â »ç¿ëÇÒ Å¸ÀÔ Á¤ÀÇ(type define)¸¦ ÇÒ¼ö ÀÖ´Ù. »ç¿ëÀÚ Á¤ÀÇ Çü¼±¾ðÀº scalar, array, record µîÀ» ÀÌ¿ëÇÒ¼ö ÀÖ´Ù. VHDLÀº ÆÄ»ý Çü(subtype)µµ Áö¿øÇÑ´Ù. ÀÌ¿Í °°ÀÌ VHDLÀº °´Ã¼ÀÇ ¼±¾ð°ú »ç¿ëµ¥ ´ëÇؼ ¸¹Àº À¶Å뼺À» ºÎ¿©ÇÑ °´Ã¼ ÁöÇâÀûÀÎ ¾ð¾î¶ó ÇÏ°Ú´Ù.
À̹ø¿£ ¸îºñÆ® Â¥¸®ÀÎÁö ±â¼úÇÑ´Ù. ¹ö½ºÀÏ °æ¿ì bit ȤÀº std_logic µÚ¿¡ _vector¶ó°í µ¡ºÑÀδÙ.
- 1 ºñÆ® Â¥¸® : bit, std_logic
- ¿©·¯ºñÆ® Â¥¸® : bit_vector, std_logic_vector
±×¸®°í ¿©·¯ºñÆ® Â¥¸®Àΰæ¿ì ¿ÞÂʺÎÅÍ MSBÀ϶§ 'downto', LSB °¡¸ÕÀú À϶§ 'to' ¶ó°í Ç¥ÇöÇÑ´Ù.
- MSB ¿ì¼± : std_logic_vector( 3 DOWNTO 0 )
- LSB ¿ì¼± : std_logic_vector( 0 TO 3 )
Á¤¼öÇü(integer)ÀÇ °æ¿ì ±âº»ÀûÀ¸·Î 16 ȤÀº 32ºñÆ®ÀÇ ÆøÀ» °®´Â´Ù. ¶ÇÇÑ ½Ç¼öÇü(real)ÀÇ °æ¿ì ÇÕ¼º °¡´ÉÇÑ ¿¬»êÀÌ Áö¿ø µÅÁö ¾ÊÀ¸³ª Á¤¼öÇüÀÇ °æ¿ì »ê¼ú ¿¬»êÀÚÀÇ ÀÌ¿ë°ú ÀÌ¿¡ µû¸¥ ÇÕ¼ºÀÌ Áö¿øµÇ°í ÀÖ´Ù. ÇÕ¼º °¡´ÉÇÑ »ê¼ú¿¬»ê¿¡ ´ëÇؼ´Â ³ªÁß¿¡ ´Ù·ç¾î º¸±â·Î ÇÏ°í °£´ÜÇÑ ¿¹¸¦ º¸¸é ´ÙÀ½°ú °°´Ù. Á¤¼öÇüÀÇ °æ¿ì¿¡µµ »ç¿ëÇÏ·Á´Â ¼öÀÇ ¹üÀ§¸¦ ¼ºÁ¤ÇÒ¼ö Àִµ¥, ¾Æ·¡ÀÇ ¿¹´Â Á¤¼öÇüÀÇ ¹üÀ§¸¦ -128~127 ·Î Á¤Çؼ ¼±¾ðÇÑ °æ¿ì ÀÌ´Ù. ÇÕ¼º °á°ú´Â ±×¸² 3°ú °°´Ù. ÇÕ¼º±â´Â ¼öÀÇ ¹üÀ§¿¡ ¸Â°Ô ºñÆ®ÆøÀ¸·Î ÇÕ¼ºÇØ ³½´Ù.
LIBRARY ieee; ENTITY integer_test IS a : IN integer range -128 to 127; END integer_test; ARCHITECTURE behave OF integer_test IS mul_ab <= a * b; END behave; |
¡¡
±×¸² 3. Á¤¼öÇü(integer)¿¬»êÀÇ ÇÕ¼º°á°ú
4. Architecture
ENTITY·Î ¼³°èÀÇ °Ñ¸ð¾çÀÌ Áغñ µÇ¾úÀ¸¸é ÀÌÁ¦ ¼³°è³»¿ëÀ» ARCHITECTURE ¿¡ ±â¼ú ÇÑ´Ù. ÀÌÁ¦ º»°ÝÀûÀ¸·Î ¼³°è°¡ ½ÃÀ۵Ǵ °ÍÀÌ´Ù. C¿Í °°Àº ÇÁ·Î±×·¡¹Ö ¾ð¾î¿¡¼ µ¶¸³ ¸ðµâ·Î¼ ÇÔ¼ö´Â ÇÔ¼öÀÇ À̸§°ú ÆĶó¸ÞÅÍ ¸®½ºÆ® ±×¸®°í ÇÔ¼öÀÇ ¸öÅëºÎºÐÀÌ ÀÏüÇüÀ¸·Î ÀÌ·ç¾îÁø °Í°ú´Â ´Ù¸£°Ô VHDL¿¡¼ ENTITY¿Í ARCHITECTURE´Â °¢°¢ µ¶¸³ÀûÀÎ ±¸¼º¿ä¼Ò¶ó´Â Á¡Àº »ý°¢ÇØ º¼ ÇÊ¿ä°¡ ÀÖ´Ù.
VHDL¿¡¼ ARCHITECTURE´Â µ¶¸³ÀûÀÎ ¿ä¼Ò·Î¼ À̸§À» °®°ÔµÇ¸ç ¸öÅëºÎºÐÀº BEGIN ~ END ·Î ÀÌ·ç¾î Áø´Ù. ¿¹¸¦µé¸é,
ARCHITECTURE behave OF count IS BEGIN ............... END behave; |
"ARCHITECTURE behave OF counter IS"´Â "counter"¶ó´Â À̸§ÀÇ ENTITY¿ëÀ¸·Î ¸¸µé¾îÁø "behave"¶ó´Â À̸§À» °®´Â ARCHITECTURE ¼³°è¶ó´Â ¶æÀÌ´Ù. ±×·¯¸é ARCHITECTURE ¸¶´Ù À̸§ÀÌ ºÑ´Â´Ù´Â °ÍÀε¥, ÀÌ´Â ´Ù¸¥¸»·Î Çϸé ÇϳªÀÇ ENTITY¿¡ ¿©·¯°³ÀÇ ¸öÅëÀÌ Á¸ÀçÇÒ¼öµµ ÀÖ´Ù´Â °ÍÀÌ´Ù. ±×·¯³ª ¿©·¯°³ÀÇ ARCHITECTURE°¡ Á¸Àç ÇÏ´õ¶óµµ °¢°¢ÀÇ ¼³°è´Â "1°³ÀÇ ENTITY ¿Í 1°³ÀÇ ARCHITECTURE°¡ ¦À» ÀÌ·ç¾î ±¸¼º" µÇ¾îÁ®¾ß ÇÑ´Ù.¡¡
¿¹¸¦µé¾î RS Flip-FlopÀ» Çϳª ¸¸µç´Ù°í ÇÏÀÚ. RS F/FÀÇ À̸§À» "rs_ff" ¶ó°í ÇÏ°í ENTITY¸¦ ´ÙÀ½°ú °°ÀÌ ±â¼úÇÏ¿´´Ù.¡¡
ENTITY rs_ff IS r : IN std_logic; END rs_ff; |
±×¸®°í "rs_ff"ÀÇ ¸öÅëÀ» "behave"¶ó´Â À̸§À¸·Î ARCHITECTURE¸¦ ´ÙÀ½°ú °°ÀÌ ±â¼ú ÇÑ´Ù.
ARCHITECTURE behave OF rs_ff IS q <= q_s; END behave; |
¡¡
¡¡
±×¸² 4. ±â´ÉÀûÀÎ ¼öÁØÀÇ RS_FFÀÇ ±â¼ú ¹× ÇÕ¼º°á°ú
À̹ø¿¡´Â ¹Ì¸® ±¸¼ºµÇ¾î ÀÖ´Â gateÀÇ ¶óÀ̺귯¸®¿¡¼ AND¿Í NOT ¸¦ ºÒ·¯´Ù°¡(instanciation) ±¸Á¶ÀûÀ¸·Î ±â¼úÇÑ °æ¿ì¸¦ »ìÆì º¸±â·Î ÇÏÀÚ.
±×·¡¼ À̹ø¿¡´Â ÀÌµé µÎ°³ÀÇ ¶óÀ̺귯¸®¸¦ ÂüÁ¶ÇÏ¿© Àû´çÇÑ AND ¿Í NOT¸¦ °ñ¶ó À̸¦ ÀÌ¿ëÇÏ¿© "rs_ff"¸¦ ¼³°èÇϵµ·Ï ÇÏ¿´À¾´Ï´Ù.
ARCHITECTURE struct OF rs_ff IS COMPONENT and00 i0 : IN std_logic; END COMPONENT; COMPONENT inv01 i : IN std_logic; END COMPONENT; SIGNAL q_s, qb_s : std_logic; BEGIN q <= q_s; u1 : and00 u2 : and00 u3 : inv01 u4 : inv01 END struct; |
¡¡
±×¸² 5. ±¸Á¶Àû ÇüÅ·Π±â¼úÇÑ RS_FF¿Í ÇÕ¼º °á°ú
¡¡
"struct"¶ó´Â À̸§ÀÇ ARCHITECTURE¿¡´Â µÎ°³ÀÇ ½ÇÁ¦ ºÎÇ°(COMPONENT)ÀÌ »ç¿ëµÇ¾ú´Ù. ÀÌµé µÎ°¡Áö ºÎÇ°À» ÀÌ¿ëÇÏ¿© ±¸Á¶ÀûÀÎ ÇüÅ·Π±â¼úÇÑ ARCHITECTURE°¡ ¡°struct¡±ÀÌ´Ù. ÀÌ·¸°Ô ÇÏ¿© "rs_ff"¿¡´Â ±â´ÉÀ» ±â¼úÇÑ "behave" ¿Í ºÎÇ°À» »ç¿ëÇÑ "struct"¶ó´Â À̸§ÀÇ µÎ°³ÀÇ ARCHITECTURE°¡ ¸¸µé¾î Á³´Ù.
5. Configuration
¾Õ¿¡¼ ¹Ì¸® »ìÆì º¸¾ÒµíÀÌ ÇÑ°³ÀÇ ENTITY¿¡´Â ´Ù¼öÀÇ ARCHITECTURE°¡ Á¸ÀçÇÒ ¼ö ÀÖ´Ù. ÀÌ·± »óȲ¿¡¼ ½Ã¹Ä·¹À̼ÇÀ̳ª ÇÕ¼ºÀ» ¼öÇàÇÒ ¶§ ÇÑ ENTITY¿¡ ARCHITECTURE¸¦ °áÇÕ½ÃÄÑ ÁÖ¾î¾ß Çϴµ¥ À̶§ »ç¿ëÇÏ´Â °ÍÀÌ CONFIGURATIONÀÌ´Ù.
CONFIGURATION conf1 OF rs_ff IS END FOR; END conf1; |
À§ÀÇ ¿¹´Â CONFIGURATION À̸§ÀÌ "conf1" ÀÌ°í ÀÌ´Â "rs_ff"¶ó´Â ENTITY¿¡ ±¸¼ºÇÒ ARCHITECTURE¸¦ "behave"·Î ÇÑ´Ù´Â °ÍÀ» ³ªÅ¸³½ °ÍÀÌ´Ù.
CONFIGURATION conf2 OF rs_ff IS FOR struct FOR u1, u2 : and00 USE ENTITY work.and00(behave); END FOR; FOR u3, u4 : inv01 USE ENTITY work.inv01(behave); END FOR; END FOR END conf2; |
¡¡
À§ÀÇ ¿¹´Â CONFIGURATION À̸§ÀÌ "conf2"ÀÌ°í ÀÌ´Â "rs_ff"¶ó´Â ENTITY¿¡ ±¸¼ºÇÒ ARCHITECTURE¸¦ "struct"·Î ÇÑ´Ù´Â °ÍÀ» ³ªÅ¸³½´Ù. "struct"¶ó´Â ARCHITECTURE¿¡´Â ´Ù½Ã »ç¿ëµÈ ºÎÇ°µéÀÌ Àִµ¥ ±×À̸§ÀÌ u1, u2, u3 ,u4ÀÌ°í ÀÌµé ¸ðµ¨¸µµÇ¾î ¶óÀ̺귯¸®·Î Á¸ÀçÇÏ´Â °÷À» ÁöÁ¤ ÇÏ°í ÀÖ´Ù.
6. WORK ¶óÀ̺귯¸®
VHDL ¿¡¼ "."´Â µðÀÚÀÎ ¶óÀ̺귯¸®ÀÇ °èÃþ±¸Á¶¸¦ Ç¥Çö ÇÑ´Ù. VHDL¿¡¼´Â »ç¿ëÇÒ ¶óÀ̺귯¸®´Â LIBRARY Å°¿öµå¸¦ ÀÌ¿ëÇÏ¿© ÁöÁ¤ÇØ Áִµ¥ ´ÙÀ½°ú °°´Ù.
LIBRARY ieee;
½ÇÁ¦·Î ÀÌ ¶óÀ̺귯¸®°¡ Á¸ÀçÇÏ´Â µð·ºÅ丮´Â ½Ã¹Ä·¹ÀÌ¼Ç ¶Ç´Â ÇÕ¼ºÅøÀÇ È¯°æ º¯¼ö·Î ÁöÁ¤µÇ¾î ÀÖ°Ô µÈ´Ù. Compass ToolÀÇ °æ¿ì Manager À©µµ¿ì¸¦ ¶ç¿ì¸é ¶óÀ̺귯¸® Æнº (library path)¸¦ ÁöÁ¤ÇÏ´Â °ÍÀ» º¼¼ö ÀÖÀ» °ÍÀÌ´Ù. MaxPlus ¿¡µµ User Library¸¦ ÁöÁ¤ÇÏ´Â ¸Þ´º°¡ ÀÖ°í V-System/VHDL ¿¡µµ ¿ª½Ã ¶óÀ̺귯¸® Æнº¸¦ ÁöÁ¤ÇÏ´Â ¸Þ´º°¡ ÀÖÀ¾´Ï´Ù. ´ë°³ ¶óÀ̺귯¸® À̸§°ú µð·ºÅ丮 Æнº¸¦ ¿¬°á ½ÃÅ°µµ·Ï µÇ¾î Àִµ¥, ¶óÀ̺귯¸® ¸í(library name)°ú Æнº(directory path)¸¦ ¸ÅÇÎ(mapping) ½ÃŲ´Ù°í ÇÑ´Ù.
USE ieee.std_logic_1164.ALL;
ÀÌ´Â ieee¶ó´Â ¶óÀ̺귯¸®¿¡¼ std_logic_1164 ¶ó´Â À̸§ÀÇ ÆÐÅ°Áö(package)¸¦ °¡Á®´Ù°¡ ±×¾È¿¡ ÀÖ´Â ÇÔ¼ö(function)µéÀ» ¸ðµÎ »ç¿ëÇÑ´Ù´Â ¶æÀ¸·Î ALL À̶ó°í ÇÑ °ÍÀÌ´Ù. ALLÀº VHDL ÀÇ Å°¿öµå ÀÌ´Ù. ¹°·Ð ALL ´ë½Å ÆÐÅ°Áö ³»¿¡¼ »ç¿ëÇÒ ÇÔ¼ö¸¦ ÁöÁ¤ÇÒ ¼öµµ ÀÖ´Ù.
USE ENTITY work.and00(behave);
À§ÀÇ °æ¿ì´Â CONFIGURATION¿¡¼ ¶óÀ̺귯¸® ¹× ENTITY, ARCHITECTURE¸¦ ÁöÁ¤ÇÑ °Í ÀÌ´Ù. "work" ¶ó´Â ¶óÀ̺귯¸®¿¡ "and00" À̶ó´Â ENTITY ¿Í "behave"¶ó´ÂARCHITECTURE¸¦ ÁöÁ¤ÇØ ÁØ °ÍÀÌ´Ù. VHDLÀ» º¸¸é "work" ¶ó´Â library ¸íÀÌ ¸¹ÀÌ µîÀåÇϴµ¥ ÀÌ´Â ÇöÀç ÀÛ¾÷ÁßÀÎ ¼³°èÀÇ ±âº»(default) ÀÛ¾÷ ¶óÀ̺귯¸®(working library)·Î Á¤ÇØÁø À̸§ÀÌ´Ù. Åø¿¡µû¶ó ÇöÀç ÀÛ¾÷ÁßÀÎ ¼³°èÀÇ ¶óÀ̺귯¸® À̸§ ¡°work¡±¸¦ ²À ÁöÁ¤ÇØ ÁÖ¾î¾ß Çϱ⵵ ÇÏÁö¸¸ ´ë°³ ÁöÁ¤ÇÏÁö ¾ÊÀ¸¸é ÀÚµ¿À¸·Î "work" ¶ó°í ÀνÄÇÑ´Ù. ÀÛ¾÷ ¶óÀ̺귯¸®ÀÇ ÁöÁ¤ Àº ´ÙÀ½°ú °°´Ù.
LIBRARY work;
USE work.ALL;
ÀÛ¾÷ ¶óÀ̺귯¸®¿¡ ÆÐÅ°Áö°¡ ¾øÀ¸¹Ç·Î ÆÐÅ°Áö¸íÀº »ý·«ÇÑ´Ù.
7. VHDL ±â¼úÀÇ Ãß»óÈ ¼öÁØ
VHDLÀº Å©°Ô structural, data flow, behavioral µî 3°¡Áö ¼öÁØÀÇ Ãß»óÈ(abstraction) ¹× À̵éÀÇ È¥ÇÕÇÑ ±â¼úµµ °¡´ÉÇÏ´Ù. (Ãß»óȶõ ¾î¶² ±¸Ã¼ÀûÀÎ ³»¿ëÀ» ¾à¼ÓµÈ Àǹ̷Π³ªÅ¸³»´Â ÇàÀ§¸¦ ¸»ÇÑ´Ù. ÇÑ ¿¹·Î ´ë¼ö °è»êÀÇ µ¡¼ÀÀ» ¡°+¡±¶ó´Â ±âÈ£·Î ³ªÅ¸³»´Â °Íµµ Ãß»óÈ ÀÌ´Ù. ÇÁ·Î±×·¡¹Ö ¾ð¾î¿¡¼ Ãß»óȶõ ÇÔ¼ö¸¦ µé¼ö ÀÖ´Ù. ¼ºê ÇÁ·Î±×·¥³»ÀÇ ÀÏ·ÃÀÇ °è»ê ÀýÂ÷ °úÁ¤À» ÇÔ¼ö À̸§À¸·Î ´ëÇ¥ÇÏ¿© ³ªÅ¸³»´Â ÇàÀ§µîÀÌ´Ù.)
´ÙÀ½Àº °£´ÜÇÑ ¿¹·Î¼ VHDL·Î Çϵå¿þ¾î »Ó¸¸ ¾Æ´Ï¶ó ´Ù¾çÇÑ ÀÌ¿ëÀÌ °¡´ÉÇÔÀ» º¸¿©ÁØ´Ù. ÀÌ ¿¹Á¦ ¡®Hello World¡¯´Â ÀÌ¾î¼ ¼³¸íÇÒ ¼¼°¡Áö Ãß»óÈÀÇ ¿¹Á¦·Îµµ »ç¿ëµÉ °ÍÀÌ´Ù.
entity hello is port (clock, reset : in boolean; char : out character) ; end hello; architecture behavioral of hello is constant char_sequence : string := "hello world"; signal step : integer range 1 to char_sequence'high := 1; begin -- Counter if reset then step <= 1; elsif clock and clock'event then if step = char_sequence'high then step <= 1; else step <= step + 1; end if; end if; end process ; ¡¡ -- Output Decoder end behavioral ; |
¡¡
ÀÌ ¿¹¿¡¼´Â µÎ°³ÀÇ ÀÔ·Â ½ÅÈ£¸¦ ¹Þ¾Æ¼ ¹®ÀÚ¿À» Ãâ·ÂÇÑ´Ù. clock ½ÅÈ£ÀÇ rising-edge¿¡¼ 1°³ÀÇ ¹®ÀÚ°¡ Ãâ·ÂµÈ´Ù. resetÀº ºñµ¿±âÀûÀ¸·Î °É¸®¸ç ¹®ÀÚ¿ Ãâ·Â ¼ø¼¸¦ ÃʱâÈ ÇÑ´Ù. ´ÙÀ½ ±×¸²Àº ¿¹Á¦ ¡®Hello World¡¯ÀÇ ½Ã¹Ä·¹ÀÌ¼Ç °á°úÀÌ´Ù.
±×¸² 6. ¡®Hello World¡¯ ½Ã¹Ä·¹ÀÌ¼Ç °á°ú
¡¡
7-1. Structural VHDL¡¡
Structural VHDLÀº º´·Ä±¸¹®(concurrent statement)¿¡ ºÎÇ°(component)À» ºÒ·¯³½ÈÄ(instantiation) À̵éÀÇ ¿¬°á(netlist)À» Ç¥ÇöÇÑ °ÍÀÌ´Ù. ¸»ÇÏÀÚ¸é Structural VHDLÀº ³×Æ®¸®½ºÆ®(netlist)¼öÁØÀÇ ±â¼úÀ̶ó ÇÏ°Ú´Ù. ´ëºÎºÐ µµ¸é¿¡ ÀÇÇÑ È¸·Î ¼³°è(schematic capture) Åø¿¡¼ ½±°Ô ȸ·Î¸¦ ±¸¹®À¸·Î ÃßÃâ(extract)Çس»´Â ¹æ¹ýÀÌ´Ù. ¶ÇÇÑ ºÎÇ°ÀÇ »óÈ£¿¬°á±¸Á¶¸¦ °èÃþÀû(hierachy)À¸·Î ³ªÅ¸³»´Â °ÍÀ¸·Î ÇÏÀ§ ºÎÇ°ÀÇ ±â´É¿¡ ´ëÇÑ ±â¼úÀÌ data flow, behavioral ¼öÁØÀ¸·Î °¡´ÉÇÏ´Ù. ÀÌ¿Í °°ÀÌ ÇÏÀ§ ºÎÇ°À» ÀÌ¿ëÇÑ °èÃþÀû ¼³°è´Â ÀÚ¿ø Àç»ç¿ë ±â¹ý(reusablity)°ú ¼³°è ÅëÇÕ(integrating design) °úÁ¤¿¡¼ À¯¿ëÇÏ´Ù.
´ÙÀ½Àº ¡®Hello World¡¯ ¿¹Á¦¸¦ µÎ°³ÀÇ ºÎÇ°(component)À¸·Î ³ª´©¾î ÀÛ¼ºÇÑ °ÍÀÌ´Ù. °¢°¢ ÀÛ¼ºµÈ µÎ ºÎÇ°Àº »óÀ§ ¼³°è¿¡¼ ºÒ·ÁÁøÈÄ »óÈ£ ¿¬°á ÇüÅ·Π±â¼úµÈ´Ù. µÎ°³ÀÇ ºÎÇ° counter ¿Í decoderÀº °¢°¢ entity/architecture·Î ±â¼úµÇ¾î¾ß ÇÑ´Ù.
entity hello is port( clock, reset : in boolean; char : out character ) ; end hello; architecture structural of hello is constant char_sequence : string := "hello world"; subtype short is integer range 1 to char_sequence'high; signal step : short; component counter port ( clock , reset : in boolean; num : out short ) ; end component; component decoder port ( num : in short ; res : out character) ; end component; begin U0 : counter port map (clock,reset,step); U1 : decoder port map (step,char); end structural; |
¡¡
ÀÌ¿Í °°ÀÌ ºÎÇ°(components)À¸·Î ³ª´©¾î ±â¼úÇÏ´Â ¹æ¹ýÀÇ ¶Ç´Ù¸¥ ÀÕÁ¡Àº ´ÜÀÏ ¼ÒÀÚ(Programmable device)¿¡ ÇÁ·Î±×·¥ÇØ ³ÖÀ» ¼ö ¾øÀ» Á¤µµÀÇ Å« ¼³°èÀÇ °æ¿ì ´Ù¼öÀÇ ¼ÒÀÚ¿¡ ³ª´¶§ À¯¿ëÇÏ´Ù. °¢°¢ÀÇ ¼ÒÀÚ¿¡ µÎ ºÎºÐÀ» ³ª´©¾î ÇÁ·Î±×·¥ÇØ ³ÖÀ» ¼ö ÀÖ´Ù. À̶§ °¢¼ÒÀÚ¿¡ µé¾î°¥ ³»¿ëÀº µ¶¸³µÈ entity/architecture·Î ±â¼úµÇ¾î¾ß ÇÑ´Ù. Å« ¼³°è¸¦ ÇÕ¼ºÇؼ ´ÜÀÏ ¼ÒÀÚ¿¡ ÇÁ·Î±×·¥ÇØ ³ÖÀ»¼ö ¾øÀ»°æ¿ì ´Ù¼öÀÇ ¼ÒÀÚ·Î ³ª´©¾î ÇÕ¼ºÇÏ´Â ÀÚµ¿ ºÐÇÒ(fitting & partition)±â´ÉÀÌ ÀÖ´Â Åøµµ ÀÖ´Ù. ±×·¯³ª ÀÌ¿Í °°Àº ÀÚµ¿ ºÐÇÒ ±â´É(auto-partition)ÀÌ ¾ÊµÇ´Â ÅøÀÌ ´õ¸¹´Ù. ¶ÇÇÑ °¡´ÉÇϸé Åø¿¡ ÀÇÇÑ ÀÚµ¿ ºÐÇÒÇÏ´Â °ÍÀº ½Å·Úµµ°¡ ¶³¾îÁö´Â °ÍÀ¸·Î º¸À̸ç, ÇÕ¼ºÈÄ post-simulationÀÌ ¸Å¿ì º¹ÀâÇØÁø´Ù.
7-2. Data Flow VHDL¡¡
º´·Ä±¸¹®¿¡ ÀÇÇÑ ½ÅÈ£ ÇÒ´ç(concurrent signal assignment, <=)¹®À¸·Î ±â¼úµÈ °æ¿ìÀÌ´Ù. ÀÌ·¯ÇÑ °æ¿ì¸¦ RTL (register-transfer-level) ±â¼úÀ̶ó°í ¸»Çϱ⵵ ÇÑ´Ù. ¡®Hello World¡¯ÀÇ ¿¹Á¦¸¦ data flow VHDL·Î ±â¼úÇÏ¸é ´ÙÀ½°ú °°´Ù.
entity hello is port ( clock , reset: in boolean; char : out character ) ; end hello; architecture data_flow of hello is constant char_sequence : string := "hello world"; begin -- Output decoder -- Counter logic -- Counter flip flops step1 when clock and clock'event; end data_flow; |
¡¡
dataflow VHDL¿¡¼ Á¶ÇÕ³í¸®È¸·Î(combinational logic)´Â ½ÅÈ£ ÇÒ´ç(signal assignment, <=)±¸¹®À¸·Î °£´ÜÇÏ°Ô ±â¼úµÉ ¼ö ÀÖ´Ù. ±×·¯³ª counter´Â ¼øÂ÷³í¸®È¸·Î(sequential logic)ÀÌ¸ç ½ÅÈ£ÇÒ´ç(signal assignment) ±¸¹®¿¡¼ Á¶ÇÕ³í¸®È¸·Î¸¦ Ưº°È÷ µû·Î ´Ù·çÁö ¾Ê´Â´Ù. µû¶ó¼ when~else~ ¿¡¼ else°¡ ¾ø´Â ¹Ì°áµÈ when ¹®ÀåÀº ¼øÂ÷³í¸®È¸·Î·Î °£ÁÖÇÑ´Ù (infered as sequential logic). À§ÀÇ ¿¹¿¡¼, step1 ÀÌ else °¡ ¾ø´Â when ±¸¹®À¸·Î ±â¼úµÈ °ÍÀ» º¼ ¼ö ÀÖ´Ù. ¾Õ¼ ¾ð±ÞÇßÁö¸¸ VHDLÀÇ º´·Ä±¸¹®(concurrent statement)°ú ¼øÂ÷±¸¹®(sequential statement)ÀÌ ³í¸®È¸·ÎÀÇ Á¶ÇÕȸ·Î¿Í ¼øÂ÷ȸ·Î¸¦ Á÷Á¢ ÀǹÌÇÏ´Â °ÍÀº ¾Æ´Ï´Ù. ´Ù¸¸ ÄÚµù ½ºÅ¸ÀÏ¿¡ µû¶ó VHDL ¼øÂ÷ ±¸¹®À¸·Îµµ Á¶ÇÕ³í¸® ȸ·Î°¡ µÉ¼ö ÀÖ°í ȤÀº Çø³Ç÷Ó(Flip-Flop)°ú °°Àº ¼øÂ÷³í¸®È¸·Î¸¦ ±â¼úÇØ ³¾¼ö ÀÖ´Ù.
7-3. Behavioral VHDL¡¡
PROCESS ±¸¹®Àº VHDLÀÇ °¡Àå °·ÂÇÑ º´·Ä±¸¹®ÀÇ ÇϳªÀÌ´Ù. PROCESS´Â ¼øÂ÷±¸¹®µé·Î ±¸¼ºµÈ ºí·° À¸·Î¼ PROCESS ºí·° ÀÚü¸¦ 1°³ÀÇ º´·Ä±¸¹®À¸·Î °£ÁÖÇÑ´Ù. µû¶ó¼ PROCESS ±¸¹®¿¡ ÀÇÇÑ VHDLÀÇ ±â¼úÀº behavioral ¼öÁØÀÇ Ãß»óÈ ±â¹ýÀÌ´Ù. ¿¹¸¦ µé¸é,
process (insig) variable var1: integer; -- variable declaration begin var1:= insig; -- variable assignment var1:= function_name(var1 + 1); -- function call end process; |
¡¡
Çϵå¿þ¾î ¼³°è¿¡ ÀÖ¾î¼ process ±¸¹®À» »ç¿ëÇÏ´Â ¹æ¹ýÀº Á¶ÇÕ³í¸®È¸·Î¸¦ ±â¼úÇÏ´Â ¹æ¹ý°ú ¼øÂ÷³í¸®È¸·Î¸¦ ±â¼úÇÏ´Â ¹æ¹ýµî µÎ°¡Áö°¡ ÀÖ´Ù. Process ±¸¹®À¸·Î Á¶ÇÕȸ·Î¸¦ ±â¼úÇÏ´Â ÀϹÝÀûÀÎ ÇüÅ´ ´ÙÀ½°ú °°´Ù.
process (signal_name, signal_name, signal_name,......) begin ..... end process; |
¡¡
¼øÂ÷³í¸®È¸·Î¸¦ ±â¼úÇÏ´Â ¹æ¹ýÀº ´ÙÀ½°ú °°´Ù.
process (clock_signal) begin if (clock_signal and clock_signal'event) then .... end if; end process; |
¡¡
Á¶ÇÕ³í¸®È¸·Î(combinational logic)Àΰæ¿ì ÇÒ´ç¹®(assignment statement)ÀÇ ¿À¸¥ÂÊ(R-value)¿¡ ¾²´Â ÀÔ·Â signal µéÀº processÀÇ °¨ÀÀ ¸®½ºÆ®(sensitive list)¿¡ ¸ðµÎ ³ª¿µÇ¾î¾ß ÇÑ´Ù. ±×·¯³ª ¼øÂ÷³í¸®È¸·Î(sequential logic)¸¦ ±¸¼ºÇÏ°íÀÚ ÇÒ°æ¿ì wait¹®À» ÀÌ¿ëÇÑ´Ù¸é °¨ÀÀ¸®½ºÆ®¸¦ ³ª¿ÇÏÁö ¾Ê´Â¹Ý¸é if ¹®ÀåÀ¸·Î Ŭ·° ½ÅÈ£¸¦ ¾µ°æ¿ì °¨ÀÀ¸®½ºÆ®¿¡ Ŭ·°½ÅÈ£¸¦ ¹Ýµå½Ã ³ª¿ÇؾßÇÑ´Ù. VHDL¿¡¼ µ¿½Ã¿¡ °¨ÀÀ¸®½ºÆ®¿Í wait±¸¹®À» »ç¿ëÇÒ¼ö´Â ¾ø´Ù. (process ¿¡ °¨ÀÀ ¸®½ºÆ®¸¦ ¾²´Â ÀÌÀ¯´Â process ºí·°Àº °¨ÀÀ¸®½ºÆ®¿¡ ³ª¿µÈ ½ÅÈ£¼±µéÀÇ º¯È(event)¿¡ ÀÇÇÏ¿© ÇÑ°³ÀÇ º´·Ä±¸¹®(concurrent statement)À¸·Î¼ µ¿ÀÛÇÑ´Ù(evaluate). µû¶ó¼ ÇÒ´ç¹® ¿À¸¥ÂÊ signal µéÀº ¸ðµÎ °¨ÀÀ ¸®½ºÆ®¿¡ ½áÁÜÀ¸·Î¼ À̵é signalÀÇ º¯È¿¡ ÀÇÇÑ ÇÒ´ç µ¿ÀÛÀ» ºÐ¸íÈ÷ ÇÒ¼ö ÀÖ´Ù. °¨ÀÀ¸®½ºÆ®¸¦ Á¦´ë·Î ³ª¿ÇÏÁö ¾Ê´Â °ÍÀº VHDL ±¸¹®ÀÇ ¿¡·¯°¡ ¾Æ´Ï´Ù. ¸¸ÀÏ À̸¦ Á¦´ë·Î ÇÏÁö ¾ÊÀ»°æ¿ì ½Ã¹Ä·¹ÀÌ¼Ç °á°ú¸¦ ¿¹ÃøÇÒ¼ö ¾ø´Â°æ¿ìµµ ¹ß»ýÇÑ´Ù. ±×·¯³ª ´ëºÎºÐ ÇÕ¼º±â´Â °¨ÀÀ ¸®½ºÆ®ÀÇ signalÀ» °Ë»çÇÑ´Ù. ÀÌ°æ¿ì VHDL µ¿ÀÛ ½Ã¹Ä·¹À̼ǰú ÇÕ¼ºÈÄ ³í¸® °ÔÀÌÆ® ½Ã¹Ä·¹À̼ÇÀÇ °á°ú¸¦ º¸ÀåÇÒ¼ö ¾ø°ÔµÈ´Ù. VHDLÀº event-drive ÇÑ´Ù!)
(VHDLÀÇ ¾ð¾î·Î¼ ±â¼úÇÏ´Â ±¸¹®ÀÇ Á¾·ù·Î º´·Ä±¸¹®°ú ¼øÂ÷±¸¹®ÀÌ ÀÖ°í, µðÁöÅ» Çϵå¿þ¾îÀÇ ³í¸®È¸·Î¸¦ ±¸ºÐ ÇÏ´Â °ÍÀ¸·Î¼ Á¶ÇÕȸ·Î¿Í ¼øÂ÷ȸ·Î°¡ ÀÖ´Ù. º´·Ä±¸¹® ¸¸À¸·Îµµ Á¶ÇÕȸ·Î¿Í ¼øÂ÷ȸ·ÎÀÇ ±â¼úÀÌ °¡´ÉÇϸç process ±¸¹® ³»ÀÇ ¼øÂ÷±¸¹®À¸·Îµµ Á¶ÇÕȸ·Î¿Í ¼øÂ÷ȸ·ÎÀÇ ±â¼úÀÌ °¡´ÉÇÏ´Ù´Â Á¡À» ±â¾ïÇØ¾ß ÇÑ´Ù. VHDLÀÇ ±¸¹®À» »ç¿ëÇÏ¿© µðÁöÅ» ȸ·Î¸¦ ±â¼úÇÒ¶§ ±â¼úµÈ ÇüÅ¿¡ µû¶ó Á¶ÇÕ È¤Àº ¼øÂ÷ ³í¸®È¸·Î°¡ µÈ´Ù.)
µÎ°³ÀÇ process ±¸¹®À» ½á¼ ¡®Hello World¡¯ ¿¹Á¦¸¦ ±â¼úÇÏ¸é ´ÙÀ½°ú °°´Ù.
entity hello is port ( clock, reset : in boolean; char : out character) ; end hello; architecture behavioral of hello is constant char_sequence : string := "hello world"; signal step : integer range 1 to char_sequence'high := 1; begin counter : process (reset, clock) begin if reset then step <= 1; elsif clock and clockevent then if step = char_sequence'high then step <= 1; else step <= step + 1; end if; end if; end process ; decoder :process (step) begin char <= char_sequence(step); end process ; end behavioral ; |
¡¡
8. ½Ã¹Ä·¹À̼ÇÀÌ µÇ¾ú´Ù°í Çؼ...
À̹ø¿¡´Â VHDL ½Ã¹Ä·¹ÀÌÅ͸¦ ÀÌ¿ëÇؼ ¿øÇÏ´Â °á°ú°¡ ¾ò¾îÁ³´Ù°íÇؼ ¾È½ÉÇÒÀÏÀÌ ¾Æ´Ï¶ó´Â Á¡À» ¸»ÇÏ°íÀÚ ÇÑ´Ù. ¼³°è°¡ Çϵå¿þ¾î·Î ÀÌ·ç¾îÁö±â ±îÁø ¾ÆÁ÷ ÇÕ¼º(synthesis)ÀÌ ³²¾Ò´Ù. ¾ÆÁ÷ VHDLÀ̶ó´Â ¾ð¾î·Î ºÎÅÍ È¸·Î¸¦ ¾ò¾î³»±â À§ÇÑ ÇÕ¼º±âµéÀº ¾ÆÁ÷ ¸ðµç VHDL ¸ðµ¨À» Áö¿øÇÏÁö ¸øÇÑ´Ù. ƯÈ÷ °í¼öÁØÀÇ VHDL ¸ðµ¨, Å×½ºÆ®¸¦ À§ÇÑ ÀÔ/Ãâ·Â ÆÄÇü, ½Ã½ºÅÛ ±â¼úµîÀº ÇÕ¼º ºÒ°¡´É ÇÏ´Ù. (after ¹®¿¡ ÀÇÇÑ Áö¿¬(delay)¸ðµ¨ µîÀ» ¾î¶»°Ô ÇÕ¼ºÇس¾¼ö ÀÖÀ»±î?)
ÇÕ¼ºÀº ÀûÀýÇÑ ³í¸®È¸·ÎÀÇ ±â¼úÀÌ ÀÌ·ç¾îÁ³À»¶§ °¡´ÉÇÏ¸ç ¸ðµç ¼³°è°¡ ÇÕ¼º°¡´ÉÇÏÁö ¾Ê´Ù. VHDL ¼³°èÀÚµéÀº ÀÌ·¯ÇÑ ÇÕ¼º±âÀÇ Á¦¾à»çÇ×(constraints)À» ¹Ýµå½Ã ¼÷ÁöÇÏ°í ÀÖ¾î¾ß ÇÑ´Ù.
¾Æ¹«¸® ÀÌ·ÐÀûÀ¸·Î ¿Ïº®ÇÏ°í Àß Ç¥Çö µÇ¾ú´õ¶óµµ ½ÇÁ¦·Î ±¸ÇöµÇ±â ¾î·Á¿î °ÍµéÀÌ ¸¹Àº ¹ýÀÌ´Ù. VHDLÀÌ ºñ·Ï Çϵå¿þ¾î¸¦ ±â¼úÇϱâ À§ÇÑ °ÍÀ̶óÁö¸¸ °ð¹Ù·Î Çϵå¿þ¾î¸¦ ÀǹÌÇϴ°ÍÀº ¾Æ´Ï´Ù.
´ÙÀ½¿¡´Â VHDL±¸¹®À» »ìÆ캸°í ÇÕ¼º°¡´ÉÇÑ ÄÚµù ½ºÅ¸ÀÏ°ú ½ÇÁ¦·Î ÇÕ¼º±â Åø¿¡¼ ¾ò¾îÁø °á°ú¸¦ ºñ±³ÇØ º¸±â·Î ÇÏ°Ú´Ù.
mailto:goodkook@csvlsi.kyunghee.ac.kr
CSA & VLSI Design Lab. Kyunghee Univ