【文章內(nèi)容簡(jiǎn)介】
library IEEE。use 。use 。use 。 Unment the following lines to use the declarations that are provided for instantiating Xilinx primitive ponents.library UNISIM。use 。entity s_m_hour is port( clk0: in std_logic。 clk0工作時(shí)鐘,clk1預(yù)置脈沖 lock : in std_logic_vector(2 downto 0)。 工作模式選擇 s0,s1 : out std_logic_vector(3 downto 0)。 m0,m1 : out std_logic_vector(3 downto 0)。 h0,h1 : out std_logic_vector(3 downto 0)。 co : out std_logic。_vector(2 downto 0)。 hour產(chǎn)生進(jìn)位 en : in std_logic。 co1 : out std_logic整小時(shí)b報(bào)時(shí)輸出 )。end s_m_hour。architecture Behavioral of s_m_hour issignal ts0 : std_logic_vector(3 downto 0):=0100。signal ts1 : std_logic_vector(3 downto 0):=0101。signal tm0 : std_logic_vector(3 downto 0):=1001。signal tm1 : std_logic_vector(3 downto 0):=0101。signal th0 : std_logic_vector(3 downto 0):=0011。signal th1 : std_logic_vector(3 downto 0):=0010。signal cc : std_logic。begins0=ts0。s1=ts1。m0=tm0。m1=tm1。h0=th0。h1=th1。co=cc。 P2: process(clk0,lock,en) begin if en=39。139。thenshow hour munite second if lock=000 then if clk039。event AND clk0=39。139。then if ts1=0101 and ts0=1001then ts1=0000。ts0=0000。 elsif ts0=1001then ts0=0000。ts1=ts1+39。139。 else ts0=ts0+39。139。ts1=ts1。 如果ts0不等于9則ts1保持不變 end if。 if ts0=1001and ts1=0101then if tm1=0101and tm0=1001 then tm1=0000。tm0=0000。 co1=39。139。當(dāng)59分59秒時(shí)產(chǎn)生一個(gè)整點(diǎn)小時(shí),輸出給整點(diǎn)報(bào)時(shí)模塊 elsif tm0=1001then tm0=0000。tm1=tm1+39。139。co1=39。039。 else tm0=tm0+39。139。tm1=tm1。co1=39。039。 end if。 end if。 if ts0=1001and ts1=0101and tm0=1001and tm1=0101 then if th1=0010AND th0=0011then th1=0000。th0=0000。 cc=39。139。 elsif th0=1001then th0=0000。th1=th1+39。139。cc=39。039。 else th0=th0+39。139。th1=th1。cc=39。039。 end if。 end if。 end if。 end if。 end if。 end process P2。 end Behavioral。時(shí)分秒置數(shù)模塊 Company: Engineer: Create Date: 20:15:01 01/13/2014 Design Name: Module Name: s_m_yuz1 Behavioral Project Name: Target Devices: Tool versions: Description: Dependencies: Revision: Revision File Created Additional Comments: library IEEE。use 。use 。use 。 Unment the following library declaration if using arithmetic functions with Signed or Unsigned valuesuse 。 Unment the following library declaration if instantiating any Xilinx primitives in this code.library UNISIM。use 。entity s_m_yuz1 is port( clk1 : in std_logic。 clk0工作時(shí)鐘,clk1預(yù)置脈沖 lock : in std_logic_vector(2 downto 0)。 s0,s1 : out std_logic_vector(3 downto 0)。 m0,m1 : out std_logic_vector(3 downto 0)。 h0,h1 : out std_logic_vector(3 downto 0)。 tn : in std_logic。 tn=1預(yù)置數(shù)加1,tn=0預(yù)置數(shù)減1 en : in std_logic )。end s_m_yuz1。architecture Behavioral of s_m_yuz1 issignal ts10 : std_logic_vector(3 downto 0):=0100。signal ts11 : std_logic_vector(3 downto 0):=0101。signal tm10 : std_logic_vector(3 downto 0):=1001。signal tm11 : std_logic_vector(3 downto 0):=0101。signal th10 : std_logic_vector(3 downto 0):=0011。signal th11 : std_logic_vector(3 downto 0):=0010。begins0=ts10。s1=ts11。m0=tm10。m1=tm11。h0=th10。h1=th11。process(clk1,lock,tn,en) begin if en=39。139。 then if clk139。event and clk1=39。139。then 選擇置數(shù)時(shí)鐘為clk1 if lock=101and tn=39。039。then 對(duì)時(shí)進(jìn)行置數(shù)(減1) if th10=0000and th11=0000 then 00 th10=0011。th11=0010。 elsif th10=0000and th11/=0000then 個(gè)位為0 十位不為0 th10=1001。th11=th111。 個(gè)位變9 十位減一 else th10=th1039。139。th11=th11。 end if。 elsif lock=101 and tn=39。139。then 對(duì)時(shí)置數(shù)加1 if th11=0010AND th10=0011then th11=0000。th10=0000。 elsif th10=1001then th10=0000。th11=th11+39。139。 else th10=th10+39。139。th11=th11。 end if。 elsif lock=110and tn=39。039。then 對(duì)分進(jìn)行置數(shù)減1 if tm10=0000and tm11=0000 then 00 tm10=1001。 tm11=0101。 elsif tm10=0000and tm11/=0000then 個(gè)位為0 十位不為0 tm10=1001。tm11=tm1139。139。 個(gè)位變9 十位減一 else tm10=tm1039。139。tm11=tm11。 end if。 elsif lock=110 and tn=39。139。then 對(duì)分置數(shù)加1 if tm11=0101AND tm10=1001 then tm11=0000。 tm10=0000。 elsif tm10=1001then tm10=0000。tm11=tm11+39。139。 else tm10=tm10+39。139。 tm11=tm11。 end if。 elsif lock=111and tn=39。039。then 對(duì)秒進(jìn)行置數(shù)減1 if ts10=0000and ts11=0000then ts10=1001。ts11=0101。 elsif ts10=0000and ts11/=0000then 個(gè)位為0 十位不為0 ts10=1001。ts11=ts1139。139。 個(gè)位變9 十位減? else ts10=ts1039。139。ts11=ts11。 end if。 elsif lock=111and tn=39。139。then 對(duì)秒進(jìn)行置數(shù)加1 if ts11=0101AND ts10=1001 then ts11=0000。ts10=0000。 elsif ts10=1001then ts10=0000。ts11=ts11+39。139。 else