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

Subversion Repositories ethmac

[/] [ethmac/] [tags/] [rel_14/] [rtl/] [verilog/] [eth_spram_256x32.v] - Blame information for rev 227

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 227 tadejm
// Revision 1.3  2002/10/10 16:29:30  mohor
45
// BIST added.
46
//
47 210 mohor
// Revision 1.2  2002/09/23 18:24:31  mohor
48
// ETH_VIRTUAL_SILICON_RAM supported (for ASIC implementation).
49
//
50 204 mohor
// Revision 1.1  2002/07/23 16:36:09  mohor
51
// ethernet spram added. So far a generic ram and xilinx RAMB4 are used.
52 122 mohor
//
53
//
54 204 mohor
//
55 122 mohor
 
56 204 mohor
`include "eth_defines.v"
57 122 mohor
`include "timescale.v"
58
 
59
module eth_spram_256x32(
60
        // Generic synchronous single-port RAM interface
61
        clk, rst, ce, we, oe, addr, di, do
62 210 mohor
 
63
`ifdef ETH_BIST
64 227 tadejm
  ,
65
  // debug chain signals
66
  scanb_rst,      // bist scan reset
67
  scanb_clk,      // bist scan clock
68
  scanb_si,       // bist scan serial in
69
  scanb_so,       // bist scan serial out
70
  scanb_en        // bist scan shift enable
71 210 mohor
`endif
72
 
73
 
74
 
75 122 mohor
);
76
 
77
        //
78
        // Generic synchronous single-port RAM interface
79
        //
80
        input           clk;  // Clock, rising edge
81
        input           rst;  // Reset, active high
82
        input           ce;   // Chip enable input, active high
83
        input           we;   // Write enable input, active high
84
        input           oe;   // Output enable input, active high
85
        input  [7:0]    addr; // address bus inputs
86
        input  [31:0]   di;   // input data bus
87
        output [31:0]   do;   // output data bus
88
 
89
 
90 210 mohor
`ifdef ETH_BIST
91 227 tadejm
  input   scanb_rst;      // bist scan reset
92
  input   scanb_clk;      // bist scan clock
93
  input   scanb_si;       // bist scan serial in
94
  output  scanb_so;       // bist scan serial out
95
  input   scanb_en;       // bist scan shift enable
96 210 mohor
`endif
97
 
98 122 mohor
`ifdef ETH_XILINX_RAMB4
99
 
100
    RAMB4_S16 ram0
101
    (
102
        .DO      (do[15:0]),
103
        .ADDR    (addr),
104
        .DI      (di[15:0]),
105
        .EN      (ce),
106
        .CLK     (clk),
107
        .WE      (we),
108
        .RST     (rst)
109
    );
110
 
111
    RAMB4_S16 ram1
112
    (
113
        .DO      (do[31:16]),
114
        .ADDR    (addr),
115
        .DI      (di[31:16]),
116
        .EN      (ce),
117
        .CLK     (clk),
118
        .WE      (we),
119
        .RST     (rst)
120
    );
121
 
122 204 mohor
`else   // !ETH_XILINX_RAMB4
123
`ifdef  ETH_VIRTUAL_SILICON_RAM
124 210 mohor
  `ifdef ETH_BIST
125
      vs_hdsp_256x32_bist ram0_bist
126
  `else
127
      vs_hdsp_256x32 ram0
128
  `endif
129
      (
130
        .CK         (clk),
131
        .CEN        (!ce),
132
        .WEN        (!we),
133
        .OEN        (!oe),
134
        .ADR        (addr),
135
        .DI         (di),
136
        .DOUT       (do)
137 122 mohor
 
138 210 mohor
      `ifdef ETH_BIST
139
        ,
140
        // debug chain signals
141 227 tadejm
        .scanb_rst      (scanb_rst),
142
        .scanb_clk      (scanb_clk),
143
        .scanb_si       (scanb_si),
144
        .scanb_so       (scanb_so),
145
        .scanb_en       (scanb_en)
146 210 mohor
      `endif
147
      );
148
 
149 204 mohor
`else   // !ETH_VIRTUAL_SILICON_RAM
150
 
151 122 mohor
        //
152
        // Generic single-port synchronous RAM model
153
        //
154
 
155
        //
156
        // Generic RAM's registers and wires
157
        //
158
        reg  [31:0] mem [255:0];  // RAM content
159
        wire [31:0] q;          // RAM output
160
        reg  [7:0]  raddr;      // RAM read address
161
        //
162
        // Data output drivers
163
        //
164
        assign do = (oe & ce) ? q : {32{1'bz}};
165
 
166
        //
167
        // RAM read and write
168
        //
169
 
170
        // read operation
171
        always@(posedge clk)
172
        if (ce) // && !we)
173
                raddr <= #1 addr;    // read address needs to be registered to read clock
174
 
175
        assign #1 q = rst ? {32{1'b0}} : mem[raddr];
176
 
177
        // write operation
178
        always@(posedge clk)
179
                if (ce && we)
180
                        mem[addr] <= #1 di;
181
 
182
        // Task prints range of memory
183
        // *** Remember that tasks are non reentrant, don't call this task in parallel for multiple instantiations. 
184
        task print_ram;
185
        input [7:0] start;
186
        input [7:0] finish;
187
        integer rnum;
188
        begin
189
                for (rnum=start;rnum<=finish;rnum=rnum+1)
190
                        $display("Addr %h = %h",rnum,mem[rnum]);
191
        end
192
        endtask
193
 
194 204 mohor
`endif  // !ETH_VIRTUAL_SILICON_RAM
195
`endif  // !ETH_XILINX_RAMB4
196 122 mohor
 
197
endmodule

powered by: WebSVN 2.1.0

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