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

Subversion Repositories gpib_controller

[/] [gpib_controller/] [trunk/] [vhdl/] [src/] [gpib/] [if_func_T_TE.vhd] - Blame information for rev 3

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

Line No. Rev Author Line
1 3 Andrewski
--------------------------------------------------------------------------------
2
-- Entity:      if_func_T_TE
3
-- Date:        01:04:57 10/01/2011
4
-- Author:      apaluch
5
--------------------------------------------------------------------------------
6
library IEEE;
7
 
8
use ieee.std_logic_1164.all;
9
 
10
use work.utilPkg.all;
11
 
12
 
13
entity if_func_T_TE is
14
        port(
15
                -- clock
16
                clk : in std_logic; -- clock
17
                -- function settings
18
                isTE : in std_logic;
19
                -- local instruction inputs
20
                pon : in std_logic; -- power on
21
                ton : in std_logic; -- talk only
22
                endOf : in std_logic; -- end of byte string
23
                -- state inputs
24
                ACDS : in std_logic; -- accept data state (AH)
25
                APRS : in std_logic; -- affirmative poll response
26
                LPAS : in std_logic; -- listener primary state (LE)
27
                -- remote instruction inputs
28
                ATN : in std_logic; -- attention
29
                IFC : in std_logic; -- interface clear
30
                SPE : in std_logic; -- serial poll enable
31
                SPD : in std_logic; -- serial poll disable
32
                MTA : in std_logic; -- my talk address
33
                OTA : in std_logic; -- other talk address
34
                MLA : in std_logic; -- my listen address
35
                OSA : in std_logic; -- other secondary address
36
                MSA : in std_logic; -- my secondary address
37
                PCG : in std_logic; -- primary command group
38
                -- remote instruction outputs
39
                END_OF : out std_logic; -- end of data
40
                RQS : out std_logic; -- data accepted
41
                DAB : out std_logic; -- data byte
42
                EOS : out std_logic; -- end of string
43
                STB : out std_logic; -- status byte
44
                -- local instruction outputs
45
                tac : out std_logic; -- talker active
46
                -- reported states
47
                SPAS : out std_logic; -- serial poll active state
48
                TPAS : out std_logic; -- transmitter active state
49
                TADS : out std_logic; -- talker addressed state
50
                TACS : out std_logic -- talker active state
51
        );
52
end if_func_T_TE;
53
 
54
architecture Behavioral of if_func_T_TE is
55
 
56
        -- states
57
        type T_STATE_1 is (
58
                -- talker idle state
59
                ST_TIDS,
60
                -- talker addressed state
61
                ST_TADS,
62
                -- talker active state
63
                ST_TACS,
64
                -- serial poll active state
65
                ST_SPAS
66
        );
67
 
68
        type T_STATE_2 is (
69
                -- serial poll idle state
70
                ST_SPIS,
71
                -- seriall poll mode state
72
                ST_SPMS
73
        );
74
 
75
        type T_STATE_3 is (
76
                -- talker primary idle state
77
                ST_TPIS,
78
                -- talker primary addressed state
79
                ST_TPAS
80
        );
81
 
82
        -- current state
83
        signal current_state_1 : T_STATE_1;
84
        signal current_state_2 : T_STATE_2;
85
        signal current_state_3 : T_STATE_3;
86
 
87
        -- events
88
        signal event1_1, event1_2, event1_3, event1_4, event1_5, event1_6 : boolean;
89
        signal event2_1, event2_2, event2_3 : boolean;
90
        signal event3_1, event3_2, event3_3 : boolean;
91
 
92
 
93
begin
94
 
95
        -- state machine process - T_STATE_1
96
        process(pon, clk) begin
97
                if pon = '1' then
98
                        current_state_1 <= ST_TIDS;
99
                elsif rising_edge(clk) then
100
                        case current_state_1 is
101
                                ------------------
102
                                when ST_TIDS =>
103
                                        if event1_6 then
104
                                                -- no state change
105
                                        elsif event1_1 then
106
                                                current_state_1 <= ST_TADS;
107
                                        end if;
108
                                ------------------
109
                                when ST_TADS =>
110
                                        if event1_6 then
111
                                                current_state_1 <= ST_TIDS;
112
                                        elsif event1_2 then
113
                                                current_state_1 <= ST_SPAS;
114
                                        elsif event1_3 then
115
                                                current_state_1 <= ST_TIDS;
116
                                        elsif event1_4 then
117
                                                current_state_1 <= ST_TACS;
118
                                        end if;
119
                                ------------------
120
                                when ST_SPAS =>
121
                                        if event1_6 then
122
                                                current_state_1 <= ST_TIDS;
123
                                        elsif event1_5 then
124
                                                current_state_1 <= ST_TADS;
125
                                        end if;
126
                                ------------------
127
                                when ST_TACS =>
128
                                        if event1_6 then
129
                                                current_state_1 <= ST_TIDS;
130
                                        elsif event1_5 then
131
                                                current_state_1 <= ST_TADS;
132
                                        end if;
133
                                ------------------
134
                                when others =>
135
                                        current_state_1 <= ST_TIDS;
136
                        end case;
137
                end if;
138
        end process;
139
 
140
        -- state machine process - T_STATE_2
141
        process(pon, clk) begin
142
                if pon = '1' then
143
                        current_state_2 <= ST_SPIS;
144
                elsif rising_edge(clk) then
145
                        case current_state_2 is
146
                                ------------------
147
                                when ST_SPIS =>
148
                                        if event2_3 then
149
                                                -- no state change
150
                                        elsif event2_1 then
151
                                                current_state_2 <= ST_SPMS;
152
                                        end if;
153
                                ------------------
154
                                when ST_SPMS =>
155
                                        if event2_3 then
156
                                                current_state_2 <= ST_SPIS;
157
                                        elsif event2_2 then
158
                                                current_state_2 <= ST_SPIS;
159
                                        end if;
160
                                ------------------
161
                                when others =>
162
                                        current_state_2 <= ST_SPIS;
163
                        end case;
164
                end if;
165
        end process;
166
 
167
        -- state machine process - T_STATE_3
168
        process(pon, clk) begin
169
                if pon = '1' then
170
                        current_state_3 <= ST_TPIS;
171
                elsif rising_edge(clk) then
172
                        case current_state_3 is
173
                                ------------------
174
                                when ST_TPIS =>
175
                                        if event3_3 then
176
                                                -- no state change
177
                                        elsif event3_1 then
178
                                                current_state_3 <= ST_TPAS;
179
                                        end if;
180
                                ------------------
181
                                when ST_TPAS =>
182
                                        if event3_3 then
183
                                                current_state_3 <= ST_TPIS;
184
                                        elsif event3_2 then
185
                                                current_state_3 <= ST_TPIS;
186
                                        end if;
187
                                ------------------
188
                                when others =>
189
                                        current_state_3 <= ST_TPIS;
190
                        end case;
191
                end if;
192
        end process;
193
 
194
        -- events
195
        event1_1 <= is_1(
196
                -- TE
197
                (isTE and
198
                        (ton or (MSA and ACDS and to_stdl(current_state_3=ST_TPAS)))) or
199
                -- T
200
                (not isTE and
201
                        (ton or (MTA and ACDS)))
202
                );
203
        event1_2 <= ATN='0' and current_state_2=ST_SPMS;
204
        event1_3 <=
205
                        -- TE
206
                        (isTE='1' and ((OTA='1' and ACDS='1') or
207
                        (OSA='1' and current_state_3=ST_TPAS and ACDS='1') or
208
                        (MSA='1' and LPAS='1' and ACDS='1'))) or
209
                        -- T
210
                        (isTE='0' and ((OTA='1' and ACDS='1') or (MLA='1' and ACDS='1')));
211
        event1_4 <= ATN='0' and current_state_2/=ST_SPMS;
212
        event1_5 <= ATN='1';
213
        event1_6 <= IFC='1';
214
 
215
        event2_1 <= SPE='1' and ACDS='1';
216
        event2_2 <= SPD='1' and ACDS='1';
217
        event2_3 <= IFC='1';
218
 
219
        event3_1 <= MTA='1' and ACDS='1';
220
        event3_2 <= PCG='1' and MTA='0' and ACDS='1';
221
        event3_3 <= IFC='1';
222
 
223
        -- TADS generator
224
        with current_state_1 select
225
                TADS <=
226
                        '1' when ST_TADS,
227
                        '0' when others;
228
 
229
        -- TACS generator
230
        with current_state_1 select
231
                TACS <=
232
                        '1' when ST_TACS,
233
                        '0' when others;
234
 
235
        -- DAB generator
236
        with current_state_1 select
237
                DAB <=
238
                        '1' when ST_TACS,
239
                        '0' when others;
240
 
241
        -- EOS is kind of DAB
242
        with current_state_1 select
243
                EOS <=
244
                        '1' when ST_TACS,
245
                        '0' when others;
246
 
247
        -- STB generator
248
        with current_state_1 select
249
                STB <=
250
                        '1' when ST_SPAS,
251
                        '0' when others;
252
 
253
        -- SPAS generator
254
        with current_state_1 select
255
                SPAS <=
256
                        '1' when ST_SPAS,
257
                        '0' when others;
258
 
259
        -- TPAS generator
260
        with current_state_3 select
261
                TPAS <=
262
                        '1' when ST_TPAS,
263
                        '0' when others;
264
 
265
        -- tac generator
266
        with current_state_1 select
267
                tac <=
268
                        '1' when ST_TACS,
269
                        '0' when others;
270
 
271
        -- END_OF generator
272
        with current_state_1 select
273
                END_OF <=
274
                        endOf when ST_TACS,
275
                        endOf when ST_SPAS,
276
                        '0' when others;
277
 
278
        -- RQS generator
279
        RQS <= APRS when current_state_1=ST_SPAS else '0';
280
 
281
end Behavioral;

powered by: WebSVN 2.1.0

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