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

Subversion Repositories gpib_controller

[/] [gpib_controller/] [trunk/] [vhdl/] [src/] [gpib/] [if_func_L_LE.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_L_LE
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_L_LE is
29
        port(
30
                -- clock
31
                clk : in std_logic; -- clock
32
                -- function settings
33
                isLE : in std_logic;
34
                -- local commands
35
                pon : in std_logic; -- power on
36
                ltn : in std_logic; -- listen
37
                lun : in std_logic; -- local unlisten
38
                lon : in std_logic; -- listen only
39
                -- state inputs
40
                ACDS : in std_logic; -- accept data state (AH)
41
                CACS : in std_logic; -- controller active state (C)
42
                TPAS : in std_logic; -- talker primary address state (T)
43
                -- remote commands
44
                ATN : in std_logic; -- attention
45
                IFC : in std_logic; -- interface clear
46
                MLA : in std_logic; -- my listen address
47
                MTA : in std_logic; -- my talk address
48
                UNL : in std_logic; -- unlisten
49
                PCG : in std_logic; -- primary command group
50
                MSA : in std_logic; -- my secondary address
51
                -- reported states
52
                LACS : out std_logic; -- listener active state
53
                LADS : out std_logic; -- listener addressed state
54
                LPAS : out std_logic -- listener primary addressed state
55
                ;debug1 : out std_logic
56
        );
57
end if_func_L_LE;
58
 
59
architecture Behavioral of if_func_L_LE is
60
 
61
        -- states
62
        type LE_STATE_1 is (
63
                -- listener idle state
64
                ST_LIDS,
65
                -- listener addressed state
66
                ST_LADS,
67
                -- listener active state
68
                ST_LACS
69
        );
70
 
71
        -- states
72
        type LE_STATE_2 is (
73
                -- listener primary idle state
74
                ST_LPIS,
75
                -- listener primary addressed state
76
                ST_LPAS
77
        );
78
 
79
        -- current state
80
        signal current_state_1 : LE_STATE_1;
81
        signal current_state_2 : LE_STATE_2;
82
 
83
        -- predicates
84
        signal event0, event1, event2, event3, event4 : boolean;
85
 
86
begin
87
 
88
        debug1 <= to_stdl(current_state_1 = ST_LACS) or
89
                to_stdl(current_state_1 = ST_LADS);
90
 
91
        -- state machine process - L_STATE_1
92
        process(pon, clk) begin
93
        if pon = '1' then
94
                        current_state_1 <= ST_LIDS;
95
                elsif rising_edge(clk) then
96
                        case current_state_1 is
97
                                ------------------
98
                                when ST_LIDS =>
99
                                        if event0 then
100
                                                -- no state change
101
                                        elsif event1 then
102
                                                current_state_1 <= ST_LADS;
103
                                        end if;
104
                                ------------------
105
                                when ST_LADS =>
106
                                        if event0 then
107
                                                current_state_1 <= ST_LIDS;
108
                                        elsif event2 then
109
                                                current_state_1 <= ST_LIDS;
110
                                        elsif ATN='0' then
111
                                                current_state_1 <= ST_LACS;
112
                                        end if;
113
                                ------------------
114
                                when ST_LACS =>
115
                                        if event0 then
116
                                                current_state_1 <= ST_LIDS;
117
                                        elsif ATN='1' then
118
                                                current_state_1 <= ST_LADS;
119
                                        end if;
120
                                ------------------
121
                                when others =>
122
                                        current_state_1 <= ST_LIDS;
123
                        end case;
124
                end if;
125
        end process;
126
 
127
        -- state machine process - L_STATE_2
128
        process(pon, clk) begin
129
                if pon = '1' then
130
                        current_state_2 <= ST_LPIS;
131
                elsif rising_edge(clk) then
132
                        case current_state_2 is
133
                                ------------------
134
                                when ST_LPIS =>
135
                                        if event0 then
136
                                                -- no state change
137
                                        elsif event3 then
138
                                                current_state_2 <= ST_LPAS;
139
                                        end if;
140
                                ------------------
141
                                when ST_LPAS =>
142
                                        if event0 then
143
                                                current_state_2 <= ST_LPIS;
144
                                        elsif event4 then
145
                                                current_state_2 <= ST_LPIS;
146
                                        end if;
147
                                ------------------
148
                                when others =>
149
                                        current_state_2 <= ST_LPIS;
150
                        end case;
151
                end if;
152
        end process;
153
 
154
        -- events
155
        event0 <= IFC='1';
156
 
157
        event1 <= (isLE='1' and (
158
                                lon='1' or (ltn='1' and CACS='1') or
159
                                (MSA='1' and current_state_2=ST_LPAS and ACDS='1')
160
                        )) or
161
                        (isLE='0' and (
162
                                lon='1' or (MLA='1' and ACDS='1') or (ltn='1' and CACS='1')
163
                        ));
164
 
165
        event2 <= (isLE='1' and (
166
                                (UNL='1' and ACDS='1') or
167
                                (lun='1' and CACS='1') or
168
                                (MSA='1' and TPAS='1' and ACDS='1')
169
                        )) or
170
                        (isLE='0' and (
171
                                (UNL='1' and ACDS='1') or
172
                                (MTA='1' and ACDS='1') or
173
                                (lun='1' and CACS='1')
174
                        ));
175
 
176
        event3 <= MLA='1' and ACDS='1';
177
        event4 <= PCG='1' and MLA='0' and ACDS='1';
178
 
179
        LACS <= to_stdl(current_state_1 = ST_LACS);
180
        LADS <= to_stdl(current_state_1 = ST_LADS);
181
        LPAS <= to_stdl(current_state_2 = ST_LPAS);
182
 
183
end Behavioral;

powered by: WebSVN 2.1.0

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