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 11

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

Line No. Rev Author Line
1 11 nussgipfel
library ieee;
2
use ieee.std_logic_1164.all;
3
use ieee.std_logic_arith.all;
4
 
5
library work;
6
use work.USB_TMC_func.all;
7
use work.USB_TMC_IP_Defs.all;
8
use work.USB_TMC_cmp.all;
9
 
10
 
11
entity USB_TMC_IP is
12
  port (
13
    i_nReset,
14
    i_IFCLK,                                                                     -- GPIF CLK (is Master)
15
         i_SYSCLK,                                                                       -- FPGA System CLK
16
    i_WRU,                              -- write from GPIF
17
    i_RDYU        : in          std_logic;        -- GPIF is ready
18
--       i_ENAIP          : in          std_logic;               -- enable the IP core
19
--       i_RDYD2IP : in         std_logic;                       -- data RDY 2 the IP core   
20
--       i_d2USB   : in         std_logic_vector(SIZE_DBUS_FPGA-1 downto 0);  -- FPGA DBUS
21
--       i_RxD    : in          std_logic;
22
--       o_TxD     : out                std_logic;
23
--       i_Switches: in         std_logic_vector(NUMBER_OF_SW-1 downto 0);
24
    o_WRX,                              -- To write to GPIF
25
    o_RDYX    : out     std_logic;      -- Core is ready
26
--       o_RDYIP   : out        std_logic;               -- IP ready FPGA site
27
--       o_DAVIP   : out        std_logic;               -- Data available for FPGA
28
         o_LEDrx,                            -- controll LED rx __DEB_INFO__
29
         o_LEDtx : out          std_logic;               -- controll LED tx __DEB_INFO__
30
         o_LEDrun  : out        std_logic;      -- controll LED running signalisation __DEB_INFO__
31
--       o_d2FPGA  : out        std_logic_vector(SIZE_DBUS_FPGA-1 downto 0);  -- FPGA DBUS
32
    b_dbus        : inout       std_logic_vector(SIZE_DBUS_GPIF-1 downto 0));  -- bidirect data bus
33
end USB_TMC_IP;
34
 
35
 
36
 
37
architecture top_core of USB_TMC_IP is
38
 
39
 
40
  -- interconection signals
41
 
42
  signal s_FIFOrst           : std_logic;
43
 
44
     -- U2X
45
  signal s_U2X_FIFO_WR_EN,
46
         s_U2X_FIFO_RD_EN,
47
         s_U2X_FULL,
48
         s_U2X_AM_FULL,
49
         s_U2X_EMPTY,
50
         s_U2X_AM_EMPTY : std_logic;
51
 
52
     -- X2U
53
  signal s_X2U_FIFO_WR_EN,
54
         s_X2U_FIFO_RD_EN,
55
         s_X2U_FULL,
56
         s_X2U_AM_FULL,
57
         s_X2U_EMPTY,
58
         s_X2U_AM_EMPTY : std_logic;
59
 
60
        -- data signals
61
        signal s_X2U_FIFO_dbus_out : std_logic_vector(SIZE_DBUS_GPIF-1 downto 0);
62
 
63
 
64
  -------------------------------------------------------------------------------
65
  -- data bus
66
  -------------------------------------------------------------------------------
67
 
68
  -- data signals
69
        signal s_dbus_in  : std_logic_vector(SIZE_DBUS_GPIF-1 downto 0);
70
        signal s_dbus_out : std_logic_vector(SIZE_DBUS_GPIF-1 downto 0);
71
 
72
        signal s_opb_in : std_logic_vector(SIZE_DBUS_FPGA-1 downto 0);
73
        signal s_opb_out        : std_logic_vector(SIZE_DBUS_FPGA-1 downto 0);
74
 
75
 
76
  -------------------------------------------------------------------------------
77
  -- USBTMC
78
  -------------------------------------------------------------------------------
79
 
80
        type tHeaderRegAccess is (EOT,SET);
81
 
82
        signal s_U2X_HeaderReg,
83
          s_X2U_HeaderReg                : tHeaderReg;
84
 
85
        signal s_U2X_setHeader,
86
          s_X2U_setHeader     : tHeaderRegAccess;
87
 
88
 
89
        signal s_U2X_extracted     : std_logic;
90
 
91
        -- header extraction
92
        signal s_U2X_WR_EN,
93
--        s_X2U_WR_EN,
94
--                       s_U2X_RD_EN,
95
          s_X2U_RD_EN          : std_logic;
96
 
97
 
98
 
99
--  -------------------------------------------------------------------------------
100
--  -- UART 
101
--  -------------------------------------------------------------------------------
102
--      signal s_UART_RD        : std_logic;
103
--      signal s_UART_WR        : std_logic;
104
--      signal s_CS                     : std_logic;
105
--      signal s_uart_data: std_logic_vector(BYTE-1 downto 0);
106
 
107
 
108
 
109
  -----------------------------------------------------------------------------
110
  -- COMPONENTS
111
  -----------------------------------------------------------------------------
112
 
113
--COMPONENT miniUART
114
--  port (
115
--     SysClk   : in  Std_Logic;  -- System Clock
116
--     Reset    : in  Std_Logic;  -- Reset input
117
--     CS_N     : in  Std_Logic;
118
--     RD_N     : in  Std_Logic;
119
--     WR_N     : in  Std_Logic;
120
--     RxD      : in  Std_Logic;
121
--     TxD      : out Std_Logic;
122
--     IntRx_N  : out Std_Logic;  -- Receive interrupt
123
--     IntTx_N  : out Std_Logic;  -- Transmit interrupt
124
--     Addr     : in  Std_Logic_Vector(1 downto 0); -- 
125
--     DataIn   : in  Std_Logic_Vector(7 downto 0); -- 
126
--     DataOut  : out Std_Logic_Vector(7 downto 0)); -- 
127
--end COMPONENT miniUART;
128
 
129
 
130
begin
131
 
132
  -----------------------------------------------------------------------------
133
  -- Port map
134
  -----------------------------------------------------------------------------
135
 
136
F_IN : fifo_U2X_2C_1024B
137
                port map (
138
                        din          => s_dbus_in,
139
                        rd_clk       => i_SYSCLK,
140
                        rd_en        => s_U2X_FIFO_RD_EN,
141
                        rst          => s_FIFOrst,
142
                        wr_clk       => i_IFCLK ,
143
                        wr_en        => s_U2X_FIFO_WR_EN,
144
                        almost_empty => s_U2X_AM_EMPTY,
145
                        almost_full  => s_U2X_AM_FULL,
146
                        dout         => s_opb_in,
147
                        empty        => s_U2X_EMPTY,
148
                        full         => s_U2X_FULL
149
                        );
150
 
151
 
152
F_OUT : fifo_X2U_2C_1024B
153
                port map (
154
                        din          => s_opb_out,
155
                        rd_clk       => i_IFCLK,
156
                        rd_en        => s_X2U_FIFO_RD_EN,
157
                        rst          => s_FIFOrst,
158
                        wr_clk       => i_SYSCLK,
159
                        wr_en        => s_X2U_FIFO_WR_EN,
160
                        almost_empty => s_X2U_AM_EMPTY,
161
                        almost_full  => s_X2U_AM_FULL,
162
                        dout         => s_X2U_FIFO_dbus_out,
163
                        empty        => s_X2U_EMPTY,
164
                        full         => s_X2U_FULL
165
                        );
166
 
167
FSM_GPIF : gpif_com
168
                                port map (
169
                                        i_nReset                        => i_nReset,
170
                                        i_IFCLK                 =>      i_IFCLK,
171
                                        i_WRU                           => i_WRU,
172
                                        i_RDYU                  => i_RDYU,
173
                                        i_U2X_FULL              => s_U2X_FULL,
174
                                        i_U2X_AM_FULL   => s_U2X_AM_FULL,
175
                                        i_X2U_AM_EMPTY  => s_X2U_AM_EMPTY,
176
                                        i_X2U_EMPTY             => s_X2U_EMPTY,
177
                                        i_dbus                  => s_dbus_out,       -- data from the FPGA usr dep application
178
                                        o_U2X_WR_EN             => s_U2X_WR_EN,      -- wr ena for in fifo
179
                                        o_X2U_RD_EN             => s_X2U_RD_EN,      -- rd ena for out fifo
180
                                        o_FIFOrst               => s_FIFOrst,        -- abord dedection to rst the fifo's
181
                                        o_WRX                           => o_WRX,
182
                                        o_RDYX                  => o_RDYX,
183
                                        o_LEDrx                    => o_LEDrx,
184
                                        o_LEDtx                    => o_LEDtx,
185
                                        o_LEDrun                => o_LEDrun,
186
                                        o_dbus                  => s_dbus_in,        -- data from the GPIF 
187
                                        b_dbus                  => b_dbus
188
                                );
189
 
190
 
191
Loopback : USB_TMC_IP_loopback
192
                port map (
193
                        i_nReset                        => i_nReset,
194
                        i_SYSCLK                        => i_SYSCLK,                                                                     -- FPGA System CLK
195
                        i_U2X_EMPTY             => s_U2X_EMPTY,
196
                        i_U2X_AM_EMPTY     => s_U2X_AM_EMPTY,
197
                        i_X2U_AM_FULL      => s_X2U_AM_FULL,
198
                        i_X2U_FULL                 => s_X2U_FULL,
199
                        i_U2X_DATA                 => s_opb_in,
200
                        o_X2U_DATA        => s_opb_out,
201
                        o_U2X_RD_EN             => s_U2X_FIFO_RD_EN,
202
                        o_X2U_WR_EN             => s_X2U_FIFO_WR_EN
203
                );
204
 
205
 
206
 
207
MAP_U2X_Data : process(i_nReset, i_IFCLK)
208
        variable count : integer range 0 to 7;
209
        begin
210
        if ( i_nReset = '0') then
211
         count := 0;
212
         s_U2X_FIFO_WR_EN <= '0';
213
         s_U2X_extracted  <= '0';
214
         rst_header_Reg(s_U2X_HeaderReg);
215
 
216
        elsif rising_edge(i_IFCLK) then
217
                if (s_U2X_setHeader = EOT ) then
218
                        count := 0;
219
                        s_U2X_FIFO_WR_EN <= '0';
220
                        s_U2X_extracted  <= '0';
221
                else
222
                  if count < HEAD_EXT_VAL then
223
                         wr_header_Reg_element(count,s_dbus_in,s_U2X_HeaderReg);
224
                    count := count+1;
225
                         s_U2X_FIFO_WR_EN <= '0';
226
                  else
227
                    s_U2X_FIFO_WR_EN <= s_U2X_WR_EN;
228
                         s_U2X_extracted  <= '1';
229
                  end if;
230
           end if;
231
        end if;
232
end process MAP_U2X_Data;
233
 
234
 
235
 
236
--
237
--MAP_U2X_Data : process(i_nReset, i_IFCLK)
238
--      variable count integer range 0 to 7;
239
--      begin
240
--      if ( i_nReset = '0') then
241
--       s_U2X_HeaderReg <= (others => '0');
242
--       count := 0;
243
--       s_U2X_FIFO_WR_EN <= '0';
244
--       s_U2X_extracted  <= '0';
245
--       
246
--      elsif rising_edge(i_IFCLK) then
247
--              if (s_U2X_setHeader = EOT ) then
248
--                      count := '0';
249
--                      s_U2X_FIFO_WR_EN <= '0';
250
--                      s_U2X_extracted  <= '0';
251
--              else
252
--                if count < HEAD_EXT_VAL then
253
--                  s_U2X_HeaderReg(2*count)     <= s_dbus_in(BYTE-1 downto 0);
254
--                  s_U2X_HeaderReg((2*count)+1) <= s_dbus_in((2*BYTE)-1 downto BYTE); 
255
--                  count := count+1;
256
--                       s_U2X_FIFO_WR_EN <= '0';
257
--                else
258
--                  s_U2X_FIFO_WR_EN <= s_U2X_WR_EN;
259
--                       s_U2X_extracted  <= '1';
260
--                end if;
261
--         end if;
262
--      end if;
263
--end process MAP_U2X_Data;
264
 
265
 
266
MAP_X2U_Data : process(i_nReset, i_SYSCLK)
267
        variable count : integer range 0 to 7;
268
        begin
269
        if ( i_nReset = '0') then
270
         count := 0;
271
         s_X2U_FIFO_RD_EN <= '0';
272
 
273
        elsif rising_edge(i_IFCLK) then
274
                if (s_X2U_setHeader = EOT ) then
275
                        count := 0;
276
                        s_X2U_FIFO_RD_EN <= '0';
277
                else
278
                  if count < HEAD_EXT_VAL then
279
                  rd_header_Reg_element(count,s_X2U_HeaderReg,s_dbus_out);
280
                    count := count+1;
281
                         s_X2U_FIFO_RD_EN <= '0';
282
                  else
283
                    s_X2U_FIFO_RD_EN <= s_X2U_RD_EN;
284
                         s_dbus_out <= s_X2U_FIFO_dbus_out;
285
                  end if;
286
           end if;
287
        end if;
288
 
289
end process MAP_X2U_Data;
290
 
291
 
292
 
293
--
294
--uart : miniUART
295
--                      port map (
296
--                      SysClk  => i_SYSCLK,
297
--                      Reset   => i_nReset,
298
--                      CS_N    => s_CS,
299
--                      RD_N    => s_UART_RD,
300
--                      WR_N    => s_UART_WR,
301
--                      RxD     => i_RxD,
302
--                      TxD      => o_TxD,
303
--                      IntRx_N  => open,
304
--                      IntTx_N  => open,
305
--                      Addr     => "00",
306
--                      DataIn   => (others => 'Z'),
307
--                      DataOut  => s_uart_data
308
--                      );          
309
 
310
 
311
 
312
 
313
end top_core;

powered by: WebSVN 2.1.0

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