【正文】
s_2 : in STD_LOGIC_VECTOR (3 downto 0)。 m_1 : in STD_LOGIC_VECTOR (3 downto 0)。 m_2 : in STD_LOGIC_VECTOR (3 downto 0)。 shumaguan : out STD_LOGIC_VECTOR (7 downto 0)。 duanSel : out STD_LOGIC_VECTOR (6 downto 0))。 dpsel :out STD_LOGIC。end display。architecture Behavioral of display issignal count:STD_LOGIC_VECTOR(2 downto 0):=000。signal BCD:STD_LOGIC_VECTOR (3 downto 0)。signal sig:STD_LOGIC_VECTOR (7 downto 0)。signal dp:STD_LOGIC:=39。139??刂菩?shù)點的亮與滅begin完成計數(shù)功能t:process(clk) isbegin if rising_edge(clk) and clk=39。139。 then if count=111 then count=000。 else count=count+1。 end if。 end if。end process。多路選擇器MUL:process(count) isbegincase count is when 000=BCD=hs_1。 when 001=BCD=hs_2。 when 010=BCD=1111。 when 011=BCD=s_1。 when 100=BCD=s_2。 when 101=BCD=1111。 when 110=BCD=m_1。 when 111=BCD=m_2。 when others=BCD=1111。end case。end process。段選控制DUAN:process(BCD) isbegin case BCD is abcdefg 0123456 when 0000=duanSel=0000001。 when 0001=duanSel=1001111。 when 0010=duansel=0010010。 when 0011=duansel=0000110。 when 0100=duansel=1001100。 when 0101=duansel=0100100。 when 0110=duansel=0100000。 when 0111=duansel=0001111。 when 1000=duansel=0000000。 when 1001=duansel=0000100。 when 1111=duansel=1111110。 when others=duansel=1111110。 end case。 if count=011 or count=110 then dp=39。039。 end if。end process。dpsel=dp。片選控制pian:process(count) isbegincase count is when 000=sig=11111110。 when 001=sig=11111101。 when 010=sig=11111011。 when 011=sig=11110111。 when 100=sig=11101111。 when 101=sig=11011111。 when 110=sig=10111111。 when 111=sig=01111111。 when others=sig=11111111。end case。end process。shumaguan=sig。end Behavioral。6 按鍵消抖電路library IEEE。use 。use 。use 。 Unment the following library declaration if instantiating any Xilinx primitives in this code.library UNISIM。use 。entity key_debounce is Port ( clk : in STD_LOGIC。 key_in : in STD_LOGIC。 key_out : out STD_LOGIC)。end key_debounce。architecture Behavioral of key_debounce issignal t:std_logic_vector(2 downto 0)。signal k1,k2:std_logic。beginP1:process(key_in,clk) begin if key_in=39。139。 then t=000。 elsif falling_edge(clk) then if t/=7 then t=t+1。 end if。 end if。end process。P2:process(clk)begin if falling_edge(clk) then if t/=7 then k1=39。039。 else k1=39。139。 end if。 k2=k1。 end if。end process。P3:key_out=(not k1) and k2。end Behavioral。24