counter2.vhd.bak

来自「vhdl实现交通灯设计,可以实现十字路口处交通控制,开发工具quartus」· BAK 代码 · 共 35 行

BAK
35
字号
library ieee;
use ieee.std_logic_1164.all;
entity counter2 is
port(clk: in std_logic;
	 reset: in std_logic;
	 hold : in std_logic;
	 led : out std_logic_vector(0 to 2);
	 cnum: buffer integer range 0 to 62);
end counter2;
architecture ctr of counter2 is
type fsm_st is(s0,s1,s2,s3,s4);
signal current_state,next_state:fsm_st;
signal abc: integer range 0 to 62;
begin
process(clk,reset)
begin
if reset='1' then cnum<=0;
elsif rising_edge(clk) then
	if hold='1' then cnum<=cnum;
	elsif cnum=0 then current_state<=next_state;cnum<=abc;
		 else cnum<=cnum-1;
end if;
end if;
end process;
com: process(current_state)
begin
	case current_state is
	 when s0 => abc<=34;next_state<=s1;led<="101";
	 when s1 => abc<=29;next_state<=s2;led<="011";
	 when s2 => abc<=4; next_state<=s3;led<="110";
	 when s3 => abc<=34;next_state<=s4;led<="101";
	 when s4 => abc<=34;next_state<=s0;led<="101";	
	end case;
	end process;
end ctr;

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?