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 14

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: Christoph Zimmermann
28
--  Date of creation: 8. April 2009
29
--  Description:
30
--      First test scenario for the GECKO3com IP core. 
31
--              This module (to be implemented as top module) is used to test the
32
--    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
--  Target Devices:     Xilinx Spartan3 FPGA's (usage of BlockRam in the Datapath)
42
--  Tool versions:      11.1
43
--  Dependencies:
44
--
45
----------------------------------------------------------------------------------
46
 
47 11 nussgipfel
library ieee;
48
use ieee.std_logic_1164.all;
49
 
50
library work;
51 14 nussgipfel
use work.GECKO3COM_defines.all;
52 11 nussgipfel
 
53 14 nussgipfel
entity gpif_com_test is
54 11 nussgipfel
  port (
55
    i_nReset,
56 14 nussgipfel
    i_IFCLK,                                                                     -- GPIF CLK (GPIF is Master and provides the clock)
57
    i_SYSCLK,                                                                    -- FPGA System CLK
58
    i_WRU,                              -- write from GPIF
59
    i_RDYU        : in          std_logic;        -- GPIF is ready
60
    o_WRX,                              -- To write to GPIF
61
    o_RDYX    : out     std_logic;      -- IP Core is ready
62
    o_LEDrx,                            -- controll LED rx
63
    o_LEDtx : out               std_logic;               -- controll LED tx
64
    o_LEDrun  : out     std_logic;      -- controll LED running signalisation
65
    b_gpif_bus    : inout       std_logic_vector(SIZE_DBUS_GPIF-1 downto 0));  -- bidirect data bus
66 11 nussgipfel
        );
67 14 nussgipfel
end gpif_com_test;
68 11 nussgipfel
 
69
 
70
 
71 14 nussgipfel
architecture loopback of gpif_com_test is
72 11 nussgipfel
 
73
 
74
  type t_fsmLoop is (rst, idle, writeRQ, writeIn, writeEnd);
75
 
76
  signal pr_stateLoop, nx_stateLoop : t_fsmLoop;
77 14 nussgipfel
 
78
  signal  i_U2X_AM_EMPTY,
79
          i_U2X_EMPTY,
80
          i_X2U_AM_FULL,
81
          i_X2U_FULL        : in  std_logic;
82
        signal  i_U2X_DATA     : in  std_logic_vector(SIZE_DBUS_FPGA-1 downto 0);
83
        signal  o_U2X_RD_EN,
84
          o_X2U_WR_EN    : out std_logic;
85
  signal  o_X2U_DATA     : out std_logic_vector(SIZE_DBUS_FPGA-1 downto 0)
86 11 nussgipfel
 
87
  -----------------------------------------------------------------------------
88
  -- controll bus
89
  -----------------------------------------------------------------------------
90
         signal s_U2X_RD_EN,
91
                                s_X2U_WR_EN : std_logic;
92
 
93
 
94 14 nussgipfel
  --------------------------------------------------------------------------------- 
95
  --     COMPONENTS  
96
  ---------------------------------------------------------------------------------
97
 
98
  component gpif_com
99
  port (
100
    i_nReset,
101
    i_IFCLK,                                                                     -- GPIF CLK (GPIF is Master and provides the clock)
102
    i_SYSCLK,                                                                    -- FPGA System CLK
103
    i_WRU,                              -- write from GPIF
104
    i_RDYU        : in          std_logic;        -- GPIF is ready
105
    o_WRX,                              -- To write to GPIF
106
    o_RDYX    : out     std_logic;      -- IP Core is ready
107
    o_ABORT   : out   std_logic;  -- Abort detected, you have to flush the data
108
    o_RX,                            -- controll LED rx
109
    o_TX : out          std_logic;               -- controll LED tx
110
    b_gpif_bus    : inout       std_logic_vector(SIZE_DBUS_GPIF-1 downto 0));  -- bidirect data bus
111
  end USB_TMC_IP;
112
 
113 11 nussgipfel
begin
114
 
115
         o_U2X_RD_EN  <=  s_U2X_RD_EN;
116
         o_X2U_WR_EN  <=  s_X2U_WR_EN;
117 14 nussgipfel
 
118
   o_LEDrun <= '1';
119
 
120
 
121
   GPIF_INTERFACE : gpif_com
122
   port map (
123
    i_nReset    =>  i_nReset,
124
    i_IFCLK     =>  i_IFCLK,                                                                     -- GPIF CLK (GPIF is Master and provides the clock)
125
    i_SYSCLK    =>  i_SYSCLK,                                                                    -- FPGA System CLK
126
    i_WRU       =>  i_WRU,                              -- write from GPIF
127
    i_RDYU      =>  i_RDYU,        -- GPIF is ready
128
    o_WRX       =>  o_WRX,                              -- To write to GPIF
129
    o_RDYX      =>  o_RDYX,      -- IP Core is ready
130
    o_ABORT     =>  o_ABORT,  -- Abort detected, you have to flush the data
131
    o_LEDrx     =>  o_LEDrx,                            -- controll LED rx
132
    o_LEDtx     =>  o_LEDtx,             -- controll LED tx
133
    o_LEDrun    =>  o_LEDrun,      -- controll LED running signalisation
134
    b_gpif_bus  =>  b_gpif_buf
135
   );
136 11 nussgipfel
 
137
    ---------------------------------------------------------------------------
138
    -- FPGA CLK DOMAIN -> opb site
139
    ---------------------------------------------------------------------------
140
 
141
  bus_loop_Dmap : process (i_SYSCLK)
142
 
143
  begin  -- process bus_access
144
    if rising_edge(i_SYSCLK) then
145
          o_X2U_DATA <= i_U2X_DATA;
146
    end if;
147
  end process bus_loop_Dmap;
148
 
149
 
150
 -----------------------------------------------------------------------------
151
  -- FSM Loop
152
  -----------------------------------------------------------------------------
153
 
154
    -- state reg
155
  actionLoop : process(i_SYSCLK, i_nReset)
156
    begin
157
 
158
      if i_nReset = '0' then
159
        pr_stateLoop <= rst;
160
 
161
      elsif rising_edge(i_SYSCLK) then
162
 
163
                  pr_stateLoop <= nx_stateLoop;
164
 
165
      end if;
166
    end process actionLoop;
167
 
168
 
169
    -- comb logic
170
    loopTrans : process(pr_stateLoop, i_U2X_AM_EMPTY, i_U2X_EMPTY, i_X2U_AM_FULL )
171
    begin  -- process transaction
172
 
173
            -- default signal sets to avoid latches
174
                         s_X2U_WR_EN <= '0';
175
          s_U2X_RD_EN <= '0';
176
 
177
      case pr_stateLoop is
178
        -- controll
179
 
180
        when rst =>
181
                         s_X2U_WR_EN <= '0';
182
          s_U2X_RD_EN <= '0';
183
          nx_stateLoop <= idle;
184
 
185
        when idle =>
186 14 nussgipfel
                   -- when the input fifo has data (is not empty) and the output fifo is not full:
187 11 nussgipfel
                        if i_U2X_AM_EMPTY = '0' and i_X2U_AM_FULL = '0' then
188
                          nx_stateLoop <= writeRQ;
189 12 nussgipfel
                          s_U2X_RD_EN <= '1';
190 11 nussgipfel
                        else
191
                          nx_stateLoop <= idle;
192
        end if;
193
 
194
        when writeRQ =>
195 14 nussgipfel
                    -- enable read from input fifo. wait one cycle untill the data is available to be written
196 11 nussgipfel
          s_U2X_RD_EN <= '1';
197
                         s_X2U_WR_EN <= '0';
198
                         nx_stateLoop <= writeIn;
199
 
200
                  when writeIn =>
201
 
202
                         if i_U2X_EMPTY = '1' and i_X2U_AM_FULL = '0' then
203 14 nussgipfel
                              -- input fifo is empty, end the transfer
204 11 nussgipfel
                                        nx_stateLoop <= writeEnd;
205 14 nussgipfel
                                        s_U2X_RD_EN <= '1'; -- i guess that this should be '0' here. zac1
206 11 nussgipfel
                                        s_X2U_WR_EN <= '1';
207
 
208
                         elsif i_U2X_EMPTY = '0' and i_X2U_AM_FULL = '1' then
209 14 nussgipfel
                              -- output data is full, still data in the input fifo
210 11 nussgipfel
                                        nx_stateLoop <= writeEnd;
211
                                        s_U2X_RD_EN <= '0';
212
                                        s_X2U_WR_EN <= '1';
213
 
214
                         elsif i_U2X_EMPTY = '1' and i_X2U_AM_FULL = '1' then
215 14 nussgipfel
                                        -- input fifo empty and output fifo full
216 11 nussgipfel
                                        nx_stateLoop <= writeEnd; --idle;
217
                                        s_U2X_RD_EN <= '0';
218
                                        s_X2U_WR_EN <= '1'; ---s_X2U_WR_EN <= '0';
219
 
220
                          else
221 14 nussgipfel
                              -- input fifo has data, output fifo has free space
222 11 nussgipfel
                              nx_stateLoop <= writeIn;
223
                                        s_X2U_WR_EN <= '1';
224
                                        s_U2X_RD_EN <= '1';
225
                         end if;
226
 
227
 
228
                  when writeEnd =>
229 14 nussgipfel
                      -- copy the last data from the register to the output fifo
230 11 nussgipfel
                                nx_stateLoop <= idle;
231
                                s_U2X_RD_EN <= '0';
232 12 nussgipfel
                                s_X2U_WR_EN <= '1';
233 11 nussgipfel
 
234
 
235
        -- error case
236
        when others =>
237
          nx_stateLoop <= idle;
238
      end case;
239
 
240
    end process loopTrans;
241
 
242
end loopback;

powered by: WebSVN 2.1.0

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