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 27

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 20 nussgipfel
  signal s_RD_EN, s_WR_EN, s_EOM : std_logic;
83 18 nussgipfel
  signal s_TX_DATA : std_logic_vector(SIZE_DBUS_GPIF-1 downto 0);
84
 
85
  signal s_ABORT, s_ABORT_TMP : std_logic;
86 11 nussgipfel
 
87 18 nussgipfel
  signal s_RX_DATA_TMP : std_logic_vector(SIZE_DBUS_GPIF-1 downto 0);
88
  signal s_EMPTY_TMP, s_FULL_TMP : std_logic;
89 11 nussgipfel
 
90 18 nussgipfel
  signal s_rom_adress : std_logic_vector(4 downto 0);
91
 
92
 
93
  ----------------------------------------------------------------------------- 
94 14 nussgipfel
  --     COMPONENTS  
95 18 nussgipfel
  -----------------------------------------------------------------------------
96
 
97 14 nussgipfel
  component gpif_com
98 18 nussgipfel
    port (
99
      i_nReset   : in    std_logic;
100
      i_SYSCLK   : in    std_logic;
101
      o_ABORT    : out   std_logic;
102
      o_RX       : out   std_logic;
103
      o_TX       : out   std_logic;
104
      i_RD_EN    : in    std_logic;
105
      o_EMPTY    : out   std_logic;
106
      o_RX_DATA  : out   std_logic_vector(SIZE_DBUS_GPIF-1 downto 0);
107 20 nussgipfel
      i_EOM      : in    std_logic;
108 18 nussgipfel
      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 20 nussgipfel
      i_EOM      => s_EOM,
138 18 nussgipfel
      i_WR_EN    => s_WR_EN,
139
      o_FULL     => s_FULL,
140
      i_TX_DATA  => s_TX_DATA,
141
      --i_IFCLK    => i_SYSCLK,
142
      i_IFCLK    => i_IFCLK,
143
      i_WRU      => i_WRU,
144
      i_RDYU     => i_RDYU,
145
      o_WRX      => o_WRX,
146
      o_RDYX     => o_RDYX,
147
      b_gpif_bus => b_gpif_bus);
148 11 nussgipfel
 
149
 
150 18 nussgipfel
 
151
  o_LEDrun <= '1';
152 11 nussgipfel
 
153 18 nussgipfel
 
154 11 nussgipfel
  -----------------------------------------------------------------------------
155 18 nussgipfel
  --     RX DATA CONSUMER WITH THROTLING  
156
  -----------------------------------------------------------------------------
157 11 nussgipfel
 
158 18 nussgipfel
  -- purpose: activates the read enable signal of the receive FIFO as slow as
159
  -- you want.
160
  -- type   : sequential
161
  -- inputs : i_SYSCLK
162
  -- outputs: s_RX_DATA_TMP
163
  rx_throtling: process (i_SYSCLK, i_nReset)
164 19 nussgipfel
    -- counter variable
165
    variable v_rx_throtle_count : std_logic_vector(6 downto 0);
166 18 nussgipfel
  begin
167
    if i_nReset = '0' then
168
      v_rx_throtle_count := (others => '0');
169
      s_RD_EN <= '0';
170
    elsif i_SYSCLK = '1' and i_SYSCLK'event then
171 27 nussgipfel
      if v_rx_throtle_count >= 0 and s_EMPTY = '0' then
172 18 nussgipfel
        s_RD_EN <= '1';
173
        v_rx_throtle_count := (others => '0');
174
      else
175
        v_rx_throtle_count := v_rx_throtle_count + 1;
176
        s_RD_EN <= '0';
177
      end if;
178
    end if;
179
  end process rx_throtling;
180 11 nussgipfel
 
181 18 nussgipfel
  -- purpose: reads the receive data from the GPIF interface
182
  -- type   : sequential
183
  -- inputs : i_SYSCLK
184
  -- outputs: s_RX_DATA_TMP
185
  rx_consumer: process (i_SYSCLK)
186
  begin  -- process rx_consumer
187
    if i_SYSCLK = '1' and i_SYSCLK'event then
188
      s_RX_DATA_TMP <= s_RX_DATA;
189
      s_EMPTY_TMP <= s_EMPTY;
190
      s_FULL_TMP <= s_FULL;
191
      s_ABORT_TMP <= s_ABORT;
192
    end if;
193
  end process rx_consumer;
194 11 nussgipfel
 
195
 
196 18 nussgipfel
  -- dummy logic to "use" these signals and avoid that they are removed by
197
  -- the optimizer
198 19 nussgipfel
  process(s_RX_DATA_TMP, s_EMPTY_TMP, s_FULL_TMP, s_ABORT_TMP)
199 18 nussgipfel
    variable result : std_logic := '0';
200
  begin
201
    result := '0';
202
    for i in s_RX_DATA_TMP'range loop
203
      result := result or s_RX_DATA_TMP(i);
204
    end loop;
205
    o_dummy <= result or s_EMPTY_TMP or s_FULL_TMP or s_ABORT_TMP;
206
  end process;
207 11 nussgipfel
 
208 18 nussgipfel
  -----------------------------------------------------------------------------
209
  --     RESPONSE MESSAGE GENERATOR  
210
  -----------------------------------------------------------------------------
211
 
212
  message_rom_1: message_rom
213
    port map (
214
      A => s_rom_adress,
215
      D => s_TX_DATA);
216
 
217
  -- purpose: counts up the rom adress lines to read out the response message
218
  -- type   : sequential
219
  -- inputs : i_SYSCLK
220
  -- outputs: s_RX_DATA_TMP
221
  rom_adress_counter: process (i_SYSCLK, i_nReset)
222
  begin
223
    if i_nReset = '0' then
224
      s_rom_adress <= (others => '0');
225
      s_WR_EN <= '0';
226 20 nussgipfel
      --s_WR_EN <= '0';
227 18 nussgipfel
    elsif i_SYSCLK = '1' and i_SYSCLK'event then
228 24 nussgipfel
      if s_rom_adress = 24 then
229
        s_rom_adress <= s_rom_adress + 1;
230
        s_WR_EN <= '0';
231
        s_EOM <= '1';
232
      elsif s_rom_adress >= 24 then
233 18 nussgipfel
        s_rom_adress <= s_rom_adress;
234
        s_WR_EN <= '0';
235 24 nussgipfel
        s_EOM <= '0';
236 18 nussgipfel
      else
237 20 nussgipfel
        if s_FULL ='0' then
238
          s_rom_adress <= s_rom_adress + 1;
239
          s_WR_EN <= '1';
240
        end if;
241
        s_EOM <= '0';
242 11 nussgipfel
      end if;
243 18 nussgipfel
    end if;
244
  end process rom_adress_counter;
245
 
246
end behaviour;

powered by: WebSVN 2.1.0

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