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

Subversion Repositories gpib_controller

[/] [gpib_controller/] [trunk/] [prototype_1/] [fpga/] [xilinx_prj/] [src/] [main.vhd] - Diff between revs 5 and 11

Only display areas with differences | Details | Blame | View Log

Rev 5 Rev 11
 
--------------------------------------------------------------------------------
 
--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/>.
----------------------------------------------------------------------------------
----------------------------------------------------------------------------------
-- Company: 
-- Author: Andrzej Paluch
-- Engineer: 
 
-- 
-- 
-- Create Date:    22:17:28 01/24/2012 
-- Create Date:    22:17:28 01/24/2012 
-- Design Name: 
-- Design Name: 
-- Module Name:    main - Behavioral 
-- Module Name:    main - Behavioral 
-- Project Name: 
-- Project Name: 
-- Target Devices: 
-- Target Devices: 
-- Tool versions: 
-- Tool versions: 
-- Description: 
-- Description: 
--
--
-- Dependencies: 
-- Dependencies: 
--
--
-- Revision: 
-- Revision: 
-- Revision 0.01 - File Created
-- Revision 0.01 - File Created
-- Additional Comments: 
-- Additional Comments: 
--
--
----------------------------------------------------------------------------------
----------------------------------------------------------------------------------
library IEEE;
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
use IEEE.STD_LOGIC_1164.ALL;
use IEEE.STD_LOGIC_ARITH.ALL;
use IEEE.STD_LOGIC_ARITH.ALL;
use IEEE.STD_LOGIC_UNSIGNED.ALL;
use IEEE.STD_LOGIC_UNSIGNED.ALL;
 
 
-- Uncomment the following library declaration if using
-- Uncomment the following library declaration if using
-- arithmetic functions with Signed or Unsigned values
-- arithmetic functions with Signed or Unsigned values
--use IEEE.NUMERIC_STD.ALL;
--use IEEE.NUMERIC_STD.ALL;
 
 
-- Uncomment the following library declaration if instantiating
-- Uncomment the following library declaration if instantiating
-- any Xilinx primitives in this code.
-- any Xilinx primitives in this code.
--library UNISIM;
--library UNISIM;
--use UNISIM.VComponents.all;
--use UNISIM.VComponents.all;
 
 
use work.communication.ALL;
use work.communication.ALL;
use work.wrapperComponents.ALL;
use work.wrapperComponents.ALL;
use work.helperComponents.ALL;
use work.helperComponents.ALL;
 
 
 
 
entity main is
entity main is
        port(
        port(
                --reset : in std_logic;
                --reset : in std_logic;
                clk : in std_logic;
                clk : in std_logic;
 
 
                ------ UART ---------
                ------ UART ---------
                RX : in std_logic;
                RX : in std_logic;
                TX : out std_logic;
                TX : out std_logic;
 
 
                ------ GPIB ---------
                ------ GPIB ---------
                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);
                ATN_in : in std_logic;
                ATN_in : in std_logic;
                ATN_out : out std_logic;
                ATN_out : out std_logic;
                DAV_in : in std_logic;
                DAV_in : in std_logic;
                DAV_out : out std_logic;
                DAV_out : out std_logic;
                NRFD_in : in std_logic;
                NRFD_in : in std_logic;
                NRFD_out : out std_logic;
                NRFD_out : out std_logic;
                NDAC_in : in std_logic;
                NDAC_in : in std_logic;
                NDAC_out : out std_logic;
                NDAC_out : out std_logic;
                EOI_in : in std_logic;
                EOI_in : in std_logic;
                EOI_out : out std_logic;
                EOI_out : out std_logic;
                SRQ_in : in std_logic;
                SRQ_in : in std_logic;
                SRQ_out : out std_logic;
                SRQ_out : out std_logic;
                IFC_in : in std_logic;
                IFC_in : in std_logic;
                IFC_out : out std_logic;
                IFC_out : out std_logic;
                REN_in : in std_logic;
                REN_in : in std_logic;
                REN_out : out std_logic;
                REN_out : out std_logic;
 
 
                ------ LEDS ---------
                ------ LEDS ---------
                led1 : out std_logic;
                led1 : out std_logic;
                led2 : out std_logic
                led2 : out std_logic
                ------ DEBUG --------
                ------ DEBUG --------
                ;debug1 : out std_logic
                ;debug1 : out std_logic
                ;debug2 : out std_logic
                ;debug2 : out std_logic
        );
        );
end main;
end main;
 
 
architecture Behavioral of main is
architecture Behavioral of main is
 
 
        constant BUF_LEN_MAX_BIT_NUM : integer := 11;
        constant BUF_LEN_MAX_BIT_NUM : integer := 11;
 
 
        type UART_REC_STATES is (
        type UART_REC_STATES is (
                ST_UART_REC_READ_ADDR,
                ST_UART_REC_READ_ADDR,
                ST_UART_REC_READ_B1,
                ST_UART_REC_READ_B1,
                ST_UART_REC_READ_B2,
                ST_UART_REC_READ_B2,
 
 
                ST_UART_REC_READ_BURST_W_LEN_B1,
                ST_UART_REC_READ_BURST_W_LEN_B1,
                ST_UART_REC_READ_BURST_W_LEN_B2,
                ST_UART_REC_READ_BURST_W_LEN_B2,
 
 
                ST_UART_REC_BURST_READ
                ST_UART_REC_BURST_READ
        );
        );
 
 
        type UART_TR_STATES is (
        type UART_TR_STATES is (
                ST_UART_TR_IDLE,
                ST_UART_TR_IDLE,
                ST_UART_TR_WAIT_NOT_READY_TO_SEND_1,
                ST_UART_TR_WAIT_NOT_READY_TO_SEND_1,
                ST_UART_TR_WRITE_B1,
                ST_UART_TR_WRITE_B1,
                ST_UART_TR_WAIT_NOT_READY_TO_SEND_2,
                ST_UART_TR_WAIT_NOT_READY_TO_SEND_2,
                ST_UART_TR_WRITE_B2,
                ST_UART_TR_WRITE_B2,
 
 
                ST_UART_TR_WRITE_BURST,
                ST_UART_TR_WRITE_BURST,
                ST_UART_TR_WAIT_BURST_NOT_READY_TO_SEND,
                ST_UART_TR_WAIT_BURST_NOT_READY_TO_SEND,
                ST_UART_TR_WAIT_BURST_READY_TO_SEND
                ST_UART_TR_WAIT_BURST_READY_TO_SEND
        );
        );
 
 
        ---------- global -------------
        ---------- global -------------
        signal reset : std_logic;
        signal reset : std_logic;
        signal reset_timer : integer range 0 to 50000000;
        signal reset_timer : integer range 0 to 50000000;
 
 
        ---------- UART ---------------
        ---------- UART ---------------
        signal uart_reset, uart_clk, uart_RX, uart_TX, uart_data_out_ready,
        signal uart_reset, uart_clk, uart_RX, uart_TX, uart_data_out_ready,
                uart_data_in_ready, uart_ready_to_send : std_logic;
                uart_data_in_ready, uart_ready_to_send : std_logic;
        signal uart_data_out, uart_data_in : std_logic_vector(7 downto 0);
        signal uart_data_out, uart_data_in : std_logic_vector(7 downto 0);
 
 
        ---------- GPIB ------------------------
        ---------- GPIB ------------------------
        signal gpib_reset, gpib_clk : std_logic;
        signal gpib_reset, gpib_clk : std_logic;
        ---------- GPIB interface signals ------
        ---------- GPIB interface signals ------
        signal gpib_DI, gpib_DO : std_logic_vector (7 downto 0);
        signal gpib_DI, gpib_DO : std_logic_vector (7 downto 0);
        signal gpib_output_valid : std_logic;
        signal gpib_output_valid : std_logic;
        signal gpib_ATN_in, gpib_ATN_out, gpib_DAV_in, gpib_DAV_out, gpib_NRFD_in,
        signal gpib_ATN_in, gpib_ATN_out, gpib_DAV_in, gpib_DAV_out, gpib_NRFD_in,
                gpib_NRFD_out, gpib_NDAC_in, gpib_NDAC_out, gpib_EOI_in, gpib_EOI_out,
                gpib_NRFD_out, gpib_NDAC_in, gpib_NDAC_out, gpib_EOI_in, gpib_EOI_out,
                gpib_SRQ_in, gpib_SRQ_out, gpib_IFC_in, gpib_IFC_out, gpib_REN_in,
                gpib_SRQ_in, gpib_SRQ_out, gpib_IFC_in, gpib_IFC_out, gpib_REN_in,
                gpib_REN_out : std_logic;
                gpib_REN_out : std_logic;
        ---------- registers access -------------
        ---------- registers access -------------
        signal gpib_data_in, gpib_data_out : std_logic_vector(15 downto 0);
        signal gpib_data_in, gpib_data_out : std_logic_vector(15 downto 0);
        signal gpib_reg_addr : std_logic_vector(14 downto 0);
        signal gpib_reg_addr : std_logic_vector(14 downto 0);
        signal gpib_strobe_read, gpib_strobe_write : std_logic;
        signal gpib_strobe_read, gpib_strobe_write : std_logic;
 
 
        ----------- writer strobe pulse generator
        ----------- writer strobe pulse generator
        signal t_in_strobe_write, t_out_strobe_write : std_logic;
        signal t_in_strobe_write, t_out_strobe_write : std_logic;
        ----------- reader strobe pulse generator
        ----------- reader strobe pulse generator
        signal t_in_strobe_read, t_out_strobe_read : std_logic;
        signal t_in_strobe_read, t_out_strobe_read : std_logic;
 
 
        ---------- interrupt line ---------------
        ---------- interrupt line ---------------
        signal gpib_interrupt_line : std_logic;
        signal gpib_interrupt_line : std_logic;
 
 
        ---------- UART transceiver -------------
        ---------- UART transceiver -------------
        signal uart_rec_state : UART_REC_STATES;
        signal uart_rec_state : UART_REC_STATES;
        signal uart_strobe_write_s1, uart_strobe_write_s2 : std_logic;
        signal uart_strobe_write_s1, uart_strobe_write_s2 : std_logic;
        signal uart_tr_state : UART_TR_STATES;
        signal uart_tr_state : UART_TR_STATES;
 
 
        signal burstLen : std_logic_vector (BUF_LEN_MAX_BIT_NUM downto 0);
        signal burstLen : std_logic_vector (BUF_LEN_MAX_BIT_NUM downto 0);
        signal isBurstRead : std_logic;
        signal isBurstRead : std_logic;
        signal subscribeBurstRead_1, subscribeBurstRead_2 : std_logic;
        signal subscribeBurstRead_1, subscribeBurstRead_2 : std_logic;
        signal currentBurstReadLen : integer range 0 to 2**BUF_LEN_MAX_BIT_NUM;
        signal currentBurstReadLen : integer range 0 to 2**BUF_LEN_MAX_BIT_NUM;
 
 
        -- GPIB synchronizer
        -- GPIB synchronizer
        signal gSync_clk : std_logic;
        signal gSync_clk : std_logic;
        signal gSync_DI : std_logic_vector(7 downto 0);
        signal gSync_DI : std_logic_vector(7 downto 0);
        signal gSync_DO : std_logic_vector(7 downto 0);
        signal gSync_DO : std_logic_vector(7 downto 0);
        signal gSync_ATN_in : std_logic;
        signal gSync_ATN_in : std_logic;
        signal gSync_ATN_Out : std_logic;
        signal gSync_ATN_Out : std_logic;
        signal gSync_DAV_in : std_logic;
        signal gSync_DAV_in : std_logic;
        signal gSync_DAV_out : std_logic;
        signal gSync_DAV_out : std_logic;
        signal gSync_NRFD_in : std_logic;
        signal gSync_NRFD_in : std_logic;
        signal gSync_NRFD_out : std_logic;
        signal gSync_NRFD_out : std_logic;
        signal gSync_NDAC_in : std_logic;
        signal gSync_NDAC_in : std_logic;
        signal gSync_NDAC_out : std_logic;
        signal gSync_NDAC_out : std_logic;
        signal gSync_EOI_in : std_logic;
        signal gSync_EOI_in : std_logic;
        signal gSync_EOI_out : std_logic;
        signal gSync_EOI_out : std_logic;
        signal gSync_SRQ_in : std_logic;
        signal gSync_SRQ_in : std_logic;
        signal gSync_SRQ_out : std_logic;
        signal gSync_SRQ_out : std_logic;
        signal gSync_IFC_in : std_logic;
        signal gSync_IFC_in : std_logic;
        signal gSync_IFC_out : std_logic;
        signal gSync_IFC_out : std_logic;
        signal gSync_REN_in : std_logic;
        signal gSync_REN_in : std_logic;
        signal gSync_REN_out : std_logic;
        signal gSync_REN_out : std_logic;
 
 
begin
begin
 
 
        -- UART
        -- UART
        uart_reset <= reset;
        uart_reset <= reset;
        uart_clk <= clk;
        uart_clk <= clk;
        uart_RX <= RX;
        uart_RX <= RX;
        TX <= uart_TX;
        TX <= uart_TX;
 
 
        -- GPIB sync
        -- GPIB sync
        gSync_clk <= clk;
        gSync_clk <= clk;
        gSync_DI <= DI;
        gSync_DI <= DI;
        gSync_ATN_in <= ATN_in;
        gSync_ATN_in <= ATN_in;
        gSync_DAV_in <= DAV_in;
        gSync_DAV_in <= DAV_in;
        gSync_NRFD_in <= NRFD_in;
        gSync_NRFD_in <= NRFD_in;
        gSync_NDAC_in <= NDAC_in;
        gSync_NDAC_in <= NDAC_in;
        gSync_EOI_in <= EOI_in;
        gSync_EOI_in <= EOI_in;
        gSync_SRQ_in <= SRQ_in;
        gSync_SRQ_in <= SRQ_in;
        gSync_IFC_in <= IFC_in;
        gSync_IFC_in <= IFC_in;
        gSync_REN_in <= REN_in;
        gSync_REN_in <= REN_in;
 
 
 
 
        -- GPIB
        -- GPIB
        gpib_reset <= reset;
        gpib_reset <= reset;
        gpib_clk <= clk;
        gpib_clk <= clk;
        gpib_DI <= not gSync_DO;
        gpib_DI <= not gSync_DO;
        DO <= gpib_DO when gpib_output_valid = '1' else "00000000";
        DO <= gpib_DO when gpib_output_valid = '1' else "00000000";
        gpib_ATN_in <= not gSync_ATN_Out;
        gpib_ATN_in <= not gSync_ATN_Out;
        ATN_out <= gpib_ATN_out;
        ATN_out <= gpib_ATN_out;
        gpib_DAV_in <= not gSync_DAV_out;
        gpib_DAV_in <= not gSync_DAV_out;
        DAV_out <= gpib_DAV_out;
        DAV_out <= gpib_DAV_out;
        gpib_NRFD_in <= not gSync_NRFD_out;
        gpib_NRFD_in <= not gSync_NRFD_out;
        NRFD_out <= gpib_NRFD_out;
        NRFD_out <= gpib_NRFD_out;
        gpib_NDAC_in <= not gSync_NDAC_out;
        gpib_NDAC_in <= not gSync_NDAC_out;
        NDAC_out <= gpib_NDAC_out;
        NDAC_out <= gpib_NDAC_out;
        gpib_EOI_in <= not gSync_EOI_out;
        gpib_EOI_in <= not gSync_EOI_out;
        EOI_out <= gpib_EOI_out;
        EOI_out <= gpib_EOI_out;
        gpib_SRQ_in <= not gSync_SRQ_out;
        gpib_SRQ_in <= not gSync_SRQ_out;
        SRQ_out <= gpib_SRQ_out;
        SRQ_out <= gpib_SRQ_out;
        gpib_IFC_in <= not gSync_IFC_out;
        gpib_IFC_in <= not gSync_IFC_out;
        IFC_out <= gpib_IFC_out;
        IFC_out <= gpib_IFC_out;
        gpib_REN_in <= not gSync_REN_out;
        gpib_REN_in <= not gSync_REN_out;
        REN_out <= gpib_REN_out;
        REN_out <= gpib_REN_out;
 
 
        -- DEBUG
        -- DEBUG
        --led1 <= reset;
        --led1 <= reset;
        led2 <= uart_data_out_ready;
        led2 <= uart_data_out_ready;
        --debug1 <= gpib_output_valid;
        --debug1 <= gpib_output_valid;
 
 
        ---------- receive from UART -----------
        ---------- receive from UART -----------
        process (reset, uart_data_out_ready, uart_strobe_write_s2) begin
        process (reset, uart_data_out_ready, uart_strobe_write_s2) begin
                if reset = '1' then
                if reset = '1' then
                        uart_strobe_write_s1 <= uart_strobe_write_s2;
                        uart_strobe_write_s1 <= uart_strobe_write_s2;
                        t_in_strobe_write <= '0';
                        t_in_strobe_write <= '0';
 
 
                        subscribeBurstRead_1 <= '0';
                        subscribeBurstRead_1 <= '0';
 
 
                        uart_rec_state <= ST_UART_REC_READ_ADDR;
                        uart_rec_state <= ST_UART_REC_READ_ADDR;
                elsif rising_edge(uart_data_out_ready) then
                elsif rising_edge(uart_data_out_ready) then
                        case uart_rec_state is
                        case uart_rec_state is
                                when ST_UART_REC_READ_ADDR =>
                                when ST_UART_REC_READ_ADDR =>
                                        gpib_reg_addr(14 downto 6) <= "000000000";
                                        gpib_reg_addr(14 downto 6) <= "000000000";
                                        gpib_reg_addr(5 downto 0) <= uart_data_out(5 downto 0);
                                        gpib_reg_addr(5 downto 0) <= uart_data_out(5 downto 0);
 
 
                                        if uart_data_out(7) = '1' then
                                        if uart_data_out(7) = '1' then
                                                if uart_data_out(6) = '1' then
                                                if uart_data_out(6) = '1' then
                                                        isBurstRead <= '1';
                                                        isBurstRead <= '1';
                                                        uart_rec_state <= ST_UART_REC_READ_BURST_W_LEN_B1;
                                                        uart_rec_state <= ST_UART_REC_READ_BURST_W_LEN_B1;
                                                else
                                                else
                                                        uart_strobe_write_s1 <= not uart_strobe_write_s2;
                                                        uart_strobe_write_s1 <= not uart_strobe_write_s2;
                                                        uart_rec_state <= ST_UART_REC_READ_ADDR;
                                                        uart_rec_state <= ST_UART_REC_READ_ADDR;
                                                end if;
                                                end if;
                                        else
                                        else
                                                if uart_data_out(6) = '1' then
                                                if uart_data_out(6) = '1' then
                                                        isBurstRead <= '0';
                                                        isBurstRead <= '0';
                                                        uart_rec_state <= ST_UART_REC_READ_BURST_W_LEN_B1;
                                                        uart_rec_state <= ST_UART_REC_READ_BURST_W_LEN_B1;
                                                else
                                                else
                                                        uart_rec_state <= ST_UART_REC_READ_B1;
                                                        uart_rec_state <= ST_UART_REC_READ_B1;
                                                end if;
                                                end if;
                                        end if;
                                        end if;
 
 
                                when ST_UART_REC_READ_B1 =>
                                when ST_UART_REC_READ_B1 =>
                                        gpib_data_in(7 downto 0) <= uart_data_out;
                                        gpib_data_in(7 downto 0) <= uart_data_out;
                                        uart_rec_state <= ST_UART_REC_READ_B2;
                                        uart_rec_state <= ST_UART_REC_READ_B2;
 
 
                                when ST_UART_REC_READ_B2 =>
                                when ST_UART_REC_READ_B2 =>
                                        gpib_data_in(15 downto 8) <= uart_data_out;
                                        gpib_data_in(15 downto 8) <= uart_data_out;
                                        t_in_strobe_write <= not t_out_strobe_write;
                                        t_in_strobe_write <= not t_out_strobe_write;
                                        uart_rec_state <= ST_UART_REC_READ_ADDR;
                                        uart_rec_state <= ST_UART_REC_READ_ADDR;
 
 
                                -- burst length
                                -- burst length
                                when ST_UART_REC_READ_BURST_W_LEN_B1 =>
                                when ST_UART_REC_READ_BURST_W_LEN_B1 =>
                                        burstLen(7 downto 0) <= uart_data_out;
                                        burstLen(7 downto 0) <= uart_data_out;
                                        uart_rec_state <= ST_UART_REC_READ_BURST_W_LEN_B2;
                                        uart_rec_state <= ST_UART_REC_READ_BURST_W_LEN_B2;
 
 
                                when ST_UART_REC_READ_BURST_W_LEN_B2 =>
                                when ST_UART_REC_READ_BURST_W_LEN_B2 =>
                                        burstLen(11 downto 8) <= uart_data_out(3 downto 0);
                                        burstLen(11 downto 8) <= uart_data_out(3 downto 0);
                                        if isBurstRead = '1' then
                                        if isBurstRead = '1' then
                                                subscribeBurstRead_1 <= not subscribeBurstRead_2;
                                                subscribeBurstRead_1 <= not subscribeBurstRead_2;
                                                uart_rec_state <= ST_UART_REC_READ_ADDR;
                                                uart_rec_state <= ST_UART_REC_READ_ADDR;
                                        else
                                        else
                                                uart_rec_state <= ST_UART_REC_BURST_READ;
                                                uart_rec_state <= ST_UART_REC_BURST_READ;
                                        end if;
                                        end if;
 
 
                                when ST_UART_REC_BURST_READ =>
                                when ST_UART_REC_BURST_READ =>
                                        gpib_data_in(7 downto 0) <= uart_data_out;
                                        gpib_data_in(7 downto 0) <= uart_data_out;
                                        t_in_strobe_write <= not t_out_strobe_write;
                                        t_in_strobe_write <= not t_out_strobe_write;
                                        burstLen <= burstLen - 1;
                                        burstLen <= burstLen - 1;
 
 
                                        if burstLen = "000000000001" then
                                        if burstLen = "000000000001" then
                                                uart_rec_state <= ST_UART_REC_READ_ADDR;
                                                uart_rec_state <= ST_UART_REC_READ_ADDR;
                                        end if;
                                        end if;
 
 
                                when others =>
                                when others =>
                                        uart_rec_state <= ST_UART_REC_READ_ADDR;
                                        uart_rec_state <= ST_UART_REC_READ_ADDR;
                        end case;
                        end case;
                end if;
                end if;
        end process;
        end process;
 
 
        ---------- write to UART ---------------------
        ---------- write to UART ---------------------
        process (reset, clk, uart_strobe_write_s1) begin
        process (reset, clk, uart_strobe_write_s1) begin
                if reset = '1' then
                if reset = '1' then
                        uart_strobe_write_s2 <= uart_strobe_write_s1;
                        uart_strobe_write_s2 <= uart_strobe_write_s1;
                        uart_data_in_ready <= '0';
                        uart_data_in_ready <= '0';
                        t_in_strobe_read <= '0';
                        t_in_strobe_read <= '0';
 
 
                        subscribeBurstRead_2 <= '0';
                        subscribeBurstRead_2 <= '0';
 
 
                        led1 <= '0';
                        led1 <= '0';
 
 
                        uart_tr_state <= ST_UART_TR_IDLE;
                        uart_tr_state <= ST_UART_TR_IDLE;
                elsif rising_edge(clk) then
                elsif rising_edge(clk) then
                        case uart_tr_state is
                        case uart_tr_state is
                                when ST_UART_TR_IDLE =>
                                when ST_UART_TR_IDLE =>
                                        if uart_strobe_write_s2 /= uart_strobe_write_s1 and
                                        if uart_strobe_write_s2 /= uart_strobe_write_s1 and
                                                        uart_ready_to_send = '1' then
                                                        uart_ready_to_send = '1' then
                                                uart_strobe_write_s2 <= uart_strobe_write_s1;
                                                uart_strobe_write_s2 <= uart_strobe_write_s1;
                                                uart_data_in <= gpib_data_out(7 downto 0);
                                                uart_data_in <= gpib_data_out(7 downto 0);
                                                uart_data_in_ready <= '1';
                                                uart_data_in_ready <= '1';
                                                uart_tr_state <= ST_UART_TR_WAIT_NOT_READY_TO_SEND_1;
                                                uart_tr_state <= ST_UART_TR_WAIT_NOT_READY_TO_SEND_1;
                                        elsif subscribeBurstRead_1 /= subscribeBurstRead_2 and
                                        elsif subscribeBurstRead_1 /= subscribeBurstRead_2 and
                                                        uart_ready_to_send = '1' then
                                                        uart_ready_to_send = '1' then
                                                subscribeBurstRead_2 <= subscribeBurstRead_1;
                                                subscribeBurstRead_2 <= subscribeBurstRead_1;
                                                currentBurstReadLen <= conv_integer(UNSIGNED(burstLen));
                                                currentBurstReadLen <= conv_integer(UNSIGNED(burstLen));
 
 
                                                uart_tr_state <= ST_UART_TR_WRITE_BURST;
                                                uart_tr_state <= ST_UART_TR_WRITE_BURST;
                                        end if;
                                        end if;
 
 
                                when ST_UART_TR_WAIT_NOT_READY_TO_SEND_1 =>
                                when ST_UART_TR_WAIT_NOT_READY_TO_SEND_1 =>
                                        if uart_ready_to_send = '0' then
                                        if uart_ready_to_send = '0' then
                                                uart_data_in_ready <= '0';
                                                uart_data_in_ready <= '0';
                                                uart_tr_state <= ST_UART_TR_WRITE_B1;
                                                uart_tr_state <= ST_UART_TR_WRITE_B1;
                                        end if;
                                        end if;
 
 
                                when ST_UART_TR_WRITE_B1 =>
                                when ST_UART_TR_WRITE_B1 =>
                                        if uart_ready_to_send = '1' then
                                        if uart_ready_to_send = '1' then
                                                uart_data_in <= gpib_data_out(15 downto 8);
                                                uart_data_in <= gpib_data_out(15 downto 8);
                                                uart_data_in_ready <= '1';
                                                uart_data_in_ready <= '1';
                                                uart_tr_state <= ST_UART_TR_WAIT_NOT_READY_TO_SEND_2;
                                                uart_tr_state <= ST_UART_TR_WAIT_NOT_READY_TO_SEND_2;
                                        end if;
                                        end if;
 
 
                                when ST_UART_TR_WAIT_NOT_READY_TO_SEND_2 =>
                                when ST_UART_TR_WAIT_NOT_READY_TO_SEND_2 =>
                                        if uart_ready_to_send = '0' then
                                        if uart_ready_to_send = '0' then
                                                uart_data_in_ready <= '0';
                                                uart_data_in_ready <= '0';
                                                uart_tr_state <= ST_UART_TR_WRITE_B2;
                                                uart_tr_state <= ST_UART_TR_WRITE_B2;
                                        end if;
                                        end if;
 
 
                                when ST_UART_TR_WRITE_B2 =>
                                when ST_UART_TR_WRITE_B2 =>
                                        if uart_ready_to_send = '1' then
                                        if uart_ready_to_send = '1' then
                                                t_in_strobe_read <= not t_out_strobe_read;
                                                t_in_strobe_read <= not t_out_strobe_read;
 
 
                                                uart_tr_state <= ST_UART_TR_IDLE;
                                                uart_tr_state <= ST_UART_TR_IDLE;
                                        end if;
                                        end if;
 
 
                                -- burst read
                                -- burst read
                                when ST_UART_TR_WRITE_BURST =>
                                when ST_UART_TR_WRITE_BURST =>
                                        if uart_ready_to_send = '1' then
                                        if uart_ready_to_send = '1' then
                                                uart_data_in <= gpib_data_out(7 downto 0);
                                                uart_data_in <= gpib_data_out(7 downto 0);
                                                uart_data_in_ready <= '1';
                                                uart_data_in_ready <= '1';
                                                currentBurstReadLen <= currentBurstReadLen - 1;
                                                currentBurstReadLen <= currentBurstReadLen - 1;
 
 
                                                led1 <= '1';
                                                led1 <= '1';
 
 
                                                uart_tr_state <= ST_UART_TR_WAIT_BURST_NOT_READY_TO_SEND;
                                                uart_tr_state <= ST_UART_TR_WAIT_BURST_NOT_READY_TO_SEND;
                                        end if;
                                        end if;
 
 
                                when ST_UART_TR_WAIT_BURST_NOT_READY_TO_SEND =>
                                when ST_UART_TR_WAIT_BURST_NOT_READY_TO_SEND =>
                                        if uart_ready_to_send = '0' then
                                        if uart_ready_to_send = '0' then
                                                uart_data_in_ready <= '0';
                                                uart_data_in_ready <= '0';
                                                t_in_strobe_read <= not t_out_strobe_read;
                                                t_in_strobe_read <= not t_out_strobe_read;
 
 
                                                uart_tr_state <= ST_UART_TR_WAIT_BURST_READY_TO_SEND;
                                                uart_tr_state <= ST_UART_TR_WAIT_BURST_READY_TO_SEND;
                                        end if;
                                        end if;
 
 
                                when ST_UART_TR_WAIT_BURST_READY_TO_SEND =>
                                when ST_UART_TR_WAIT_BURST_READY_TO_SEND =>
                                        if uart_ready_to_send = '1' then
                                        if uart_ready_to_send = '1' then
 
 
                                                if currentBurstReadLen > 0 then
                                                if currentBurstReadLen > 0 then
                                                        uart_tr_state <= ST_UART_TR_WRITE_BURST;
                                                        uart_tr_state <= ST_UART_TR_WRITE_BURST;
                                                else
                                                else
                                                        led1 <= '0';
                                                        led1 <= '0';
                                                        uart_tr_state <= ST_UART_TR_IDLE;
                                                        uart_tr_state <= ST_UART_TR_IDLE;
                                                end if;
                                                end if;
                                        end if;
                                        end if;
 
 
 
 
                                when others =>
                                when others =>
                                        uart_tr_state <= ST_UART_TR_IDLE;
                                        uart_tr_state <= ST_UART_TR_IDLE;
                        end case;
                        end case;
                end if;
                end if;
        end process;
        end process;
 
 
        process (clk) begin
        process (clk) begin
                if rising_edge(clk) then
                if rising_edge(clk) then
                        if reset_timer < 50000000 then
                        if reset_timer < 50000000 then
                                reset_timer <= reset_timer + 1;
                                reset_timer <= reset_timer + 1;
                                reset <= '1';
                                reset <= '1';
                        else
                        else
                                reset <= '0';
                                reset <= '0';
                        end if;
                        end if;
                end if;
                end if;
        end process;
        end process;
 
 
        uart0: Uart port map(
        uart0: Uart port map(
                reset => uart_reset, clk => uart_clk, RX => uart_RX, TX => uart_TX,
                reset => uart_reset, clk => uart_clk, RX => uart_RX, TX => uart_TX,
                data_out => uart_data_out, data_out_ready => uart_data_out_ready,
                data_out => uart_data_out, data_out_ready => uart_data_out_ready,
                data_in => uart_data_in, data_in_ready => uart_data_in_ready,
                data_in => uart_data_in, data_in_ready => uart_data_in_ready,
                ready_to_send => uart_ready_to_send
                ready_to_send => uart_ready_to_send
        );
        );
 
 
        spg_strobe_write: SinglePulseGenerator generic map (WIDTH => 1) port map(
        spg_strobe_write: SinglePulseGenerator generic map (WIDTH => 1) port map(
                reset => reset, clk => clk,
                reset => reset, clk => clk,
                t_in => t_in_strobe_write, t_out => t_out_strobe_write,
                t_in => t_in_strobe_write, t_out => t_out_strobe_write,
                pulse => gpib_strobe_write
                pulse => gpib_strobe_write
        );
        );
 
 
        spg_strobe_read: SinglePulseGenerator generic map (WIDTH => 1) port map(
        spg_strobe_read: SinglePulseGenerator generic map (WIDTH => 1) port map(
                reset => reset, clk => clk,
                reset => reset, clk => clk,
                t_in => t_in_strobe_read, t_out => t_out_strobe_read,
                t_in => t_in_strobe_read, t_out => t_out_strobe_read,
                pulse => gpib_strobe_read
                pulse => gpib_strobe_read
        );
        );
 
 
        gpibSync: GpibSynchronizer port map (
        gpibSync: GpibSynchronizer port map (
                clk => gSync_clk,
                clk => gSync_clk,
                DI => gSync_DI,
                DI => gSync_DI,
                DO => gSync_DO,
                DO => gSync_DO,
                ATN_in => gSync_ATN_in,
                ATN_in => gSync_ATN_in,
                ATN_out => gSync_ATN_Out,
                ATN_out => gSync_ATN_Out,
                DAV_in => gSync_DAV_in,
                DAV_in => gSync_DAV_in,
                DAV_out => gSync_DAV_out,
                DAV_out => gSync_DAV_out,
                NRFD_in => gSync_NRFD_in,
                NRFD_in => gSync_NRFD_in,
                NRFD_out => gSync_NRFD_out,
                NRFD_out => gSync_NRFD_out,
                NDAC_in => gSync_NDAC_in,
                NDAC_in => gSync_NDAC_in,
                NDAC_out => gSync_NDAC_out,
                NDAC_out => gSync_NDAC_out,
                EOI_in => gSync_EOI_in,
                EOI_in => gSync_EOI_in,
                EOI_out => gSync_EOI_out,
                EOI_out => gSync_EOI_out,
                SRQ_in => gSync_SRQ_in,
                SRQ_in => gSync_SRQ_in,
                SRQ_out => gSync_SRQ_out,
                SRQ_out => gSync_SRQ_out,
                IFC_in => gSync_IFC_in,
                IFC_in => gSync_IFC_in,
                IFC_out => gSync_IFC_out,
                IFC_out => gSync_IFC_out,
                REN_in => gSync_REN_in,
                REN_in => gSync_REN_in,
                REN_out => gSync_REN_out
                REN_out => gSync_REN_out
        );
        );
 
 
        gpib0: RegsGpibFasade port map(
        gpib0: RegsGpibFasade port map(
                reset => gpib_reset, clk => gpib_clk,
                reset => gpib_reset, clk => gpib_clk,
                DI => gpib_DI, DO => gpib_DO, output_valid => gpib_output_valid,
                DI => gpib_DI, DO => gpib_DO, output_valid => gpib_output_valid,
                ATN_in => gpib_ATN_in, ATN_out => gpib_ATN_out,
                ATN_in => gpib_ATN_in, ATN_out => gpib_ATN_out,
                DAV_in => gpib_DAV_in, DAV_out => gpib_DAV_out,
                DAV_in => gpib_DAV_in, DAV_out => gpib_DAV_out,
                NRFD_in => gpib_NRFD_in, NRFD_out => gpib_NRFD_out,
                NRFD_in => gpib_NRFD_in, NRFD_out => gpib_NRFD_out,
                NDAC_in => gpib_NDAC_in, NDAC_out => gpib_NDAC_out,
                NDAC_in => gpib_NDAC_in, NDAC_out => gpib_NDAC_out,
                EOI_in => gpib_EOI_in, EOI_out => gpib_EOI_out,
                EOI_in => gpib_EOI_in, EOI_out => gpib_EOI_out,
                SRQ_in => gpib_SRQ_in, SRQ_out => gpib_SRQ_out,
                SRQ_in => gpib_SRQ_in, SRQ_out => gpib_SRQ_out,
                IFC_in => gpib_IFC_in, IFC_out => gpib_IFC_out,
                IFC_in => gpib_IFC_in, IFC_out => gpib_IFC_out,
                REN_in => gpib_REN_in, REN_out => gpib_REN_out,
                REN_in => gpib_REN_in, REN_out => gpib_REN_out,
                data_in => gpib_data_in, data_out => gpib_data_out,
                data_in => gpib_data_in, data_out => gpib_data_out,
                reg_addr => gpib_reg_addr,
                reg_addr => gpib_reg_addr,
                strobe_read => gpib_strobe_read,
                strobe_read => gpib_strobe_read,
                strobe_write => gpib_strobe_write,
                strobe_write => gpib_strobe_write,
                interrupt_line => gpib_interrupt_line,
                interrupt_line => gpib_interrupt_line,
                debug1 => debug1, debug2 => debug2
                debug1 => debug1, debug2 => debug2
        );
        );
 
 
end Behavioral;
end Behavioral;
 
 
 
 

powered by: WebSVN 2.1.0

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