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

Subversion Repositories gpib_controller

[/] [gpib_controller/] [trunk/] [vhdl/] [src/] [gpib_helper/] [gpibReader.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
-- Entity: gpibReader
3
-- Date: 2011-10-30  
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 gpibReader is
15
        port (
16
                -- clock
17
                clk : in std_logic;
18
                -- reset
19
                reset : std_logic;
20
                ------------------------------------------------------------------------
21
                ------ GPIB interface --------------------------------------------------
22
                ------------------------------------------------------------------------
23
                -- input data
24
                data_in : in std_logic_vector (7 downto 0);
25
                -- data valid
26
                dvd : in std_logic;
27
                -- listener active
28
                lac : in std_logic;
29
                -- last byte
30
                lsb : in std_logic;
31
                -- ready to next byte
32
                rdy : out std_logic;
33
                ------------------------------------------------------------------------
34
                ------ external interface ----------------------------------------------
35
                ------------------------------------------------------------------------
36
                -- is LE function active
37
                isLE : in std_logic;
38
                -- current secondary address
39
                secAddr : in std_logic_vector (4 downto 0);
40
                -- secondary address of data
41
                dataSecAddr : out std_logic_vector (4 downto 0);
42
                -- buffer ready interrupt
43
                buf_interrupt : out std_logic;
44
                -- indicates end of stream
45
                end_of_stream : out std_logic;
46
                -- resets reader
47
                reset_reader : in std_logic;
48
                ------------------ fifo --------------------------------------
49
                -- indicates fifo full
50
                fifo_full : in std_logic;
51
                -- indicates fifo ready to write
52
                fifo_ready_to_write : in std_logic;
53
                -- indicates at least one byte in fifo
54
                at_least_one_byte_in_fifo : in std_logic;
55
                -- output data
56
                data_out : out std_logic_vector (7 downto 0);
57
                -- fifo strobe
58
                fifo_strobe : out std_logic
59
        );
60
end gpibReader;
61
 
62
architecture arch of gpibReader is
63
 
64
        -- reader states
65
        type READER_STATE is (
66
                ST_IDLE,
67
                ST_WAIT_DVD_1,
68
                ST_WAIT_DVD_0
69
        );
70
 
71
        signal current_state : READER_STATE;
72
        signal buf_ready_to_write : boolean;
73
 
74
begin
75
 
76
        buf_interrupt <= not to_stdl(buf_ready_to_write);
77
 
78
 
79
        process (clk, reset, reset_reader) begin
80
                if reset = '1' then
81
                        current_state <= ST_IDLE;
82
                        rdy <= '1';
83
                        buf_ready_to_write <= TRUE;
84
                        end_of_stream <= '0';
85
                        fifo_strobe <= '0';
86
                        dataSecAddr <= "00000";
87
                elsif reset_reader='1' then
88
                        buf_ready_to_write <= TRUE;
89
                        end_of_stream <= '0';
90
                        fifo_strobe <= '0';
91
                        dataSecAddr <= "00000";
92
                elsif rising_edge(clk) then
93
                        case current_state is
94
                                when ST_IDLE =>
95
                                        if lac='1' and buf_ready_to_write then
96
 
97
                                                if isLE = '1' then
98
                                                        dataSecAddr <= secAddr;
99
                                                end if;
100
 
101
                                                rdy <= '1';
102
                                                current_state <= ST_WAIT_DVD_1;
103
                                        elsif lac='0' and at_least_one_byte_in_fifo='1' then
104
                                                buf_ready_to_write <= FALSE;
105
                                        end if;
106
                                when ST_WAIT_DVD_1 =>
107
                                        if dvd='1' and fifo_ready_to_write='1' then
108
                                                fifo_strobe <= '1';
109
 
110
                                                data_out <= data_in;
111
 
112
                                                if lsb='1'or fifo_full='1' then
113
                                                        buf_ready_to_write <= FALSE;
114
                                                        end_of_stream <= lsb;
115
                                                end if;
116
 
117
                                                rdy <= '0';
118
                                                current_state <= ST_WAIT_DVD_0;
119
                                        elsif lac='0' then
120
                                                current_state <= ST_IDLE;
121
                                        end if;
122
                                when ST_WAIT_DVD_0 =>
123
                                        if dvd='0' then
124
                                                fifo_strobe <= '0';
125
                                                current_state <= ST_IDLE;
126
                                        end if;
127
                                when others =>
128
                                        current_state <= ST_IDLE;
129
                        end case;
130
                end if;
131
        end process;
132
 
133
end arch;
134
 

powered by: WebSVN 2.1.0

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