EDA與VHDL題目 數字鐘

2021-10-19 09:13:03 字數 4659 閱讀 4658

library ieee;

use ieee.std_logic_1164.all;

use ieee.std_logic_unsigned.all;

entity clock is

port (

clk : in std_logic;

reset : in std_logic;

reset2 : in std_logic;

xianshi : out std_logic_vector(7 downto 0); --

xuanze : out std_logic_vector(5 downto 0) --選擇數碼管亮滅

);end clock;

architecture code1 of clock is

signal clk1: std_logic; -- 定義 1hz 訊號 秒錶輸入

signal clk2: std_logic; -- 定義 1/60 hz 訊號 秒錶輸出,分鐘輸入

signal clk3: std_logic; --定義 1/3600 hz 訊號 分鐘輸出,時鐘輸入

signal clk4: std_logic; --定義 1khz 訊號 用於 數碼管選擇

signal sh: std_logic_vector(3 downto 0):="0000";--秒個位

signal sl: std_logic_vector(3 downto 0):="0000";--秒十位

signal mh: std_logic_vector(3 downto 0):="0000";--分個位

signal ml: std_logic_vector(3 downto 0):="0000";--分十位

signal hl:std_logic_vector(3 downto 0):="0000";--時個位

signal hh:std_logic_vector(3 downto 0):="0000";--時十位

signal sel:std_logic_vector(2 downto 0);

signal a: std_logic_vector(3 downto 0);

begin

p1 :process (clk) --並行處理,程序1產生1hz的訊號clk1,作為秒錶輸入

variable count: integer range 0 to 25000000 := 0;

variable count1: std_logic := '1';

begin

if (clk'event and clk='1') then

count := count+1;

if count=25000000 then

count:=0;

count1:=not count1;

end if;

clk1 <= count1;

end if;

end process;

p2 :process (clk) --程序2 產生 1khz 的訊號clk4,作為數碼管選擇

variable count: integer range 0 to 25000 := 0;

variable count1: std_logic := '1';

begin

if clk'event and clk='1' then

count := count+1;

if count=25000 then

count:=0;

count1:=not count1;

end if;

clk4 <= count1;

end if;

end process;

p3 :process(clk1,reset) --程序3 秒錶 以 1hz的clk1為輸入,以 clk2 為輸出

begin

if(reset = '0') then --非同步清零

sh <= "0000";

sl <= "0000";

elsif(clk1'event and clk1 ='1') then -- 模60開始

if (sh="0101" and sl="1001" ) then

clk2 <= '1';

sh <= "0000";

sl <= "0000";

else

clk2 <= '0';

if (sl = 9) then

sl <= "0000";

if (sh = 5) then

sh <= "0000";

else

sh<= sh + 1;

end if;

else

sl <= sl + 1;

end if;

end if;

end if;

end process;

p4 :process(clk2,reset) --程序4 分鐘 以 clk2為輸入,以 clk3 為輸出

begin

if (mh="0101" and ml="1001" ) then

clk3 <= '1';

else

clk3 <= '0';

if(reset = '0') then --非同步清零

mh <= "0000";

ml <= "0000";

elsif(clk2'event and clk2 ='1') then -- 模60開始

if (ml = 9) then

ml <= "0000";

if (mh = 5) then

mh <= "0000";

else

mh<= mh + 1;

end if;

else

ml <= ml + 1;

end if;

end if;

end if;

end process;

p5:process(clk3) --程序5 時鐘 以 clk2為輸入,以 clk3 為輸出

begin

if(reset = '1') then

if(clk3'event and clk3='1')then

hl<=hl+1;

if(hl = 9) then

hl<="0000";

hh<=hh + 1;

end if;

if(hh=2 and hl = 3)then

hh<="0000";

hl<="0000";

end if;

end if;

else

null;

end if;

end process;

p6:process(clk4,sl,sh,ml,mh,hl,hh) -- 選數碼管 以1khz訊號輸入,

begin

if clk4'event and clk4='1' then --6個數碼管,不斷地從 0-5 迴圈,不斷選擇數碼管 頻率為1khz

sel<=sel+1;

if (sel = 5) then

sel <= "000";

end if;

end if;

case sel is

when "000" => xuanze <= "111110";a <= sl; --秒個位, 選擇數碼管

when "001" => xuanze <= "111101";a <= sh;

when "010" => xuanze <= "111011";a <= ml;

when "011" => xuanze <= "110111";a <= mh;

when "100" => xuanze <= "101111";a <= hl;

when "101" => xuanze <= "011111";a <= hh; --時十位

when others => null;

end case;

case a is

when "0000" => xianshi <= "00111111"; --數碼管表示數字 0 解碼

when "0001" => xianshi <= "00000110"; --1

when "0010" => xianshi <= "01011011"; --2

when "0011" => xianshi <= "01001111"; --3

when "0100" => xianshi <= "01100110"; --4

when "0101" => xianshi <= "01101101"; --5

when "0110" => xianshi <= "01111101"; --6

when "0111" => xianshi <= "00000111"; --7

when "1000" => xianshi <= "01111111"; --8

when "1001" => xianshi <= "01101111"; --9

when others => null;

end case;

end process;

end code1;

eda技術試卷 EDA技術與VHDL期末考試試卷

eda 技術與vhdl 期末考試試卷 一 單項選擇題 分 ip 核在eda 技術和開發中具有十分重要的地位 提供用 vhdl 等硬體描述語 言描述的功能塊,但不涉及實現該功能塊的具體電路的 ip核為 da 瘦ip b.固ip c.胖ip d.都不是綜合是 eda設計流程的關鍵步驟,在下面對綜合的描述...

二級專案 數字系統設計 數字鐘系統設計

摘要 本專案旨在設計 乙個多功能數字鐘系統,實現了數字鐘的計時 校時,校分,校天 秒清零 保持當前計數 和整點報時等多種基本功能,還實現了鬧鐘,星期 計數等附加功能 並且編寫了匯程式設計序實現數字鐘功能。關鍵字 數字鐘 計時 報時 校時 鬧鐘 電路 匯程式設計序 一 課程設計的目的和要求 目的 小型...

數字邏輯與數字系統(VHDL)動態掃瞄數碼顯示器

做乙個動態掃瞄數碼顯示器 一共需要三個部件 模八計數器 8選一資料選擇器 7段解碼器 library ieee use ieee.std logic 1164.all use ieee.std logic unsigned.all use ieee.std logic arith entity m8...