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

Subversion Repositories gecko3

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

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 18 nussgipfel
--------------------------------------------------------------------------------
26 14 nussgipfel
--
27
--  Author: Christoph Zimmermann
28
--  Date of creation: 8. April 2009
29
--  Description:
30 18 nussgipfel
--    First test scenario for the GECKO3com IP core. 
31
--    This module (to be implemented as top module) is used to test the
32 14 nussgipfel
--    low-level communication between the GPIF from the EZ-USB and the FPGA.
33
--    For this, it instantiates the the gpif_com module, reads all the 
34
--    received data from the FIFO (and puts them to nowhere) and writes a pre
35
--    defined USB TMC response packet to the send FIFO.
36
--
37
--    If you would like to change the USB TMC response, you have to change the 
38
--    ROM content in this file (don't forget to adjust the the transfer size 
39
--    field AND the counter limit).
40
--
41 18 nussgipfel
--  Target Devices:     Xilinx Spartan3 FPGA's (usage of BlockRam in the
42
--                      Datapath)
43
--  Tool versions:      11.1
44 14 nussgipfel
--  Dependencies:
45
--
46 18 nussgipfel
--------------------------------------------------------------------------------
47 14 nussgipfel
 
48 11 nussgipfel
library ieee;
49
use ieee.std_logic_1164.all;
50 18 nussgipfel
use ieee.std_logic_unsigned.all;
51 11 nussgipfel
 
52
library work;
53 14 nussgipfel
use work.GECKO3COM_defines.all;
54 11 nussgipfel
 
55 14 nussgipfel
entity gpif_com_test is
56 11 nussgipfel
  port (
57 18 nussgipfel
    i_nReset   : in    std_logic;
58
    i_IFCLK    : in    std_logic;       -- GPIF CLK (GPIF is Master and provides the clock)
59
    i_SYSCLK   : in    std_logic;       -- FPGA System CLK
60
    i_WRU      : in    std_logic;       -- write from GPIF
61
    i_RDYU     : in    std_logic;       -- GPIF is ready
62
    o_WRX      : out   std_logic;       -- To write to GPIF
63
    o_RDYX     : out   std_logic;       -- IP Core is ready
64
    b_gpif_bus : inout std_logic_vector(SIZE_DBUS_GPIF-1 downto 0);  -- bidirect data bus
65
    o_LEDrx    : out   std_logic;       -- controll LED rx
66
    o_LEDtx    : out   std_logic;       -- controll LED tx
67
    o_LEDrun   : out   std_logic;       -- controll LED running signalisation
68
    o_dummy    : out   std_logic        -- dummy output for RX data consumer
69
    );
70 14 nussgipfel
end gpif_com_test;
71 11 nussgipfel
 
72
 
73
 
74 18 nussgipfel
architecture behaviour of gpif_com_test is
75 11 nussgipfel
 
76
 
77
  -----------------------------------------------------------------------------
78
  -- controll bus
79
  -----------------------------------------------------------------------------
80 18 nussgipfel
  signal s_EMPTY, s_FULL : std_logic;
81
  signal s_RX_DATA : std_logic_vector(SIZE_DBUS_GPIF-1 downto 0);
82
  signal s_RD_EN, s_WR_EN : std_logic;
83
  signal s_TX_DATA : std_logic_vector(SIZE_DBUS_GPIF-1 downto 0);
84
  signal s_RDYX : std_logic;
85
 
86
  signal s_ABORT, s_ABORT_TMP : std_logic;
87 11 nussgipfel
 
88 18 nussgipfel
  signal s_RX_DATA_TMP : std_logic_vector(SIZE_DBUS_GPIF-1 downto 0);
89
  signal s_EMPTY_TMP, s_FULL_TMP : std_logic;
90 11 nussgipfel
 
91 18 nussgipfel
  signal s_rom_adress : std_logic_vector(4 downto 0);
92
 
93
 
94
  ----------------------------------------------------------------------------- 
95 14 nussgipfel
  --     COMPONENTS  
96 18 nussgipfel
  -----------------------------------------------------------------------------
97
 
98 14 nussgipfel
  component gpif_com
99 18 nussgipfel
    port (
100
      i_nReset   : in    std_logic;
101
      i_SYSCLK   : in    std_logic;
102
      o_ABORT    : out   std_logic;
103
      o_RX       : out   std_logic;
104
      o_TX       : out   std_logic;
105
      i_RD_EN    : in    std_logic;
106
      o_EMPTY    : out   std_logic;
107
      o_RX_DATA  : out   std_logic_vector(SIZE_DBUS_GPIF-1 downto 0);
108
      i_WR_EN    : in    std_logic;
109
      o_FULL     : out   std_logic;
110
      i_TX_DATA  : in    std_logic_vector(SIZE_DBUS_GPIF-1 downto 0);
111
      i_IFCLK    : in    std_logic;
112
      i_WRU      : in    std_logic;
113
      i_RDYU     : in    std_logic;
114
      o_WRX      : out   std_logic;
115
      o_RDYX     : out   std_logic;
116
      b_gpif_bus : inout std_logic_vector(SIZE_DBUS_GPIF-1 downto 0));
117
  end component;
118 11 nussgipfel
 
119 18 nussgipfel
  component message_rom
120
    port (
121
      A : in  std_logic_vector(4 downto 0);
122
      D : out std_logic_vector(15 downto 0));
123
  end component;
124 11 nussgipfel
 
125 18 nussgipfel
begin  -- behaviour
126 11 nussgipfel
 
127 18 nussgipfel
  GPIF_INTERFACE: gpif_com
128
    port map (
129
      i_nReset   => i_nReset,
130
      i_SYSCLK   => i_SYSCLK,
131
      o_ABORT    => s_ABORT,
132
      o_RX       => o_LEDrx,
133
      o_TX       => o_LEDtx,
134
      i_RD_EN    => s_RD_EN,
135
      o_EMPTY    => s_EMPTY,
136
      o_RX_DATA  => s_RX_DATA,
137
      i_WR_EN    => s_WR_EN,
138
      o_FULL     => s_FULL,
139
      i_TX_DATA  => s_TX_DATA,
140
      --i_IFCLK    => i_SYSCLK,
141
      i_IFCLK    => i_IFCLK,
142
      i_WRU      => i_WRU,
143
      i_RDYU     => i_RDYU,
144
      o_WRX      => o_WRX,
145
      o_RDYX     => o_RDYX,
146
      b_gpif_bus => b_gpif_bus);
147 11 nussgipfel
 
148
 
149 18 nussgipfel
 
150
  o_LEDrun <= '1';
151 11 nussgipfel
 
152 18 nussgipfel
 
153 11 nussgipfel
  -----------------------------------------------------------------------------
154 18 nussgipfel
  --     RX DATA CONSUMER WITH THROTLING  
155
  -----------------------------------------------------------------------------
156 11 nussgipfel
 
157 18 nussgipfel
  -- purpose: activates the read enable signal of the receive FIFO as slow as
158
  -- you want.
159
  -- type   : sequential
160
  -- inputs : i_SYSCLK
161
  -- outputs: s_RX_DATA_TMP
162
  rx_throtling: process (i_SYSCLK, i_nReset)
163
    variable v_rx_throtle_count : std_logic_vector(6 downto 0);  -- counter variable
164
  begin
165
    if i_nReset = '0' then
166
      v_rx_throtle_count := (others => '0');
167
      s_RD_EN <= '0';
168
    elsif i_SYSCLK = '1' and i_SYSCLK'event then
169
      if v_rx_throtle_count >= 63 then
170
        s_RD_EN <= '1';
171
        v_rx_throtle_count := (others => '0');
172
      else
173
        v_rx_throtle_count := v_rx_throtle_count + 1;
174
        s_RD_EN <= '0';
175
      end if;
176
    end if;
177
  end process rx_throtling;
178 11 nussgipfel
 
179 18 nussgipfel
  -- purpose: reads the receive data from the GPIF interface
180
  -- type   : sequential
181
  -- inputs : i_SYSCLK
182
  -- outputs: s_RX_DATA_TMP
183
  rx_consumer: process (i_SYSCLK)
184
  begin  -- process rx_consumer
185
    if i_SYSCLK = '1' and i_SYSCLK'event then
186
      s_RX_DATA_TMP <= s_RX_DATA;
187
      s_EMPTY_TMP <= s_EMPTY;
188
      s_FULL_TMP <= s_FULL;
189
      s_ABORT_TMP <= s_ABORT;
190
    end if;
191
  end process rx_consumer;
192 11 nussgipfel
 
193
 
194 18 nussgipfel
  -- dummy logic to "use" these signals and avoid that they are removed by
195
  -- the optimizer
196
  process(s_RX_DATA_TMP, s_EMPTY_TMP, s_FULL_TMP, s_ABORT_TMP, s_RDYX)
197
    variable result : std_logic := '0';
198
  begin
199
    result := '0';
200
    for i in s_RX_DATA_TMP'range loop
201
      result := result or s_RX_DATA_TMP(i);
202
    end loop;
203
    o_dummy <= result or s_EMPTY_TMP or s_FULL_TMP or s_ABORT_TMP;
204
  end process;
205 11 nussgipfel
 
206 18 nussgipfel
  -----------------------------------------------------------------------------
207
  --     RESPONSE MESSAGE GENERATOR  
208
  -----------------------------------------------------------------------------
209
 
210
  message_rom_1: message_rom
211
    port map (
212
      A => s_rom_adress,
213
      D => s_TX_DATA);
214
 
215
  -- purpose: counts up the rom adress lines to read out the response message
216
  -- type   : sequential
217
  -- inputs : i_SYSCLK
218
  -- outputs: s_RX_DATA_TMP
219
  rom_adress_counter: process (i_SYSCLK, i_nReset)
220
  begin
221
    if i_nReset = '0' then
222
      s_rom_adress <= (others => '0');
223
      --DEBUG s_WR_EN <= '1';
224
      s_WR_EN <= '0';
225
    elsif i_SYSCLK = '1' and i_SYSCLK'event then
226
      if s_rom_adress = 24 then
227
        s_rom_adress <= s_rom_adress;
228
        s_WR_EN <= '0';
229
      else
230
        s_rom_adress <= s_rom_adress + 1;
231
        --DEBUG s_WR_EN <= '1';
232
        s_WR_EN <= '0';
233 11 nussgipfel
      end if;
234 18 nussgipfel
    end if;
235
  end process rom_adress_counter;
236
 
237
end behaviour;

powered by: WebSVN 2.1.0

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