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

Subversion Repositories ethmac

[/] [ethmac/] [tags/] [rel_26/] [rtl/] [verilog/] [eth_spram_256x32.v] - Blame information for rev 338

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

powered by: WebSVN 2.1.0

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