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

Subversion Repositories gpib_controller

[/] [gpib_controller/] [trunk/] [vhdl/] [src/] [gpib_helper/] [gpibWriter.vhd] - Blame information for rev 6

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

Line No. Rev Author Line
1 3 Andrewski
--------------------------------------------------------------------------------
2
-- Entity: gpibWriter
3
-- Date: 2011-11-01
4
-- Author: apaluch
5
--------------------------------------------------------------------------------
6
library ieee;
7
use ieee.std_logic_1164.all;
8
use ieee.std_logic_unsigned.all;
9
use ieee.std_logic_arith.all;
10
 
11
use work.utilPkg.all;
12
 
13
 
14
entity gpibWriter is
15
        port (
16
                -- clock
17
                clk : in std_logic;
18
                -- reset
19
                reset : std_logic;
20
                ------------------------------------------------------------------------
21
                ------ GPIB interface --------------------------------------------------
22
                ------------------------------------------------------------------------
23
                -- output data
24
                data_out : out std_logic_vector (7 downto 0);
25
                -- wait for new cycle
26
                wnc : in std_logic;
27
                -- seriall poll active
28
                spa : in std_logic;
29
                -- new byte available
30
                nba : out std_logic;
31
                -- end of string
32
                endOf : out std_logic;
33
                -- talker active
34
                tac : in std_logic;
35
                -- controller write command
36
                cwrc : in std_logic;
37
                ------------------------------------------------------------------------
38
                ------ external interface ----------------------------------------------
39
                ------------------------------------------------------------------------
40
                -- TE is extended
41
                isTE : in std_logic;
42
                -- current secondary address
43
                secAddr : in std_logic_vector (4 downto 0);
44
                -- secondary address of data
45
                dataSecAddr : in std_logic_vector (4 downto 0);
46
                -- buffer consumed
47
                buf_interrupt : out std_logic;
48
                -- indicates end of stream
49
                end_of_stream : in std_logic;
50
                -- resets writer
51
                reset_writer : in std_logic;
52
                -- enables writer
53
                writer_enable : in std_logic;
54
                ---------------- fifo ---------------------------
55
                availableFifoBytesCount : in std_logic_vector(10 downto 0);
56
                -- fifo read strobe
57
                fifo_read_strobe : out std_logic;
58
                -- indicates fifo ready to read
59
                fifo_ready_to_read : in std_logic;
60
                -- input data
61
                fifo_data_in : in std_logic_vector (7 downto 0)
62
        );
63
end gpibWriter;
64
 
65
architecture arch of gpibWriter is
66
 
67
        -- writer states
68
        type WRITER_STATE is (
69
                ST_IDLE,
70
                ST_WAIT_WNC_1,
71
                ST_WAIT_WNC_0
72
        );
73
 
74
 
75
        signal current_state : WRITER_STATE;
76
        -- triggered by spa
77
        signal tr_by_spa : std_logic;
78
        signal readyToSend : boolean;
79
        signal at_least_one_byte_in_fifo : boolean;
80
 
81
begin
82
 
83
        buf_interrupt <= to_stdl(not at_least_one_byte_in_fifo);
84
        data_out <= fifo_data_in;
85
        at_least_one_byte_in_fifo <= availableFifoBytesCount /= "000000000000";
86
 
87
        readyToSend <=
88
                (
89
                                writer_enable = '1'
90
                        and
91
                                at_least_one_byte_in_fifo
92
                        and
93
                        (
94
                                (
95
                                        tac='1'
96
                                        and
97
                                        (
98
                                                (isTE='1' and dataSecAddr=secAddr)
99
                                                or
100
                                                isTE='0'
101
                                        )
102
                                )
103
                                or
104
                                cwrc='1'
105
                        )
106
                        and
107
                        fifo_ready_to_read='1'
108
                )
109
                or
110
                spa='1';
111
 
112
        process (clk, reset, reset_writer) begin
113
                if reset = '1' or reset_writer = '1' then
114
                        nba <= '0';
115
                        endOf <= '0';
116
                        fifo_read_strobe <= '0';
117
                        tr_by_spa <= '0';
118
                        current_state <= ST_IDLE;
119
                elsif rising_edge(clk) then
120
                        case current_state is
121
                                when ST_IDLE =>
122
                                        if readyToSend then
123
                                                nba <= '1';
124
 
125
                                                tr_by_spa <= spa;
126
 
127
                                                if availableFifoBytesCount="000000000001" and
128
                                                                end_of_stream='1' and spa='0' and tac='1' and
129
                                                                cwrc='0' then
130
                                                        endOf <= '1';
131
                                                end if;
132
 
133
                                                current_state <= ST_WAIT_WNC_1;
134
                                        end if;
135
                                when ST_WAIT_WNC_1 =>
136
                                        if wnc='1' then
137
                                                nba <= '0';
138
 
139
                                                if tr_by_spa='0' then
140
                                                        endOf <= '0';
141
                                                        fifo_read_strobe <= '1';
142
                                                end if;
143
 
144
                                                current_state <= ST_WAIT_WNC_0;
145
                                        end if;
146
                                when ST_WAIT_WNC_0 =>
147
                                        if wnc='0' then
148
                                                if tr_by_spa='0' then
149
                                                        fifo_read_strobe <= '0';
150
                                                end if;
151
 
152
                                                current_state <= ST_IDLE;
153
                                        end if;
154
                                when others =>
155
                                        current_state <= ST_IDLE;
156
                        end case;
157
                end if;
158
        end process;
159
 
160
end arch;
161
 

powered by: WebSVN 2.1.0

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