| 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: WriterControlReg0
|
| 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 |
|
|
use work.utilPkg.all;
|
| 28 |
|
|
use work.helperComponents.all;
|
| 29 |
|
|
|
| 30 |
|
|
entity WriterControlReg0 is
|
| 31 |
|
|
port (
|
| 32 |
|
|
clk : in std_logic;
|
| 33 |
|
|
reset : in std_logic;
|
| 34 |
|
|
strobe : in std_logic;
|
| 35 |
|
|
data_in : in std_logic_vector (15 downto 0);
|
| 36 |
|
|
data_out : out std_logic_vector (15 downto 0);
|
| 37 |
|
|
------------------- gpib -------------------------
|
| 38 |
|
|
-- buffer consumed
|
| 39 |
|
|
buf_interrupt : in std_logic;
|
| 40 |
|
|
-- data avilable - at least one byte in buffer
|
| 41 |
|
|
data_available : out std_logic;
|
| 42 |
|
|
-- indicates end of stream
|
| 43 |
|
|
end_of_stream : out std_logic;
|
| 44 |
|
|
-- resets buffer
|
| 45 |
|
|
reset_buffer : out std_logic;
|
| 46 |
|
|
-- secondary address of data
|
| 47 |
|
|
dataSecAddr : out std_logic_vector (4 downto 0);
|
| 48 |
|
|
-- serial poll status byte
|
| 49 |
|
|
status_byte : out std_logic_vector (6 downto 0)
|
| 50 |
|
|
);
|
| 51 |
|
|
end WriterControlReg0;
|
| 52 |
|
|
|
| 53 |
|
|
architecture arch of WriterControlReg0 is
|
| 54 |
|
|
|
| 55 |
|
|
signal i_data_available : std_logic;
|
| 56 |
|
|
signal i_end_of_stream : std_logic;
|
| 57 |
|
|
signal i_reset_buffer : std_logic;
|
| 58 |
|
|
signal i_dataSecAddr : std_logic_vector (4 downto 0);
|
| 59 |
|
|
signal i_status_byte : std_logic_vector (6 downto 0);
|
| 60 |
|
|
|
| 61 |
|
|
signal t_in, t_out : std_logic;
|
| 62 |
|
|
|
| 63 |
|
|
begin
|
| 64 |
|
|
|
| 65 |
|
|
data_out(0) <= buf_interrupt;
|
| 66 |
|
|
data_out(1) <= i_data_available;
|
| 67 |
|
|
data_out(2) <= i_end_of_stream;
|
| 68 |
|
|
data_out(3) <= i_reset_buffer;
|
| 69 |
|
|
data_out(8 downto 4) <= i_dataSecAddr;
|
| 70 |
|
|
data_out(15 downto 9) <= i_status_byte;
|
| 71 |
|
|
|
| 72 |
|
|
data_available <= i_data_available;
|
| 73 |
|
|
end_of_stream <= i_end_of_stream;
|
| 74 |
|
|
reset_buffer <= i_reset_buffer;
|
| 75 |
|
|
dataSecAddr <= i_dataSecAddr;
|
| 76 |
|
|
status_byte <= i_status_byte;
|
| 77 |
|
|
|
| 78 |
|
|
process (reset, strobe) begin
|
| 79 |
|
|
if reset = '1' then
|
| 80 |
|
|
t_in <= '0';
|
| 81 |
|
|
i_data_available <= '1';
|
| 82 |
|
|
elsif rising_edge(strobe) then
|
| 83 |
|
|
|
| 84 |
|
|
i_data_available <= data_in(1);
|
| 85 |
|
|
i_end_of_stream <= data_in(2);
|
| 86 |
|
|
|
| 87 |
|
|
if data_in(3) = '1' then
|
| 88 |
|
|
t_in <= not t_out;
|
| 89 |
|
|
end if;
|
| 90 |
|
|
|
| 91 |
|
|
i_dataSecAddr <= data_in(8 downto 4);
|
| 92 |
|
|
i_status_byte <= data_in(15 downto 9);
|
| 93 |
|
|
|
| 94 |
|
|
end if;
|
| 95 |
|
|
end process;
|
| 96 |
|
|
|
| 97 |
|
|
spg: SinglePulseGenerator generic map (WIDTH => 3) port map(
|
| 98 |
|
|
reset => reset, clk => clk,
|
| 99 |
|
|
t_in => t_in, t_out => t_out,
|
| 100 |
|
|
pulse => i_reset_buffer
|
| 101 |
|
|
);
|
| 102 |
|
|
|
| 103 |
|
|
end arch;
|
| 104 |
|
|
|