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

Subversion Repositories gecko3

[/] [gecko3/] [trunk/] [GECKO3COM/] [gecko3com-ip/] [core/] [gpif_com.vhd] - Diff between revs 12 and 14

Go to most recent revision | Show entire file | Details | Blame | View Log

Rev 12 Rev 14
Line 1... Line 1...
 
--  GECKO3COM IP Core
 
--
 
--  Copyright (C) 2009 by
 
--   ___    ___   _   _
 
--  (  _ \ (  __)( ) ( )
 
--  | (_) )| (   | |_| |   Bern University of Applied Sciences
 
--  |  _ < |  _) |  _  |   School of Engineering and
 
--  | (_) )| |   | | | |   Information Technology
 
--  (____/ (_)   (_) (_)
 
--
 
--  This program 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.
 
--
 
--  This program 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 this program.  If not, see <http://www.gnu.org/licenses/>.
 
--
 
--  URL to the project description: 
 
--    http://labs.ti.bfh.ch/gecko/wiki/systems/gecko3com/start
 
----------------------------------------------------------------------------------
 
--
 
--  Author:  Andreas Habegger, Christoph Zimmermann
 
--  Date of creation: 8. April 2009
 
--  Description:
 
--      GECKO3COM defines the communication between the GECKO3main and a USB Master e.g. a computer.
 
--              This file is the top module, it instantiates all required submodules and connects them 
 
--              together.
 
--
 
--  Target Devices:     Xilinx Spartan3 FPGA's (usage of BlockRam in the Datapath)
 
--  Tool versions:      11.1
 
--  Dependencies:
 
--
 
----------------------------------------------------------------------------------
 
 
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;
 
 
library work;
library work;
use work.USB_TMC_IP_Defs.all;
use work.GECKO3COM_defines.all;
use work.USB_TMC_cmp.all;
use work.USB_TMC_cmp.all;
 
 
 
 
entity USB_TMC_IP is
entity gpif_com is
  port (
  port (
    i_nReset,
    i_nReset,
    i_IFCLK,                                                                     -- GPIF CLK (is Master)
    i_IFCLK,                                                                     -- GPIF CLK (GPIF is Master and provides the clock)
         i_SYSCLK,                                                                       -- FPGA System CLK
         i_SYSCLK,                                                                       -- FPGA System CLK
    i_WRU,                              -- write from GPIF
    i_WRU,                              -- write from GPIF
    i_RDYU        : in          std_logic;        -- GPIF is ready
    i_RDYU        : in          std_logic;        -- GPIF is ready
--       i_ENAIP          : in          std_logic;               -- enable the IP core
 
--       i_RDYD2IP : in         std_logic;                       -- data RDY 2 the IP core   
 
--       i_d2USB   : in         std_logic_vector(SIZE_DBUS_FPGA-1 downto 0);  -- FPGA DBUS
 
--       i_RxD    : in          std_logic;
 
--       o_TxD     : out                std_logic;
 
--       i_Switches: in         std_logic_vector(NUMBER_OF_SW-1 downto 0);
 
    o_WRX,                              -- To write to GPIF
    o_WRX,                              -- To write to GPIF
    o_RDYX    : out     std_logic;      -- Core is ready
    o_RDYX    : out     std_logic;      -- IP Core is ready
--       o_RDYIP   : out        std_logic;               -- IP ready FPGA site
    o_ABORT   : out   std_logic;  -- Abort detected, you have to flush the data
--       o_DAVIP   : out        std_logic;               -- Data available for FPGA
    o_RX,                            -- controll LED rx
         o_LEDrx,                            -- controll LED rx __DEB_INFO__
    o_TX : out          std_logic;               -- controll LED tx
         o_LEDtx : out          std_logic;               -- controll LED tx __DEB_INFO__
    b_gpif_bus    : inout       std_logic_vector(SIZE_DBUS_GPIF-1 downto 0));  -- bidirect data bus
         o_LEDrun  : out        std_logic;      -- controll LED running signalisation __DEB_INFO__
end gpif_com;
--       o_d2FPGA  : out        std_logic_vector(SIZE_DBUS_FPGA-1 downto 0);  -- FPGA DBUS
 
    b_dbus        : inout       std_logic_vector(SIZE_DBUS_GPIF-1 downto 0));  -- bidirect data bus
 
end USB_TMC_IP;
 
 
 
 
 
 
 
architecture top_core of USB_TMC_IP is
 
 
 
 
architecture structure of gpif_com is
 
 
  -- interconection signals
  -- interconection signals
 
 
  signal s_FIFOrst           : std_logic;
  signal s_FIFOrst           : std_logic;
 
 
     -- U2X
  signal s_ABORT_FSM, s_ABORT_TMP  : std_logic;
 
  signal s_RX_FSM, s_RX_TMP  : std_logic;
 
  signal s_TX_FSM, s_TX_TMP  : std_logic;
 
 
 
     -- USB to Xilinx (U2X)
  signal s_U2X_WR_EN,
  signal s_U2X_WR_EN,
         s_U2X_RD_EN,
         s_U2X_RD_EN,
         s_U2X_FULL,
         s_U2X_FULL,
         s_U2X_AM_FULL,
         s_U2X_AM_FULL,
         s_U2X_EMPTY,
         s_U2X_EMPTY,
         s_U2X_AM_EMPTY : std_logic;
         s_U2X_AM_EMPTY : std_logic;
 
 
     -- X2U
     -- Xilinx to USB (X2U)
  signal s_X2U_WR_EN,
  signal s_X2U_WR_EN,
         s_X2U_RD_EN,
         s_X2U_RD_EN,
         s_X2U_FULL,
         s_X2U_FULL,
         s_X2U_AM_FULL,
         s_X2U_AM_FULL,
         s_X2U_EMPTY,
         s_X2U_EMPTY,
Line 59... Line 92...
  -------------------------------------------------------------------------------
  -------------------------------------------------------------------------------
  -- data bus
  -- data bus
  -------------------------------------------------------------------------------
  -------------------------------------------------------------------------------
 
 
  -- data signals
  -- data signals
 
  signal s_dbus_trans_dir     : std_logic;
        signal s_dbus_in  : std_logic_vector(SIZE_DBUS_GPIF-1 downto 0);
        signal s_dbus_in  : std_logic_vector(SIZE_DBUS_GPIF-1 downto 0);
        signal s_dbus_out : std_logic_vector(SIZE_DBUS_GPIF-1 downto 0);
        signal s_dbus_out : std_logic_vector(SIZE_DBUS_GPIF-1 downto 0);
 
 
        signal s_opb_in : std_logic_vector(SIZE_DBUS_FPGA-1 downto 0);
        signal s_opb_in : std_logic_vector(SIZE_DBUS_FPGA-1 downto 0);
        signal s_opb_out        : std_logic_vector(SIZE_DBUS_FPGA-1 downto 0);
        signal s_opb_out        : std_logic_vector(SIZE_DBUS_FPGA-1 downto 0);
 
 
--  -------------------------------------------------------------------------------
 
--  -- UART 
 
--  -------------------------------------------------------------------------------
 
--      signal s_UART_RD        : std_logic;
 
--      signal s_UART_WR        : std_logic;
 
--      signal s_CS                     : std_logic;
 
--      signal s_uart_data: std_logic_vector(BYTE-1 downto 0);
 
 
 
 
 
 
 
  -----------------------------------------------------------------------------
  -----------------------------------------------------------------------------
  -- COMPONENTS
  -- COMPONENTS
  -----------------------------------------------------------------------------
  -----------------------------------------------------------------------------
 
 
--COMPONENT miniUART
  -- FSM GPIF
--  port (
  component gpif_com_fsm
--     SysClk   : in  Std_Logic;  -- System Clock
  port (
--     Reset    : in  Std_Logic;  -- Reset input
    i_nReset,
--     CS_N     : in  Std_Logic;
    i_IFCLK,                                                                    -- GPIF CLK (is Master)
--     RD_N     : in  Std_Logic;
    i_WRU,                             -- write from GPIF
--     WR_N     : in  Std_Logic;
    i_RDYU            : in    std_logic;       -- GPIF is ready
--     RxD      : in  Std_Logic;
    i_U2X_FULL,
--     TxD      : out Std_Logic;
    i_U2X_AM_FULL,       -- signals for IN FIFO
--     IntRx_N  : out Std_Logic;  -- Receive interrupt
    i_X2U_AM_EMPTY,
--     IntTx_N  : out Std_Logic;  -- Transmit interrupt
    i_X2U_EMPTY : in  std_logic;     -- signals for OUT FIFO
--     Addr     : in  Std_Logic_Vector(1 downto 0); -- 
    o_bus_trans_dir        : out    std_logic;
--     DataIn   : in  Std_Logic_Vector(7 downto 0); -- 
    o_U2X_WR_EN,                                                      -- signals for IN FIFO
--     DataOut  : out Std_Logic_Vector(7 downto 0)); -- 
    o_X2U_RD_EN,                                                                -- signals for OUT FIFO
--end COMPONENT miniUART;
    o_FIFOrst,
 
    o_WRX,                             -- To write to GPIF
 
    o_RDYX    : out   std_logic;       -- Core is ready
 
    o_ABORT   : out   std_logic;       -- abort condition detected. we have to flush the data
 
    o_RX,
 
    o_TX      : out   std_logic                 --
 
  );
 
  end component;
 
 
 
  -- FIFO dualclock to cross the clock domain between the GPIF and the FPGA
 
  component fifo_dualclock
 
  port (
 
    i_din          : IN  std_logic_VECTOR(SIZE_DBUS_GPIF-1 downto 0);
 
    i_rd_clk       : IN  std_logic;
 
    i_rd_en        : IN  std_logic;
 
    i_rst          : IN  std_logic;
 
    i_wr_clk       : IN  std_logic;
 
    i_wr_en        : IN  std_logic;
 
    o_almost_empty : OUT std_logic;
 
    o_almost_full  : OUT std_logic;
 
    o_dout         : OUT std_logic_VECTOR(SIZE_DBUS_GPIF-1 downto 0);
 
    o_empty        : OUT std_logic;
 
    o_full         : OUT std_logic);
 
  end component;
 
 
 
 
begin
begin
 
 
  -----------------------------------------------------------------------------
  -----------------------------------------------------------------------------
  -- Port map
  -- Port map
  -----------------------------------------------------------------------------
  -----------------------------------------------------------------------------
 
 
F_IN : fifo_U2X_2C_1024B
  F_IN : fifo_dualclock
                port map (
                port map (
                        din          => s_dbus_in,
    i_din          => s_dbus_in,
                        rd_clk       => i_SYSCLK,
    i_rd_clk       => i_SYSCLK,
                        rd_en        => s_U2X_RD_EN,
    i_rd_en        => s_U2X_RD_EN,
                        rst          => s_FIFOrst,
    i_rst          => s_FIFOrst,
                        wr_clk       => i_IFCLK ,
    i_wr_clk       => i_IFCLK ,
                        wr_en        => s_U2X_WR_EN,
    i_wr_en        => s_U2X_WR_EN,
                        almost_empty => s_U2X_AM_EMPTY,
    o_almost_empty => s_U2X_AM_EMPTY,
                        almost_full  => s_U2X_AM_FULL,
    o_almost_full  => s_U2X_AM_FULL,
                        dout         => s_opb_in,
    o_dout         => s_opb_in,
                        empty        => s_U2X_EMPTY,
    o_empty        => s_U2X_EMPTY,
                        full         => s_U2X_FULL
    o_full         => s_U2X_FULL
                        );
                        );
 
 
 
 
F_OUT : fifo_X2U_2C_1024B
  F_OUT : fifo_dualclock
                port map (
                port map (
                        din          => s_opb_out,
    i_din          => s_opb_out,
                        rd_clk       => i_IFCLK,
    i_rd_clk       => i_IFCLK,
                        rd_en        => s_X2U_RD_EN,
    i_rd_en        => s_X2U_RD_EN,
                        rst          => s_FIFOrst,
    i_rst          => s_FIFOrst,
                        wr_clk       => i_SYSCLK,
    i_wr_clk       => i_SYSCLK,
                        wr_en        => s_X2U_WR_EN,
    i_wr_en        => s_X2U_WR_EN,
                        almost_empty => s_X2U_AM_EMPTY,
    o_almost_empty => s_X2U_AM_EMPTY,
                        almost_full  => s_X2U_AM_FULL,
    o_almost_full  => s_X2U_AM_FULL,
                        dout         => s_dbus_out,
    o_dout         => s_dbus_out,
                        empty        => s_X2U_EMPTY,
    o_empty        => s_X2U_EMPTY,
                        full         => s_X2U_FULL
    o_full         => s_X2U_FULL
                        );
                        );
 
 
 
 
FSM_GPIF : gpif_com
  FSM_GPIF : gpif_com_fsm
                                port map (
                                port map (
                                        i_nReset                        => i_nReset,
                                        i_nReset                        => i_nReset,
                                        i_IFCLK                 =>      i_IFCLK,
                                        i_IFCLK                 =>      i_IFCLK,
                                        i_WRU                           => i_WRU,
                                        i_WRU                           => i_WRU,
                                        i_RDYU                  => i_RDYU,
                                        i_RDYU                  => i_RDYU,
                                        i_U2X_FULL              => s_U2X_FULL,
                                        i_U2X_FULL              => s_U2X_FULL,
                                        i_U2X_AM_FULL   => s_U2X_AM_FULL,
                                        i_U2X_AM_FULL   => s_U2X_AM_FULL,
                                        i_X2U_AM_EMPTY  => s_X2U_AM_EMPTY,
                                        i_X2U_AM_EMPTY  => s_X2U_AM_EMPTY,
                                        i_X2U_EMPTY             => s_X2U_EMPTY,
                                        i_X2U_EMPTY             => s_X2U_EMPTY,
                                        i_dbus                  => s_dbus_out,
 
                                        o_U2X_WR_EN             => s_U2X_WR_EN,
                                        o_U2X_WR_EN             => s_U2X_WR_EN,
                                        o_X2U_RD_EN             => s_X2U_RD_EN,
                                        o_X2U_RD_EN             => s_X2U_RD_EN,
                                        o_FIFOrst               => s_FIFOrst,
                                        o_FIFOrst               => s_FIFOrst,
 
                o_bus_trans_dir => s_dbus_trans_dir,
                                        o_WRX                           => o_WRX,
                                        o_WRX                           => o_WRX,
                                        o_RDYX                  => o_RDYX,
                                        o_RDYX                  => o_RDYX,
                                        o_LEDrx                    => o_LEDrx,
    o_ABORT     => s_ABORT_FSM,
                                        o_LEDtx                    => o_LEDtx,
                o_RX               => o_RX,
                                        o_LEDrun                => o_LEDrun,
                o_TX               => o_TX,
                                        o_dbus                  => s_dbus_in,
 
                                        b_dbus                  => b_dbus
 
                                );
                                );
 
 
 
  -- Double buffer the ABORT, RX and TX signal to avoid metastability
 
  double_buf_sig : process (i_SYSCLK, i_nReset)
 
  begin
 
    if i_nReset = '0' then
 
      o_ABORT <= '0';
 
      s_ABORT_TMP <= '0';
 
      s_TX_FSM <= '0';
 
      s_TX_TMP <= '0';
 
      s_RX_FSM <= '0';
 
      s_TX_TMP <= '0';
 
    elsif rising_edge(i_SYSCLK)
 
      o_ABORT <= s_ABORT_TMP;
 
      s_ABORT_TMP <= s_ABORT_FSM;
 
      o_TX <= s_TX_TMP;
 
      s_TX_TMP <= s_TX_FSM;
 
      o_RX <= s_RX_TMP;
 
      s_RX_TMP <= s_RX_FSM;
 
    end if;
 
  end process double_buf_sig;
 
 
Loopback : USB_TMC_IP_loopback
 
                port map (
 
                        i_nReset                        => i_nReset,
 
                        i_SYSCLK                        => i_SYSCLK,                                                                     -- FPGA System CLK
 
                        i_U2X_EMPTY             => s_U2X_EMPTY,
 
                        i_U2X_AM_EMPTY     => s_U2X_AM_EMPTY,
 
                        i_X2U_AM_FULL      => s_X2U_AM_FULL,
 
                        i_X2U_FULL                 => s_X2U_FULL,
 
                        i_U2X_DATA                 => s_opb_in,
 
                        o_U2X_RD_EN             => s_U2X_RD_EN,
 
                        o_X2U_WR_EN             => s_X2U_WR_EN,
 
                        o_X2U_DATA        => s_opb_out
 
                );
 
 
 
 
 
 
 
--
 
--uart : miniUART
 
--                      port map (
 
--                      SysClk  => i_SYSCLK,
 
--                      Reset   => i_nReset,
 
--                      CS_N    => s_CS,
 
--                      RD_N    => s_UART_RD,
 
--                      WR_N    => s_UART_WR,
 
--                      RxD     => i_RxD,
 
--                      TxD      => o_TxD,
 
--                      IntRx_N  => open,
 
--                      IntTx_N  => open,
 
--                      Addr     => "00",
 
--                      DataIn   => (others => 'Z'),
 
--                      DataOut  => s_uart_data
 
--                      );          
 
 
 
 
  -----------------------------------------------------------------------------
 
  -- Data bus access
 
  -----------------------------------------------------------------------------
 
 
 
  -- purpose: to handle the access on the bidirectional bus
 
  -- type   : combinational
 
  -- inputs : s_bus_trans_dir
 
  -- outputs: 
 
  bus_access : process (s_dbus_trans_dir, s_dbus_out)
 
  begin  -- process bus_access
 
    if s_dbus_trans_dir = '1' then
 
      b_gpifbus <= s_dbus_out;
 
    else
 
      b_gpifbus <= (others => 'Z');
 
    end if;
 
  end process bus_access;
 
 
 
  s_dbus_in <= b_gpifbus;
 
 
end top_core;
end structure;
 
 
 No newline at end of file
 No newline at end of file

powered by: WebSVN 2.1.0

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