OpenCores
URL https://opencores.org/ocsvn/idea/idea/trunk

Subversion Repositories idea

[/] [idea/] [trunk/] [fsm/] [key_regulator/] [count2x.fsm] - Blame information for rev 9

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 6 marta
--Nama file : count2x.fsm
2
--Deskripsi : counter 2 bit
3
--Author    : Mas Adit
4
--Tanggal  : 31 Agustus 2001
5
 
6
entity count2x is
7
port (
8
        clk : in bit;
9
        rst : in bit;
10
       q : out bit_vector(1 downto 0);
11
       vdd : in bit;
12
       vss : in bit
13
      );
14
end count2x;
15
 
16
architecture STATE_MACHINE of count2x is
17
 
18
type STATE_TYPE IS (S0, S1, S2, S3);
19
 
20
-- pragma CLOCK clk
21
-- pragma CURRENT_STATE CURRENT_STATE
22
-- pragma NEXT_STATE NEXT_STATE
23
 
24
signal CURRENT_STATE, NEXT_STATE: STATE_TYPE;
25
 
26
begin
27
  process ( CURRENT_STATE, rst )
28
    begin
29
      if ( rst = '1' ) then
30
          NEXT_STATE <= S0;
31
          q <= "00";
32
      else
33
          case CURRENT_STATE IS
34
             when S0 =>
35
                q <= "00";
36
                NEXT_STATE <= S1;
37
             when S1 =>
38
                q <= "01";
39
                NEXT_STATE <= S2;
40
             when S2 =>
41
                q <= "10";
42
                NEXT_STATE <= S3;
43
             when S3 =>
44
                q <= "11";
45
                NEXT_STATE <= S0;
46
             when OTHERS =>
47
                assert ( '1' )
48
                report "Illegal State";
49
 
50
          end case;
51
      end if;
52
end process;
53
 
54
process (clk)
55
  begin
56
    if ((clk = '1') and not (clk'STABLE)) then
57
         CURRENT_STATE <= NEXT_STATE;
58
    end if;
59
end process;
60
 
61
end STATE_MACHINE;

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.