【正文】
end minute。 set_minute:in std_logic_vector(7 downto 0)。 use 。 end process。039。 m:=0。 m:=0。 m:=m+1。n,m must be modified at the same time。039。039。left downto out139。 out1:out std_logic_vector(7 downto 0))。 reset:in std_logic。 use 。 end。 參考程序如圖 所示: 75 圖 仿真波形如圖 所示: 圖 “File→New” 命令,打開(kāi)一個(gè)新的“ Memory initialization file”編輯窗口, 建立存儲(chǔ)器初值設(shè)定文件 ,如圖 ;然后 利用 MegaWizard PlugIn Manager定制lpmrom, 參考程序如圖 所示: 圖 76 圖 仿真波形如圖 所示: 圖 習(xí)題 9 : library ieee。 end if。dout=39。 elsif din=10 then p_state:=s6。 end if。139。dout=39。dout=39。 elsif din=01 then p_state:=s3。 end if。139。dout=39。dout=39。 elsif din=01 then p_state:=s1。 end if。139。dout=39。dout=39。 then時(shí)鐘上升沿,判斷并處理當(dāng)前輸入的位 case p_state is 圖 S0 10/0 S1 S2 S6 S5 11/1 S3 S4 00/1 00/1 00/1 00/1 00/1 00/1 01/1 01/1 01/1 01/1 01/1 01/1 10/0 10/0 10/0 10/0 10/0 10/0 73 when s0=if din=00 then p_state:=s1。039。 begin process(clk,clr) variable p_state:statetype。工作時(shí)鐘,復(fù)位信號(hào) din: in std_logic_vector(1 downto 0)。 仿真波形如圖 示: 0/0 圖 S0 1/0 S1 S2 S4 S3 0/0 1/0 1/0 1/0 0/0 0/1 X/1 72 圖 移圖如圖 所示。序列檢測(cè)正確 end case。end if。 then p_state:=s4。039。039。dout=39。 when s1=if din=39。 else p_state:=s0。139。then dout=39。 architecture art of sequence_check is type statetype is (s0,s1,s2,s3,s4)。 use 。 end process。 temp(0)=dil。 end loop。) then temp=data。139。 begin process(clr,clk,load,s,dir,dil) begin if clk39。 data: in std_logic_vector(31 downto 0)。 end art。 end if。039。 then if(d=9)then d=0000。event and clk=39。 elsif load=39。 architecture art of counter10 is signal d: std_logic_vector(3 downto 0)。 entity counter10 is port(clk,clr,load,s:in std_logic。 end art。 else dout=dout1。 then dout =din。event and clk=39。s=1 加法計(jì)數(shù), s=0 減法計(jì)數(shù) din: in std_logic_vector(15 downto 0)。 仿真波形如圖 所示: 68 圖 : library ieee。 q=sig_save when oen=39。 end。 entity latch16b is port(d: in std_logic_vector(15 downto 0)。 end my_pkg。 package my_pkg is ponent latch1 port(d:in std_logic。 end process。 architecture art of latch1 is begin process(d,ena) begin if ena=39。 entity latch1 is 67 port(d: in std_logic。 end process。 end if。139。039。039。039。139。039。 begin process(clk,clr,set,j,k) begin if clk39。 entity jkff_logic is port(j,k,clk,clr,set:in std_logic。 end process。event and clk=39。139。039。 entity dff_logic is port(d,clk,clr,set:in std_logic。 end process。 sint=aa+bb+cin。 bb=39。 else aa=39。 signal aa,bb:std_logic_vector(12 downto 0)。 s: out std_logic_vector(11 downto 0)。 use 。 end if。 elsif(d=1100)then dout=1001110。 elsif(d=1000)then dout=1111111。 elsif(d=0100)then dout=0110011。 architecture art of led is begin process(d) begin if(d=0000)then dout=1111110。 use 。 end if。 gs=39。q1=39。)then q3=39。eo=39。q0=39。q2=39。 elsif(ei=39。 gs=39。q1=39。)then d15 prioty encoder q3=39。 elsif(d(15)=39。 gs=39。q1=39。)then q3=39。 63 elsif(d(14)=39。 gs=39。q1=39。)then q3=39。 elsif(d(13)=39。 gs=39。q1=39。)then q3=39。 elsif(d(12)=39。 gs=39。q1=39。)then q3=39。 elsif(d(11)=39。 gs=39。q1=39。)then q3=39。 elsif(d(10)=39。 gs=39。q1=39。)then q3=39。 elsif(d(9)=39。 gs=39。q1=39。)then q3=39。 elsif(d(8)=39。 gs=39。q1=39。)then q3=39。 elsif(d(7)=39。 gs=39。q1=39。)then q3=39。 elsif(d(6)=39。 gs=39。q1=39。)then q3=39。 elsif(d(5)=39。 gs=39。q1=39。)then q3=39。 elsif(d(4)=39。 gs=39。q1=39。)then q3=39。 elsif(d(3)=39。 gs=39。q1=39。)then q3=39。 elsif(d(2)=39。 gs=39。q1=39。)then q3=39。 elsif(d(1)=39。 gs=39。q1=39。)then q3=39。 architecture encoder of pencoder is begin process(d) begin if(d(0)=39。ei:enable input 62 gs,eo:out bit。 頂層模塊還可采用 原理圖輸入法,參考原理圖如圖 所示: 圖 仿真波形如圖 所示: 圖 習(xí)題 6 : library ieee。 b2v_inst5 : latch8 port map (clk = synthesized_wire _8, clr = enable, d = synthesized_wire _4, qx = synthesized_wire _6)。 begin m = synthesized_wire _6。 signal synthesized_wire _2 : std_logic _vector (7 downto 0)。 s : out std_logic _vector (7 downto 0) )。 qout : out std_logic)。 end ponent。 ponent latch8 60 port (clk : in std_logic。 ponent andl port (x : in std_logic。 ponent enable port( clk : in std_logic。 load : in std_logic。 b : in std_logic _vector (3 downto 0)。 library work。 end process。 entity enable is port(clk,en:in std_logic。 end process。 qt: out std_logic_vector(7 downto 0))。 5)與 模塊源程序 library ieee。 then qx=d。 then qx=00000000。 qx: buffer std_logic_vector(7 downto 0))。 4) 8 位鎖存器模塊源程序 library ieee。b。a。 signal aa,bb:std_logic_vector(8 downto 0)。 entity adder8b is port(a,b: in std_logic_vector(7 downto 0)。 58 end art。039。event and clk=39。 then q(8 downto 0):=00000amp。 end。 use 。 end if。 then qout=q(0)。 then q:=a。 end。 use 。 end art。 end if。 elsif s=39。139。清零 elsif load=39。139。 architecture art of counter4b is begin process(clk,clr,s,load,din) begin if clk39。 entity counter4b is port(clk,clr,s,load:in std_logic。 end art。計(jì)數(shù)到 256 時(shí)清零 else dout=dout+1。 elsif clk39。 end。 use 。 序列數(shù)檢測(cè)錯(cuò)誤,輸出 b end if 。 end if 。 else q = 0 。 when 3= if din = d(1) then q = 4 。 end if 。 else q = 0 。 elsif clk39。 5 位待檢測(cè)預(yù) 置數(shù) begin d = 10010 。 串行輸入數(shù)據(jù)位 /工作時(shí)鐘 /復(fù)位信號(hào) ab : out std_logic_vector(3 downto 0))。 end rtl。 end if 。 else temp=temp1。