




版權說明:本文檔由用戶提供并上傳,收益歸屬內容提供方,若內容存在侵權,請進行舉報或認領
文檔簡介
1、何賓2008.10第第 4章章u 在復雜數(shù)字系統(tǒng)中,其結構總可以用若干基本邏輯單元的組合進行描述。u 基本邏輯單元一般分為組合邏輯電路和時序電路兩大類。在此基礎上,可以更進一步進行組合。u 本章所介紹的存儲器、運算單元和有限自動狀態(tài)機就是由基本邏輯單元組合而成的。u 本章首先介紹基本的組合邏輯電路和時序電路設計,然后介紹在數(shù)字系統(tǒng)設計中普遍使用的存儲器電路、運算單元和有限自動狀態(tài)機。u 對基本邏輯門的操作主要有:與、與非、或、或非、異或、異或非和非操作。通過使用vhdl語言中描述基本邏輯門電路操作的關鍵字:and(與),nand(與非),or(或),nor(或非),xor(異或),xnor(異
2、或非),not(非)來實現(xiàn)對基本邏輯門的操作。一堆復雜的邏輯門操作總可以化簡為集中基本邏輯門操作的組合。【例例4-1】基本門電路的設計 library ieee; use ieee.std_logic_1164.all; entity gate is port(a, b,c : in std_logic; d : out std_logic); end gate; architecture rtl of gate isbegin d=(not a) and b) or c;end rtl; u 在數(shù)字系統(tǒng)中,常常會將某一信息用特定的代碼進行描述,這稱為編碼過程。編碼過程可以通過編碼器電路實現(xiàn)。
3、同時,將某一特定的代碼翻譯成原始的信息,這稱為譯碼過程。譯碼過程可以通過譯碼器電路實現(xiàn)。 u 將某一信息用一組按一定規(guī)律排列的二進制代碼描述稱為編碼。典型的有8421碼、bcd碼等。在使用vhdl語言設計編碼器時,通過使用case和if語句實現(xiàn)對編碼器的描述。【例例4-2】8/3線編碼器的vhdl描述 library ieee; use ieee.std_logic_1164.all; entity priority_encoder_1 is port ( sel : in std_logic_vector (7 downto 0); code :out std_logic_vector (2
4、 downto 0); end priority_encoder_1; architecture archi of priority_encoder_1 is begin code = 000 when sel(0) = 1 else 001 when sel(1) = 1 else 010 when sel(2) = 1 else 011 when sel(3) = 1 else 100 when sel(4) = 1 else 101 when sel(5) = 1 else 110 when sel(6) = 1 else 111 when sel(7) = 1 else zzz; en
5、d archi;u 譯碼的過程實際上就是編碼過程的逆過程,即將一組按一定規(guī)律排列的二進制數(shù)還原為原始的信息。下面以最常用的3:8譯碼器為例,給出其vhdl語言描述。【例例4-4】十六進制數(shù)的共陽極十六進制數(shù)的共陽極7段數(shù)碼顯示段數(shù)碼顯示vhdl描述描述 library ieee; use ieee.std_logic_1164.all; use ieee.std_logic_unsigned.all; entity decoder is port(hex: in std_logic_vector(3 downto 0); led : out std_logic_vector(6downto 0
6、); end decoder; architecture rtl of decoder is begin with hex select led= 1111001 when 0001, -1 0100100 when 0010, -2 0110000 when 0011, -3 0011001 when 0100, -4 0010010 when 0101, -5 0000010 when 0110, -6 1111000 when 0111, -7 0000000 when 1000, -8 0010000 when 1001, -9 0001000 when 1010, -a 000001
7、1 when 1011, -b 1000110 when 1100, -c 0100001 when 1101, -d 0000110 when 1110, -e 0001110 when 1111, -f 1000000 when others; -0 end rtl;u case和if語句描述數(shù)據(jù)緩沖器 在數(shù)字系統(tǒng)設計中,常使用case和if語句描述數(shù)據(jù)緩沖器。下面給出這兩種描述方法。【例例4-5】4選1多路選擇器的if語句描述library ieee;use ieee.std_logic_1164.all;entity multiplexers_1 isport (a, b, c, d
8、: in std_logic;s : in std_logic_vector (1 downto 0);o : out std_logic);end multiplexers_1;architecture archi of multiplexers_1 isbeginprocess (a, b, c, d, s)beginif (s = 00) then o = a;elsif (s = 01) then o = b;elsif (s = 10) then o = c;else o o o o o = d;end case;end process;end archi;u 使用三態(tài)緩沖語句也可以
9、描述多路數(shù)據(jù)選擇器。圖4.5給出了4選1多路選擇器的三態(tài)的原理。圖4.5 三態(tài)緩沖實現(xiàn)4選1多路選擇器【例例4-7】4選1多路選擇器的三態(tài)描述library ieee;use ieee.std_logic_1164.all;entity multiplexers_3 isport (a, b, c, d : in std_logic;s : in std_logic_vector (3 downto 0);o : out std_logic);end multiplexers_3;architecture archi of multiplexers_3 isbegino = a when (s
10、(0)=0) else z;o = b when (s(1)=0) else z;o = c when (s(2)=0) else z;o = d when (s(3)=0) else z;end archi;u 比較器就是對輸入數(shù)據(jù)進行比較,并判斷其大小的邏輯電路。在數(shù)字系統(tǒng)中,比較器是基本的組合邏輯單元之一,比較器主要是使用關系運算符實現(xiàn)的。【例例4-8】8位數(shù)據(jù)比較器的vhdl描述library ieee;use ieee.std_logic_1164.all;use ieee.std_logic_unsigned.all;entity comparator_1 isport(a,b :
11、 in std_logic_vector(7 downto 0);cmp : out std_logic);end comparator_1;architecture archi of comparator_1 isbegincmp = b else 0;end archi; 從上面的例子可以看出,使用vhdl中的、=、=、=、/=,這幾種關系運算符及其它們的組合,可以設計出具有復雜比較功能的比較器。u 數(shù)據(jù)運算單元主要包含加法器、減法器、乘法器和除法器,由這四種運算單元和邏輯運算單元一起,可以完成復雜數(shù)學運算。在vhdl語言中,支持的幾種運算有:加(+)、減(-)、乘(*)、除(/)、取余(
12、mod)、冪乘(*)。u 在vhdl描述加法器時,使用+運算符比門級描述更簡單。下面給出帶進位輸入和輸出的無符號的8比特加法器的vhdl描述。【例4-9】帶進位輸入和輸出的無符號的8比特加法器的vhdl描述library ieee;use ieee.std_logic_1164.all;use ieee.std_logic_arith.all;use ieee.std_logic_unsigned.all;entity adders_4 isport(a,b,ci : in std_logic_vector(7 downto 0);sum : out std_logic_vector(7 do
13、wnto 0);co : out std_logic);end adders_4;architecture archi of adders_4 issignal tmp: std_logic_vector(8 downto 0);begin sum = tmp(7 downto 0);co = tmp(8);tmp = conv_std_logic_vector(conv_integer(a) + conv_integer(b) +conv_integer(ci),9);end archi;u 減法是加法的反運算,采用vhdl語言的-符號描述減法器,比用門級描述更簡單。下面給出一個無符號8位帶
14、借位的減法器的vhdl描述。【例例4-10】無符號8位帶借位的減法器的vhdl描述library ieee;use ieee.std_logic_1164.all;use ieee.std_logic_unsigned.all;entity adders_8 isport(a,b : in std_logic_vector(7 downto 0);bi : in std_logic;res : out std_logic_vector(7 downto 0);end adders_8;architecture archi of adders_8 isbeginres = a - b - bi;
15、end archi;u 用vhdl語言實現(xiàn)乘法器時,乘積和符號應該為2的冪次方。pld的優(yōu)點就是在內部集成了乘法器的硬核,具體在ip核的設計中詳細討論。【例例4-11】下面給出一個8位和4位無符號的乘法器的vhdl描述library ieee;use ieee.std_logic_1164.all;use ieee.std_logic_unsigned.all;entity multipliers_1 isport(a : in std_logic_vector(7 downto 0);b : in std_logic_vector(3 downto 0);res : out std_logi
16、c_vector(11 downto 0);end multipliers_1;architecture beh of multipliers_1 isbeginres = a * b;end beh;u 除法器可以用vhdl語言的/符號實現(xiàn),需要注意的是在使用/符號進行除法運算時,除數(shù)必須是常數(shù),而且是2的整數(shù)冪。因為除法器的運行有這樣的限制,實際上除法也可以用移位運算實現(xiàn)。下面給出一個除法器的vhdl描述。 【例例4-12】除法器的vhdl描述。 library ieee; use ieee.std_logic_1164.all; use entity divider_1 is port(
17、di : in unsigned(7 downto 0); do : out unsigned(7 downto 0); end divider_1; architecture archi of divider_1 is begin do = di / 2; end archi;【例例4-13】三態(tài)門的進程描述library ieee;use ieee.std_logic_1164.all;entity tri_gate is port (en : in std_logic; din : in std_logic_vector(7 downto 0); dout : out std_logic
18、_vector(7 downto 0);end tri_gate;architecture rtl of tri_gate isbegin process(din,en) begin if(en=1) then dout=din; else dout=zzzzzzzz; end if; end process;end rtl;【例例4-14】三態(tài)門的when-else進程描述library ieee;use ieee.std_logic_1164.all;entity tri_gate is port (en : in std_logic; din : in std_logic_vector(
19、7 downto 0); dout : out std_logic_vector(7 downto 0);end tri_gate;architecture rtl of tri_gate isbegindout= din when en =1 else zzzzzzzz;end rtl; 從上面的兩個例子中可以看出,使用條件并行語句描述三態(tài)門比使用進程要簡單的多。【例例4-15】雙向總線緩沖器的描述 library ieee; use ieee.std_logic_1164.all; entity bidir is port(a : inout std_logic_vector(15 dow
20、nto 0); end bidir; architecture rtl of bidir is signal a_in : std_logic_vector(15 downto 0); signal a_out : std_logic_vector(15 downto 0); signal t : std_logic; begin a= a_out when t = 0 else zzzzzzzzzzzzzzzz; a_out=a; end rtl;u 時序邏輯電路的輸出狀態(tài)不僅與輸入變量的狀態(tài)有關,而且還與系統(tǒng)原先的狀態(tài)有關。時序電路最重要的特點是存在著記憶單元部分,時序電路主要包括:時鐘和
21、復位、基本觸發(fā)器、計數(shù)器、移位寄存器等。u 時序電路由時鐘驅動,時序電路只有在時鐘信號的邊沿到來時,其狀態(tài)才發(fā)生改變。在數(shù)字系統(tǒng)中,時序電路的時鐘驅動部分一般包括時鐘信號和系統(tǒng)復位信號。根據(jù)時鐘和復位的描述不同,時序電路一般分成同步復位電路和異步復位電路兩類。u 在時序電路中,不論采用什么方法描述時鐘信號,必須指明時鐘的邊沿條件(clock edge condition)。時鐘沿條件有上升沿和下降沿兩種。 時鐘的上升沿條件可以用下面的語句描述:clockevent and clock = 1 rising_edge(clock)時鐘的下降沿條件可以用下面的語句描述:clockevent and
22、 clock = 0falling_edge(clock)u 在時序電路中,對時鐘信號的驅動方法有如下幾種描述方式: 1)進程的敏感信號是時鐘信號,在進程內部用if 語句描述時鐘的邊沿條件。【例例4-16】時鐘信號的if描述 process (clock_signal) begin if (clock_edge_condition) then signal_out = signal_in ; 其它時序語句 end if ; end process ; 2)在進程中用wait until語句描述時鐘信號,此時進程將沒有敏感信號。 【例例4-17】時鐘信號的wait until描述 process
23、 begin wait until (clock_edge_condition); signal_out = signal_in ; 其它時序語句 end process ; 注意:1)在對時鐘邊沿說明時,一定要注明是上升沿還是下降沿。 2)一個進程中只能描述一個時鐘信號。 3)wait until 語句只能放在進程的最前面或最后面。u 前面已經提到,根據(jù)復位和時鐘信號的關系不同。時序電路分為同步復位電路和異步復位電路兩大類。u、同步復位描述 同步復位指:當復位信號有效,并且在給定的時鐘邊沿有效時,時序電路才被復位。 在同步復位電路中,在只有以時鐘為敏感信號的進程中定義。 【例例4-18】同步
24、復位的vhdl描述 process (clock_signal) begin if (clock_edge_condition) then if (reset_condition) then signal_out = reset_value; else signal_out = signal_in ; end if ; end if ; end process ; u 、異步復位描述異步復位指:當復位信號有效時,時序電路就被復位。在異步復位電路中,進程的敏感信號表中除時鐘信號外,還有復位信號。 【例例4-19】異步復位的vhdl描述process (reset_signal, clock_si
25、gnal) begin if (reset_condition) then signal_out = reset_value; elsif (clock_edge_condition) then signal_out = signal_in ; end if ; end process ; u 觸發(fā)器是時序邏輯電路的最基本單元,觸發(fā)器具有“記憶”能力。u根據(jù)沿觸發(fā)、復位和置位方式的不同觸發(fā)器可以有多種實現(xiàn)方式。在pld中經常使用的觸發(fā)器有d觸發(fā)器、jk觸發(fā)器和t觸發(fā)器等。【例例4-20】帶時鐘使能和異步復位/置位的d觸發(fā)器的vhdl描述。d觸發(fā)器是數(shù)字電路中應用最多的一種時序電路。表4.1給出
26、了帶時鐘使能和異步復位/置位的d觸發(fā)器的真值表。輸入輸出clrprecedcq1xxxx001xxx1000xx無變化0010000111library ieee;useieee.std_logic_1164.all;entity fdd is port(clk,d,clr,pre,ce : in std_logic; q : out std_logic);end fdd;architecture rtl of dff is signal q_tmp : std_logic; begin q=q_tmp; process(clk,clr,pre,c) begin if(clr=1) then
27、q_tmp=0; elsif(pre=1) then q_tmp=1; elsif rising_edge(clk) then if(ce=1) then q_tmp=d; else q_tmp=q_tmp; end if; end if; end process;end rtl;u 鎖存器和觸發(fā)器不同之處,就在于觸發(fā)方式的不同,觸發(fā)器是靠敏感信號的邊沿出發(fā),而鎖存器是靠敏感信號的電平觸發(fā)。下面給出鎖存器的vhdl描述。【例例4-23】鎖存器的vhdl描述library ieee;use ieee.std_logic_1164.all;entity latch isport(gate,data
28、,set : in std_logic; q : out std_logic);end latch;architecture rtl of latch isbegin process(gate,data,set) begin if(set=0) then q=1; elsif(gate=1) then q=data; end if; end process;end rtl;u 根據(jù)計數(shù)器的觸發(fā)方式不同,計數(shù)器可以分為:同步計數(shù)器和異步計數(shù)器兩種。當賦予計數(shù)器更多的功能時,計數(shù)器的功能就非常復雜了。需要注意的是,計數(shù)器是常用的定時器的核心部分,當計數(shù)器輸出控制信號時,計數(shù)器也就變成了定時器了。所
29、以只要掌握了計數(shù)器的設計方法,就可以很容易的設計定時器。本書中主要介紹同步計數(shù)器的設計。u 同步計數(shù)器指在時鐘脈沖(計數(shù)脈沖)的控制下,計數(shù)器做加法或減法的運算。【例例4-24】可逆計數(shù)器的描述library ieee;use ieee.std_logic_1164.all;use ieee.std_logic_unsigned.all;entity updowncounter64 is port(clk,clr,dir : in std_logic; q : out std_logic_vector(4 downto0);end updowncounter64; architecture r
30、tl of updowncounter64 is signal count_tmp: std_logic_vector(4downto 0);begin q=count_tmp;process(clr,clk) begin if(clr=1) then count_tmp=”000000”; elsif rising_edge(clk) then if (dir=1) then count_tmp=count_tmp+1; else count_tmp=count_tmp-1; end if; end if; end process;end rtl;【例例4-25】四比特帶有最大計數(shù)限制的計數(shù)
31、器vhdl描述library ieee;use ieee.std_logic_1164.all;use ieee.std_logic_arith.all;entity counters_8 isgeneric (max : integer := 16);port(c, clr : in std_logic;q : out integer range 0 to max-1);end counters_8;architecture archi of counters_8 issignal cnt : integer range 0 to max-1;begin q = cnt;process (c
32、, clr)beginif (clr=1) thencnt = 0;elsif (rising_edge(c) thencnt = (cnt + 1) mod max ;end if;end process;end archi;n 在vhdl語言中,對移位寄存器的描述有三種方式: )并置操作符 shreg = shreg (6 downto 0) & si; 2)for-loop語句 for i in 0 to 6 loop shreg(i+1) = shreg(i); end loop; shreg(0) = si; 3)預定義的移位操作符sll或srl等n 1、預定義的移位操作符(
33、1)算術左移的vhdl描述/ sla (2)邏輯左移的vhdl描述 / sll (3)算術右移的vhdl描述/ sra (4)邏輯右移的vhdl描述 / srl 【例例4-26】移位操作符實現(xiàn)邏輯左移的vhdl描述library ieee;use ieee.std_logic_1164.all;use ieee.numeric_std.all;entity logical_shifters_2 isport(di : in unsigned(7 downto 0); sel : in unsigned(1 downto 0); so : out unsigned(7 downto 0);end
34、 logical_shifters_2;architecture archi of logical_shifters_2 isbeginprocess()begin if ( event and =1) then case sel is when 00 = so so so so so= di ; end case; end if;end process;end archi;n 2、通過vhdl的類型操作,元件例化、信號連接等不同實現(xiàn)方法實現(xiàn)移位操作運算。下面通過函數(shù)調用,元件例化、信號連接等不同實現(xiàn)方法實現(xiàn)一個16位的串行輸入、串行輸出的移位寄存器。【例例4-27】元件例化的方法實現(xiàn)16位串
35、入/串出移位寄存器的vhdl描述library ieee;use ieee.std_logic_1164.all;entity shift8 is port (a,clk : in std_logic; b : out std_logic);end shift8;architecture rtl of shift8 is component dff port(d,clk : in std_logic; q : out std_logic); end component;signal z : std_logic_vector(15 downto 0);begin z(0)=a; g1: for
36、i in 0 to 15 generate dffx : dff port map(z(i),clk,z(i+1); end generate; b=z(15);end rtl;【例例4-28】類型操作實現(xiàn)16位移位寄存器的vhdl描述library ieee;use ieee.std_logic_1164.all;entity shift_registers_1 isport(c, si : in std_logic; so : out std_logic);end shift_registers_1; architecture archi of shift_registers_1 is s
37、ignal tmp: std_logic_vector(15 downto 0); begin so = tmp(7); process (c) begin if rising_edge(c) then for i in 0 to 14 loop tmp(i+1) = tmp(i); end loop; tmp(0) = si; end if; end process;end archi;【例例4-29】并置操作實現(xiàn)16位串入/并出移位寄存器的vhdl描述library ieee;use ieee.std_logic_1164.all;entity shift_registers_5 ispo
38、rt(c, si : in std_logic;po : out std_logic_vector(15 downto 0);end shift_registers_5;architecture archi of shift_registers_5 issignal tmp: std_logic_vector(7 downto 0);begin po = tmp; process (c) begin if rising_edge(c) then tmp = tmp(14 downto 0)& si; end if; end process;end archi;n 存儲器按其類型主要分為
39、只讀存儲器和隨機存儲器兩種。雖然存儲器從其工藝和原理上各不相同,但有一點是相同的,即存儲器是單個存儲單元的集合體,并且按照順序排列。其中的每一個存儲單元由n位二進制位構成,表示存放的數(shù)據(jù)的值。n 由于這些特點,所以可以用vhdl的類型語句進行描述。1、用整數(shù)描述: type mem is array(integer range) of integer;2、用位矢量描述: subtype wrd is std_logic_vector(k-1 downto 0); type mem is array(0 to 2*w-1) of wrd;n 需要注意的是,雖然在本節(jié)給出了存儲器的原理描述和實現(xiàn)方
40、法,但在實際中,尤其是在fpga的設計中,存儲器在fpga內作為核提供給設計人員進行使用,設計人員只需要對這些核進行配置,就可以生成高性能的存儲器模塊,根本沒有必要用vhdl語言進行原理和功能的描述。u 只讀存儲器的數(shù)據(jù)被事先保存到了每個存儲單元中,在pld中保存數(shù)據(jù)的方法有很多。當對rom進行讀操作時,只要在控制信號的控制下,對操作的單元給出讀取的數(shù)值即可。【例例4-30】rom的vhdl描述en為rom的使能信號,addr為rom的地址信號,clk為rom的時鐘信號,data為數(shù)據(jù)信號。圖4.16 rom的結構圖library ieee;use ieee.std_logic_1164.al
41、l;use ieee.std_logic_unsigned.all;entity rams_21a isport (clk : in std_logic;en : in std_logic;addr : in std_logic_vector(5 downto 0);data : out std_logic_vector(19 downto 0);end rams_21a;architecture syn of rams_21a istype rom_type is array (63 downto 0) of std_logic_vector (19 downto 0);signal rom
42、 : rom_type:= (x0200a, x00300, x08101, x04000, x08601, x0233a,x00300, x08602, x02310, x0203b, x08300, x04002,x08201, x00500, x04001, x02500, x00340,x00241,x04002, x08300, x08201, x00500, x08101, x00602,x04003, x0241e,x“00301”, x00102, x02122, x02021,x00301, x00102, x02222, x04001, x00342, x0232b,x00
43、900, x00302, x00102, x04002, x00900, x08201,x02023, x00303, x02433, x00301, x04004, x00301,x00102, x02137,x02036, x00301, x00102, x02237,x04004, x00304, x04040, x02500, x02500, x02500,x0030d, x02341, x08201, x0400d);beginprocess (clk)beginif rising_edge(clk) thenif (en = 1) thendata = rom(conv_integ
44、er(addr);end if;end if;end process;end syn;u ram和rom的區(qū)別,在于ram有讀寫兩種操作,而rom只有讀操作。另外,ram對讀寫的時序也有著嚴格的要求。【例例4-31】一個單端口ram的vhdl的描述 en為ram使能信號, we為ram寫信號, di為ram數(shù)據(jù)輸入信號, addr為ram地址信號, clk為ram時鐘信號, do為ram數(shù)據(jù)輸出信號。library ieee;use ieee.std_logic_1164.all;use ieee.std_logic_unsigned.all;entity rams_01 isport (cl
45、k : in std_logic;we : in std_logic;en : in std_logic;addr : in std_logic_vector(5 downto 0);di : in std_logic_vector(15 downto 0);do : out std_logic_vector(15 downto 0);end rams_01;architecture syn of rams_01 istype ram_type is array (63 downto 0) ofstd_logic_vector (15 downto 0);signal ram: ram_typ
46、e;beginprocess (clk)beginif clkevent and clk = 1 thenif en = 1 thenif we = 1 thenram(conv_integer(addr) = di;end if;do = ram(conv_integer(addr) ;end if;end if;end process;end syn;u 先進先出的對列fifo在數(shù)字系統(tǒng)設計中有著非常重要的應用,它經常用來對付時間不同步情況下的數(shù)據(jù)操作問題,在這里通過vhdl語言進行了描述。但在實際的pld設計時,設計者可以很方便的使用eda廠商提供的ip核自動生成fifo,而無須用vhd
47、l語言進行復雜的原理描述。u fifo和ram有很多相同的地方,唯一不同的是,fifo的操作沒有地址,而只有內部的指針,保證數(shù)據(jù)在fifo中先入先出順序的正確性。fifo一般由下列單元:存儲單元,寫指針,讀指針、滿、空標志和讀寫控制信號等構成。u 有限自動狀態(tài)機fsm(finate state machine)的設計是復雜數(shù)字系統(tǒng)中非常重要的一部分,是實現(xiàn)高效率高可靠性邏輯控制的重要途徑。大部分數(shù)字系統(tǒng)都是由控制單元和數(shù)據(jù)單元組成的。數(shù)據(jù)單元負責數(shù)據(jù)的處理和傳輸,而控制單元主要是控制數(shù)據(jù)單元的操作的順序。而在數(shù)字系統(tǒng)中,控制單元往往是通過使用有限狀態(tài)機實現(xiàn)的,有限狀態(tài)機接受外部信號以及數(shù)據(jù)單元
48、產生的狀態(tài)信息,產生控制信號序列。 從上面的數(shù)學模型可以看出,如果在數(shù)字系統(tǒng)中實現(xiàn)有限狀態(tài)機,則應該包含三部分:狀態(tài)寄存器;下狀態(tài)轉移邏輯;輸出邏輯。 描述有限狀態(tài)機的關鍵是狀態(tài)機的狀態(tài)集合以及這些狀態(tài)之間的轉移關系。描述這種轉換關系除了數(shù)學模型外,還可以用狀態(tài)轉移圖或狀態(tài)轉移表來實現(xiàn)。 狀態(tài)轉移圖由三部分組成:表示不同狀態(tài)的狀態(tài)點、連接這些狀態(tài)點的有向箭頭以及標注在這些箭頭上的狀態(tài)轉移條件。 狀態(tài)轉移表采用表格的方式描述狀態(tài)機。狀態(tài)轉移表由三部分組成:當前狀態(tài)、狀態(tài)轉移事件和下一狀態(tài)。狀態(tài)機分類很多,主要分為moore狀態(tài)機、mealy狀態(tài)機和擴展有限狀態(tài)機。 下面就moore狀態(tài)機、mea
49、ly狀態(tài)機的原理和應用進行詳細的介紹。 mealy型狀態(tài)機的輸出由狀態(tài)機的輸入和狀態(tài)機的狀態(tài)共同決定;【例例4-31】mealy型狀態(tài)機的vhdl描述 process (state, , , .) -定義過程,輸出和輸入及狀態(tài)有關 begin if (state = st3_ and = 1) then _i = 1; else _i = 0; end if; end process;process (state, , , .) -定義過程,確定狀態(tài)的遷移 begin next_state = state; case (state) is when st1_ = if = 1 then nex
50、t_state = st2_; end if; when st2_ = if = 1 then next_state = st3_; end if; when st3_ = next_state = st1_; when others = next_state = st1_; end case; end process;u moore型狀態(tài)機的輸出僅與狀態(tài)機的狀態(tài)有關,與狀態(tài)機的輸入無關。【例例4-31】moore型狀態(tài)機的vhdl語言的描述 type state_type is (st1_, st2_, .); -定義狀態(tài) signal state, next_state : state_t
51、ype; signal _i : std_logic; - example output signal -定義所有輸出信號 sync_proc: process (,) -定義狀態(tài)的遷移 begin if ( = 1) then state = st1_; = 0; elsif (rising_edge() then state = next_state; = _i; -定義所有的輸出 end if; end process; process (state) begin if state = st3_ then _i = 1; else _i = 0; end if; end process;
52、 process (state, , , .) -定義不同狀態(tài)下的輸出 begin next_state = state; case (state) is when st1_ = if = 1 then next_state = st2_; end if; when st2_ = if = 1 then next_state = st3_; end if; when st3_ = next_state = st1_; when others = next_state = st1_; end case; end process;u 雖然在這里將兩種類型的狀態(tài)機加以區(qū)分,但是在實際的狀態(tài)機的設計中,設計人員根本不需要這些差別,只要滿足狀態(tài)機設計的規(guī)則和狀態(tài)機運行的條件,采用任何一種狀態(tài)機都可以實現(xiàn),并且設計人員可以在實際的設計過程中形成自己獨特的狀態(tài)
溫馨提示
- 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請下載最新的WinRAR軟件解壓。
- 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯(lián)系上傳者。文件的所有權益歸上傳用戶所有。
- 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內容里面會有圖紙預覽,若沒有圖紙預覽就沒有圖紙。
- 4. 未經權益所有人同意不得將文件中的內容挪作商業(yè)或盈利用途。
- 5. 人人文庫網(wǎng)僅提供信息存儲空間,僅對用戶上傳內容的表現(xiàn)方式做保護處理,對用戶上傳分享的文檔內容本身不做任何修改或編輯,并不能對任何下載內容負責。
- 6. 下載文件中如有侵權或不適當內容,請與我們聯(lián)系,我們立即糾正。
- 7. 本站不保證下載資源的準確性、安全性和完整性, 同時也不承擔用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。
最新文檔
- 清遠市棋牌室管理辦法
- 石油化工培訓課件
- 重慶理工職業(yè)學院《表現(xiàn)技法系列課程》2023-2024學年第一學期期末試卷
- 監(jiān)理公司管理培訓課件
- 全國各地高考語文模擬題分類匯編100練【文言文閱讀】
- 寵物電競陪玩服務行業(yè)商業(yè)模式創(chuàng)新案例分析
- 采茶廠高管出差審批與行程備案制度
- 低碳建筑設計規(guī)范與標準企業(yè)制定與實施新質生產力項目商業(yè)計劃書
- 歷史文化主題微電影與短視頻制作企業(yè)制定與實施新質生產力項目商業(yè)計劃書
- 空中花園燒烤行業(yè)跨境出海項目商業(yè)計劃書
- 2025區(qū)域型變電站智能巡視系統(tǒng)技術規(guī)范
- 財務報表編制與審核合同模板
- 上海閔行區(qū)教育系統(tǒng)招聘實驗員考試真題2024
- 建設部建設工程重大質量安全事故應急預案
- 2025年中航油招聘筆試參考題庫附帶答案詳解
- 人工智能技術創(chuàng)新對產業(yè)高質量發(fā)展的推動作用
- GB/T 27772-2025病媒生物密度控制水平蠅類
- 【MOOC】《算法設計與分析》(東北大學) 中國大學慕課答案
- 2025年部門預算支出經濟分類科目說明表
- 品管圈PDCA提高手衛(wèi)生依從性
- 2022版體育與健康課程標準
評論
0/150
提交評論