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 3

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

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

powered by: WebSVN 2.1.0

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