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

Subversion Repositories mips_enhanced

[/] [mips_enhanced/] [trunk/] [grlib-gpl-1.0.19-b3188/] [lib/] [gaisler/] [spacewire/] [grspw2.vhd] - Blame information for rev 2

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 2 dimamali
------------------------------------------------------------------------------
2
--  This file is a part of the GRLIB VHDL IP LIBRARY
3
--  Copyright (C) 2003, Gaisler Research
4
--
5
--  This program is free software; you can redistribute it and/or modify
6
--  it under the terms of the GNU General Public License as published by
7
--  the Free Software Foundation; either version 2 of the License, or
8
--  (at your option) any later version.
9
--
10
--  This program is distributed in the hope that it will be useful,
11
--  but WITHOUT ANY WARRANTY; without even the implied warranty of
12
--  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13
--  GNU General Public License for more details.
14
--
15
--  You should have received a copy of the GNU General Public License
16
--  along with this program; if not, write to the Free Software
17
--  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA 
18
-----------------------------------------------------------------------------
19
-- Entity:      grspw2
20
-- File:        grspw2.vhd
21
-- Author:      Marko Isomaki - Gaisler Research 
22
-- Description: GRLIB wrapper for grspw core
23
------------------------------------------------------------------------------
24
library ieee;
25
use ieee.std_logic_1164.all;
26
library grlib;
27
use grlib.amba.all;
28
library techmap;
29
use techmap.gencomp.all;
30
use grlib.stdlib.all;
31
use grlib.devices.all;
32
library gaisler;
33
use gaisler.spacewire.all;
34
library spw;
35
use spw.spwcomp.all;
36
 
37
entity grspw2 is
38
  generic(
39
    tech         : integer range 0 to NTECH     := inferred;
40
    hindex       : integer range 0 to NAHBMST-1 := 0;
41
    pindex       : integer range 0 to NAPBSLV-1 := 0;
42
    paddr        : integer range 0 to 16#FFF#   := 0;
43
    pmask        : integer range 0 to 16#FFF#   := 16#FFF#;
44
    pirq         : integer range 0 to NAHBIRQ-1 := 0;
45
    nsync        : integer range 1 to 2  := 1;
46
    rmap         : integer range 0 to 1  := 0;
47
    rmapcrc      : integer range 0 to 1  := 0;
48
    fifosize1    : integer range 4 to 32 := 32;
49
    fifosize2    : integer range 16 to 64 := 64;
50
    rxclkbuftype : integer range 0 to 2 := 0;
51
    rxunaligned  : integer range 0 to 1 := 0;
52
    rmapbufs     : integer range 2 to 8 := 4;
53
    ft           : integer range 0 to 2 := 0;
54
    scantest     : integer range 0 to 1 := 0;
55
    techfifo     : integer range 0 to 1 := 1;
56
    ports        : integer range 1 to 2 := 1;
57
    dmachan      : integer range 1 to 4 := 1;
58
    memtech      : integer range 0 to NTECH := DEFMEMTECH
59
  );
60
  port(
61
    rst        : in  std_ulogic;
62
    clk        : in  std_ulogic;
63
    txclk      : in  std_ulogic;
64
    ahbmi      : in  ahb_mst_in_type;
65
    ahbmo      : out ahb_mst_out_type;
66
    apbi       : in  apb_slv_in_type;
67
    apbo       : out apb_slv_out_type;
68
    swni       : in  grspw_in_type;
69
    swno       : out grspw_out_type
70
  );
71
end entity;
72
 
73
architecture rtl of grspw2 is
74
  constant fabits1      : integer := log2(fifosize1);
75
  constant fabits2      : integer := log2(fifosize2);
76
  constant rfifo        : integer := 5 + log2(rmapbufs);
77
  constant REVISION     : integer := 0;
78
  constant pconfig      : apb_config_type := (
79
 
80
    1 => apb_iobar(paddr, pmask));
81
 
82
  constant hconfig : ahb_config_type := (
83
 
84
  others => zero32);
85
 
86
  signal rxclki, nrxclki, rxclko : std_logic_vector(1 downto 0);
87
 
88
  --rx ahb fifo
89
  signal rxrenable    : std_ulogic;
90
  signal rxraddress   : std_logic_vector(4 downto 0);
91
  signal rxwrite      : std_ulogic;
92
  signal rxwdata      : std_logic_vector(31 downto 0);
93
  signal rxwaddress   : std_logic_vector(4 downto 0);
94
  signal rxrdata      : std_logic_vector(31 downto 0);
95
  --tx ahb fifo
96
  signal txrenable    : std_ulogic;
97
  signal txraddress   : std_logic_vector(4 downto 0);
98
  signal txwrite      : std_ulogic;
99
  signal txwdata      : std_logic_vector(31 downto 0);
100
  signal txwaddress   : std_logic_vector(4 downto 0);
101
  signal txrdata      : std_logic_vector(31 downto 0);
102
  --nchar fifo
103
  signal ncrenable    : std_ulogic;
104
  signal ncraddress   : std_logic_vector(5 downto 0);
105
  signal ncwrite      : std_ulogic;
106
  signal ncwdata      : std_logic_vector(8 downto 0);
107
  signal ncwaddress   : std_logic_vector(5 downto 0);
108
  signal ncrdata      : std_logic_vector(8 downto 0);
109
  --rmap buf
110
  signal rmrenable    : std_ulogic;
111
  signal rmraddress   : std_logic_vector(7 downto 0);
112
  signal rmwrite      : std_ulogic;
113
  signal rmwdata      : std_logic_vector(7 downto 0);
114
  signal rmwaddress   : std_logic_vector(7 downto 0);
115
  signal rmrdata      : std_logic_vector(7 downto 0);
116
  --misc
117
  signal irq          : std_ulogic;
118
  signal rxclk, nrxclk : std_logic_vector(ports-1 downto 0);
119
  signal testin        : std_logic_vector(3 downto 0);
120
 
121
begin
122
 
123
  testin <= ahbmi.testen & "000";
124
 
125
  grspwc0 : grspwc2
126
    generic map(
127
      nsync        => nsync,
128
      rmap         => rmap,
129
      rmapcrc      => rmapcrc,
130
      fifosize1    => fifosize1,
131
      fifosize2    => fifosize2,
132
      rxunaligned  => rxunaligned,
133
      rmapbufs     => rmapbufs,
134
      scantest     => scantest,
135
      ports        => ports,
136
      dmachan      => dmachan,
137
      tech         => tech)
138
    port map(
139
      rst          => rst,
140
      clk          => clk,
141
      txclk        => txclk,
142
      --ahb mst in
143
      hgrant       => ahbmi.hgrant(hindex),
144
      hready       => ahbmi.hready,
145
      hresp        => ahbmi.hresp,
146
      hrdata       => ahbmi.hrdata,
147
      --ahb mst out
148
      hbusreq      => ahbmo.hbusreq,
149
      hlock        => ahbmo.hlock,
150
      htrans       => ahbmo.htrans,
151
      haddr        => ahbmo.haddr,
152
      hwrite       => ahbmo.hwrite,
153
      hsize        => ahbmo.hsize,
154
      hburst       => ahbmo.hburst,
155
      hprot        => ahbmo.hprot,
156
      hwdata       => ahbmo.hwdata,
157
      --apb slv in 
158
      psel         => apbi.psel(pindex),
159
      penable      => apbi.penable,
160
      paddr        => apbi.paddr,
161
      pwrite       => apbi.pwrite,
162
      pwdata       => apbi.pwdata,
163
      --apb slv out
164
      prdata       => apbo.prdata,
165
      --spw in
166
      di           => swni.d,
167
      si           => swni.s,
168
      --spw out
169
      do           => swno.d,
170
      so           => swno.s,
171
      --time iface
172
      tickin       => swni.tickin,
173
      tickout      => swno.tickout,
174
      --clk bufs
175
      rxclki       => rxclki,
176
      nrxclki      => nrxclki,
177
      rxclko       => rxclko,
178
      --irq
179
      irq          => irq,
180
      --misc     
181
      clkdiv10     => swni.clkdiv10,
182
      dcrstval     => swni.dcrstval,
183
      timerrstval  => swni.timerrstval,
184
      --rmapen    
185
      rmapen       => swni.rmapen,
186
      --rx ahb fifo
187
      rxrenable    => rxrenable,
188
      rxraddress   => rxraddress,
189
      rxwrite      => rxwrite,
190
      rxwdata      => rxwdata,
191
      rxwaddress   => rxwaddress,
192
      rxrdata      => rxrdata,
193
      --tx ahb fifo
194
      txrenable    => txrenable,
195
      txraddress   => txraddress,
196
      txwrite      => txwrite,
197
      txwdata      => txwdata,
198
      txwaddress   => txwaddress,
199
      txrdata      => txrdata,
200
      --nchar fifo
201
      ncrenable    => ncrenable,
202
      ncraddress   => ncraddress,
203
      ncwrite      => ncwrite,
204
      ncwdata      => ncwdata,
205
      ncwaddress   => ncwaddress,
206
      ncrdata      => ncrdata,
207
      --rmap buf
208
      rmrenable    => rmrenable,
209
      rmraddress   => rmraddress,
210
      rmwrite      => rmwrite,
211
      rmwdata      => rmwdata,
212
      rmwaddress   => rmwaddress,
213
      rmrdata      => rmrdata,
214
      linkdis      => swno.linkdis,
215
      testclk      => clk,
216
      testrst      => ahbmi.testrst,
217
      testen       => ahbmi.testen
218
      );
219
 
220
  irqdrv : process(irq)
221
  begin
222
    apbo.pirq        <= (others => '0');
223
    apbo.pirq(pirq)  <= irq;
224
  end process;
225
 
226
  ahbmo.hirq       <= (others => '0');
227
  ahbmo.hconfig    <= hconfig;
228
  ahbmo.hindex     <= hindex;
229
 
230
  apbo.pconfig <= pconfig;
231
  apbo.pindex  <= pindex;
232
 
233
  ntst: if scantest = 0 generate
234
    cbufloop : for i in 0 to ports-1 generate
235
      rx_clkbuf : techbuf generic map(tech => tech, buftype => rxclkbuftype)
236
      port map(i => rxclko(i), o => rxclki(i));
237
    end generate;
238
  end generate;
239
  tst: if scantest = 1 generate
240
    cloop : for i in 0 to ports-1 generate
241
      rxclk(i) <= clk when ahbmi.testen = '1' else rxclko(i);
242
      nrxclk(i) <= clk when ahbmi.testen = '1' else not rxclko(i);
243
      rx_clkbuf : techbuf generic map(tech => tech, buftype => rxclkbuftype)
244
        port map(i => rxclk(i), o => rxclki(i));
245
      nrx_clkbuf : techbuf generic map(tech => tech, buftype => rxclkbuftype)
246
        port map(i => nrxclk(i), o => nrxclki(i));
247
    end generate;
248
  end generate;
249
 
250
  ------------------------------------------------------------------------------
251
  -- FIFOS ---------------------------------------------------------------------
252
  ------------------------------------------------------------------------------
253
 
254
  nft : if ft = 0 generate
255
    --receiver AHB FIFO
256
    rx_ram0 : syncram_2p generic map(memtech*techfifo, fabits1, 32)
257
    port map(clk, rxrenable, rxraddress(fabits1-1 downto 0),
258
      rxrdata, clk, rxwrite,
259
      rxwaddress(fabits1-1 downto 0), rxwdata, testin);
260
 
261
    --receiver nchar FIFO
262
    rx_ram1 : syncram_2p generic map(memtech*techfifo, fabits2, 9)
263
    port map(clk, ncrenable, ncraddress(fabits2-1 downto 0),
264
      ncrdata, clk, ncwrite,
265
      ncwaddress(fabits2-1 downto 0), ncwdata, testin);
266
 
267
    --transmitter FIFO
268
    tx_ram0 : syncram_2p generic map(memtech*techfifo, fabits1, 32)
269
    port map(clk, txrenable, txraddress(fabits1-1 downto 0),
270
      txrdata, clk, txwrite, txwaddress(fabits1-1 downto 0), txwdata, testin);
271
 
272
    --RMAP Buffer
273
    rmap_ram : if (rmap = 1) generate
274
      ram0 : syncram_2p generic map(memtech, rfifo, 8)
275
      port map(clk, rmrenable, rmraddress(rfifo-1 downto 0),
276
        rmrdata, clk, rmwrite, rmwaddress(rfifo-1 downto 0),
277
        rmwdata, testin);
278
    end generate;
279
  end generate;
280
 
281
  ft1 : if ft /= 0 generate
282
    --receiver AHB FIFO
283
    rx_ram0 : syncram_2pft generic map(memtech*techfifo, fabits1, 32, 0, 0, ft*techfifo)
284
    port map(clk, rxrenable, rxraddress(fabits1-1 downto 0),
285
      rxrdata, clk, rxwrite,
286
      rxwaddress(fabits1-1 downto 0), rxwdata, testin);
287
 
288
    --receiver nchar FIFO
289
    rx_ram1 : syncram_2pft generic map(memtech*techfifo, fabits2, 9, 0, 0, 2*techfifo)
290
    port map(clk, ncrenable, ncraddress(fabits2-1 downto 0),
291
      ncrdata, clk, ncwrite,
292
      ncwaddress(fabits2-1 downto 0), ncwdata, testin);
293
 
294
    --transmitter FIFO
295
    tx_ram0 : syncram_2pft generic map(memtech*techfifo, fabits1, 32, 0, 0, ft*techfifo)
296
    port map(clk, txrenable, txraddress(fabits1-1 downto 0),
297
      txrdata, clk, txwrite, txwaddress(fabits1-1 downto 0), txwdata, testin);
298
 
299
    --RMAP Buffer
300
    rmap_ram : if (rmap = 1) generate
301
      ram0 : syncram_2pft generic map(memtech, rfifo, 8, 0, 0, 2)
302
      port map(clk, rmrenable, rmraddress(rfifo-1 downto 0),
303
        rmrdata, clk, rmwrite, rmwaddress(rfifo-1 downto 0),
304
        rmwdata, testin);
305
    end generate;
306
  end generate;
307
 
308
-- pragma translate_off
309
    msg0 : if (rmap = 0) generate
310
      bootmsg : report_version
311
        generic map ("grspw" & tost(pindex) &
312
          ": Spacewire link rev " & tost(REVISION) & ", AHB fifos 2x" &
313
          tost(fifosize1*4)  & " bytes, rx fifo " & tost(fifosize2) &
314
         " bytes, irq " & tost(pirq));
315
    end generate;
316
 
317
    msg1 : if (rmap = 1) generate
318
      bootmsg : report_version
319
        generic map ("grspw" & tost(pindex) &
320
          ": Spacewire link rev " & tost(REVISION) & ", AHB fifos 2x " &
321
          tost(fifosize1*4)  & " bytes, rx fifo " & tost(fifosize2) &
322
         " bytes, irq " & tost(pirq) & " , RMAP Buffer " &
323
         tost(rmapbufs*32) & " bytes");
324
    end generate;
325
 
326
-- pragma translate_on
327
 
328
end architecture;

powered by: WebSVN 2.1.0

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