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

Subversion Repositories idea

[/] [idea/] [trunk/] [fsm/] [key_regulator/] [count3x.fsm] - Blame information for rev 6

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 6 marta
--Nama file : count3x.fsm
2
--Deskripsi : counter 3 bit
3
--Author    : Mas Adit
4
--Tanggal  : 31 Agustus 2001
5
 
6
entity count3x is
7
port (
8
        clk : in bit;
9
        rst : in bit;
10
       q : out bit_vector(2 downto 0);
11
       vdd : in bit;
12
       vss : in bit
13
      );
14
end count3x;
15
 
16
architecture STATE_MACHINE of count3x is
17
 
18
type STATE_TYPE IS (S0, S1, S2, S3, S4, S5, S6, S7);
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 <= "000";
32
      else
33
          case CURRENT_STATE IS
34
             when S0 =>
35
                q <= "000";
36
                NEXT_STATE <= S1;
37
             when S1 =>
38
                q <= "001";
39
                NEXT_STATE <= S2;
40
             when S2 =>
41
                q <= "010";
42
                NEXT_STATE <= S3;
43
             when S3 =>
44
                q <= "011";
45
                NEXT_STATE <= S4;
46
             when S4 =>
47
                q <= "100";
48
                NEXT_STATE <= S5;
49
             when S5 =>
50
                q <= "101";
51
                NEXT_STATE <= S6;
52
             when S6 =>
53
                q <= "110";
54
                NEXT_STATE <= S7;
55
             when S7 =>
56
                q <= "111";
57
                NEXT_STATE <= S0;
58
             when OTHERS =>
59
                assert ( '1' )
60
                report "Illegal State";
61
 
62
          end case;
63
      end if;
64
end process;
65
 
66
process (clk)
67
  begin
68
    if ((clk = '1') and not (clk'STABLE)) then
69
         CURRENT_STATE <= NEXT_STATE;
70
    end if;
71
end process;
72
 
73
end STATE_MACHINE;

powered by: WebSVN 2.1.0

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