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 13

Details | Compare with Previous | View Log

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

powered by: WebSVN 2.1.0

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