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

Subversion Repositories ethmac

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

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

powered by: WebSVN 2.1.0

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