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

Subversion Repositories altor32

[/] [altor32/] [trunk/] [rtl/] [sim/] [ram.v] - Blame information for rev 32

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 27 ultra_embe
//-----------------------------------------------------------------
2 32 ultra_embe
//                           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 27 ultra_embe
// Module: ram - dual port block RAM
40
//-----------------------------------------------------------------
41
module ram
42
(
43
    // Port A
44
    input clka_i /*verilator public*/,
45 32 ultra_embe
    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 27 ultra_embe
    input [31:2] addra_i /*verilator public*/,
50
    input [31:0] dataa_i /*verilator public*/,
51
    output [31:0] dataa_o /*verilator public*/,
52 32 ultra_embe
    output reg acka_o /*verilator public*/,
53 27 ultra_embe
 
54
    // Port B
55
    input clkb_i /*verilator public*/,
56 32 ultra_embe
    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 27 ultra_embe
    input [31:2] addrb_i /*verilator public*/,
61
    input [31:0] datab_i /*verilator public*/,
62 32 ultra_embe
    output [31:0] datab_o /*verilator public*/,
63
    output reg ackb_o /*verilator public*/
64 27 ultra_embe
);
65
 
66
//-----------------------------------------------------------------
67
// Params
68
//-----------------------------------------------------------------
69
parameter  [31:0]       block_count  = 6;
70
parameter  [31:0]       SIZE         = 14;
71
 
72
//-----------------------------------------------------------------
73
// Instantiation
74
//-----------------------------------------------------------------
75
 
76 32 ultra_embe
wire [3:0] wr_a = {4{stba_i}} & {4{wea_i}} & sela_i;
77
wire [3:0] wr_b = {4{stbb_i}} & {4{web_i}} & selb_i;
78
 
79 27 ultra_embe
ram_dp8
80
#(
81
    .WIDTH(8),
82
    .SIZE(SIZE)
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 32 ultra_embe
    .awr_i(wr_a[0]),
91 27 ultra_embe
 
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 32 ultra_embe
    .bwr_i(wr_b[0])
97 27 ultra_embe
);
98
 
99
ram_dp8
100
#(
101
    .WIDTH(8),
102
    .SIZE(SIZE)
103
)
104
u1
105
(
106
    .aclk_i(clka_i),
107
    .aadr_i(addra_i[SIZE+2-1:2]),
108
    .adat_o(dataa_o[15:8]),
109
    .adat_i(dataa_i[15:8]),
110 32 ultra_embe
    .awr_i(wr_a[1]),
111 27 ultra_embe
 
112
    .bclk_i(clkb_i),
113
    .badr_i(addrb_i[SIZE+2-1:2]),
114
    .bdat_o(datab_o[15:8]),
115
    .bdat_i(datab_i[15:8]),
116 32 ultra_embe
    .bwr_i(wr_b[1])
117 27 ultra_embe
);
118
 
119
ram_dp8
120
#(
121
    .WIDTH(8),
122
    .SIZE(SIZE)
123
)
124
u2
125
(
126
    .aclk_i(clka_i),
127
    .aadr_i(addra_i[SIZE+2-1:2]),
128
    .adat_o(dataa_o[23:16]),
129
    .adat_i(dataa_i[23:16]),
130 32 ultra_embe
    .awr_i(wr_a[2]),
131 27 ultra_embe
 
132
    .bclk_i(clkb_i),
133
    .badr_i(addrb_i[SIZE+2-1:2]),
134
    .bdat_o(datab_o[23:16]),
135
    .bdat_i(datab_i[23:16]),
136 32 ultra_embe
    .bwr_i(wr_b[2])
137 27 ultra_embe
);
138
 
139
ram_dp8
140
#(
141
    .WIDTH(8),
142
    .SIZE(SIZE)
143
)
144
u3
145
(
146
    .aclk_i(clka_i),
147
    .aadr_i(addra_i[SIZE+2-1:2]),
148
    .adat_o(dataa_o[31:24]),
149
    .adat_i(dataa_i[31:24]),
150 32 ultra_embe
    .awr_i(wr_a[3]),
151 27 ultra_embe
 
152
    .bclk_i(clkb_i),
153
    .badr_i(addrb_i[SIZE+2-1:2]),
154
    .bdat_o(datab_o[31:24]),
155
    .bdat_i(datab_i[31:24]),
156 32 ultra_embe
    .bwr_i(wr_b[3])
157 27 ultra_embe
);
158
 
159 32 ultra_embe
// AckA
160
always @(posedge clka_i or posedge rsta_i)
161
begin
162
    if (rsta_i == 1'b1)
163
    begin
164
        acka_o  <= 1'b0;
165
    end
166
    else
167
    begin
168
        acka_o  <= stba_i;
169
    end
170
end
171
 
172
// AckB
173
always @(posedge clkb_i or posedge rstb_i)
174
begin
175
    if (rstb_i == 1'b1)
176
    begin
177
        ackb_o  <= 1'b0;
178
    end
179
    else
180
    begin
181
        ackb_o  <= stbb_i;
182
    end
183
end
184
 
185 27 ultra_embe
endmodule

powered by: WebSVN 2.1.0

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