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

Subversion Repositories altor32

[/] [altor32/] [trunk/] [rtl/] [sim_icarus/] [ram.v] - Blame information for rev 37

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 37 ultra_embe
//-----------------------------------------------------------------
2
//                           AltOR32 
3
//                Alternative Lightweight OpenRisc 
4
//                            V2.0
5
//                     Ultra-Embedded.com
6
//                   Copyright 2011 - 2013
7
//
8
//               Email: admin@ultra-embedded.com
9
//
10
//                       License: LGPL
11
//-----------------------------------------------------------------
12
//
13
// Copyright (C) 2011 - 2013 Ultra-Embedded.com
14
//
15
// This source file may be used and distributed without         
16
// restriction provided that this copyright statement is not    
17
// removed from the file and that any derivative work contains  
18
// the original copyright notice and the associated disclaimer. 
19
//
20
// This source file is free software; you can redistribute it   
21
// and/or modify it under the terms of the GNU Lesser General   
22
// Public License as published by the Free Software Foundation; 
23
// either version 2.1 of the License, or (at your option) any   
24
// later version.
25
//
26
// This source is distributed in the hope that it will be       
27
// useful, but WITHOUT ANY WARRANTY; without even the implied   
28
// warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR      
29
// PURPOSE.  See the GNU Lesser General Public License for more 
30
// details.
31
//
32
// You should have received a copy of the GNU Lesser General    
33
// Public License along with this source; if not, write to the 
34
// Free Software Foundation, Inc., 59 Temple Place, Suite 330, 
35
// Boston, MA  02111-1307  USA
36
//-----------------------------------------------------------------
37
 
38
//-----------------------------------------------------------------
39
// Module: ram - dual port block RAM
40
//-----------------------------------------------------------------
41
module ram
42
(
43
    // Port A
44
    input clka_i /*verilator public*/,
45
    input rsta_i /*verilator public*/,
46
    input stba_i /*verilator public*/,
47
    input wea_i /*verilator public*/,
48
    input [3:0] sela_i /*verilator public*/,
49
    input [31:2] addra_i /*verilator public*/,
50
    input [31:0] dataa_i /*verilator public*/,
51
    output [31:0] dataa_o /*verilator public*/,
52
    output reg acka_o /*verilator public*/,
53
 
54
    // Port B
55
    input clkb_i /*verilator public*/,
56
    input rstb_i /*verilator public*/,
57
    input stbb_i /*verilator public*/,
58
    input web_i /*verilator public*/,
59
    input [3:0] selb_i /*verilator public*/,
60
    input [31:2] addrb_i /*verilator public*/,
61
    input [31:0] datab_i /*verilator public*/,
62
    output [31:0] datab_o /*verilator public*/,
63
    output reg ackb_o /*verilator public*/
64
);
65
 
66
//-----------------------------------------------------------------
67
// Params
68
//-----------------------------------------------------------------
69
parameter  [31:0]       SIZE         = 14;
70
 
71
//-----------------------------------------------------------------
72
// Instantiation
73
//-----------------------------------------------------------------
74
 
75
wire [3:0] wr_a = {4{stba_i}} & {4{wea_i}} & sela_i;
76
wire [3:0] wr_b = {4{stbb_i}} & {4{web_i}} & selb_i;
77
 
78
ram_dp8
79
#(
80
    .WIDTH(8),
81
    .SIZE(SIZE),
82
    .FILENAME("mem_3.hex")
83
)
84
u0
85
(
86
    .aclk_i(clka_i),
87
    .aadr_i(addra_i[SIZE+2-1:2]),
88
    .adat_o(dataa_o[7:0]),
89
    .adat_i(dataa_i[7:0]),
90
    .awr_i(wr_a[0]),
91
 
92
    .bclk_i(clkb_i),
93
    .badr_i(addrb_i[SIZE+2-1:2]),
94
    .bdat_o(datab_o[7:0]),
95
    .bdat_i(datab_i[7:0]),
96
    .bwr_i(wr_b[0])
97
);
98
 
99
ram_dp8
100
#(
101
    .WIDTH(8),
102
    .SIZE(SIZE),
103
    .FILENAME("mem_2.hex")
104
)
105
u1
106
(
107
    .aclk_i(clka_i),
108
    .aadr_i(addra_i[SIZE+2-1:2]),
109
    .adat_o(dataa_o[15:8]),
110
    .adat_i(dataa_i[15:8]),
111
    .awr_i(wr_a[1]),
112
 
113
    .bclk_i(clkb_i),
114
    .badr_i(addrb_i[SIZE+2-1:2]),
115
    .bdat_o(datab_o[15:8]),
116
    .bdat_i(datab_i[15:8]),
117
    .bwr_i(wr_b[1])
118
);
119
 
120
ram_dp8
121
#(
122
    .WIDTH(8),
123
    .SIZE(SIZE),
124
    .FILENAME("mem_1.hex")
125
)
126
u2
127
(
128
    .aclk_i(clka_i),
129
    .aadr_i(addra_i[SIZE+2-1:2]),
130
    .adat_o(dataa_o[23:16]),
131
    .adat_i(dataa_i[23:16]),
132
    .awr_i(wr_a[2]),
133
 
134
    .bclk_i(clkb_i),
135
    .badr_i(addrb_i[SIZE+2-1:2]),
136
    .bdat_o(datab_o[23:16]),
137
    .bdat_i(datab_i[23:16]),
138
    .bwr_i(wr_b[2])
139
);
140
 
141
ram_dp8
142
#(
143
    .WIDTH(8),
144
    .SIZE(SIZE),
145
    .FILENAME("mem_0.hex")
146
)
147
u3
148
(
149
    .aclk_i(clka_i),
150
    .aadr_i(addra_i[SIZE+2-1:2]),
151
    .adat_o(dataa_o[31:24]),
152
    .adat_i(dataa_i[31:24]),
153
    .awr_i(wr_a[3]),
154
 
155
    .bclk_i(clkb_i),
156
    .badr_i(addrb_i[SIZE+2-1:2]),
157
    .bdat_o(datab_o[31:24]),
158
    .bdat_i(datab_i[31:24]),
159
    .bwr_i(wr_b[3])
160
);
161
 
162
// AckA
163
always @(posedge clka_i or posedge rsta_i)
164
begin
165
    if (rsta_i == 1'b1)
166
    begin
167
        acka_o  <= 1'b0;
168
    end
169
    else
170
    begin
171
        acka_o  <= stba_i;
172
    end
173
end
174
 
175
// AckB
176
always @(posedge clkb_i or posedge rstb_i)
177
begin
178
    if (rstb_i == 1'b1)
179
    begin
180
        ackb_o  <= 1'b0;
181
    end
182
    else
183
    begin
184
        ackb_o  <= stbb_i;
185
    end
186
end
187
 
188
endmodule

powered by: WebSVN 2.1.0

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