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 204

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

powered by: WebSVN 2.1.0

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