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

Subversion Repositories ethmac

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

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

powered by: WebSVN 2.1.0

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