| 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: helperComponents
|
| 18 |
|
|
-- Date:2011-11-10
|
| 19 |
13 |
Andrewski |
-- Author: Andrzej Paluch
|
| 20 |
3 |
Andrewski |
--
|
| 21 |
|
|
-- Description ${cursor}
|
| 22 |
|
|
--------------------------------------------------------------------------------
|
| 23 |
|
|
library ieee;
|
| 24 |
|
|
use ieee.std_logic_1164.all;
|
| 25 |
|
|
use ieee.std_logic_unsigned.all;
|
| 26 |
|
|
|
| 27 |
|
|
|
| 28 |
|
|
package helperComponents is
|
| 29 |
|
|
|
| 30 |
|
|
component gpibReader is
|
| 31 |
|
|
port (
|
| 32 |
|
|
-- clock
|
| 33 |
|
|
clk : in std_logic;
|
| 34 |
|
|
-- reset
|
| 35 |
|
|
reset : std_logic;
|
| 36 |
|
|
------------------------------------------------------------------------
|
| 37 |
|
|
------ GPIB interface --------------------------------------------------
|
| 38 |
|
|
------------------------------------------------------------------------
|
| 39 |
|
|
-- input data
|
| 40 |
|
|
data_in : in std_logic_vector (7 downto 0);
|
| 41 |
|
|
-- data valid
|
| 42 |
|
|
dvd : in std_logic;
|
| 43 |
|
|
-- listener active
|
| 44 |
|
|
lac : in std_logic;
|
| 45 |
|
|
-- last byte
|
| 46 |
|
|
lsb : in std_logic;
|
| 47 |
|
|
-- ready to next byte
|
| 48 |
|
|
rdy : out std_logic;
|
| 49 |
|
|
------------------------------------------------------------------------
|
| 50 |
|
|
------ external interface ----------------------------------------------
|
| 51 |
|
|
------------------------------------------------------------------------
|
| 52 |
|
|
-- is LE function active
|
| 53 |
|
|
isLE : in std_logic;
|
| 54 |
|
|
-- current secondary address
|
| 55 |
|
|
secAddr : in std_logic_vector (4 downto 0);
|
| 56 |
|
|
-- secondary address of data
|
| 57 |
|
|
dataSecAddr : out std_logic_vector (4 downto 0);
|
| 58 |
|
|
-- buffer ready interrupt
|
| 59 |
|
|
buf_interrupt : out std_logic;
|
| 60 |
|
|
-- indicates end of stream
|
| 61 |
|
|
end_of_stream : out std_logic;
|
| 62 |
|
|
-- resets reader
|
| 63 |
|
|
reset_reader : in std_logic;
|
| 64 |
|
|
------------------ fifo --------------------------------------
|
| 65 |
|
|
-- indicates fifo full
|
| 66 |
|
|
fifo_full : in std_logic;
|
| 67 |
|
|
-- indicates fifo ready to write
|
| 68 |
|
|
fifo_ready_to_write : in std_logic;
|
| 69 |
|
|
-- indicates at least one byte in fifo
|
| 70 |
|
|
at_least_one_byte_in_fifo : in std_logic;
|
| 71 |
|
|
-- output data
|
| 72 |
|
|
data_out : out std_logic_vector (7 downto 0);
|
| 73 |
|
|
-- fifo strobe
|
| 74 |
|
|
fifo_strobe : out std_logic
|
| 75 |
|
|
);
|
| 76 |
|
|
end component;
|
| 77 |
|
|
|
| 78 |
|
|
component gpibWriter is
|
| 79 |
|
|
port (
|
| 80 |
|
|
-- clock
|
| 81 |
|
|
clk : in std_logic;
|
| 82 |
|
|
-- reset
|
| 83 |
|
|
reset : std_logic;
|
| 84 |
|
|
------------------------------------------------------------------------
|
| 85 |
|
|
------ GPIB interface --------------------------------------------------
|
| 86 |
|
|
------------------------------------------------------------------------
|
| 87 |
|
|
-- output data
|
| 88 |
|
|
data_out : out std_logic_vector (7 downto 0);
|
| 89 |
|
|
-- wait for new cycle
|
| 90 |
|
|
wnc : in std_logic;
|
| 91 |
|
|
-- seriall poll active
|
| 92 |
|
|
spa : in std_logic;
|
| 93 |
|
|
-- new byte available
|
| 94 |
|
|
nba : out std_logic;
|
| 95 |
|
|
-- end of string
|
| 96 |
|
|
endOf : out std_logic;
|
| 97 |
|
|
-- talker active
|
| 98 |
|
|
tac : in std_logic;
|
| 99 |
|
|
-- controller write command
|
| 100 |
|
|
cwrc : in std_logic;
|
| 101 |
|
|
------------------------------------------------------------------------
|
| 102 |
|
|
------ external interface ----------------------------------------------
|
| 103 |
|
|
------------------------------------------------------------------------
|
| 104 |
|
|
-- TE is extended
|
| 105 |
|
|
isTE : in std_logic;
|
| 106 |
|
|
-- current secondary address
|
| 107 |
|
|
secAddr : in std_logic_vector (4 downto 0);
|
| 108 |
|
|
-- secondary address of data
|
| 109 |
|
|
dataSecAddr : in std_logic_vector (4 downto 0);
|
| 110 |
|
|
-- buffer consumed
|
| 111 |
|
|
buf_interrupt : out std_logic;
|
| 112 |
|
|
-- indicates end of stream
|
| 113 |
|
|
end_of_stream : in std_logic;
|
| 114 |
|
|
-- resets writer
|
| 115 |
|
|
reset_writer : in std_logic;
|
| 116 |
|
|
-- enables writer
|
| 117 |
|
|
writer_enable : in std_logic;
|
| 118 |
|
|
---------------- fifo ---------------------------
|
| 119 |
|
|
availableFifoBytesCount : in std_logic_vector(10 downto 0);
|
| 120 |
|
|
-- fifo read strobe
|
| 121 |
|
|
fifo_read_strobe : out std_logic;
|
| 122 |
|
|
-- indicates fifo ready to read
|
| 123 |
|
|
fifo_ready_to_read : in std_logic;
|
| 124 |
|
|
-- input data
|
| 125 |
|
|
fifo_data_in : in std_logic_vector (7 downto 0)
|
| 126 |
|
|
);
|
| 127 |
|
|
end component;
|
| 128 |
|
|
|
| 129 |
|
|
component SerialPollCoordinator is
|
| 130 |
|
|
port (
|
| 131 |
|
|
-- clock
|
| 132 |
|
|
clk : in std_logic;
|
| 133 |
|
|
-- reset
|
| 134 |
|
|
reset : in std_logic;
|
| 135 |
|
|
-- data accepted
|
| 136 |
|
|
DAC : in std_logic;
|
| 137 |
|
|
-- receive status byte
|
| 138 |
|
|
rec_stb : in std_logic;
|
| 139 |
|
|
-- attention in
|
| 140 |
|
|
ATN_in : in std_logic;
|
| 141 |
|
|
-- attention out
|
| 142 |
|
|
ATN_out : out std_logic;
|
| 143 |
|
|
-- output valid in
|
| 144 |
|
|
output_valid_in : in std_logic;
|
| 145 |
|
|
-- output valid out
|
| 146 |
|
|
output_valid_out : out std_logic;
|
| 147 |
|
|
-- stb received
|
| 148 |
|
|
stb_received : out std_logic
|
| 149 |
|
|
);
|
| 150 |
|
|
end component;
|
| 151 |
|
|
|
| 152 |
|
|
component MemoryBlock is
|
| 153 |
|
|
port (
|
| 154 |
|
|
reset : in std_logic;
|
| 155 |
|
|
clk : in std_logic;
|
| 156 |
|
|
-------------------------------------------------
|
| 157 |
|
|
p1_addr : in std_logic_vector(10 downto 0);
|
| 158 |
|
|
p1_data_in : in std_logic_vector(7 downto 0);
|
| 159 |
|
|
p1_strobe : in std_logic;
|
| 160 |
|
|
p1_data_out : out std_logic_vector(7 downto 0);
|
| 161 |
|
|
-------------------------------------------------
|
| 162 |
|
|
p2_addr : in std_logic_vector(10 downto 0);
|
| 163 |
|
|
p2_data_in : in std_logic_vector(7 downto 0);
|
| 164 |
|
|
p2_strobe : in std_logic;
|
| 165 |
|
|
p2_data_out : out std_logic_vector(7 downto 0)
|
| 166 |
|
|
);
|
| 167 |
|
|
end component;
|
| 168 |
|
|
|
| 169 |
|
|
component Fifo8b is
|
| 170 |
|
|
generic (
|
| 171 |
|
|
MAX_ADDR_BIT_NUM : integer := 10
|
| 172 |
|
|
);
|
| 173 |
|
|
port (
|
| 174 |
|
|
reset : in std_logic;
|
| 175 |
|
|
clk : in std_logic;
|
| 176 |
|
|
-------------- fifo --------------------
|
| 177 |
|
|
bytesAvailable : out std_logic;
|
| 178 |
|
|
availableBytesCount : out std_logic_vector(MAX_ADDR_BIT_NUM downto 0);
|
| 179 |
|
|
bufferFull : out std_logic;
|
| 180 |
|
|
resetFifo : in std_logic;
|
| 181 |
|
|
----------------------------------------
|
| 182 |
|
|
data_in : in std_logic_vector(7 downto 0);
|
| 183 |
|
|
ready_to_write :out std_logic;
|
| 184 |
|
|
strobe_write : in std_logic;
|
| 185 |
|
|
----------------------------------------
|
| 186 |
|
|
data_out : out std_logic_vector(7 downto 0);
|
| 187 |
|
|
ready_to_read : out std_logic;
|
| 188 |
|
|
strobe_read : in std_logic
|
| 189 |
|
|
);
|
| 190 |
|
|
end component;
|
| 191 |
|
|
|
| 192 |
|
|
component Clk2x is
|
| 193 |
|
|
port (
|
| 194 |
|
|
reset: in std_logic;
|
| 195 |
|
|
clk : in std_logic;
|
| 196 |
|
|
clk2x : out std_logic
|
| 197 |
|
|
);
|
| 198 |
|
|
end component;
|
| 199 |
|
|
|
| 200 |
|
|
component SinglePulseGenerator is
|
| 201 |
|
|
generic (
|
| 202 |
|
|
WIDTH : integer := 3
|
| 203 |
|
|
);
|
| 204 |
|
|
|
| 205 |
|
|
port (
|
| 206 |
|
|
reset : in std_logic;
|
| 207 |
|
|
clk : in std_logic;
|
| 208 |
|
|
t_in: in std_logic;
|
| 209 |
|
|
t_out : out std_logic;
|
| 210 |
|
|
pulse : out std_logic
|
| 211 |
|
|
);
|
| 212 |
|
|
end component;
|
| 213 |
|
|
|
| 214 |
|
|
component EdgeDetector is
|
| 215 |
|
|
generic (
|
| 216 |
|
|
RISING : std_logic := '1';
|
| 217 |
|
|
FALLING : std_logic := '0';
|
| 218 |
|
|
PULSE_WIDTH : integer := 10
|
| 219 |
|
|
);
|
| 220 |
|
|
|
| 221 |
|
|
port (
|
| 222 |
|
|
reset : in std_logic;
|
| 223 |
|
|
clk : in std_logic;
|
| 224 |
|
|
in_data : in std_logic;
|
| 225 |
|
|
pulse : out std_logic
|
| 226 |
|
|
);
|
| 227 |
|
|
end component;
|
| 228 |
|
|
|
| 229 |
|
|
component EventMem is
|
| 230 |
|
|
port (
|
| 231 |
|
|
reset : std_logic;
|
| 232 |
|
|
-- event occured
|
| 233 |
|
|
occured : in std_logic;
|
| 234 |
|
|
-- event approved
|
| 235 |
|
|
approved : in std_logic;
|
| 236 |
|
|
-- output
|
| 237 |
|
|
output : out std_logic
|
| 238 |
|
|
);
|
| 239 |
|
|
end component;
|
| 240 |
|
|
|
| 241 |
|
|
component GpibSynchronizer is
|
| 242 |
|
|
port (
|
| 243 |
|
|
-- clk
|
| 244 |
|
|
clk : std_logic;
|
| 245 |
|
|
-- DIO
|
| 246 |
|
|
DI : in std_logic_vector (7 downto 0);
|
| 247 |
|
|
DO : out std_logic_vector (7 downto 0);
|
| 248 |
|
|
-- attention
|
| 249 |
|
|
ATN_in : in std_logic;
|
| 250 |
|
|
ATN_out : out std_logic;
|
| 251 |
|
|
-- data valid
|
| 252 |
|
|
DAV_in : in std_logic;
|
| 253 |
|
|
DAV_out : out std_logic;
|
| 254 |
|
|
-- not ready for data
|
| 255 |
|
|
NRFD_in : in std_logic;
|
| 256 |
|
|
NRFD_out : out std_logic;
|
| 257 |
|
|
-- no data accepted
|
| 258 |
|
|
NDAC_in : in std_logic;
|
| 259 |
|
|
NDAC_out : out std_logic;
|
| 260 |
|
|
-- end or identify
|
| 261 |
|
|
EOI_in : in std_logic;
|
| 262 |
|
|
EOI_out : out std_logic;
|
| 263 |
|
|
-- service request
|
| 264 |
|
|
SRQ_in : in std_logic;
|
| 265 |
|
|
SRQ_out : out std_logic;
|
| 266 |
|
|
-- interface clear
|
| 267 |
|
|
IFC_in : in std_logic;
|
| 268 |
|
|
IFC_out : out std_logic;
|
| 269 |
|
|
-- remote enable
|
| 270 |
|
|
REN_in : in std_logic;
|
| 271 |
|
|
REN_out : out std_logic
|
| 272 |
|
|
);
|
| 273 |
|
|
end component;
|
| 274 |
|
|
|
| 275 |
|
|
end helperComponents;
|
| 276 |
|
|
|