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

Subversion Repositories gecko3

[/] [gecko3/] [trunk/] [GECKO3COM/] [gecko3com-ip/] [core/] [gpif_com.vhd] - Blame information for rev 16

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 14 nussgipfel
--  GECKO3COM IP Core
2
--
3
--  Copyright (C) 2009 by
4
--   ___    ___   _   _
5
--  (  _ \ (  __)( ) ( )
6
--  | (_) )| (   | |_| |   Bern University of Applied Sciences
7
--  |  _ < |  _) |  _  |   School of Engineering and
8
--  | (_) )| |   | | | |   Information Technology
9
--  (____/ (_)   (_) (_)
10
--
11
--  This program is free software: you can redistribute it and/or modify
12
--  it under the terms of the GNU General Public License as published by
13
--  the Free Software Foundation, either version 3 of the License, or
14
--  (at your option) any later version.
15
--
16
--  This program is distributed in the hope that it will be useful,
17
--  but WITHOUT ANY WARRANTY; without even the implied warranty of
18
--  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
19
--  GNU General Public License for more details. 
20
--  You should have received a copy of the GNU General Public License
21
--  along with this program.  If not, see <http://www.gnu.org/licenses/>.
22
--
23
--  URL to the project description: 
24
--    http://labs.ti.bfh.ch/gecko/wiki/systems/gecko3com/start
25
----------------------------------------------------------------------------------
26
--
27
--  Author:  Andreas Habegger, Christoph Zimmermann
28
--  Date of creation: 8. April 2009
29
--  Description:
30
--      GECKO3COM defines the communication between the GECKO3main and a USB Master e.g. a computer.
31
--              This file is the top module, it instantiates all required submodules and connects them 
32
--              together.
33
--
34
--  Target Devices:     Xilinx Spartan3 FPGA's (usage of BlockRam in the Datapath)
35
--  Tool versions:      11.1
36
--  Dependencies:
37
--
38
----------------------------------------------------------------------------------
39
 
40 11 nussgipfel
library ieee;
41
use ieee.std_logic_1164.all;
42
use ieee.std_logic_arith.all;
43
 
44
library work;
45 14 nussgipfel
use work.GECKO3COM_defines.all;
46 11 nussgipfel
use work.USB_TMC_cmp.all;
47
 
48
 
49 14 nussgipfel
entity gpif_com is
50 11 nussgipfel
  port (
51
    i_nReset,
52 14 nussgipfel
    i_IFCLK,                                                                     -- GPIF CLK (GPIF is Master and provides the clock)
53
    i_SYSCLK,                                                                    -- FPGA System CLK
54 11 nussgipfel
    i_WRU,                              -- write from GPIF
55
    i_RDYU        : in          std_logic;        -- GPIF is ready
56
    o_WRX,                              -- To write to GPIF
57 14 nussgipfel
    o_RDYX    : out     std_logic;      -- IP Core is ready
58
    o_ABORT   : out   std_logic;  -- Abort detected, you have to flush the data
59
    o_RX,                            -- controll LED rx
60
    o_TX : out          std_logic;               -- controll LED tx
61
    b_gpif_bus    : inout       std_logic_vector(SIZE_DBUS_GPIF-1 downto 0));  -- bidirect data bus
62
end gpif_com;
63 11 nussgipfel
 
64
 
65
 
66 14 nussgipfel
architecture structure of gpif_com is
67
 
68 11 nussgipfel
  -- interconection signals
69
 
70
  signal s_FIFOrst           : std_logic;
71 14 nussgipfel
 
72
  signal s_ABORT_FSM, s_ABORT_TMP  : std_logic;
73
  signal s_RX_FSM, s_RX_TMP  : std_logic;
74
  signal s_TX_FSM, s_TX_TMP  : std_logic;
75
 
76
     -- USB to Xilinx (U2X)
77 12 nussgipfel
  signal s_U2X_WR_EN,
78
         s_U2X_RD_EN,
79 11 nussgipfel
         s_U2X_FULL,
80
         s_U2X_AM_FULL,
81
         s_U2X_EMPTY,
82
         s_U2X_AM_EMPTY : std_logic;
83
 
84 14 nussgipfel
     -- Xilinx to USB (X2U)
85 12 nussgipfel
  signal s_X2U_WR_EN,
86
         s_X2U_RD_EN,
87 11 nussgipfel
         s_X2U_FULL,
88
         s_X2U_AM_FULL,
89
         s_X2U_EMPTY,
90
         s_X2U_AM_EMPTY : std_logic;
91
 
92
  -------------------------------------------------------------------------------
93
  -- data bus
94
  -------------------------------------------------------------------------------
95
 
96
  -- data signals
97 14 nussgipfel
  signal s_dbus_trans_dir     : std_logic;
98 11 nussgipfel
        signal s_dbus_in  : std_logic_vector(SIZE_DBUS_GPIF-1 downto 0);
99
        signal s_dbus_out : std_logic_vector(SIZE_DBUS_GPIF-1 downto 0);
100
 
101
        signal s_opb_in : std_logic_vector(SIZE_DBUS_FPGA-1 downto 0);
102
        signal s_opb_out        : std_logic_vector(SIZE_DBUS_FPGA-1 downto 0);
103 14 nussgipfel
 
104 11 nussgipfel
 
105
  -----------------------------------------------------------------------------
106
  -- COMPONENTS
107
  -----------------------------------------------------------------------------
108
 
109 14 nussgipfel
  -- FSM GPIF
110
  component gpif_com_fsm
111
  port (
112
    i_nReset,
113
    i_IFCLK,                                                                    -- GPIF CLK (is Master)
114
    i_WRU,                             -- write from GPIF
115
    i_RDYU            : in    std_logic;       -- GPIF is ready
116
    i_U2X_FULL,
117
    i_U2X_AM_FULL,       -- signals for IN FIFO
118
    i_X2U_AM_EMPTY,
119
    i_X2U_EMPTY : in  std_logic;     -- signals for OUT FIFO
120
    o_bus_trans_dir        : out    std_logic;
121
    o_U2X_WR_EN,                                                      -- signals for IN FIFO
122
    o_X2U_RD_EN,                                                                -- signals for OUT FIFO
123
    o_FIFOrst,
124
    o_WRX,                             -- To write to GPIF
125
    o_RDYX    : out   std_logic;       -- Core is ready
126
    o_ABORT   : out   std_logic;       -- abort condition detected. we have to flush the data
127
    o_RX,
128
    o_TX      : out   std_logic                 --
129
  );
130
  end component;
131 11 nussgipfel
 
132 14 nussgipfel
  -- FIFO dualclock to cross the clock domain between the GPIF and the FPGA
133
  component fifo_dualclock
134
  port (
135
    i_din          : IN  std_logic_VECTOR(SIZE_DBUS_GPIF-1 downto 0);
136
    i_rd_clk       : IN  std_logic;
137
    i_rd_en        : IN  std_logic;
138
    i_rst          : IN  std_logic;
139
    i_wr_clk       : IN  std_logic;
140
    i_wr_en        : IN  std_logic;
141
    o_almost_empty : OUT std_logic;
142
    o_almost_full  : OUT std_logic;
143
    o_dout         : OUT std_logic_VECTOR(SIZE_DBUS_GPIF-1 downto 0);
144
    o_empty        : OUT std_logic;
145
    o_full         : OUT std_logic);
146
  end component;
147
 
148 11 nussgipfel
 
149
begin
150
 
151
  -----------------------------------------------------------------------------
152
  -- Port map
153
  -----------------------------------------------------------------------------
154
 
155 14 nussgipfel
  F_IN : fifo_dualclock
156
  port map (
157
    i_din          => s_dbus_in,
158
    i_rd_clk       => i_SYSCLK,
159
    i_rd_en        => s_U2X_RD_EN,
160
    i_rst          => s_FIFOrst,
161
    i_wr_clk       => i_IFCLK ,
162
    i_wr_en        => s_U2X_WR_EN,
163
    o_almost_empty => s_U2X_AM_EMPTY,
164
    o_almost_full  => s_U2X_AM_FULL,
165
    o_dout         => s_opb_in,
166
    o_empty        => s_U2X_EMPTY,
167
    o_full         => s_U2X_FULL
168
  );
169 11 nussgipfel
 
170
 
171 14 nussgipfel
  F_OUT : fifo_dualclock
172
  port map (
173
    i_din          => s_opb_out,
174
    i_rd_clk       => i_IFCLK,
175
    i_rd_en        => s_X2U_RD_EN,
176
    i_rst          => s_FIFOrst,
177
    i_wr_clk       => i_SYSCLK,
178
    i_wr_en        => s_X2U_WR_EN,
179
    o_almost_empty => s_X2U_AM_EMPTY,
180
    o_almost_full  => s_X2U_AM_FULL,
181
    o_dout         => s_dbus_out,
182
    o_empty        => s_X2U_EMPTY,
183
    o_full         => s_X2U_FULL
184
  );
185 11 nussgipfel
 
186 12 nussgipfel
 
187 14 nussgipfel
  FSM_GPIF : gpif_com_fsm
188
        port map (
189
    i_nReset                    => i_nReset,
190
                i_IFCLK                 =>      i_IFCLK,
191
                i_WRU                           => i_WRU,
192
                i_RDYU                  => i_RDYU,
193
                i_U2X_FULL              => s_U2X_FULL,
194
                i_U2X_AM_FULL   => s_U2X_AM_FULL,
195
                i_X2U_AM_EMPTY  => s_X2U_AM_EMPTY,
196
                i_X2U_EMPTY             => s_X2U_EMPTY,
197
                o_U2X_WR_EN             => s_U2X_WR_EN,
198
                o_X2U_RD_EN             => s_X2U_RD_EN,
199
                o_FIFOrst               => s_FIFOrst,
200
                o_bus_trans_dir => s_dbus_trans_dir,
201
                o_WRX                           => o_WRX,
202
                o_RDYX                  => o_RDYX,
203
    o_ABORT     => s_ABORT_FSM,
204
                o_RX               => o_RX,
205
                o_TX               => o_TX,
206
        );
207 11 nussgipfel
 
208 14 nussgipfel
  -- Double buffer the ABORT, RX and TX signal to avoid metastability
209
  double_buf_sig : process (i_SYSCLK, i_nReset)
210
  begin
211
    if i_nReset = '0' then
212
      o_ABORT <= '0';
213
      s_ABORT_TMP <= '0';
214
      s_TX_FSM <= '0';
215
      s_TX_TMP <= '0';
216
      s_RX_FSM <= '0';
217
      s_TX_TMP <= '0';
218
    elsif rising_edge(i_SYSCLK)
219
      o_ABORT <= s_ABORT_TMP;
220
      s_ABORT_TMP <= s_ABORT_FSM;
221
      o_TX <= s_TX_TMP;
222
      s_TX_TMP <= s_TX_FSM;
223
      o_RX <= s_RX_TMP;
224
      s_RX_TMP <= s_RX_FSM;
225
    end if;
226
  end process double_buf_sig;
227
 
228 11 nussgipfel
 
229 14 nussgipfel
  -----------------------------------------------------------------------------
230
  -- Data bus access
231
  -----------------------------------------------------------------------------
232 11 nussgipfel
 
233 14 nussgipfel
  -- purpose: to handle the access on the bidirectional bus
234
  -- type   : combinational
235
  -- inputs : s_bus_trans_dir
236
  -- outputs: 
237
  bus_access : process (s_dbus_trans_dir, s_dbus_out)
238
  begin  -- process bus_access
239
    if s_dbus_trans_dir = '1' then
240
      b_gpifbus <= s_dbus_out;
241
    else
242
      b_gpifbus <= (others => 'Z');
243
    end if;
244
  end process bus_access;
245 11 nussgipfel
 
246 14 nussgipfel
  s_dbus_in <= b_gpifbus;
247
 
248
end structure;

powered by: WebSVN 2.1.0

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