--------------------------------------------------------------------------------
|
--------------------------------------------------------------------------------
|
|
--This file is part of fpga_gpib_controller.
|
|
--
|
|
-- Fpga_gpib_controller is free software: you can redistribute it and/or modify
|
|
-- it under the terms of the GNU General Public License as published by
|
|
-- the Free Software Foundation, either version 3 of the License, or
|
|
-- (at your option) any later version.
|
|
--
|
|
-- Fpga_gpib_controller is distributed in the hope that it will be useful,
|
|
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
-- GNU General Public License for more details.
|
|
|
|
-- You should have received a copy of the GNU General Public License
|
|
-- along with Fpga_gpib_controller. If not, see <http://www.gnu.org/licenses/>.
|
|
--------------------------------------------------------------------------------
|
-- Entity: helperComponents
|
-- Entity: helperComponents
|
-- Date:2011-11-10
|
-- Date:2011-11-10
|
-- Author: Administrator
|
-- Author: Andrzej Paluch
|
--
|
--
|
-- Description ${cursor}
|
-- Description ${cursor}
|
--------------------------------------------------------------------------------
|
--------------------------------------------------------------------------------
|
library ieee;
|
library ieee;
|
use ieee.std_logic_1164.all;
|
use ieee.std_logic_1164.all;
|
use ieee.std_logic_unsigned.all;
|
use ieee.std_logic_unsigned.all;
|
|
|
|
|
package helperComponents is
|
package helperComponents is
|
|
|
component gpibReader is
|
component gpibReader is
|
port (
|
port (
|
-- clock
|
-- clock
|
clk : in std_logic;
|
clk : in std_logic;
|
-- reset
|
-- reset
|
reset : std_logic;
|
reset : std_logic;
|
------------------------------------------------------------------------
|
------------------------------------------------------------------------
|
------ GPIB interface --------------------------------------------------
|
------ GPIB interface --------------------------------------------------
|
------------------------------------------------------------------------
|
------------------------------------------------------------------------
|
-- input data
|
-- input data
|
data_in : in std_logic_vector (7 downto 0);
|
data_in : in std_logic_vector (7 downto 0);
|
-- data valid
|
-- data valid
|
dvd : in std_logic;
|
dvd : in std_logic;
|
-- listener active
|
-- listener active
|
lac : in std_logic;
|
lac : in std_logic;
|
-- last byte
|
-- last byte
|
lsb : in std_logic;
|
lsb : in std_logic;
|
-- ready to next byte
|
-- ready to next byte
|
rdy : out std_logic;
|
rdy : out std_logic;
|
------------------------------------------------------------------------
|
------------------------------------------------------------------------
|
------ external interface ----------------------------------------------
|
------ external interface ----------------------------------------------
|
------------------------------------------------------------------------
|
------------------------------------------------------------------------
|
-- is LE function active
|
-- is LE function active
|
isLE : in std_logic;
|
isLE : in std_logic;
|
-- current secondary address
|
-- current secondary address
|
secAddr : in std_logic_vector (4 downto 0);
|
secAddr : in std_logic_vector (4 downto 0);
|
-- secondary address of data
|
-- secondary address of data
|
dataSecAddr : out std_logic_vector (4 downto 0);
|
dataSecAddr : out std_logic_vector (4 downto 0);
|
-- buffer ready interrupt
|
-- buffer ready interrupt
|
buf_interrupt : out std_logic;
|
buf_interrupt : out std_logic;
|
-- indicates end of stream
|
-- indicates end of stream
|
end_of_stream : out std_logic;
|
end_of_stream : out std_logic;
|
-- resets reader
|
-- resets reader
|
reset_reader : in std_logic;
|
reset_reader : in std_logic;
|
------------------ fifo --------------------------------------
|
------------------ fifo --------------------------------------
|
-- indicates fifo full
|
-- indicates fifo full
|
fifo_full : in std_logic;
|
fifo_full : in std_logic;
|
-- indicates fifo ready to write
|
-- indicates fifo ready to write
|
fifo_ready_to_write : in std_logic;
|
fifo_ready_to_write : in std_logic;
|
-- indicates at least one byte in fifo
|
-- indicates at least one byte in fifo
|
at_least_one_byte_in_fifo : in std_logic;
|
at_least_one_byte_in_fifo : in std_logic;
|
-- output data
|
-- output data
|
data_out : out std_logic_vector (7 downto 0);
|
data_out : out std_logic_vector (7 downto 0);
|
-- fifo strobe
|
-- fifo strobe
|
fifo_strobe : out std_logic
|
fifo_strobe : out std_logic
|
);
|
);
|
end component;
|
end component;
|
|
|
component gpibWriter is
|
component gpibWriter is
|
port (
|
port (
|
-- clock
|
-- clock
|
clk : in std_logic;
|
clk : in std_logic;
|
-- reset
|
-- reset
|
reset : std_logic;
|
reset : std_logic;
|
------------------------------------------------------------------------
|
------------------------------------------------------------------------
|
------ GPIB interface --------------------------------------------------
|
------ GPIB interface --------------------------------------------------
|
------------------------------------------------------------------------
|
------------------------------------------------------------------------
|
-- output data
|
-- output data
|
data_out : out std_logic_vector (7 downto 0);
|
data_out : out std_logic_vector (7 downto 0);
|
-- wait for new cycle
|
-- wait for new cycle
|
wnc : in std_logic;
|
wnc : in std_logic;
|
-- seriall poll active
|
-- seriall poll active
|
spa : in std_logic;
|
spa : in std_logic;
|
-- new byte available
|
-- new byte available
|
nba : out std_logic;
|
nba : out std_logic;
|
-- end of string
|
-- end of string
|
endOf : out std_logic;
|
endOf : out std_logic;
|
-- talker active
|
-- talker active
|
tac : in std_logic;
|
tac : in std_logic;
|
-- controller write command
|
-- controller write command
|
cwrc : in std_logic;
|
cwrc : in std_logic;
|
------------------------------------------------------------------------
|
------------------------------------------------------------------------
|
------ external interface ----------------------------------------------
|
------ external interface ----------------------------------------------
|
------------------------------------------------------------------------
|
------------------------------------------------------------------------
|
-- TE is extended
|
-- TE is extended
|
isTE : in std_logic;
|
isTE : in std_logic;
|
-- current secondary address
|
-- current secondary address
|
secAddr : in std_logic_vector (4 downto 0);
|
secAddr : in std_logic_vector (4 downto 0);
|
-- secondary address of data
|
-- secondary address of data
|
dataSecAddr : in std_logic_vector (4 downto 0);
|
dataSecAddr : in std_logic_vector (4 downto 0);
|
-- buffer consumed
|
-- buffer consumed
|
buf_interrupt : out std_logic;
|
buf_interrupt : out std_logic;
|
-- indicates end of stream
|
-- indicates end of stream
|
end_of_stream : in std_logic;
|
end_of_stream : in std_logic;
|
-- resets writer
|
-- resets writer
|
reset_writer : in std_logic;
|
reset_writer : in std_logic;
|
-- enables writer
|
-- enables writer
|
writer_enable : in std_logic;
|
writer_enable : in std_logic;
|
---------------- fifo ---------------------------
|
---------------- fifo ---------------------------
|
availableFifoBytesCount : in std_logic_vector(10 downto 0);
|
availableFifoBytesCount : in std_logic_vector(10 downto 0);
|
-- fifo read strobe
|
-- fifo read strobe
|
fifo_read_strobe : out std_logic;
|
fifo_read_strobe : out std_logic;
|
-- indicates fifo ready to read
|
-- indicates fifo ready to read
|
fifo_ready_to_read : in std_logic;
|
fifo_ready_to_read : in std_logic;
|
-- input data
|
-- input data
|
fifo_data_in : in std_logic_vector (7 downto 0)
|
fifo_data_in : in std_logic_vector (7 downto 0)
|
);
|
);
|
end component;
|
end component;
|
|
|
component SerialPollCoordinator is
|
component SerialPollCoordinator is
|
port (
|
port (
|
-- clock
|
-- clock
|
clk : in std_logic;
|
clk : in std_logic;
|
-- reset
|
-- reset
|
reset : in std_logic;
|
reset : in std_logic;
|
-- data accepted
|
-- data accepted
|
DAC : in std_logic;
|
DAC : in std_logic;
|
-- receive status byte
|
-- receive status byte
|
rec_stb : in std_logic;
|
rec_stb : in std_logic;
|
-- attention in
|
-- attention in
|
ATN_in : in std_logic;
|
ATN_in : in std_logic;
|
-- attention out
|
-- attention out
|
ATN_out : out std_logic;
|
ATN_out : out std_logic;
|
-- output valid in
|
-- output valid in
|
output_valid_in : in std_logic;
|
output_valid_in : in std_logic;
|
-- output valid out
|
-- output valid out
|
output_valid_out : out std_logic;
|
output_valid_out : out std_logic;
|
-- stb received
|
-- stb received
|
stb_received : out std_logic
|
stb_received : out std_logic
|
);
|
);
|
end component;
|
end component;
|
|
|
component MemoryBlock is
|
component MemoryBlock is
|
port (
|
port (
|
reset : in std_logic;
|
reset : in std_logic;
|
clk : in std_logic;
|
clk : in std_logic;
|
-------------------------------------------------
|
-------------------------------------------------
|
p1_addr : in std_logic_vector(10 downto 0);
|
p1_addr : in std_logic_vector(10 downto 0);
|
p1_data_in : in std_logic_vector(7 downto 0);
|
p1_data_in : in std_logic_vector(7 downto 0);
|
p1_strobe : in std_logic;
|
p1_strobe : in std_logic;
|
p1_data_out : out std_logic_vector(7 downto 0);
|
p1_data_out : out std_logic_vector(7 downto 0);
|
-------------------------------------------------
|
-------------------------------------------------
|
p2_addr : in std_logic_vector(10 downto 0);
|
p2_addr : in std_logic_vector(10 downto 0);
|
p2_data_in : in std_logic_vector(7 downto 0);
|
p2_data_in : in std_logic_vector(7 downto 0);
|
p2_strobe : in std_logic;
|
p2_strobe : in std_logic;
|
p2_data_out : out std_logic_vector(7 downto 0)
|
p2_data_out : out std_logic_vector(7 downto 0)
|
);
|
);
|
end component;
|
end component;
|
|
|
component Fifo8b is
|
component Fifo8b is
|
generic (
|
generic (
|
MAX_ADDR_BIT_NUM : integer := 10
|
MAX_ADDR_BIT_NUM : integer := 10
|
);
|
);
|
port (
|
port (
|
reset : in std_logic;
|
reset : in std_logic;
|
clk : in std_logic;
|
clk : in std_logic;
|
-------------- fifo --------------------
|
-------------- fifo --------------------
|
bytesAvailable : out std_logic;
|
bytesAvailable : out std_logic;
|
availableBytesCount : out std_logic_vector(MAX_ADDR_BIT_NUM downto 0);
|
availableBytesCount : out std_logic_vector(MAX_ADDR_BIT_NUM downto 0);
|
bufferFull : out std_logic;
|
bufferFull : out std_logic;
|
resetFifo : in std_logic;
|
resetFifo : in std_logic;
|
----------------------------------------
|
----------------------------------------
|
data_in : in std_logic_vector(7 downto 0);
|
data_in : in std_logic_vector(7 downto 0);
|
ready_to_write :out std_logic;
|
ready_to_write :out std_logic;
|
strobe_write : in std_logic;
|
strobe_write : in std_logic;
|
----------------------------------------
|
----------------------------------------
|
data_out : out std_logic_vector(7 downto 0);
|
data_out : out std_logic_vector(7 downto 0);
|
ready_to_read : out std_logic;
|
ready_to_read : out std_logic;
|
strobe_read : in std_logic
|
strobe_read : in std_logic
|
);
|
);
|
end component;
|
end component;
|
|
|
component Clk2x is
|
component Clk2x is
|
port (
|
port (
|
reset: in std_logic;
|
reset: in std_logic;
|
clk : in std_logic;
|
clk : in std_logic;
|
clk2x : out std_logic
|
clk2x : out std_logic
|
);
|
);
|
end component;
|
end component;
|
|
|
component SinglePulseGenerator is
|
component SinglePulseGenerator is
|
generic (
|
generic (
|
WIDTH : integer := 3
|
WIDTH : integer := 3
|
);
|
);
|
|
|
port (
|
port (
|
reset : in std_logic;
|
reset : in std_logic;
|
clk : in std_logic;
|
clk : in std_logic;
|
t_in: in std_logic;
|
t_in: in std_logic;
|
t_out : out std_logic;
|
t_out : out std_logic;
|
pulse : out std_logic
|
pulse : out std_logic
|
);
|
);
|
end component;
|
end component;
|
|
|
component EdgeDetector is
|
component EdgeDetector is
|
generic (
|
generic (
|
RISING : std_logic := '1';
|
RISING : std_logic := '1';
|
FALLING : std_logic := '0';
|
FALLING : std_logic := '0';
|
PULSE_WIDTH : integer := 10
|
PULSE_WIDTH : integer := 10
|
);
|
);
|
|
|
port (
|
port (
|
reset : in std_logic;
|
reset : in std_logic;
|
clk : in std_logic;
|
clk : in std_logic;
|
in_data : in std_logic;
|
in_data : in std_logic;
|
pulse : out std_logic
|
pulse : out std_logic
|
);
|
);
|
end component;
|
end component;
|
|
|
component EventMem is
|
component EventMem is
|
port (
|
port (
|
reset : std_logic;
|
reset : std_logic;
|
-- event occured
|
-- event occured
|
occured : in std_logic;
|
occured : in std_logic;
|
-- event approved
|
-- event approved
|
approved : in std_logic;
|
approved : in std_logic;
|
-- output
|
-- output
|
output : out std_logic
|
output : out std_logic
|
);
|
);
|
end component;
|
end component;
|
|
|
component GpibSynchronizer is
|
component GpibSynchronizer is
|
port (
|
port (
|
-- clk
|
-- clk
|
clk : std_logic;
|
clk : std_logic;
|
-- DIO
|
-- DIO
|
DI : in std_logic_vector (7 downto 0);
|
DI : in std_logic_vector (7 downto 0);
|
DO : out std_logic_vector (7 downto 0);
|
DO : out std_logic_vector (7 downto 0);
|
-- attention
|
-- attention
|
ATN_in : in std_logic;
|
ATN_in : in std_logic;
|
ATN_out : out std_logic;
|
ATN_out : out std_logic;
|
-- data valid
|
-- data valid
|
DAV_in : in std_logic;
|
DAV_in : in std_logic;
|
DAV_out : out std_logic;
|
DAV_out : out std_logic;
|
-- not ready for data
|
-- not ready for data
|
NRFD_in : in std_logic;
|
NRFD_in : in std_logic;
|
NRFD_out : out std_logic;
|
NRFD_out : out std_logic;
|
-- no data accepted
|
-- no data accepted
|
NDAC_in : in std_logic;
|
NDAC_in : in std_logic;
|
NDAC_out : out std_logic;
|
NDAC_out : out std_logic;
|
-- end or identify
|
-- end or identify
|
EOI_in : in std_logic;
|
EOI_in : in std_logic;
|
EOI_out : out std_logic;
|
EOI_out : out std_logic;
|
-- service request
|
-- service request
|
SRQ_in : in std_logic;
|
SRQ_in : in std_logic;
|
SRQ_out : out std_logic;
|
SRQ_out : out std_logic;
|
-- interface clear
|
-- interface clear
|
IFC_in : in std_logic;
|
IFC_in : in std_logic;
|
IFC_out : out std_logic;
|
IFC_out : out std_logic;
|
-- remote enable
|
-- remote enable
|
REN_in : in std_logic;
|
REN_in : in std_logic;
|
REN_out : out std_logic
|
REN_out : out std_logic
|
);
|
);
|
end component;
|
end component;
|
|
|
end helperComponents;
|
end helperComponents;
|
|
|
|
|