URL
https://opencores.org/ocsvn/idea/idea/trunk
Subversion Repositories idea
[/] [idea/] [trunk/] [fsm/] [key_regulator/] [count2x.fsm] - Rev 9
Compare with Previous | Blame | View Log
--Nama file : count2x.fsm
--Deskripsi : counter 2 bit
--Author : Mas Adit
--Tanggal : 31 Agustus 2001
entity count2x is
port (
clk : in bit;
rst : in bit;
q : out bit_vector(1 downto 0);
vdd : in bit;
vss : in bit
);
end count2x;
architecture STATE_MACHINE of count2x is
type STATE_TYPE IS (S0, S1, S2, S3);
-- pragma CLOCK clk
-- pragma CURRENT_STATE CURRENT_STATE
-- pragma NEXT_STATE NEXT_STATE
signal CURRENT_STATE, NEXT_STATE: STATE_TYPE;
begin
process ( CURRENT_STATE, rst )
begin
if ( rst = '1' ) then
NEXT_STATE <= S0;
q <= "00";
else
case CURRENT_STATE IS
when S0 =>
q <= "00";
NEXT_STATE <= S1;
when S1 =>
q <= "01";
NEXT_STATE <= S2;
when S2 =>
q <= "10";
NEXT_STATE <= S3;
when S3 =>
q <= "11";
NEXT_STATE <= S0;
when OTHERS =>
assert ( '1' )
report "Illegal State";
end case;
end if;
end process;
process (clk)
begin
if ((clk = '1') and not (clk'STABLE)) then
CURRENT_STATE <= NEXT_STATE;
end if;
end process;
end STATE_MACHINE;