【正文】
architecture behavioral of minute is begin process(clk_second,reset,set_minute) variable n:std_logic_vector(out139。BCD code output,060。 carry : out std_logic。 reset:in std_logic。 use 。 use 。 end behavioral。 end if。 end if。 else carry=39。 78 carry=39。 n:=00000000。 end if。 Because of using BCD code,so if n=1001,n=n+6。 if m=10 then m=10 means n=1001。then n:=n+1。 elsif rising_edge(clk_minute)then if start=39。right+3 downto 0))。 n:=set_hour。 carry=39。then out1=set_hour。 begin if reset=39。right)。 architecture behavioral of hour is begin process(clk_minute,reset,set_hour) variable n:std_logic_vector(out139。BCD code output,024。 carry : out std_logic。 start:in std_logic。 entity hour is port (clk_minute : in std_logic。 use 。 仿真波形如圖 所示: 77 圖 主要有 12 個子模塊構(gòu)成, 參考程序如下所示: 1)時鐘的 hour 子模塊源程序: library ieee。 architecture art of multiplier88 is begin dout=din0*din1。 dout: out integer range 0 to 65535)。 use 。 仿真波形如圖 所示: 圖 習(xí)題 7 5. 利用 MegaWizard PlugIn Manager 定制 lpmabs, 參考程序如 圖 所示: 圖 仿真波形如圖 所示: 圖 . MegaWizard PlugIn Manager 定制 lpmxor。 74 end process。 end case。139。 elsif din=01 then p_state:=s5。dout=39。139。 when s6=if din=11 then p_state:=s0。039。 elsif din=10 then p_state:=s5。dout=39。139。 when s5=if din=00 then p_state:=s6。039。 elsif din=10 then p_state:=s4。dout=39。139。 when s4=if din=00 then p_state:=s5。039。 elsif din=10 then p_state:=s3。dout=39。139。 when s3=if din=00 then p_state:=s4。039。 elsif din=10 then p_state:=s2。dout=39。139。 when s2=if din=00 then p_state:=s3。039。 elsif din=10 then p_state:=s1。dout=39。139。 when s1=if din=00 then p_state:=s2。039。 elsif din=10 then p_state:=s0。dout=39。139。 異步清零 elsif clk39。then dout=39。 begin if clr=39。 architecture art of m_state is type statetype is (s0,s1,s2,s3,s4,s5,s6)。 dout: out std_logic)。 entity m_state is port(clk,clr:in std_logic。 參考程序如下所示: library ieee。 end art。 end if。139。 when s4 =p_state:=s0。039。 else p_state:=s0。039。end if。dout=39。 then p_state:=s3。 when s2=if din=39。039。 else p_state:=s0。039。end if。dout=39。 then p_state:=s1。 then時鐘上升沿,判斷并處理當(dāng)前輸入的位 case p_state is when s0=if din=39。event and clk=39。039。139。 begin process(clk,clr) variable p_state:statetype。檢測結(jié)果輸出 end。 entity sequence_check is port(din,clk,clr:in std_logic。 71 參考程序如下所示: library ieee。 end art。 dout=temp。 end if。 end loop。 temp(31)=dir。then for i in 31 downto 1 loop實(shí)現(xiàn)右移循環(huán) temp(i1)=dout(i)。 elsif s=39。139。then temp=00000000000000000000000000000000。then if clr=39。event and clk=39。 architecture art of dcshift32b is signal temp:std_logic_vector(31 downto 0)。 70 dout: buffer std_logic_vector(31 downto 0))。 entity dcshift32b is port(clr,load,clk,s,dir,dil:in std_logic。 仿真波形如圖 所示: 圖 : library ieee。 end process。 end if。 end if。 then if(d=0)then d=1001。 elsif s=39。 else d=d+1。139。139。 elsif clk39。139。then d=0000。 begin process(clk,clr,load,s) begin if clr=39。 end。s=1 加法計數(shù), s=0 減法計數(shù) din: in std_logic_vector(3 downto 0)。 use 。 仿真波形如圖 所示: 圖 : library ieee。 end process。 end if。 then dout=dout+1。 elsif s=39。139。139。 architecture art of counter16b is begin process(clk) begin if clk39。 dout: buffer std_logic_vector(15 downto 0))。 entity counter16b is port(clk,load,s:in std_logic。 use 。 end one。039。 end generate。 architecture one of latch16b is signal sig_save:std_logic_vector(15 downto 0)。 q:out std_logic_vector(15 downto 0))。 oen: in bit。 use 。 16 位鎖存器頂層模塊源程 序: library ieee。 end ponent。 ena:in std_logic。 use 。 end art。 end if。139。 end latch1。 ena: in std_logic。 use 。 end art。 q=q_s。 end if。) then q_s=not q_s。) and (k=39。 elsif(j=39。) then q_s=39。) and (k=39。 elsif(j=39。) then q_s=39。) and (k=39。 if (j=39。 then q_s=39。 elsif clr=39。 then q_s=39。 then if set=39。event and clk=39。 architecture art of jkff_logic is signal q_s:std_logic。 q:out std_logic)。 use 。 end art。 end if。139。 elsif clk39。 then q=39。 elsif clr=39。 then q=39。 architecture art of dff_logic is begin process(clk,clr,set) begin if set=39。 q:out std_logic)。 use 。 end art。 cout=sint(12)。 end if。b。039。a。039。then sint=0000000000000。 begin process(clr) begin if clr=39。 architecture art of adder12b is signal sint:std_logic_vector(12 downto 0)。 cout:out std_logic)。 a,b: in std_logic_vector(11 downto 0)。 use 。 仿真波形如圖 所示: 圖 : library ieee。 end process。 elsif(d=1111)then dout=1000111。 elsif(d=1101)then dout=1111110。 elsif(d=1011)then dout=0011111。 elsif(d=1001)then dout=1111011。 64 elsif(d=0111)then dout=1110000。 elsif(d=0101)then dout=1011011。 elsif(d=0011)then dout=1111001。 elsif(d=0001)then dout=0110000。 end。 entity led is port(d:in std_logic_vector(3 downto 0)。 仿真波形如圖 所示: 圖 : library ieee。 end process。039。139。139。139。139。139。039。139。139。139。139。139。139。139。139。039。039。039。039。039。039。039。139。039。139。039。039。039。039。039。139。039。039。139。039。039。039。039。139。039。139。139。039。039。039。039。139。039。039。039。139。039。039。039。139。039。139。039。139。039。039。039。139。039。039。139。139。039。039。039。139。039。139。139。139。039。039。039。139。039。039。039