OpenCores
URL https://opencores.org/ocsvn/an-fpga-implementation-of-low-latency-noc-based-mpsoc/an-fpga-implementation-of-low-latency-noc-based-mpsoc/trunk

Subversion Repositories an-fpga-implementation-of-low-latency-noc-based-mpsoc

[/] [an-fpga-implementation-of-low-latency-noc-based-mpsoc/] [trunk/] [mpsoc/] [rtl/] [src_peripheral/] [ethmac/] [rtl/] [eth_spram_256x32.v] - Blame information for rev 48

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 48 alirezamon
//////////////////////////////////////////////////////////////////////
2
////                                                              ////
3
////  eth_spram_256x32.v                                          ////
4
////                                                              ////
5
////  This file is part of the Ethernet IP core project           ////
6
////  http://www.opencores.org/project,ethmac                     ////
7
////                                                              ////
8
////  Author(s):                                                  ////
9
////      - Igor Mohor (igorM@opencores.org)                      ////
10
////                                                              ////
11
////  All additional information is available in the Readme.txt   ////
12
////  file.                                                       ////
13
////                                                              ////
14
//////////////////////////////////////////////////////////////////////
15
////                                                              ////
16
//// Copyright (C) 2001, 2002 Authors                             ////
17
////                                                              ////
18
//// This source file may be used and distributed without         ////
19
//// restriction provided that this copyright statement is not    ////
20
//// removed from the file and that any derivative work contains  ////
21
//// the original copyright notice and the associated disclaimer. ////
22
////                                                              ////
23
//// This source file is free software; you can redistribute it   ////
24
//// and/or modify it under the terms of the GNU Lesser General   ////
25
//// Public License as published by the Free Software Foundation; ////
26
//// either version 2.1 of the License, or (at your option) any   ////
27
//// later version.                                               ////
28
////                                                              ////
29
//// This source is distributed in the hope that it will be       ////
30
//// useful, but WITHOUT ANY WARRANTY; without even the implied   ////
31
//// warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR      ////
32
//// PURPOSE.  See the GNU Lesser General Public License for more ////
33
//// details.                                                     ////
34
////                                                              ////
35
//// You should have received a copy of the GNU Lesser General    ////
36
//// Public License along with this source; if not, download it   ////
37
//// from http://www.opencores.org/lgpl.shtml                     ////
38
////                                                              ////
39
//////////////////////////////////////////////////////////////////////
40
//
41
// CVS Revision History
42
//
43
// $Log: not supported by cvs2svn $
44
// Revision 1.9  2003/12/05 12:43:06  tadejm
45
// Corrected address mismatch for xilinx RAMB4_S8 model which has wider address than RAMB4_S16.
46
//
47
// Revision 1.8  2003/12/04 14:59:13  simons
48
// Lapsus fixed (!we -> ~we).
49
//
50
// Revision 1.7  2003/11/12 18:24:59  tadejm
51
// WISHBONE slave changed and tested from only 32-bit accesss to byte access.
52
//
53
// Revision 1.6  2003/10/17 07:46:15  markom
54
// mbist signals updated according to newest convention
55
//
56
// Revision 1.5  2003/08/14 16:42:58  simons
57
// Artisan ram instance added.
58
//
59
// Revision 1.4  2002/10/18 17:04:20  tadejm
60
// Changed BIST scan signals.
61
//
62
// Revision 1.3  2002/10/10 16:29:30  mohor
63
// BIST added.
64
//
65
// Revision 1.2  2002/09/23 18:24:31  mohor
66
// ETH_VIRTUAL_SILICON_RAM supported (for ASIC implementation).
67
//
68
// Revision 1.1  2002/07/23 16:36:09  mohor
69
// ethernet spram added. So far a generic ram and xilinx RAMB4 are used.
70
//
71
//
72
//
73
 
74
`include "ethmac_defines.v"
75
`include "timescale.v"
76
 
77
module eth_spram_256x32(
78
        // Generic synchronous single-port RAM interface
79
        clk, rst, ce, we, oe, addr, di, dato
80
 
81
`ifdef ETH_BIST
82
  ,
83
  // debug chain signals
84
  mbist_si_i,       // bist scan serial in
85
  mbist_so_o,       // bist scan serial out
86
  mbist_ctrl_i        // bist chain shift control
87
`endif
88
 
89
 
90
 
91
);
92
 
93
   //
94
   // Generic synchronous single-port RAM interface
95
   //
96
   input           clk;  // Clock, rising edge
97
   input           rst;  // Reset, active high
98
   input           ce;   // Chip enable input, active high
99
   input  [3:0]    we;   // Write enable input, active high
100
   input           oe;   // Output enable input, active high
101
   input  [7:0]    addr; // address bus inputs
102
   input  [31:0]   di;   // input data bus
103
   output [31:0]   dato;   // output data bus
104
 
105
`ifdef ETH_BIST
106
   input           mbist_si_i;       // bist scan serial in
107
   output          mbist_so_o;       // bist scan serial out
108
   input [`ETH_MBIST_CTRL_WIDTH - 1:0] mbist_ctrl_i;       // bist chain shift control
109
`endif
110
 
111
`ifdef ETH_XILINX_RAMB4
112
 
113
   /*RAMB4_S16 ram0
114
    (
115
    .DO      (do[15:0]),
116
    .ADDR    (addr),
117
    .DI      (di[15:0]),
118
    .EN      (ce),
119
    .CLK     (clk),
120
    .WE      (we),
121
    .RST     (rst)
122
    );
123
 
124
    RAMB4_S16 ram1
125
    (
126
    .DO      (do[31:16]),
127
    .ADDR    (addr),
128
    .DI      (di[31:16]),
129
    .EN      (ce),
130
    .CLK     (clk),
131
    .WE      (we),
132
    .RST     (rst)
133
    );*/
134
 
135
   RAMB4_S8 ram0
136
     (
137
      .DO      (dato[7:0]),
138
      .ADDR    ({1'b0, addr}),
139
      .DI      (di[7:0]),
140
      .EN      (ce),
141
      .CLK     (clk),
142
      .WE      (we[0]),
143
      .RST     (rst)
144
      );
145
 
146
   RAMB4_S8 ram1
147
     (
148
      .DO      (dato[15:8]),
149
      .ADDR    ({1'b0, addr}),
150
      .DI      (di[15:8]),
151
      .EN      (ce),
152
      .CLK     (clk),
153
      .WE      (we[1]),
154
      .RST     (rst)
155
      );
156
 
157
   RAMB4_S8 ram2
158
     (
159
      .DO      (dato[23:16]),
160
      .ADDR    ({1'b0, addr}),
161
      .DI      (di[23:16]),
162
      .EN      (ce),
163
      .CLK     (clk),
164
      .WE      (we[2]),
165
      .RST     (rst)
166
      );
167
 
168
   RAMB4_S8 ram3
169
     (
170
      .DO      (dato[31:24]),
171
      .ADDR    ({1'b0, addr}),
172
      .DI      (di[31:24]),
173
      .EN      (ce),
174
      .CLK     (clk),
175
      .WE      (we[3]),
176
      .RST     (rst)
177
      );
178
 
179
`else   // !ETH_XILINX_RAMB4
180
 `ifdef  ETH_VIRTUAL_SILICON_RAM
181
  `ifdef ETH_BIST
182
   //vs_hdsp_256x32_bist ram0_bist
183
   vs_hdsp_256x32_bw_bist ram0_bist
184
  `else
185
     //vs_hdsp_256x32 ram0
186
     vs_hdsp_256x32_bw ram0
187
  `endif
188
       (
189
        .CK         (clk),
190
        .CEN        (!ce),
191
        .WEN        (~we),
192
        .OEN        (!oe),
193
        .ADR        (addr),
194
        .DI         (di),
195
        .DOUT       (dato)
196
 
197
  `ifdef ETH_BIST
198
        ,
199
        // debug chain signals
200
        .mbist_si_i       (mbist_si_i),
201
        .mbist_so_o       (mbist_so_o),
202
        .mbist_ctrl_i       (mbist_ctrl_i)
203
  `endif
204
       );
205
 
206
 `else   // !ETH_VIRTUAL_SILICON_RAM
207
 
208
  `ifdef  ETH_ARTISAN_RAM
209
   `ifdef ETH_BIST
210
   //art_hssp_256x32_bist ram0_bist
211
   art_hssp_256x32_bw_bist ram0_bist
212
   `else
213
     //art_hssp_256x32 ram0
214
     art_hssp_256x32_bw ram0
215
   `endif
216
       (
217
        .CLK        (clk),
218
        .CEN        (!ce),
219
        .WEN        (~we),
220
        .OEN        (!oe),
221
        .A          (addr),
222
        .D          (di),
223
        .Q          (dato)
224
 
225
   `ifdef ETH_BIST
226
        ,
227
        // debug chain signals
228
        .mbist_si_i       (mbist_si_i),
229
        .mbist_so_o       (mbist_so_o),
230
        .mbist_ctrl_i     (mbist_ctrl_i)
231
   `endif
232
       );
233
 
234
  `else   // !ETH_ARTISAN_RAM
235
   `ifdef ETH_ALTERA_ALTSYNCRAM
236
/*
237
   altera_spram_256x32  altera_spram_256x32_inst
238
     (
239
      .address        (addr),
240
      .wren           (ce & we),
241
      .clock          (clk),
242
      .data           (di),
243
      .q              (dato)
244
      );  //exemplar attribute altera_spram_256x32_inst NOOPT TRUE
245
 
246
 
247
   alt_spram_256x32     alt_spram_256x32_inst
248
     (
249
      .address        (addr),
250
      .wren           (ce & we),
251
      .clock          (clk),
252
      .data           (di),
253
      .q              (dato)
254
      );
255
 
256
 
257
        eth_single_port_ram #(
258
            .Dw(32),
259
            .Aw(8)
260
        )
261
        spram
262
        (
263
            .data(di),
264
            .addr(addr),
265
            .we(ce & we),
266
            .clk(clk),
267
            .q(dato)
268
        );
269
 
270
*/
271
 
272
 
273
        //localparam  RAM_ID = {"ENABLE_RUNTIME_MOD=YES,INSTANCE_NAME=",RAM_TAG_STRING};
274
 
275
        altsyncram #(
276
        .operation_mode("SINGLE_PORT"),
277
        .width_a(32),
278
        //.lpm_hint(RAM_ID),
279
        .read_during_write_mode_mixed_ports("DONT_CARE"),
280
        .widthad_a(8),
281
        .width_byteena_a(4)
282
        //.init_file(INIT_FILE)
283
 
284
        ) ram_inst(
285
                .clock0                 (clk),
286
                .address_a              (addr),
287
                .wren_a                 (ce),
288
                .data_a                 (di),
289
                .q_a                       (dato),
290
                .byteena_a     (we),
291
 
292
                .wren_b                 (        ),
293
                .rden_a                 (        ),
294
                .rden_b                 (        ),
295
                .data_b                 (        ),
296
                .address_b              (        ),
297
                .clock1                 (        ),
298
                .clocken0               (        ),
299
                .clocken1               (        ),
300
                .clocken2               (        ),
301
                .clocken3               (        ),
302
                .aclr0                  (        ),
303
                .aclr1                  (        ),
304
                .byteena_b              (        ),
305
                .addressstall_a (        ),
306
                .addressstall_b (        ),
307
                .q_b                    (        ),
308
                .eccstatus              (        )
309
        );
310
 
311
 
312
 
313
 
314
 
315
 
316
 
317
 
318
 
319
   `else   // !ETH_ALTERA_ALTSYNCRAM
320
 
321
 
322
   //
323
   // Generic single-port synchronous RAM model
324
   //
325
 
326
   //
327
   // Generic RAM's registers and wires
328
   //
329
   reg  [ 7: 0] mem0 [255:0]; // RAM content
330
   reg  [15: 8] mem1 [255:0]; // RAM content
331
   reg  [23:16] mem2 [255:0]; // RAM content
332
   reg  [31:24] mem3 [255:0]; // RAM content
333
   wire [31:0]  q;            // RAM output
334
   reg   [7:0]   raddr;        // RAM read address
335
   //
336
   // Data output drivers
337
   //
338
   assign dato = (oe & ce) ? q : {32{1'bz}};
339
 
340
   //
341
   // RAM read and write
342
   //
343
 
344
   // read operation
345
   always@(posedge clk)
346
     if (ce)
347
       raddr <=  addr; // read address needs to be registered to read clock
348
 
349
   assign  q = rst ? {32{1'b0}} : {mem3[raddr],
350
                                   mem2[raddr],
351
                                   mem1[raddr],
352
                                   mem0[raddr]};
353
 
354
    // write operation
355
    always@(posedge clk)
356
    begin
357
                if (ce && we[3])
358
                  mem3[addr] <=  di[31:24];
359
                if (ce && we[2])
360
                  mem2[addr] <=  di[23:16];
361
                if (ce && we[1])
362
                  mem1[addr] <=  di[15: 8];
363
                if (ce && we[0])
364
                  mem0[addr] <=  di[ 7: 0];
365
             end
366
 
367
   // Task prints range of memory
368
   // *** Remember that tasks are non reentrant, don't call this task in parallel for multiple instantiations. 
369
   task print_ram;
370
      input [7:0] start;
371
      input [7:0] finish;
372
      integer     rnum;
373
      begin
374
         for (rnum={24'd0,start};rnum<={24'd0,finish};rnum=rnum+1)
375
           $display("Addr %h = %0h %0h %0h %0h",rnum,mem3[rnum],mem2[rnum],mem1[rnum],mem0[rnum]);
376
      end
377
   endtask
378
 
379
   `endif  // !ETH_ALTERA_ALTSYNCRAM
380
  `endif  // !ETH_ARTISAN_RAM
381
 `endif  // !ETH_VIRTUAL_SILICON_RAM
382
`endif  // !ETH_XILINX_RAMB4
383
 
384
endmodule

powered by: WebSVN 2.1.0

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