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

Subversion Repositories ethmac

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

powered by: WebSVN 2.1.0

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