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

Subversion Repositories funbase_ip_library

[/] [funbase_ip_library/] [trunk/] [Altera/] [ip.hwp.storage/] [up_avalon_sram/] [hdl/] [Altera_UP_Avalon_SSRAM.v] - Blame information for rev 187

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 187 lanttu
/******************************************************************************
2
 * License Agreement                                                          *
3
 *                                                                            *
4
 * Copyright (c) 1991-2009 Altera Corporation, San Jose, California, USA.     *
5
 * All rights reserved.                                                       *
6
 *                                                                            *
7
 * Any megafunction design, and related net list (encrypted or decrypted),    *
8
 *  support information, device programming or simulation file, and any other *
9
 *  associated documentation or information provided by Altera or a partner   *
10
 *  under Altera's Megafunction Partnership Program may be used only to       *
11
 *  program PLD devices (but not masked PLD devices) from Altera.  Any other  *
12
 *  use of such megafunction design, net list, support information, device    *
13
 *  programming or simulation file, or any other related documentation or     *
14
 *  information is prohibited for any other purpose, including, but not       *
15
 *  limited to modification, reverse engineering, de-compiling, or use with   *
16
 *  any other silicon devices, unless such use is explicitly licensed under   *
17
 *  a separate agreement with Altera or a megafunction partner.  Title to     *
18
 *  the intellectual property, including patents, copyrights, trademarks,     *
19
 *  trade secrets, or maskworks, embodied in any such megafunction design,    *
20
 *  net list, support information, device programming or simulation file, or  *
21
 *  any other related documentation or information provided by Altera or a    *
22
 *  megafunction partner, remains with Altera, the megafunction partner, or   *
23
 *  their respective licensors.  No other licenses, including any licenses    *
24
 *  needed under any third party's intellectual property, are provided herein.*
25
 *  Copying or modifying any file, or portion thereof, to which this notice   *
26
 *  is attached violates this copyright.                                      *
27
 *                                                                            *
28
 * THIS FILE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR    *
29
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,   *
30
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL    *
31
 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER *
32
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING    *
33
 * FROM, OUT OF OR IN CONNECTION WITH THIS FILE OR THE USE OR OTHER DEALINGS  *
34
 * IN THIS FILE.                                                              *
35
 *                                                                            *
36
 * This agreement shall be governed in all respects by the laws of the State  *
37
 *  of California and by the laws of the United States of America.            *
38
 *                                                                            *
39
 ******************************************************************************/
40
 
41
/******************************************************************************
42
 *                                                                            *
43
 * This module reads and writes to the ssram chip on the DE2-70 board,        *
44
 *  with 2-cycle read latency and one cycle write latency.                    *
45
 *                                                                            *
46
 ******************************************************************************/
47
 
48
 
49
module Altera_UP_Avalon_SSRAM (
50
        // Inputs
51
        clk,
52
        reset,
53
 
54
        address,
55
        byteenable,
56
        read,
57
        write,
58
        writedata,
59
 
60
        // Bi-Directional
61
        SRAM_DQ,
62
        SRAM_DPA,
63
 
64
        // Outputs
65
        readdata,
66
 
67
        SRAM_CLK,
68
        SRAM_ADDR,
69
        SRAM_ADSC_N,
70
        SRAM_ADSP_N,
71
        SRAM_ADV_N,
72
        SRAM_BE_N,
73
        SRAM_CE1_N,
74
        SRAM_CE2,
75
        SRAM_CE3_N,
76
        SRAM_GW_N,
77
        SRAM_OE_N,
78
        SRAM_WE_N
79
);
80
 
81
 
82
/*****************************************************************************
83
 *                           Parameter Declarations                          *
84
 *****************************************************************************/
85
 
86
 
87
/*****************************************************************************
88
 *                             Port Declarations                             *
89
 *****************************************************************************/
90
// Inputs
91
input                           clk;
92
input                           reset;
93
 
94
input           [18: 0]  address;
95
input           [ 3: 0]  byteenable;
96
input                           read;
97
input                           write;
98
input           [31: 0]  writedata;
99
 
100
// Bi-Directional
101
inout           [31: 0]  SRAM_DQ;                //      SRAM Data Bus 32 Bits
102
inout           [ 3: 0]  SRAM_DPA;               //  SRAM Parity Data Bus
103
 
104
// Outputs
105
output          [31: 0]  readdata;
106
 
107
output                          SRAM_CLK;               //      SRAM Clock
108
output          [18: 0]  SRAM_ADDR;              //      SRAM Address bus 21 Bits
109
output                          SRAM_ADSC_N;    //      SRAM Controller Address Status  
110
output                          SRAM_ADSP_N;    //      SRAM Processor Address Status
111
output                          SRAM_ADV_N;             //      SRAM Burst Address Advance
112
output          [ 3: 0]  SRAM_BE_N;              //      SRAM Byte Write Enable
113
output                          SRAM_CE1_N;             //      SRAM Chip Enable
114
output                          SRAM_CE2;               //      SRAM Chip Enable
115
output                          SRAM_CE3_N;             //      SRAM Chip Enable
116
output                          SRAM_GW_N;              //  SRAM Global Write Enable
117
output                          SRAM_OE_N;              //      SRAM Output Enable
118
output                          SRAM_WE_N;              //      SRAM Write Enable
119
 
120
/*****************************************************************************
121
 *                           Constant Declarations                           *
122
 *****************************************************************************/
123
 
124
// states
125
localparam      STATE_0_SET_ADSC                = 2'h0,
126
                        STATE_1_WAIT                    = 2'h1,
127
                        STATE_2_READ_COMPLETE   = 2'h2;
128
 
129
/*****************************************************************************
130
 *                 Internal Wires and Registers Declarations                 *
131
 *****************************************************************************/
132
 
133
// Internal Wires
134
 
135
// Internal Registers
136
 
137
// State Machine Registers
138
reg                     [ 1: 0] preset_state;
139
reg                     [ 1: 0] next_state;
140
 
141
/*****************************************************************************
142
 *                         Finite State Machine(s)                           *
143
 *****************************************************************************/
144
 
145
always @(posedge clk)
146
begin
147
        if (reset)
148
                preset_state <= STATE_0_SET_ADSC;
149
        else
150
                preset_state <= next_state;
151
end
152
 
153
always @(*)
154
begin
155
        // Defaults
156
        next_state = STATE_0_SET_ADSC;
157
 
158
    case (preset_state)
159
        STATE_0_SET_ADSC:
160
        begin
161
                if (read | write)
162
                        next_state = STATE_1_WAIT;
163
                else
164
                        next_state = STATE_0_SET_ADSC;
165
        end
166
        STATE_1_WAIT:
167
        begin
168
                next_state = STATE_2_READ_COMPLETE;
169
        end
170
        STATE_2_READ_COMPLETE:
171
        begin
172
                next_state = STATE_0_SET_ADSC;
173
        end
174
        default:
175
        begin
176
                next_state = STATE_0_SET_ADSC;
177
        end
178
        endcase
179
end
180
 
181
/*****************************************************************************
182
 *                             Sequential logic                              *
183
 *****************************************************************************/
184
 
185
// Output Registers
186
 
187
// Internal Registers
188
 
189
/*****************************************************************************
190
 *                            Combinational logic                            *
191
 *****************************************************************************/
192
 
193
// Output Assignments
194
assign readdata                 = SRAM_DQ;
195
 
196
assign SRAM_DQ[31:24]   = (byteenable[3] & write) ? writedata[31:24] : 8'hzz;
197
assign SRAM_DQ[23:16]   = (byteenable[2] & write) ? writedata[23:16] : 8'hzz;
198
assign SRAM_DQ[15: 8]   = (byteenable[1] & write) ? writedata[15: 8] : 8'hzz;
199
assign SRAM_DQ[ 7: 0]    = (byteenable[0] & write) ? writedata[ 7: 0] : 8'hzz;
200
 
201
assign SRAM_DPA                 = 4'hz;
202
 
203
assign SRAM_CLK                 = clk;
204
assign SRAM_ADDR                = address;
205
assign SRAM_ADSC_N              = ~((preset_state == STATE_0_SET_ADSC) & (read|write));
206
assign SRAM_ADSP_N              = 1'b1;
207
assign SRAM_ADV_N               = 1'b1;
208
assign SRAM_BE_N[3]             = ~(byteenable[3] & write);
209
assign SRAM_BE_N[2]             = ~(byteenable[2] & write);
210
assign SRAM_BE_N[1]             = ~(byteenable[1] & write);
211
assign SRAM_BE_N[0]              = ~(byteenable[0] & write);
212
assign SRAM_CE1_N               = ~(read | write);
213
assign SRAM_CE2                 = (read | write);
214
assign SRAM_CE3_N               = ~(read | write);
215
assign SRAM_GW_N                = 1'b1;
216
assign SRAM_OE_N                = ~read;
217
assign SRAM_WE_N                = ~write;
218
 
219
// Internal Assignments
220
 
221
/*****************************************************************************
222
 *                              Internal Modules                             *
223
 *****************************************************************************/
224
 
225
 
226
endmodule
227
 

powered by: WebSVN 2.1.0

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