久久久久久久999_99精品久久精品一区二区爱城_成人欧美一区二区三区在线播放_国产精品日本一区二区不卡视频_国产午夜视频_欧美精品在线观看免费

 找回密碼
 立即注冊

QQ登錄

只需一步,快速開始

搜索
查看: 5882|回復: 3
收起左側

基于VHDL語言的電子時鐘設計-ISE開發(fā)的EDA源碼 晶振25Mhz

[復制鏈接]
ID:191542 發(fā)表于 2019-1-9 21:42 | 顯示全部樓層 |閱讀模式
本人的課程設計,和大家分享分享,多謝大家的指導和建議!
所有功能全部實現  使用的是賽靈斯的開發(fā)板 晶振是25Mhz  開發(fā)軟件是ISE
包含路徑不允許有中文....
后附完整的工程和實習報告  有需要的可以拿走
程序設計要求
(1)根據系統(tǒng)的功能和技術指標,尋找出合適的算法,并用 VHDL 語言對算法進行描述;
(2)在設計輸入后,在 EDA 軟件上對系統(tǒng)進行仿真和調試;
(3)在調試完畢后,將所設計的算法下載到目標板上查看結果;
(4)運用 VHDL 語言描述電子時鐘的時、分、秒;
(5)將時、分、秒連接成電子時鐘,秒/分/時的依次顯示并正確計數;
(6)秒/分/時各段個位滿 10 正確進位,秒/分能做到滿 60 向前進位;
(7)可以控制電子時鐘的啟停;
(8)通過鍵盤控制電子時鐘可以 12 時或 24 時計時;
(9)當認為時鐘不準確時,通過鍵盤可以分別對分/時鐘進行調整;
(10)電子時鐘具有時鐘和秒表功能,秒表和時鐘功能可以相互切換;
(11)電子時鐘具有定時功能,當定時與時鐘時間相同時,蜂鳴器發(fā)生。
0.png

目錄

一、              工程框架及頂層原理圖
二、各模塊原理圖及程序
1、分頻器
1.1、分頻器原理圖
1.2、分頻器程序
2、12/24進制時鐘
2.1、時鐘頂層、底層原理圖
2.2時鐘頂層文件
2.3、時鐘底層文件
2.3.1、四選一芯片
2.3.2、秒——60進制芯片
2.3.3、分——60進制芯片
2.3.4、時——12/24進制芯片
3、秒表
3.1、秒表頂層、底層原理圖
3.2秒表頂層文件
3.3秒表底層文件
3.3.1、十進制計時器(4個計數器級聯(lián))
4、定時鬧鐘
4.1、鬧鐘頂層原理圖
4.2、鬧鐘頂層程序
4.3、鬧鐘底層文件
4.3.1、調整位選擇
4.3.2、時間設定
4.3.3、鬧鈴
5、按鍵消抖
5.1、按鍵消抖原理圖
5.2、按鍵消抖底層程序
6、按鍵處理部分
6.1按鍵處理原理圖
6.2按鍵處理底層程序
7、選中數碼管閃爍
7.1、原理圖
7.2、底層程序
8、數碼管顯示控制
8.1、原理圖
8.2底層程序
9、數碼管譯碼器
9.1、原理圖
9.2、底層程序
10、FPGA芯片引腳鎖定UCF文件
三、仿真波形
1、秒——60進制計數
2、時鐘暫停及運行

一、        工程框架及頂層原理圖


二、各模塊原理圖及程序1、分頻器
1.1、分頻器原理圖

1.2、分頻器程序


library ieee;
use ieee.std_logic_1164.all;
use ieee.std_logic_unsigned.all;
entity fenpin is
              port(
                            clk:in std_logic;
                            c0:buffer std_logic;
                            c1:buffer std_logic;
                            c2:buffer std_logic;
                            c3:buffer std_logic;
                            );
end fenpin;
architecture behav of fenpin is
              signal counter0:integer range 0 to 12500000;
              signal counter1:integer range 0 to 125;
              signal counter2:integer range 0 to 6250000;
              signal counter3:integer range 0 to 125000;
              begin

              ctr0:--1hz
              process(clk)
                            begin

                            if(clk='1' and clk'event)then
                                          if(counter0=12500000)then
                                                        counter0<=0;c0<=not c0;
                                          else
                                                        counter0<=counter0+1;
                                          end if;
                            end if;
              end process;

              ctr1:--100khz
              process(clk)
                            begin

                            if(clk='1' and clk'event)then
                                          if(counter1=125)then
                                                        counter1<=1;c1<=not c1;
                                          else
                                                        counter1<=counter1+1;
                                          end if;
                            end if;
              end process;

              ctr2:--2Hz
              process(clk)
                            begin

                            if(clk='1' and clk'event)then
                                          if(counter2=6250000)then
                                                        counter2<=0;c2<=not c2;
                                          else
                                                        counter2<=counter2+1;
                                          end if;
                            end if;
              end process;

              ctr3:--100hz
              process(clk)
                            begin

                            if(clk='1' and clk'event)then
                                          if(counter3=125000)then
                                                        counter3<=0;c3<=not c3;
                                          else
                                                        counter3<=counter3+1;
                                          end if;
                            end if;
              end process;
end behav;




2、12/24進制時鐘2.1、時鐘頂層、底層原理圖


2.2時鐘頂層文件
library ieee;
use ieee.std_logic_1164.all;
use ieee.std_logic_unsigned.all;

entity clock is
              port(
                            clk1:in std_logic;
                            clk:in std_logic;
                            flag1:in std_logic_vector(2 downto 0);
                            step_up:in std_logic;
                            d_0,d_1:out std_logic_vector(3 downto 0);
                            d_2,d_3:out std_logic_vector(3 downto 0);
                            d_4,d_5:out std_logic_vector(3 downto 0);
                            hour_12_24:in std_logic;
                            clock_stop:in std_logic
                            );
end clock;

architecture struct of clock is

              component xuanze4_1 is
                            port(
                                          clk:in std_logic;
                                          in2,in3,in4,in5:in std_logic;
                                          step_up:in std_logic;
                                          flag1:in std_logic_vector(2 downto 0);
                                          co2,co3,co4,co5:out std_logic
                                          );
              end component;

              component hour is
                            port (
                                          clk_l:in std_logic;
                                          clk_h:in std_logic;                           
                                          d_4,d_5:out std_logic_vector(3 downto 0);
                                          cout_4,cout_5:out std_logic;
                                          hour_12_24:in std_logic
                                          );
              end component;

              component fen60 is
                            port (
                                          clk_l:in std_logic;
                                          clk_h:in std_logic;            
                                          d_2,d_3:out std_logic_vector(3 downto 0);
                                          cout_2,cout_3:out std_logic
                                          );
              end component;

              component sn60 is
                            port (
                                          clk:in std_logic;
                                          d_0,d_1:out std_logic_vector(3 downto 0);
                                          cout:out std_logic;
                                          clock_stop:in std_logic
                                          );
              end component;

              signal in2,in3,in4,in5,co2,co3,co4,co5,cout_5:std_logic;

              begin

              u20:xuanze4_1 port map (clk1,in2,in3,in4,in5,step_up,flag1,co2,co3,co4,co5);
              u21:sn60 port map(clk,d_0,d_1,in2,clock_stop);
              u22:fen60 port map(co2,co3,d_2,d_3,in3,in4);
              u23:hour port map(co4,co5,d_4,d_5,in5,cout_5,hour_12_24);

end struct;
2.3、時鐘底層文件2.3.1、四選一芯片



library ieee;
use ieee.std_logic_1164.all;
use ieee.std_logic_unsigned.all;

entity xuanze4_1 is
              port(
                            clk:in std_logic;
                            in2,in3,in4,in5:in std_logic;
                            step_up:in std_logic;
                            flag1:in std_logic_vector(2 downto 0);
                            co2,co3,co4,co5:out std_logic
                            );
end xuanze4_1;

architecture behav of xuanze4_1 is
begin
              process(clk,in2,in3,in4,in5,step_up,flag1)
              begin
                            case flag1 is
                            when "000" =>              co2<=in2;
                                                                                                  co3<=in3;
                                                                                                  co4<=in4;
                                                                                                  co5<=in5;                                                                                   
                            when "001" =>              co2<=step_up;
                                                                                                  co3<=in3;
                                                                                                  co4<=in4;
                                                                                                  co5<=in5;

                            when "010" =>              co3<=step_up;
                                                                                                  co2<=in2;
                                                                                                  co4<=in4;
                                                                                                  co5<=in5;                                                                                   
                            when "011" =>              co4<=step_up;
                                                                                                  co2<=in2;
                                                                                                  co3<=in3;
                                                                                                  co5<=in5;

                            when "100" =>              co2<=in2;
                                                                                                  co3<=in3;
                                                                                                  co4<=in4;
                                                                                                  co5<=step_up;

                            when others => co2<=in2;
                                                                                                  co3<=in3;
                                                                                                  co4<=in4;
                                                                                                  co5<=in5;
                            end case;
              end process;
end behav;



2.3.2、秒——60進制芯片
library ieee;
use ieee.std_logic_1164.all;
use ieee.std_logic_unsigned.all;
entity sn60 is
port(
              clk:in std_logic;
              d_0,d_1:out std_logic_vector(3 downto 0);
              cout:out std_logic;
              clock_stop:in std_logic
);
end sn60;

architecture behav of sn60 is
signal temp1,temp2:std_logic_vector(3 downto 0):="0000";
signal co:std_logic:='0';
begin

process(clk,clock_stop)
begin
              if(clk'event and clk='1')then
                            if(clock_stop='0')then
                                          if(temp1="1001")then--個位滿10進一 并且清零
                                                        temp1<="0000";
                                                        co<='1';
                                          else
                                                        temp1<=temp1+1;
                                                        co<='0';
                                          end if;                                         
                            end if;
              end if;
              d_0<=temp1;
end process;

process(co,clock_stop)
begin
              if(co'event and co='1')then
                            if(clock_stop='0')then
                                          if(temp2="0101")then--十位滿6進一
                                                        temp2<="0000";
                                                        cout<='1';
                                          else
                                                        temp2<=temp2+1;
                                                        cout<='0';
                                          end if;
                            end if;
              end if;
              d_1<=temp2;
end process;
end behav;
2.3.3、分——60進制芯片
library ieee;
use ieee.std_logic_1164.all;
use ieee.std_logic_unsigned.all;

entity fen60 is
              port (
                            clk_l:in std_logic;
                            clk_h:in std_logic;            
                            d_2,d_3:out std_logic_vector(3 downto 0);
                            cout_2,cout_3:out std_logic
                            );
end fen60;

architecture behav of fen60 is
signal temp1,temp2:std_logic_vector(3 downto 0);
begin

              process(clk_l)
              begin

                            if(clk_l'event and clk_l='1')then
                                          if(temp1="1001")then
                                                                      temp1<="0000";cout_2<='1';
                                          else
                                                        temp1<=temp1+1;cout_2<='0';
                                          end if;
                            end if;
              d_2<=temp1;
              end process;

              process(clk_h)
              begin

                            if(clk_h'event and clk_h='1')then
                                          if(temp2="0101")then
                                                                      temp2<="0000";cout_3<='1';
                                          else
                                                        temp2<=temp2+1;cout_3<='0';
                                          end if;
                            end if;
              d_3<=temp2;
              end process;

end behav;

2.3.4、時——12/24進制芯片


library ieee;
use ieee.std_logic_1164.all;
use ieee.std_logic_unsigned.all;
entity hour is
              port (
                            clk_l:in std_logic;
                            clk_h:in std_logic;                           
                            d_4,d_5:out std_logic_vector(3 downto 0);
                            cout_4,cout_5:out std_logic;
                            hour_12_24:in std_logic
                            );
end hour;
architecture behav of hour is
signal temp1,temp2:std_logic_vector(3 downto 0);
begin

process(clk_l,hour_12_24)
begin
              if(hour_12_24='1')then----------24小時制
                            if(clk_l'event and clk_l='1')then
                                          if(temp2="0010")then
                                                        if(temp1>="0011")then
                                                        temp1<="0000";cout_4<='1';
                                                        else
                                                        temp1<=temp1+1;cout_4<='0';
                                                        end if;
                                          elsif(temp1="1001")then
                                                        temp1<="0000";cout_4<='1';
                                          else
                                                        temp1<=temp1+1;cout_4<='0';
                                          end if;
                            end if;
                            d_4<=temp1;
              else---------------------------12小時制
                            if(clk_l'event and clk_l='1')then
                                                        if(temp2="0001")then
                                                                      if(temp1>="0010")then
                                                                                    temp1<="0001";
                                                                                    cout_4<='1';
                                                                      else
                                                                                    temp1<=temp1+1;
                                                                                    cout_4<='0';
                                                                      end if;
                                                        elsif(temp1="1001")then
                                                                                    temp1<="0000";
                                                                                    cout_4<='1';
                                                        else
                                                                      temp1<=temp1+1;


                                                                      cout_4<='0';
                                                        end if;
                                          end if;
                                          d_4<=temp1;
              end if;
end process;

process(clk_h,hour_12_24)
begin
              if(hour_12_24='1')then
                            if(clk_h'event and clk_h='1')then
                                          if(temp2="0010")then
                                                        temp2<="0000";cout_5<='1';
                                          else
                                                        temp2<=temp2+1;cout_5<='0';
                                          end if;
                            end if;
                            d_5<=temp2;
              else
                            if(clk_h'event and clk_h='1')then
                                          if(temp2="0001")then
                                                                      temp2<="0000";
                                                                      cout_5<='1';
                                          else
                                                        temp2<=temp2+1;
                                                        cout_5<='0';
                                          end if;
                            end if;
                            d_5<=temp2;
              end if;
end process;

end behav;
3、秒表


3.1、秒表頂層、底層原理圖


3.2秒表頂層文件


library ieee;
use ieee.std_logic_1164.all;
use ieee.std_logic_unsigned.all;

entity stopwatch is
              port(
                            mode:in std_logic_vector(1 downto 0);
                            clk:in std_logic;-----------100hz 精確度位0.01s
                            start:in std_logic;--step_up
                            clr:in std_logic;
                            d_6,d_7,d_8,d_9:out std_logic_vector(3 downto 0)
                            );
end stopwatch;
architecture struct of stopwatch is

              component count_10_d_0 is

                            port(            
                                                        mode:in std_logic_vector(1 downto 0);
                                                        clk1,clear,start:in std_logic;
                                                        bcd_out:out std_logic_vector(3 downto 0);
                                                        cout:buffer std_logic);
              end component;

              component count_10_d_1 is
                            port(              clk2,clear:in std_logic;
                                                        bcd_out:out std_logic_vector(3 downto 0);
                                                        cout:buffer std_logic);            
              end component;

              component count_10_d_2 is
                            port(              clk3,clear:in std_logic;
                                                        bcd_out:out std_logic_vector(3 downto 0);
                                                        cout:buffer std_logic);            
              end component;

              component count_10_d_3 is
                            port(              clk4,clear:in std_logic;
                                                        bcd_out:out std_logic_vector(3 downto 0);
                                                        cout:buffer std_logic);            
              end component;

              signal clk1,clk2,clk3,cout:std_logic;

              begin

              u31:count_10_d_0 port map(mode,clk,clr,start,d_6,clk1);
              u32:count_10_d_1 port map(clk1,clr,d_7,clk2);
              u33:count_10_d_2 port map(clk2,clr,d_8,clk3);
              u34:count_10_d_3 port map(clk3,clr,d_9,cout);

end architecture struct;

3.3秒表底層文件3.3.1、十進制計時器(4個計數器級聯(lián))
library ieee;
use ieee.std_logic_1164.all;
use ieee.std_logic_unsigned.all;
entity count_10_d_0 is
              port(            
                            mode:in std_logic_vector(1 downto 0);
                            clk1,clear,start:in std_logic;
                            bcd_out:out std_logic_vector(3 downto 0);
                            cout:buffer std_logic
);
end entity count_10_d_0;

architecture behavioral of count_10_d_0 is
              signal temp:std_logic_vector(3 downto 0);
              signal start_state:std_logic:='1';
              begin

              process(start)
              begin
                            if(start'event and start='1')then
                                          if(mode="10")then
                                                        start_state<=not start_state;
                                          else
                                                        start_state<='1';
                                          end if;
                            else start_state<=start_state;
                            end if;                                         
              end process;

              process(clk1,clear)is
              begin
                            if(clear='1')then
                                          temp<="0000";cout<='0';
                            elsif(clk1'event and clk1='1')then
                                          if(start_state='0')then
                                                        if(temp="1001")then
                                                                      temp<="0000";cout<='1';
                                                        else
                                                                      temp<=temp+1;cout<='0';
                                                        end if;
                                          else
                                                        temp<=temp;
                                          end if;
                            end if;
                            bcd_out<=temp;
              end process;
end architecture behavioral;
4、定時鬧鐘4.1、鬧鐘頂層原理圖


4.2、鬧鐘頂層程序
library ieee;
use ieee.std_logic_1164.all;
use ieee.std_logic_unsigned.all;
entity timer is
              port(
                            clk:in std_logic;
                            mode:in std_logic_vector(1 downto 0);
                            clk_1hz:in std_logic;
                            clk_2hz:in std_logic;
                            flag2:in std_logic_vector(2 downto 0);
                            step_up:in std_logic;
                            clr:in std_logic;
                            d_10,d_11,d_12,d_13:out std_logic_vector(3 downto 0);
                            led:out std_logic;
                            alarm_on:in std_logic;
                            t_now5,t_now4,t_now3,t_now2:in std_logic_vector(3 downto 0)
                            );
end entity;

architecture struct of timer is
              component xuanze_mode_4_1 is
                            port(
                                          clk:in std_logic;
                                          in2,in3,in4,in5:in std_logic;
                                          step_up:in std_logic;
                                          flag2:in std_logic_vector(2 downto 0);
                                          co2,co3,co4,co5:out std_logic
                                          );
              end component;

              component time_set is
                            port (
                                          clk:in std_logic;
                                          mode:in std_logic_vector(1 downto 0);
                                          flag2:in std_logic_vector(2 downto 0);
                                          clk1,clk2,clk3,clk4:in std_logic;
                                          clear:in std_logic;
                                          step_up:in std_logic;
                                          d_10,d_11,d_12,d_13:out std_logic_vector(3 downto 0);
                                          cout4:buffer std_logic;
                                          alarm_on:in std_logic;
                                          t_now5,t_now4,t_now3,t_now2:in std_logic_vector(3 downto 0)
                                          );
              end component;

              component alarm is
                            port(
                                          clk:in std_logic;
                                          c_in:in std_logic;
                                          c_out:out std_logic
                                          );
              end component;

              signal cout1,cout2,cout3,cout4,clk1,clk2,clk3,clk4:std_logic;

begin

              u40:xuanze_mode_4_1 port map(clk,clk_1hz,cout1,cout2,cout3,step_up,flag2,clk1,clk2,clk3,clk4);
              u41:time_set port map(clk,mode,flag2,clk1,clk2,clk3,clk4,clr,step_up,d_10,d_11,d_12,d_13,cout4,alarm_on,t_now5,t_now4,t_now3,t_now2);
              u42:alarm port map(clk_2hz,cout4,led);

end struct;

4.3、鬧鐘底層文件4.3.1、調整位選擇
library ieee;
use ieee.std_logic_1164.all;
use ieee.std_logic_unsigned.all;

entity xuanze_mode_4_1 is
              port(
                            clk:in std_logic;
                            in2,in3,in4,in5:in std_logic;
                            step_up:in std_logic;
                            flag2:in std_logic_vector(2 downto 0);
                            co2,co3,co4,co5:out std_logic
                            );
end xuanze_mode_4_1;

architecture behav of xuanze_mode_4_1 is
begin
              process(clk,flag2,in2,in3,in4,in5,step_up)
              begin
                            case flag2 is
                            when "000" =>              co2<=in2;
                                                                                                  co3<=in3;
                                                                                                  co4<=in4;
                                                                                                  co5<=in5;

                            when "001" =>              co2<=step_up;
                                                                                                  co3<=in3;
                                                                                                  co4<=in4;
                                                                                                  co5<=in5;

                            when "010" =>              co3<=step_up;                                                                                                
                            when "011" =>              co4<=step_up;                                                                                                
                            when "100" =>              co5<=step_up;                                                                                                
                            when others =>              null;
                            end case;
              end process;
end behav;

4.3.2、時間設定
library ieee;
use ieee.std_logic_1164.all;
use ieee.std_logic_unsigned.all;
entity time_set is
              port(
                            clk:in std_logic;
                            mode:in std_logic_vector(1 downto 0);
                            flag2:in std_logic_vector(2 downto 0);
                            clk1,clk2,clk3,clk4:in std_logic;
                            clear:in std_logic;
                            step_up:in std_logic;
                            d_10,d_11,d_12,d_13:out std_logic_vector(3 downto 0);
                            cout4:buffer std_logic;
                            alarm_on:in std_logic;
                            t_now5,t_now4,t_now3,t_now2:in std_logic_vector(3 downto 0)
                            );
end time_set;

architecture behav of time_set is
signal temp1,temp2,temp3,temp4:std_logic_vector(3 downto 0);

signal start_state:std_logic:='1';
begin

process(clk,cout4)
begin                           
              if(clk'event and clk='1')then
                            if(alarm_on='0')then
                                          ----目前時間和設定的時間對比
                                          if(t_now5=temp4 and t_now4=temp3 and t_now3=temp2 and t_now2=temp1)then
                                                        cout4<='1';
                                          else
                                                        cout4<='0';
                                          end if;
                            else
                                          cout4<='0';
                            end if;
              end if;                           
end process;

process(clk1,clear)is
begin                           
              if(clear='1')then
                            temp1<="0000";
              elsif(clk1'event and clk1='1')then--有脈沖信號 進行數字調整 +1
                            if(flag2/="000")then
                                          if(temp1="1001")then
                                                        temp1<="0000";
                                          else
                                                        temp1<=temp1+1;
                                          end if;
                            end if;
              end if;
              d_10<=temp1;
end process;

process(clk2,clear)is
begin
              if(clear='1')then
                            temp2<="0000";
              elsif(clk2'event and clk2='1')then
                            if(flag2/="000")then
                                          if(temp2="1001")then
                                                        temp2<="0000";
                                          else
                                                        temp2<=temp2+1;
                                          end if;
                            end if;
              end if;
              d_11<=temp2;
end process;

process(clk3,clear)is
begin
              if(clear='1')then
                            temp3<="0000";
              elsif(clk3'event and clk3='1')then
                            if(flag2/="000")then
                                          if(temp3="1001")then
                                                        temp3<="0000";
                                          else
                                                        temp3<=temp3+1;
                                          end if;
                            end if;
              end if;
              d_12<=temp3;
end process;

process(clk4,clear)is
begin
              if(clear='1')then
                            temp4<="0000";
              elsif(clk4'event and clk4='1')then
                            if(flag2/="000")then
                                          if(temp4="1001")then
                                                        temp4<="0000";
                                          else
                                                        temp4<=temp4+1;
                                          end if;
                            end if;
              end if;
              d_13<=temp4;
end process;
end behav;
4.3.3、鬧鈴
library ieee;
use ieee.std_logic_1164.all;
use ieee.std_logic_unsigned.all;

entity alarm is
              port(
                            clk:in std_logic;
                            c_in:in std_logic;
                            c_out:out std_logic--led
                            );
end entity;

architecture behav of alarm is
signal alarm_state:std_logic:='0';
begin

              process(c_in,clk)
              begin
                            if(c_in='1')then
                                          if(clk='1')then
                                                        c_out<='1';
                                          else
                                                        c_out<='0';
                                          end if;
                            else
                                          c_out<='0';
                            end if;
              end process;                                         

end behav;
5、按鍵消抖5.1、按鍵消抖原理圖

5.2、按鍵消抖底層程序
library ieee;
use ieee.std_logic_1164.all;
use ieee.std_logic_unsigned.all;

entity key is
              port(
                            clk:in std_logic;
                            mode,set,step_up,ok,clr:in std_logic;
                            mode_out,set_out,step_up_out,ok_out,clr_out:out std_logic
                            );
end key;

architecture behav of key is
begin

              process(clk,mode,set,step_up,ok,clr)
              variable count1,count2,count3,count4,count5:integer range 0 to 1000000; --20ms延時消抖
              begin

                            if rising_edge(clk) then
                                          if mode='0' then
                                                        if count1<1000000 then
                                                                      count1:=count1+1;
                                                        else
                                                                      count1:=count1;
                                                        end if;
                                                        if count1<=999999 then
                                                                      mode_out<='1';
                                                        else
                                                                      mode_out<='0';
                                                        end if;
                                          else count1:=0;
                                          end if;

                                          if set='0' then              
                                                        if count2<1000000 then
                                                                      count2:=count2+1;
                                                        else
                                                                      count2:=count2;
                                                        end if;

                                                        if count2<=999999 then
                                                                      set_out<='1';
                                                        else
                                                                      set_out<='0';
                                                        end if;
                                          else count2:=0;
                                          end if;

                                          if step_up='0' then                                          
                                                        if count3<1000000 then
                                                                      count3:=count3+1;
                                                        else
                                                                      count3:=count3;
                                                        end if;

                                                        if count3<=999999 then
                                                                      step_up_out<='1';
                                                        else
                                                                      step_up_out<='0';
                                                        end if;                                                        
                                          else count3:=0;
                                          end if;

                                          if ok='0' then
                                                        if count4<1000000 then
                                                                      count4:=count4+1;
                                                        else
                                                                      count4:=count4;
                                                        end if;

                                                        if count4<=999999 then
                                                                      ok_out<='1';
                                                        else
                                                                      ok_out<='0';
                                                        end if;
                                          else count4:=0;
                                          end if;

                                          if clr='0' then                           
                                                        if count5<1000000 then
                                                                      count5:=count5+1;
                                                        else
                                                                      count5:=count5;
                                                        end if;

                                                        if count5<=999999 then
                                                                      clr_out<='1';
                                                        else
                                                                      clr_out<='0';
                                                        end if;
                                          else count5:=0;
                                          end if;
                            end if;
              end process ;
end behav;
6、按鍵處理部分6.1按鍵處理原理圖
6.2按鍵處理底層程序
1 / 2

library ieee;
use ieee.std_logic_1164.all;
use ieee.std_logic_unsigned.all;

entity controller is
              port(
                            clk:in std_logic;
                            mode:in std_logic;
                            set:in std_logic;
                            ok:in std_logic;            
                            mode_out:buffer std_logic_vector(1 downto 0);
                            flag1,flag2:buffer std_logic_vector(2 downto 0)
                            );
end controller;

architecture behav of controller is
signal set_ok1,set_ok2: std_logic_vector(2 downto 0):="000";
signal mode_state:std_logic_vector(1 downto 0):="00";
begin

              process(mode,set,ok,clk)
              begin

                                          if(mode='1'and mode'event)then
                                                        if(mode_state="11")then
                                                                      mode_state<="00";
                                                        else
                                                                      mode_state<=mode_state+1;                                         
                                                        end if;
                                          else mode_state<=mode_state;
                                          end if;

                                          if(mode_state="00" or mode_state="01")then

                                                        if(set='1'and set'event)then
                                                                      if(set_ok1="100")then
                                                                                    set_ok1<="000";
                                                                      else
                                                                                    set_ok1<=set_ok1+1;
                                                                      end if;
                                                        end if;
                                          end if;

                                          if(mode_state="11")then
                                                        if(set='1'and set'event)then
                                                                      if(set_ok2="100")then
                                                                                    set_ok2<="000";
                                                                      else
                                                                                    set_ok2<=set_ok2+1;
                                                                      end if;
                                                        end if;
                                          end if;
                            mode_out<=mode_state;
                            flag1<=set_ok1;
                            flag2<=set_ok2;

              end process;

end behav;

7、選中數碼管閃爍7.1、原理圖

7.2、底層程序
library ieee;
use ieee.std_logic_1164.all;
use ieee.std_logic_unsigned.all;

entity shining is
              port(
                            mode:in std_logic_vector(1 downto 0);
                            clk1:in std_logic;
                            clk:in std_logic;
                            flag1,flag2:in std_logic_vector(2 downto 0);
                            d_2_in,d_3_in,d_4_in,d_5_in:in std_logic_vector(3 downto 0);
                            d_10_in,d_11_in,d_12_in,d_13_in:in std_logic_vector(3 downto 0);
                            d_2,d_3,d_4,d_5,d_10,d_11,d_12,d_13:out std_logic_vector(3 downto 0)                           
                            );
end shining;

architecture behav of shining is
begin

              process(clk1,mode,flag1,flag2,clk,d_2_in,d_3_in,d_4_in,d_5_in,d_10_in,d_11_in,d_12_in,d_13_in)
              begin
              if(clk1'event and clk1='1')then
                            case mode is
                            when "00" =>

                                          case flag1 is
                                          when "000" =>               d_2<=d_2_in;
                                                                                                                d_3<=d_3_in;
                                                                                                                d_4<=d_4_in;
                                                                                                                d_5<=d_5_in;

                                          when "001" =>              if(clk='1')then
                                                                                                                d_2<="1010";
                                                                                                  else
                                                                                                                d_2<=d_2_in;
                                                                                                  end if;
                                                                                                                d_3<=d_3_in;
                                                                                                                d_4<=d_4_in;
                                                                                                                d_5<=d_5_in;

                                          when "010" =>              if(clk='1')then
                                                                                                                d_3<="1010";
                                                                                                  else
                                                                                                                d_3<=d_3_in;
                                                                                                  end if;
                                                                                                                d_2<=d_2_in;
                                                                                                                d_4<=d_4_in;
                                                                                                                d_5<=d_5_in;

                                          when "011" =>              if(clk='1')then
                                                                                                                d_4<="1010";
                                                                                                  else
                                                                                                                d_4<=d_4_in;
                                                                                                  end if;
                                                                                                                d_2<=d_2_in;
                                                                                                                d_3<=d_3_in;
                                                                                                                d_5<=d_5_in;

                                          when "100" =>              if(clk='1')then
                                                                                                                d_5<="1010";
                                                                                                  else
                                                                                                                d_5<=d_5_in;
                                                                                                  end if;
                                                                                                                d_2<=d_2_in;
                                                                                                                d_3<=d_3_in;
                                                                                                                d_4<=d_4_in;

                                          when others =>              d_2<=d_2_in;
                                                                                                                d_3<=d_3_in;
                                                                                                                d_4<=d_4_in;
                                                                                                                d_5<=d_5_in;
                                          end case;

                            when "01" =>              d_2<=d_2_in;
                                                                                                  d_3<=d_3_in;
                                                                                                  d_4<=d_4_in;
                                                                                                  d_5<=d_5_in;
                                                                                                  d_10<=d_10_in;
                                                                                                  d_11<=d_11_in;
                                                                                                  d_12<=d_12_in;
                                                                                                  d_13<=d_13_in;            

                            when "10" =>              d_2<=d_2_in;
                                                                                                  d_3<=d_3_in;
                                                                                                  d_4<=d_4_in;
                                                                                                  d_5<=d_5_in;
                                                                                                  d_10<=d_10_in;
                                                                                                  d_11<=d_11_in;
                                                                                                  d_12<=d_12_in;
                                                                                                  d_13<=d_13_in;

                            when "11" =>            

                                          case flag2 is
                                          when "000" =>               d_10<=d_10_in;
                                                                                                                d_11<=d_11_in;
                                                                                                                d_12<=d_12_in;
                                                                                                                d_13<=d_13_in;

                                          when "001" =>              if(clk='1')then
                                                                                                                              d_10<="1010";
                                                                                                                else
                                                                                                                              d_10<=d_10_in;
                                                                                                                end if;
                                                                                                                d_11<=d_11_in;
                                                                                                                d_12<=d_12_in;
                                                                                                                d_13<=d_13_in;                                                                                                               

                                          when "010" =>              if(clk='1')then
                                                                                                                              d_11<="1010";
                                                                                                                else
                                                                                                                              d_11<=d_11_in;
                                                                                                                end if;
                                                                                                                d_10<=d_10_in;
                                                                                                                d_12<=d_12_in;
                                                                                                                d_13<=d_13_in;

                                          when "011" =>              if(clk='1')then
                                                                                                                              d_12<="1010";
                                                                                                                else
                                                                                                                              d_12<=d_12_in;
                                                                                                                end if;
                                                                                                                d_10<=d_10_in;
                                                                                                                d_11<=d_11_in;
                                                                                                                d_13<=d_13_in;            

                                          when "100" =>              if(clk='1')then
                                                                                                                              d_13<="1010";
                                                                                                                else
                                                                                                                              d_13<=d_13_in;
                                                                                                                end if;
                                                                                                                d_10<=d_10_in;
                                                                                                                d_11<=d_11_in;
                                                                                                                d_12<=d_12_in;

                                          when others =>              d_10<=d_10_in;
                                                                                                                d_11<=d_11_in;
                                                                                                                d_12<=d_12_in;
                                                                                                                d_13<=d_13_in;
                                          end case;
                            when others => null;
                            end case;
              end if;
              end process;            
end behav;
8、數碼管顯示控制8.1、原理圖

8.2底層程序
library ieee;
use ieee.std_logic_1164.all;
use ieee.std_logic_arith.all;
use ieee.std_logic_unsigned.all;
entity selection is
              port(
                            clk:in std_logic;
                            mode:in std_logic_vector(1 downto 0);
                            d_0,d_1,d_2,d_3,d_4,d_5:in std_logic_vector(3 downto 0);
                            d_6,d_7,d_8,d_9:in std_logic_vector(3 downto 0);
                            d_10,d_11,d_12,d_13:in std_logic_vector(3 downto 0);
                            d_0_out,d_1_out,d_2_out,d_3_out:out std_logic_vector(3 downto 0)
                            );
end entity;

architecture behav of selection is
begin
              process(clk,mode,d_0,d_1,d_2,d_3,d_4,d_5,d_6,d_7,d_8,d_9,d_10,d_11,d_12,d_13)
              begin
              if(clk'event and clk='1')then
                            case mode is
                            when "00" =>              d_0_out<=d_2;
                                                                                                  d_1_out<=d_3;
                                                                                                  d_2_out<=d_4;
                                                                                                  d_3_out<=d_5;            
                            when "01" =>              d_0_out<=d_0;
                                                                                                  d_1_out<=d_1;
                                                                                                  d_2_out<=d_2;
                                                                                                  d_3_out<=d_3;
                            when "10" =>              d_0_out<=d_6;
                                                                                                  d_1_out<=d_7;
                                                                                                  d_2_out<=d_8;
                                                                                                  d_3_out<=d_9;
                            when "11" =>              d_0_out<=d_10;
                                                                                                  d_1_out<=d_11;
                                                                                                  d_2_out<=d_12;
                                                                                                  d_3_out<=d_13;            
                            when others => null;
                            end case;
              end if;
              end process;
end behav;
9、數碼管譯碼器9.1、原理圖
9.2、底層程序
library ieee;
use ieee.std_logic_1164.all;
use ieee.std_logic_unsigned.all;            

entity seg7led is
              port(
                            mode:in std_logic_vector(1 downto 0);
                            clk4,clear:in std_logic;
                            d_0,d_1,d_2,d_3: in std_logic_vector(3 downto 0);
                            dis:out std_logic_vector(7 downto 0);
                            cs:out std_logic_vector(3 downto 0)
                            );
end seg7led;

architecture behav of seg7led is
signal dakey:std_logic_vector(3 downto 0);
signal ca:integer range 0 to 3;
begin

              n0:process(clk4,clear)
              variable cal:integer range 0 to 3;
              begin

                            if(clear='1')then
                                          cal:=0;
                            elsif rising_edge(clk4)then
                                          if(cal=3)then
                                                        cal:=0;
                                          else
                                                        cal:=cal+1;
                                          end if;
                            end if;                           
                            ca<=cal;
              end process n0;            

              n1:process(ca)
              variable ss:std_logic_vector(3 downto 0);
              begin
                            case ca is
                                          when 0 =>ss:=d_0(3 downto 0);cs<="0111";dis(7)<='0';
                                          when 1 =>ss:=d_1(3 downto 0);cs<="1011";dis(7)<='0';
                                          when 2 =>ss:=d_2(3 downto 0);cs<="1101";if(mode/="11")then
dis(7)<='1';else dis(7)<='0';
end if;
                                          when 3 =>ss:=d_3(3 downto 0);cs<="1110";dis(7)<='0';
                                          when others => ss:="ZZZZ";cs<="1111";
                            end case;
                            dakey<=ss;
              end process n1;
              n2:process(dakey)
              begin
                            case dakey is
                                          when "0000" => dis(6 downto 0) <= "0111111"; -- 0
                                          when "0001" => dis(6 downto 0) <= "0000110"; -- 1
                                          when "0010" => dis(6 downto 0) <= "1011011"; -- 2
                                          when "0011" => dis(6 downto 0) <= "1001111"; -- 3
                                          when "0100" => dis(6 downto 0) <= "1100110"; -- 4
                                          when "0101" => dis(6 downto 0) <= "1101101"; -- 5
                                          when "0110" => dis(6 downto 0) <= "1111101"; -- 6                                         
                                          when "0111" => dis(6 downto 0) <= "0000111"; -- 7
                                          when "1000" => dis(6 downto 0) <= "1111111"; -- 8
                                          when "1001" => dis(6 downto 0) <= "1101111"; -- 9
                                          when others => dis(6 downto 0) <= "0000000";
                            end case;
              end process;
end behav;
10、FPGA芯片引腳鎖定UCF文件
NET "clk" LOC= P23;//系統(tǒng)時鐘25MHz

NET "mode" LOC= P41;
NET "set" LOC= P44;
NET "step_up" LOC= P47;
NET "ok" LOC= P43;
NET "clr" LOC= P40;
NET "hour_12_24" LOC= P29;
NET "alarm_on" LOC= P32;
NET "clock_stop" LOC= P33;
NET "led" LOC= P27;
//位選
NET "CS<0>" LOC= P2;
NET "CS<1>" LOC= P142;
NET "CS<2>" LOC= P141;
NET "CS<3>" LOC= P132;
//段選
NET "DIS<0>" LOC= P1;
NET "DIS<1>" LOC= P140;
NET "DIS<2>" LOC= P134;
NET "DIS<3>" LOC= P138;
NET "DIS<4>" LOC= P137;
NET "DIS<5>" LOC= P143;
NET "DIS<6>" LOC= P133;
NET "DIS<7>" LOC= P139;

三、仿真波形1、秒——60進制計數

時鐘的秒位是60進制計數器,當計數到60后cout產生溢出脈沖信號

2、時鐘暫停及運行
時鐘的運行及暫停受clock_stop控制 clock_stop=’1’ 時鐘暫停;clock_stop=’0’ 時鐘運行

全部資料51hei下載地址:
EDA課程設計.rar (2.49 MB, 下載次數: 69)
  

評分

參與人數 1黑幣 +50 收起 理由
admin + 50 共享資料的黑幣獎勵!

查看全部評分

回復

使用道具 舉報

ID:191542 發(fā)表于 2019-3-15 14:58 | 顯示全部樓層
這個帖子在上傳的時候由于格式問題,瀏覽的時候有些亂,實在是不好意思。但是呢,功能全部實現。

評分

參與人數 1黑幣 +20 收起 理由
admin + 20 回帖助人的獎勵!

查看全部評分

回復

使用道具 舉報

ID:502774 發(fā)表于 2019-5-23 21:51 來自手機 | 顯示全部樓層
謝謝分享
回復

使用道具 舉報

ID:1056772 發(fā)表于 2022-12-11 01:48 來自手機 | 顯示全部樓層
總是離人淚 發(fā)表于 2019-3-15 14:58
這個帖子在上傳的時候由于格式問題,瀏覽的時候有些亂,實在是不好意思。但是呢,功能全部實現。

工程原理部分看不懂呀
回復

使用道具 舉報

您需要登錄后才可以回帖 登錄 | 立即注冊

本版積分規(guī)則

手機版|小黑屋|51黑電子論壇 |51黑電子論壇6群 QQ 管理員QQ:125739409;技術交流QQ群281945664

Powered by 單片機教程網

快速回復 返回頂部 返回列表
主站蜘蛛池模板: 午夜久久久 | 欧洲视频一区二区 | 精品国产一区二区三区久久久四川 | 黄色视频a级毛片 | 日韩av大片免费看 | 7777奇米影视 | 亚洲成人自拍网 | 国产精品小视频在线观看 | 青春草国产 | 国产日韩欧美激情 | 福利网站在线观看 | 97国产精品视频人人做人人爱 | 精品久久一区 | 亚洲黄色高清视频 | 色综合网站| 成人免费毛片在线观看 | 久久综合av | 91麻豆精品国产91久久久更新资源速度超快 | 一区二区国产精品 | 精品日韩 | 亚洲国内精品 | 午夜影视 | 国产午夜精品久久 | 久久综合888 | 日韩靠逼| 欧美日韩中文字幕在线 | 日本成人中文字幕在线观看 | 一级看片免费视频囗交动图 | 国产在线精品一区二区 | 91小视频 | 久草视频观看 | 一区二区三区四区毛片 | 日韩在线xx | 免费成人高清在线视频 | 日韩中文一区 | 欧美日韩精品久久久免费观看 | 9porny九色视频自拍 | 国产免费一区二区三区最新6 | 中文字幕亚洲一区二区三区 | 美美女高清毛片视频免费观看 | 日韩美女一区二区三区在线观看 |