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

Subversion Repositories idea

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

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 6 marta
--Nama file : kontrol_utama_invaddx.fsm
2
--Deskripsi : kontrol utama modul inv_add modulo (2^16 + 1)
3
--Author    : Mas Adit
4
--Tanggal  : 28 Agustus 2001
5
 
6
entity kontrol_utama_invaddx is
7
port (
8
        clk : in bit;
9
        rst : in bit;
10
        start : in bit;
11
        n_dtin : in bit_vector(4 downto 0);
12
        n_dtout : in bit_vector(4 downto 0);
13
        c_cdtin : out bit;
14
        en_cdtin : out bit;
15
        c_cdtout : out bit;
16
        en_cdtout : out bit;
17
        en_out : out bit;
18
        en_in : out bit;
19
        finish : out bit;
20
        vdd : in bit;
21
        vss : in bit
22
);
23
end kontrol_utama_invaddx;
24
 
25
architecture fsm of kontrol_utama_invaddx is
26
 
27
type STATE_TYPE is (S0, S1, S2, S3, S4);
28
        --pragma CLOCK clk
29
        --pragma CURRENT_STATE CURRENT_STATE
30
        --pragma NEXT_STATE NEXT_STATE
31
signal CURRENT_STATE, NEXT_STATE : STATE_TYPE;
32
 
33
begin
34
 
35
process (CURRENT_STATE, rst, start, n_dtout, n_dtin)
36
begin
37
        if (rst = '1') then
38
                NEXT_STATE <= S0;
39
                en_cdtin <= '0';
40
                c_cdtin <= '0';
41
                en_cdtout <= '0';
42
                c_cdtout <= '0';
43
                en_in <= '0';
44
                en_out <= '0';
45
                finish <= '0';
46
        else
47
                case CURRENT_STATE is
48
 
49
                when S0 =>
50
                if  (start = '1') then
51
                        if not(n_dtout = "10010") then
52
                                if (n_dtin = "00000") then
53
                                        NEXT_STATE <= S1;
54
                                        en_cdtin <= '1';
55
                                        c_cdtin <= '0';
56
                                        en_cdtout <= '1';
57
                                        c_cdtout <= '0';
58
                                        en_in <= '1';
59
                                        en_out <= '0';
60
                                        finish <= '0';
61
                                else
62
                                        NEXT_STATE <= S2;
63
                                        en_cdtin <= '0';
64
                                        c_cdtin <= '0';
65
                                        en_cdtout <= '0';
66
                                        c_cdtout <= '1';
67
                                        en_in <= '1';
68
                                        en_out <= '0';
69
                                        finish <= '0';
70
                                end if;
71
                        else
72
                                NEXT_STATE <= S4;
73
                                en_cdtin <= '0';
74
                                c_cdtin <= '0';
75
                                en_cdtout <= '0';
76
                                c_cdtout <= '0';
77
                                en_in <= '0';
78
                                en_out <= '0';
79
                                finish <= '1';
80
                        end if;
81
                else
82
                        NEXT_STATE <= S0;
83
                        en_cdtin <= '0';
84
                        c_cdtin <= '0';
85
                        en_cdtout <= '0';
86
                        c_cdtout <= '0';
87
                        en_in <= '0';
88
                        en_out <= '0';
89
                        finish <= '0';
90
                end if;
91
 
92
                when S1 =>
93
                        NEXT_STATE <= S3;
94
                        en_cdtin <= '1';
95
                        c_cdtin <= '1';
96
                        en_cdtout <= '1';
97
                        c_cdtout <= '0';
98
                        en_in <= '0';
99
                        en_out <= '1';
100
                        finish <= '0';
101
 
102
                when S2 =>
103
                        NEXT_STATE <= S3;
104
                        en_cdtin <= '1';
105
                        c_cdtin <= '1';
106
                        en_cdtout <= '1';
107
                        c_cdtout <= '0';
108
                        en_in <= '0';
109
                        en_out <= '1';
110
                        finish <= '0';
111
 
112
                when S3 =>
113
                        NEXT_STATE <= S3;
114
                        en_cdtin <= '1';
115
                        c_cdtin <= '1';
116
                        en_cdtout <= '1';
117
                        c_cdtout <= '0';
118
                        en_in <= '0';
119
                        en_out <= '1';
120
                        finish <= '0';
121
 
122
                when S4 =>
123
                        NEXT_STATE <= S4;
124
                        en_cdtin <= '0';
125
                        c_cdtin <= '0';
126
                        en_cdtout <= '0';
127
                        c_cdtout <= '0';
128
                        en_in <= '0';
129
                        en_out <= '0';
130
                        finish <= '1';
131
 
132
                end case;
133
        end if;
134
end process;
135
 
136
process (clk)
137
begin
138
        if ((clk = '0') and not(clk'STABLE)) then
139
                CURRENT_STATE <= NEXT_STATE;
140
        end if;
141
end process;
142
 
143
end fsm;
144
 
145
 
146
 
147
 
148
 

powered by: WebSVN 2.1.0

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