CH7序向逻辑与正反器设计.ppt_第1页
CH7序向逻辑与正反器设计.ppt_第2页
CH7序向逻辑与正反器设计.ppt_第3页
CH7序向逻辑与正反器设计.ppt_第4页
CH7序向逻辑与正反器设计.ppt_第5页
已阅读5页,还剩21页未读 继续免费阅读

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

1,序向邏輯與正反器設計,第七章,儒林圖書公司 TB061,VHDL數位電路設計實務教本 使用Quartus II,Process敘述和If_then_else,2,標記名稱:Process (Sensitivity List) begin Process主體敘述 End Process 標記名稱;,If (條件1) Then 指令敘述; Elsif (條件2) Then 指令敘述; : Else 指令敘述; End If;,If_Then_Else 比較指令,Process 敘述,if_then_else敘述 -D型正反器,3,LIBRARY IEEE; USE IEEE.STD_LOGIC_1164.ALL; ENTITY dff_v is PORT( CLK,D : IN STD_LOGIC; Q : OUT STD_LOGIC ); END dff_v; ARCHITECTURE a OF dff_v IS BEGIN PROCESS (CLK) BEGIN IF CLKevent AND CLK=1 THEN Q = D; END IF; END PROCESS; END a;,if_then_else敘述 -AND閘的模擬,4,library IEEE; use IEEE.std_logic_1164.all; entity AND2_vhdl is port ( X : in STD_LOGIC; C : out STD_LOGIC ); end AND2_vhdl; architecture a of AND2_vhdl is begin process (X) begin if X=“11” then C=1; elsif C= 0; end if ; end process; end a;,- define the process section,- the sensitivity list,if_then_else敘述-半加法器設計,5,library IEEE; use IEEE.std_logic_1164.all; entity halfadd_vhdl is port ( x,y : in STD_LOGIC; sum,carry: out STD_LOGIC ); end halfadd_vhdl; architecture a of halfadd_vhdl is begin process (x, y) begin if (x = 0) and (y = 0) then carry = 0; sum = 0; elsif (x = 0) and (y = 1) then carry = 0; sum = 1;,elsif (x = 1) and (y = 0) then carry = 0; sum = 1; elsif (x = 1) and (y = 1) then carry = 1; sum = 0; end if ; end process; end a;,if_then_else敘述-四對一多工器,6,方法一:單層的IF-Then-else敘述,Library IEEE; Use ieee.std_logic_1164.all; Entity MUX41 IS PORT(A,B,C,D:IN std_logic; S:IN std_logic_vector(1 downto 0); X:OUT std_logic); END MUX41; Architecture A of MUX41 IS BEGIN PROCESS (s, a, b, c, d) BEGIN,if (s = “00“) then X = a; elsif (s = “01“) then X = b; elsif (s = “10“) then X = c; else X = d; end if; END PROCESS; END a;,if_then_else敘述-四對一多工器,7,方法二:三層巢狀的IF-Then-else敘述,Library IEEE; Use ieee.std_logic_1164.all; Entity MUX41b IS PORT(A,B,C,D:IN std_logic; S:IN std_logic_vector(1 downto 0); X:OUT std_logic); END MUX41b;,Architecture A of MUX41b IS BEGIN ROCESS (s, a, b, c, d) BEGIN if (s = “00“) then X = a; else if (s = “01“) then X = b; else if (s = “10“) then X = c; else X = d; end if; end if; end if; END PROCESS; END a;,if_then_else敘述-三態緩衝閘,8,library IEEE; use IEEE.std_logic_1164.all; entity tri_gate is port (oe, X : in std_logic; Y : out std_logic); end tri_gate; architecture a of tri_gate is begin process (oe, X) begin if oe = 1 then Y = X; else Y = Z; end if; end process; end a;,三態非反相緩衝器在當Enable=0時, 輸出是浮接狀態(高阻抗輸出); Enable=1時,輸出和輸入信號相同,if_then_else敘述-優先權電路,9,功能設計:設定Y7至Y1是輸入值,Pout是輸出值;其中Y7 是最高優先權的輸入, 而Y1是最低優先權的輸入。 例 如:當Y6為1而且Y3也為1時,其輸出即應為1102(610); 同理當Y5為1而且Y2也為1時,其輸出即應為1012(510),architecture a of priority is begin process (y1, y2,y3, y4, y5, y6, y7) begin if (y7 = 1) then Pout = “111“; elsif (y6 = 1) then Pout = “110“; elsif (y5 = 1) then Pout = “101“; elsif (y4 = 1) then Pout = “100“; elsif (y3 = 1) then Pout = “011“; elsif (y2 = 1) then Pout = “010“; elsif (y1 = 1) then Pout = “001“; else Pout = “000“; end if; end process; end a;,library ieee; use ieee.std_logic_1164.all; entity priority is port ( y1, y2, y3, y4, y5, y6, y7 : in std_logic; Pout: out std_logic_vector(2 downto 0); end priority;,if_then_else敘述-邏輯模組資源分享,10,IF X=1 Then temp1 = A; temp2 = B; else temp1 = C; temp2 = D; End if; Z = temp1 + temp2;,IF X=1 Then Z = A + B; else Z = C + D; End if;,Wait 敘述與標準正反器設計,11,Wait Until 條件式 Ex:Wait Until CLKevent and CLK=1; Wait On 訊號 Ex: Wait On a,b Wait For 時間表示式 Ex: Wait For 20ns; Ex: Wait For (a*(b+c);,Wait 敘述,clk,event,以Wait 敘述描述D型正反器,12,LIBRARY IEEE; USE IEEE.STD_LOGIC_1164.ALL; ENTITY dff_v_wait IS PORT( CLK,D : IN STD_LOGIC; Q : OUT STD_LOGIC ); END dff_v_wait; ARCHITECTURE a OF dff_v_wait IS BEGIN PROCESS BEGIN Wait Until (CLKevent AND CLK=1); Q = D; END PROCESS; END a;,簡易正反器電路應用範例 -兩個D型正反器串接的同步電路,13,library ieee; use ieee.std_logic_1164.all; entity D_reg is port (A, CLK : in std_logic; C : out std_logic); end D_reg; architecture a of D_reg is signal B : std_logic; begin PROCESS (clk) BEGIN if CLKevent and CLK=1 then B = A; C = B; end if; END PROCESS; end a;,簡易正反器電路應用範例,14,library ieee; use ieee.std_logic_1164.all; entity pulse_form is port(A, CLK: in std_logic; Y : out std_logic); end pulse_form; architecture behavioral of pulse_form is signal B, C, D: std_logic; begin,D_ff: process(CLK) begin if CLKevent and CLK=1 then B = A; C = B; D = C; end if; end process D_ff; Y = C AND (not D); end behavioral;,15,簡易正反器電路應用範例-微分電路,library ieee; use ieee.std_logic_1164.all; entity diff_all is port (A, CLK : in std_logic; UP_out,DN_out,UD_out: out std_logic); end diff_all; architecture a of diff_all is signal D0,D1: std_logic;,begin PROCESS (clk) BEGIN if CLKevent and CLK=1 then D0 = A; D1 = D0; end if; END PROCESS; UP_out=D0 and (not D1); -上緣微分 DN_out=(not D0) and D1; -下緣微分 UD_out=D0 xor D1; -上下緣微分 end a;,簡易正反器電路應用範例 -四位元的串列輸入移位暫存器設計,16,LIBRARY ieee; USE ieee.std_logic_1164.all; ENTITY d_shift4 IS PORT (D, Clk : IN STD_LOGIC; Q : OUT STD_LOGIC_VECTOR(1 TO 4); END d_shift4; ARCHITECTURE Behavior OF d_shift4 IS SIGNAL Sreg : STD_LOGIC_VECTOR(1 TO 4); BEGIN PROCESS (Clk) BEGIN,IF ClkEVENT AND Clk=1 THEN Sreg(4) = D; Sreg(3) = Sreg(4); Sreg(2) = Sreg(3); Sreg(1) = Sreg(2); END IF; END PROCESS; Q = Sreg; END Behavior;,簡易正反器電路應用範例,17,LIBRARY ieee; USE ieee.std_logic_1164.all; ENTITY sync_ex IS PORT ( clock :in std_logic; Q :out std_logic_vector(2 downto 0); END sync_ex; ARCHITECTURE a OF sync_ex IS signal Qn:std_logic_vector(2 downto 0); BEGIN process(clock) begin if clockevent and clock=1 then Qn(2)=Qn(2) xor (Qn(1) and Qn(0); Qn(1)=Qn(1) xor Qn(0); Qn(0)=not Qn(0); end if; end process; Q=Qn; END a;,具有設定(Set)與重置(Reset)功能 的正反器設計 D型正反器,18,LIBRARY IEEE; USE IEEE.STD_LOGIC_1164.ALL; ENTITY dff_v1 is PORT( CLK,D,set,reset : IN STD_LOGIC; Q : OUT STD_LOGIC ); END dff_v1; ARCHITECTURE a OF dff_v1 IS BEGIN PROCESS (CLK) begin if set = 1 then q=1; elsif reset=1 then q=0; elsif CLKevent AND CLK=1 THEN Q = D; end if; END PROCESS; END a;,highest priority,具有設定(Set)與重置(Reset)功能 的正反器設計-JK正反器,19,布林代數表示式 Q(t+1)=JQ(t)+KQ(t),library ieee; use ieee.std_logic_1164.all; entity JKFF is port (Set, Reset, J, K, CLK: in std_logic; Q : inout std_logic; QN: out std_logic ); end JKFF; architecture a of JKFF is begin process (Set,Reset, CLK) begin if Reset = 1 then Q= 0 ; elsif Set = 1 then Q= 1; elsif CLKevent and CLK = 1 then Q = (J and not Q) or (not K and Q); end if; end process; QN = not Q; end a;,能夠作同步脈波控制功能的 標準正反器設計,20,為了確保數組串接的正反器之間CLK訊號能夠同步動作,避免因時間延遲而導致邏輯單元間的同步問題,我們還可以再另外設計一個EN(Enable Clock)準位來做同步脈波控制,能夠作同步脈波控制功能的 標準正反器設計,21,LIBRARY IEEE; USE IEEE.STD_LOGIC_1164.ALL; ENTITY DFF IS PORT( CLK,D,set,reset,EN : IN STD_LOGIC; Q : OUT STD_LOGIC ); END DFF; ARCHITECTURE a OF DFF IS BEGIN PROCESS (CLK) BEGIN IF set=1 then Q=1; elsif reset=1 then Q=0; elsif CLKevent AND CLK=1 then IF EN =1 THEN Q = D; END IF; END IF; END PROCESS; END a;,標準正反器應用電路範例,22,library IEEE; use IEEE.std_logic_1164.all; entity DFF_TP is port (D1, D2, reset, clk: in std_logic; Q : out std_lo

温馨提示

  • 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
  • 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
  • 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
  • 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
  • 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
  • 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
  • 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

评论

0/150

提交评论