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

Subversion Repositories gpib_controller

[/] [gpib_controller/] [trunk/] [vhdl/] [src/] [gpib/] [if_func_SH.vhd] - Blame information for rev 13

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 13 Andrewski
--------------------------------------------------------------------------------
2
--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 3 Andrewski
----------------------------------------------------------------------------------
17 13 Andrewski
-- Author: Andrzej Paluch
18 3 Andrewski
-- 
19
-- Create Date:    01:04:57 10/01/2011 
20
-- Design Name: 
21
-- Module Name:    if_func_SH - Behavioral 
22
-- Project Name: 
23
-- Target Devices: 
24
-- Tool versions: 
25
-- Description: 
26
--
27
-- Dependencies: 
28
--
29
-- Revision: 
30
-- Revision 0.01 - File Created
31
-- Additional Comments: 
32
--
33
----------------------------------------------------------------------------------
34
library IEEE;
35
use IEEE.STD_LOGIC_1164.ALL;
36
use IEEE.STD_LOGIC_ARITH.ALL;
37
use IEEE.STD_LOGIC_UNSIGNED.ALL;
38
 
39
use work.utilPkg.all;
40
 
41
entity if_func_SH is
42
        port(
43
                -- device inputs
44
                clk : in std_logic; -- clock
45
                -- settingd
46
                T1 : in std_logic_vector (7 downto 0);
47
                -- local commands
48
                pon : in std_logic; -- power on
49
                nba : in std_logic; -- new byte available
50
                -- state inputs
51
                TACS : in std_logic; -- talker active state
52
                SPAS : in std_logic; -- seriall poll active state
53
                CACS : in std_logic; -- controller active state
54
                CTRS : in std_logic; -- controller transfer state
55
                -- interface inputs
56
                ATN : in std_logic; -- attention
57
                DAC : in std_logic; -- data accepted
58
                RFD : in std_logic; -- ready for data
59
                -- remote instructions
60
                DAV : out std_logic; -- data address valid
61
                -- device outputs
62
                wnc : out std_logic; -- wait for new cycle
63
                -- reported states
64
                STRS : out std_logic; -- source transfer state
65
                SDYS : out std_logic -- source delay state
66
        );
67
end if_func_SH;
68
 
69
architecture Behavioral of if_func_SH is
70
 
71
 -- states
72
 type SH_STATE is (
73
  -- source idle state
74
  ST_SIDS,
75
  -- source generate state
76
  ST_SGNS,
77
  -- source delay state
78
  ST_SDYS,
79
  -- source transfer state
80
  ST_STRS,
81
  -- source wait for new cycle state
82
  ST_SWNS,
83
  -- source idle wait state
84
  ST_SIWS
85
 );
86
 
87
        -- current state
88
        signal current_state : SH_STATE;
89
 
90
        -- predicates
91
        signal pred1 : boolean;
92
        signal pred2 : boolean;
93
 
94
        -- timers
95
        constant TIMER_T1_MAX : integer := 255;
96
        signal timerT1 : integer range 0 to TIMER_T1_MAX;
97
        signal timerT1Expired : boolean;
98
 
99
begin
100
 
101
        -- state machine process
102
        process(pon, clk) begin
103
                if pon = '1' then
104
                        current_state <= ST_SIDS;
105
                elsif rising_edge(clk) then
106
                        case current_state is
107
                                ------------------
108
                                when ST_SIDS =>
109
                                        if pred1 then
110
                                                current_state <= ST_SGNS;
111
                                        end if;
112
                                ------------------
113
                                when ST_SGNS =>
114
                                        if nba='1' then
115
                                                timerT1 <= 0;
116
                                                current_state <= ST_SDYS;
117
                                        elsif pred2 then
118
                                                current_state <= ST_SIDS;
119
                                        end if;
120
                                ------------------
121
                                when ST_SDYS =>
122
                                        if pred2 then
123
                                                current_state <= ST_SIDS;
124
                                        elsif RFD='1' and timerT1Expired then
125
                                                current_state <= ST_STRS;
126
                                        end if;
127
 
128
                                        if timerT1 < TIMER_T1_MAX then
129
                                                timerT1 <= timerT1 + 1;
130
                                        end if;
131
                                ------------------
132
                                when ST_STRS =>
133
                                        if DAC='1' then
134
                                                current_state <= ST_SWNS;
135
                                        elsif pred2 then
136
                                                current_state <= ST_SIWS;
137
                                        end if;
138
                                ------------------
139
                                when ST_SWNS =>
140
                                        if nba='0' then
141
                                                current_state <= ST_SGNS;
142
                                        elsif pred2 then
143
                                                current_state <= ST_SIWS;
144
                                        end if;
145
                                ------------------
146
                                when ST_SIWS =>
147
                                        if nba='0' then
148
                                                current_state <= ST_SIDS;
149
                                        elsif pred1 then
150
                                                current_state <= ST_SWNS;
151
                                        end if;
152
                                ------------------
153
                                when others =>
154
                                        current_state <= ST_SIDS;
155
                        end case;
156
                end if;
157
        end process;
158
 
159
        -- events
160
        pred1 <= TACS='1' or SPAS='1' or CACS='1';
161
        pred2 <= (ATN='1' and not(CACS='1' or CTRS='1')) or
162
                         (ATN='0' and not(TACS='1' or SPAS='1'));
163
 
164
        -- timers
165
        timerT1Expired <= timerT1 >= conv_integer(UNSIGNED(T1));
166
 
167
        -- DAV command
168
        DAV <= to_stdl(current_state = ST_STRS);
169
        -- wnc command
170
        wnc <= to_stdl(current_state = ST_SWNS);
171
        -- STRS command
172
        STRS <= to_stdl(current_state = ST_STRS);
173
        -- SDYS command
174
        SDYS <= to_stdl(current_state = ST_SDYS);
175
 
176
end Behavioral;
177
 

powered by: WebSVN 2.1.0

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