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

 找回密碼
 立即注冊

QQ登錄

只需一步,快速開始

搜索
查看: 3773|回復(fù): 0
收起左側(cè)

用狀態(tài)機(jī)編寫的VHDL60分計時器

[復(fù)制鏈接]
ID:77367 發(fā)表于 2015-4-19 03:04 | 顯示全部樓層 |閱讀模式
---------------------------狀態(tài)機(jī)---------------------------
Library ieee;
Use ieee.std_logic_1164.all;
-------------------------------------------
Entity statem is
Port(clk,clr:in std_logic;
     Q0,Q1,Q2,Q3:out std_logic_vector(6 downto 0));
end;
---------------------------------------------
architecture dd of statem is
Type state is (s0,s1,s2,s3,s4,s5,s6,s7,s8,s9);
signal ss0,ss1,ss2,ss3:state;
signal Q:integer range 0 to 19999999;
signal cp:std_logic;
procedure disp(s:in state;p:out std_logic_vector(6 downto 0))is
begin
   case s is
  when s0=>p:="1000000";
  when s1=>p:="1111001";
  when s2=>p:="0100100";
  when s3=>p:="0110000";
  when s4=>p:="0011001";
  when s5=>p:="0010010";
  when s6=>p:="0000010";
  when s7=>p:="1111000";
  when s8=>p:="0000000";
  when s9=>p:="0010000";
  end case;
end disp;
----------1s---------------
begin
process(clk)
   begin
       if clk'event and clk='1' then
            Q<=Q+1;
            if Q=0 then
               cp<=not cp;
            end if;
        end if;
end process;
----------------------------------
process(cp)
   begin
   if clr='0' then
     ss0<=s0;
     ss1<=s0;
     ss2<=s0;
     ss3<=s0;
elsif cp'event and cp='1' then
     case ss0 is
     when s0=>ss0<=s1;
     when s1=>ss0<=s2;
     when s2=>ss0<=s3;
     when s3=>ss0<=s4;
     when s4=>ss0<=s5;
     when s5=>ss0<=s6;
     when s6=>ss0<=s7;
     when s7=>ss0<=s8;
     when s8=>ss0<=s9;
     when s9=>ss0<=s0;
                      case ss1 is
                     when s0=>ss1<=s1;
                     when s1=>ss1<=s2;
                     when s2=>ss1<=s3;
                     when s3=>ss1<=s4;
                     when s4=>ss1<=s5;
                     when s5=>ss1<=s0;
                                      case ss2 is
                                      when s0=>ss2<=s1;
                                      when s1=>ss2<=s2;
                                      when s2=>ss2<=s3;
                                      when s3=>ss2<=s4;
                                      when s4=>ss2<=s5;
                                      when s5=>ss2<=s6;
                                      when s6=>ss2<=s7;
                                      when s7=>ss2<=s8;
                                      when s8=>ss2<=s9;
                                      when s9=>ss2<=s0;
                                                     case ss3 is
                                                     when s0=>ss3<=s1;
                                                     when s1=>ss3<=s2;
                                                     when s2=>ss3<=s3;
                                                     when s3=>ss3<=s4;
                                                     when s4=>ss3<=s5;
                                                     when s5=>ss3<=s0;
                                                     when others=>null;
                                                    end case;
                                     end case;
                    when others=>null;
            end case;
   end case;
end if;
end process;
process(ss0,ss1)
   variable sss0,sss1,sss2,sss3:std_logic_vector(6 downto 0);
   begin
    disp(ss0,sss0);
  disp(ss1,sss1);
  disp(ss2,sss2);
  disp(ss3,sss3);
  Q0<=sss0;Q1<=sss1;Q2<=sss2;Q3<=sss3;
end process;
end;
--------------------------------判斷語句-----------------------------------------------------
  Library ieee;
Use ieee.std_logic_1164.all;
Use ieee.std_logic_unsigned.all;
Entity statem is
Port(clk,clr:in std_logic;
     Q0,Q1,Q2,Q3:out std_logic_vector(6 downto 0));
end;
architecture dd of statem is
signal ss0,ss2, ss1,ss3:std_logic_vector(3 downto 0);
signal Q:integer range 0 to 12999999;
signal cp:std_logic;
procedure disp0(s0:in std_logic_vector(3 downto 0);p0:out std_logic_vector(6 downto 0))is
begin
   case s0 is
  when "0000"=>p0:="1000000";
  when "0001"=>p0:="1111001";
  when "0010"=>p0:="0100100";
  when "0011"=>p0:="0110000";
  when "0100"=>p0:="0011001";
  when "0101"=>p0:="0010010";
  when "0110"=>p0:="0000010";
  when "0111"=>p0:="1111000";
  when "1000"=>p0:="0000000";
  when "1001"=>p0:="0010000";
  when others=>null;
  end case;
end disp0;
begin
process(clk)
   begin
if clk'event and clk='1' then
      Q<=Q+1;
    if Q=0 then
      cp<=not cp;
   end if;
end if;
end process;
process(cp)
   begin
     if clr='0' then
     ss0<="0000";
   ss1<="0000";
   ss2<="0000";
   ss3<="0000";
   elsif cp'event and cp='1' then
    ss0<=ss0+1;
      if ss0=9 then
      ss0<="0000";
      ss1<=ss1+1;
      if ss1=5 then
         ss1<="0000";
       ss2<=ss2+1;
       if ss2=9 then
          ss2<="0000";
        ss3<=ss3+1;
        if ss3=5 then
           ss3<="0000";
       end if;
       end if;
     end if;
    end if;
   end if;
end process;
process(ss0,ss1,ss2,ss3)
   variable sss0,sss1,sss2,sss3:std_logic_vector(6 downto 0);
   begin
    disp0(ss0,sss0);
  disp0(ss1,sss1);
  disp0(ss2,sss2);
  disp0(ss3,sss3);
  Q0<=sss0;Q1<=sss1;Q2<=sss2;Q3<=sss3;
end process;
end;


回復(fù)

使用道具 舉報

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

本版積分規(guī)則

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

Powered by 單片機(jī)教程網(wǎng)

快速回復(fù) 返回頂部 返回列表
主站蜘蛛池模板: 一区二区三区国产在线观看 | 成人久久 | 古装人性做爰av网站 | 成人国产在线视频 | 日本成人在线观看网站 | 国产高清一区二区三区 | 久久激情网 | 久久av一区二区三区 | 毛片电影 | 欧美激情综合五月色丁香小说 | 免费在线一区二区 | 97免费视频在线观看 | 久久久精品一区二区三区四季av | 久久久久久免费毛片精品 | 天天拍天天射 | 毛片com| 天天干视频在线 | 久久久成人一区二区免费影院 | 久久久久久高清 | 亚洲a人 | 动漫www.被爆羞羞av44 | 韩日精品在线观看 | 日韩中文字幕 | 亚洲欧美日韩精品久久亚洲区 | 一级久久久久久 | 国产一区二区三区在线视频 | 日本天天操 | 日韩高清一区二区 | 夜夜爽99久久国产综合精品女不卡 | 91久久久久久久 | 狠狠艹| 国产精品福利在线观看 | 91在线观看免费视频 | 国产福利在线看 | 成人一区av偷拍 | 久久综合香蕉 | 久久久精选 | 国内精品一区二区 | 亚洲一区av | 91久久综合亚洲鲁鲁五月天 | 亚洲一区日韩 |