1 |
27 |
bporcella |
///////////////////////////////////////////////////////////////////////////////////////////////
|
2 |
|
|
////
|
3 |
|
|
//// file name: z80_sram.v
|
4 |
|
|
//// description: simple static SRAM
|
5 |
|
|
//// project: wb_z80
|
6 |
|
|
////
|
7 |
|
|
////
|
8 |
|
|
//// Author: B.J. Porcella
|
9 |
|
|
//// bporcella@sbcglobal.net
|
10 |
|
|
////
|
11 |
|
|
////
|
12 |
|
|
////
|
13 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////
|
14 |
|
|
////
|
15 |
|
|
//// Copyright (C) 2000-2002 B.J. Porcella
|
16 |
|
|
//// Real Time Solutions
|
17 |
|
|
////
|
18 |
|
|
////
|
19 |
|
|
//// This source file may be used and distributed without
|
20 |
|
|
//// restriction provided that this copyright statement is not
|
21 |
|
|
//// removed from the file and that any derivative work contains
|
22 |
|
|
//// the original copyright notice and the associated disclaimer.
|
23 |
|
|
////
|
24 |
|
|
//// THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY
|
25 |
|
|
//// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
|
26 |
|
|
//// TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
27 |
|
|
//// FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL THE AUTHOR
|
28 |
|
|
//// OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
29 |
|
|
//// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
30 |
|
|
//// (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
|
31 |
|
|
//// GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
|
32 |
|
|
//// BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
33 |
|
|
//// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
34 |
|
|
//// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
|
35 |
|
|
//// OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
36 |
|
|
//// POSSIBILITY OF SUCH DAMAGE.
|
37 |
|
|
////
|
38 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////
|
39 |
|
|
//
|
40 |
|
|
// DESCRIPTION:
|
41 |
|
|
// This file was intended to be a generic sram module -- and started out as generic_spram.v
|
42 |
|
|
// However, the generic_spram.v device contained not only an address register, but also a
|
43 |
|
|
// data register. I guess in retrospect that I could design around that ---- by deleting the
|
44 |
|
|
// address register of the z80 and also the data output register of the z80 and use the
|
45 |
|
|
// registers of the "generic_spram" for those functions.
|
46 |
|
|
//
|
47 |
|
|
// I have opted to hack my own model of a register array.
|
48 |
|
|
// (which I know can be reasonably synthesized in most technologies).
|
49 |
|
|
// Accordingly, I decided to re-name the file -- it is very different
|
50 |
|
|
// in its behavior -- there should be no mis-understanding here.
|
51 |
|
|
//
|
52 |
|
|
// If this actually causes synthesis problems, please let me know. I will try to help.
|
53 |
|
|
// bj
|
54 |
|
|
//
|
55 |
|
|
//
|
56 |
|
|
//
|
57 |
|
|
// CVS Log
|
58 |
|
|
//
|
59 |
|
|
// $Id: z80_sram.v,v 1.1 2004-05-27 14:28:55 bporcella Exp $
|
60 |
|
|
//
|
61 |
|
|
// $Date: 2004-05-27 14:28:55 $
|
62 |
|
|
// $Revision: 1.1 $
|
63 |
|
|
// $Author: bporcella $
|
64 |
|
|
// $Locker: $
|
65 |
|
|
// $State: Exp $
|
66 |
|
|
//
|
67 |
|
|
// Change History:
|
68 |
|
|
// $Log: not supported by cvs2svn $
|
69 |
|
|
// Revision 1.1.1.1 2004/04/13 23:47:42 bporcella
|
70 |
|
|
// import first files
|
71 |
|
|
//
|
72 |
|
|
//
|
73 |
|
|
//
|
74 |
|
|
//-------1---------2---------3--------Module Name and Port List------7---------8---------9--------0
|
75 |
|
|
|
76 |
|
|
module z80_sram(
|
77 |
|
|
// Generic synchronous single-port RAM interface
|
78 |
|
|
clk, rst, ce, we, oe, addr, di, do
|
79 |
|
|
);
|
80 |
|
|
|
81 |
|
|
//
|
82 |
|
|
// Default address and data buses width
|
83 |
|
|
//
|
84 |
|
|
parameter aw = 15; //number of address-bits
|
85 |
|
|
parameter dw = 8; //number of data-bits
|
86 |
|
|
|
87 |
|
|
//
|
88 |
|
|
// Generic synchronous single-port RAM interface
|
89 |
|
|
//
|
90 |
|
|
|
91 |
|
|
|
92 |
|
|
//-------1---------2---------3--------Output Ports---------6---------7---------8---------9--------0
|
93 |
|
|
output [dw-1:0] do; // output data bus
|
94 |
|
|
|
95 |
|
|
//-------1---------2---------3--------Input Ports----------6---------7---------8---------9--------0
|
96 |
|
|
input clk; // Clock, rising edge
|
97 |
|
|
input rst; // Reset, active high
|
98 |
|
|
input ce; // Chip enable input, active high
|
99 |
|
|
input we; // Write enable input, active high
|
100 |
|
|
input oe; // Output enable input, active high
|
101 |
|
|
input [aw-1:0] addr; // address bus inputs
|
102 |
|
|
input [dw-1:0] di; // input data bus
|
103 |
|
|
//-------1---------2---------3--------Parameters-----------6---------7---------8---------9--------0
|
104 |
|
|
//-------1---------2---------3--------Wires------5---------6---------7---------8---------9--------0
|
105 |
|
|
//-------1---------2---------3--------Registers--5---------6---------7---------8---------9--------0
|
106 |
|
|
//-------1---------2---------3--------Assignments----------6---------7---------8---------9--------0
|
107 |
|
|
//-------1---------2---------3--------State Machines-------6---------7---------8---------9--------0
|
108 |
|
|
|
109 |
|
|
|
110 |
|
|
reg [dw-1:0] mem [(1<<aw)-1:0]; // RAM content
|
111 |
|
|
|
112 |
|
|
// bjp change was
|
113 |
|
|
//reg [aw-1:0] raddr; // RAM read address
|
114 |
|
|
//wire raddr = addr;
|
115 |
|
|
//
|
116 |
|
|
// Data output drivers
|
117 |
|
|
//
|
118 |
|
|
assign do = mem[addr];
|
119 |
|
|
|
120 |
|
|
|
121 |
|
|
|
122 |
|
|
// write operation
|
123 |
|
|
always@(posedge clk)
|
124 |
|
|
if (ce && we)
|
125 |
|
|
mem[addr] <= di;
|
126 |
|
|
|
127 |
|
|
|
128 |
|
|
|
129 |
|
|
endmodule
|