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

Subversion Repositories ethmac

[/] [ethmac/] [trunk/] [rtl/] [verilog/] [eth_spram_256x32.v] - Blame information for rev 352

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

Line No. Rev Author Line
1 122 mohor
//////////////////////////////////////////////////////////////////////
2
////                                                              ////
3
////  eth_spram_256x32.v                                          ////
4
////                                                              ////
5
////  This file is part of the Ethernet IP core project           ////
6 346 olof
////  http://www.opencores.org/project,ethmac                     ////
7 122 mohor
////                                                              ////
8
////  Author(s):                                                  ////
9
////      - Igor Mohor (igorM@opencores.org)                      ////
10
////                                                              ////
11 204 mohor
////  All additional information is available in the Readme.txt   ////
12 122 mohor
////  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 330 igorm
// 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 312 tadejm
// Revision 1.8  2003/12/04 14:59:13  simons
48
// Lapsus fixed (!we -> ~we).
49
//
50 306 simons
// 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 304 tadejm
// Revision 1.6  2003/10/17 07:46:15  markom
54
// mbist signals updated according to newest convention
55
//
56 302 markom
// Revision 1.5  2003/08/14 16:42:58  simons
57
// Artisan ram instance added.
58
//
59 297 simons
// Revision 1.4  2002/10/18 17:04:20  tadejm
60
// Changed BIST scan signals.
61
//
62 227 tadejm
// Revision 1.3  2002/10/10 16:29:30  mohor
63
// BIST added.
64
//
65 210 mohor
// Revision 1.2  2002/09/23 18:24:31  mohor
66
// ETH_VIRTUAL_SILICON_RAM supported (for ASIC implementation).
67
//
68 204 mohor
// 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 122 mohor
//
71
//
72 204 mohor
//
73 122 mohor
 
74 204 mohor
`include "eth_defines.v"
75 122 mohor
`include "timescale.v"
76
 
77
module eth_spram_256x32(
78
        // Generic synchronous single-port RAM interface
79
        clk, rst, ce, we, oe, addr, di, do
80 210 mohor
 
81
`ifdef ETH_BIST
82 227 tadejm
  ,
83
  // debug chain signals
84 302 markom
  mbist_si_i,       // bist scan serial in
85
  mbist_so_o,       // bist scan serial out
86
  mbist_ctrl_i        // bist chain shift control
87 210 mohor
`endif
88
 
89
 
90
 
91 122 mohor
);
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 304 tadejm
        input  [3:0]    we;   // Write enable input, active high
100 122 mohor
        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]   do;   // output data bus
104
 
105
 
106 210 mohor
`ifdef ETH_BIST
107 302 markom
  input   mbist_si_i;       // bist scan serial in
108
  output  mbist_so_o;       // bist scan serial out
109
  input [`ETH_MBIST_CTRL_WIDTH - 1:0] mbist_ctrl_i;       // bist chain shift control
110 210 mohor
`endif
111
 
112 122 mohor
`ifdef ETH_XILINX_RAMB4
113
 
114 304 tadejm
    /*RAMB4_S16 ram0
115 122 mohor
    (
116
        .DO      (do[15:0]),
117
        .ADDR    (addr),
118
        .DI      (di[15:0]),
119
        .EN      (ce),
120
        .CLK     (clk),
121
        .WE      (we),
122
        .RST     (rst)
123
    );
124
 
125
    RAMB4_S16 ram1
126
    (
127
        .DO      (do[31:16]),
128
        .ADDR    (addr),
129
        .DI      (di[31:16]),
130
        .EN      (ce),
131
        .CLK     (clk),
132
        .WE      (we),
133
        .RST     (rst)
134 304 tadejm
    );*/
135
 
136
    RAMB4_S8 ram0
137
    (
138
        .DO      (do[7:0]),
139 312 tadejm
        .ADDR    ({1'b0, addr}),
140 304 tadejm
        .DI      (di[7:0]),
141
        .EN      (ce),
142
        .CLK     (clk),
143
        .WE      (we[0]),
144
        .RST     (rst)
145 122 mohor
    );
146
 
147 304 tadejm
    RAMB4_S8 ram1
148
    (
149
        .DO      (do[15:8]),
150 312 tadejm
        .ADDR    ({1'b0, addr}),
151 304 tadejm
        .DI      (di[15:8]),
152
        .EN      (ce),
153
        .CLK     (clk),
154
        .WE      (we[1]),
155
        .RST     (rst)
156
    );
157
 
158
    RAMB4_S8 ram2
159
    (
160
        .DO      (do[23:16]),
161 312 tadejm
        .ADDR    ({1'b0, addr}),
162 304 tadejm
        .DI      (di[23:16]),
163
        .EN      (ce),
164
        .CLK     (clk),
165
        .WE      (we[2]),
166
        .RST     (rst)
167
    );
168
 
169
    RAMB4_S8 ram3
170
    (
171
        .DO      (do[31:24]),
172 312 tadejm
        .ADDR    ({1'b0, addr}),
173 304 tadejm
        .DI      (di[31:24]),
174
        .EN      (ce),
175
        .CLK     (clk),
176
        .WE      (we[3]),
177
        .RST     (rst)
178
    );
179
 
180 204 mohor
`else   // !ETH_XILINX_RAMB4
181
`ifdef  ETH_VIRTUAL_SILICON_RAM
182 210 mohor
  `ifdef ETH_BIST
183 304 tadejm
      //vs_hdsp_256x32_bist ram0_bist
184
      vs_hdsp_256x32_bw_bist ram0_bist
185 210 mohor
  `else
186 304 tadejm
      //vs_hdsp_256x32 ram0
187
      vs_hdsp_256x32_bw ram0
188 210 mohor
  `endif
189
      (
190
        .CK         (clk),
191
        .CEN        (!ce),
192 306 simons
        .WEN        (~we),
193 210 mohor
        .OEN        (!oe),
194
        .ADR        (addr),
195
        .DI         (di),
196
        .DOUT       (do)
197 122 mohor
 
198 210 mohor
      `ifdef ETH_BIST
199
        ,
200
        // debug chain signals
201 302 markom
        .mbist_si_i       (mbist_si_i),
202
        .mbist_so_o       (mbist_so_o),
203
        .mbist_ctrl_i       (mbist_ctrl_i)
204 210 mohor
      `endif
205
      );
206
 
207 204 mohor
`else   // !ETH_VIRTUAL_SILICON_RAM
208
 
209 297 simons
`ifdef  ETH_ARTISAN_RAM
210
  `ifdef ETH_BIST
211 304 tadejm
      //art_hssp_256x32_bist ram0_bist
212
      art_hssp_256x32_bw_bist ram0_bist
213 297 simons
  `else
214 304 tadejm
      //art_hssp_256x32 ram0
215
      art_hssp_256x32_bw ram0
216 297 simons
  `endif
217
      (
218
        .CLK        (clk),
219
        .CEN        (!ce),
220 306 simons
        .WEN        (~we),
221 297 simons
        .OEN        (!oe),
222
        .A          (addr),
223
        .D          (di),
224
        .Q          (do)
225
 
226
      `ifdef ETH_BIST
227
        ,
228
        // debug chain signals
229 302 markom
        .mbist_si_i       (mbist_si_i),
230
        .mbist_so_o       (mbist_so_o),
231 330 igorm
        .mbist_ctrl_i     (mbist_ctrl_i)
232 297 simons
      `endif
233
      );
234
 
235
`else   // !ETH_ARTISAN_RAM
236 330 igorm
`ifdef ETH_ALTERA_ALTSYNCRAM
237
 
238
    altera_spram_256x32 altera_spram_256x32_inst
239
    (
240
          .address        (addr),
241
          .wren           (ce & we),
242
          .clock          (clk),
243
          .data           (di),
244
          .q              (do)
245
        );  //exemplar attribute altera_spram_256x32_inst NOOPT TRUE
246
 
247
`else   // !ETH_ALTERA_ALTSYNCRAM
248
 
249
 
250 122 mohor
        //
251
        // Generic single-port synchronous RAM model
252
        //
253
 
254
        //
255
        // Generic RAM's registers and wires
256
        //
257 304 tadejm
        reg  [ 7: 0] mem0 [255:0]; // RAM content
258
        reg  [15: 8] mem1 [255:0]; // RAM content
259
        reg  [23:16] mem2 [255:0]; // RAM content
260
        reg  [31:24] mem3 [255:0]; // RAM content
261
        wire [31:0]  q;            // RAM output
262
        reg  [7:0]   raddr;        // RAM read address
263 122 mohor
        //
264
        // Data output drivers
265
        //
266
        assign do = (oe & ce) ? q : {32{1'bz}};
267
 
268
        //
269
        // RAM read and write
270
        //
271
 
272
        // read operation
273
        always@(posedge clk)
274 304 tadejm
          if (ce) // && !we)
275 352 olof
                raddr <=  addr; // read address needs to be registered to read clock
276 122 mohor
 
277 304 tadejm
        assign #1 q = rst ? {32{1'b0}} : {mem3[raddr], mem2[raddr], mem1[raddr], mem0[raddr]};
278 122 mohor
 
279
        // write operation
280
        always@(posedge clk)
281 304 tadejm
        begin
282
                if (ce && we[3])
283 352 olof
                  mem3[addr] <=  di[31:24];
284 304 tadejm
                if (ce && we[2])
285 352 olof
                  mem2[addr] <=  di[23:16];
286 304 tadejm
                if (ce && we[1])
287 352 olof
                  mem1[addr] <=  di[15: 8];
288 304 tadejm
                if (ce && we[0])
289 352 olof
                  mem0[addr] <=  di[ 7: 0];
290
             end
291 122 mohor
 
292
        // Task prints range of memory
293
        // *** Remember that tasks are non reentrant, don't call this task in parallel for multiple instantiations. 
294
        task print_ram;
295
        input [7:0] start;
296
        input [7:0] finish;
297
        integer rnum;
298
        begin
299
                for (rnum=start;rnum<=finish;rnum=rnum+1)
300 304 tadejm
                        $display("Addr %h = %0h %0h %0h %0h",rnum,mem3[rnum],mem2[rnum],mem1[rnum],mem0[rnum]);
301 122 mohor
        end
302
        endtask
303
 
304 330 igorm
`endif  // !ETH_ALTERA_ALTSYNCRAM
305 297 simons
`endif  // !ETH_ARTISAN_RAM
306 204 mohor
`endif  // !ETH_VIRTUAL_SILICON_RAM
307
`endif  // !ETH_XILINX_RAMB4
308 122 mohor
 
309
endmodule

powered by: WebSVN 2.1.0

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