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

Subversion Repositories qaz_libs

[/] [qaz_libs/] [trunk/] [basal/] [src/] [RAM/] [asym_ram_sdp_read_wider.v] - Blame information for rev 34

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 34 qaztronic
// Asymmetric port RAM
2
// Read Wider than Write. Read Statement in loop
3
//asym_ram_sdp_read_wider.v
4
module asym_ram_sdp_read_wider (clkA, clkB, enaA, weA, enaB, addrA, addrB, diA, doB);
5
parameter WIDTHA = 4;
6
parameter SIZEA = 1024;
7
parameter ADDRWIDTHA = 10;
8
parameter WIDTHB = 16;
9
parameter SIZEB = 256;
10
parameter ADDRWIDTHB = 8;
11
input clkA;
12
input clkB;
13
input weA;
14
input enaA, enaB;
15
input [ADDRWIDTHA-1:0] addrA;
16
input [ADDRWIDTHB-1:0] addrB;
17
input [WIDTHA-1:0] diA;
18
output [WIDTHB-1:0] doB;
19
`define max(a,b) {(a) > (b) ? (a) : (b)}
20
`define min(a,b) {(a) < (b) ? (a) : (b)}
21
function integer log2;
22
input integer value;
23
reg [31:0] shifted;
24
integer res;
25
begin
26
if (value < 2)
27
log2 = value;
28
else
29
begin
30
shifted = value-1;
31
for (res=0; shifted>0; res=res+1)
32
shifted = shifted>>1;
33
log2 = res;
34
end
35
end
36
endfunction
37
localparam maxSIZE = `max(SIZEA, SIZEB);
38
localparam maxWIDTH = `max(WIDTHA, WIDTHB);
39
localparam minWIDTH = `min(WIDTHA, WIDTHB);
40
localparam RATIO = maxWIDTH / minWIDTH;
41
localparam log2RATIO = log2(RATIO);
42
reg [minWIDTH-1:0] RAM [0:maxSIZE-1];
43
reg [WIDTHB-1:0] readB;
44
always @(posedge clkA)
45
begin
46
if (enaA) begin
47
if (weA)
48
RAM[addrA] <= diA;
49
end
50
end
51
always @(posedge clkB)
52
begin : ramread
53
integer i;
54
reg [log2RATIO-1:0] lsbaddr;
55
if (enaB) begin
56
for (i = 0; i < RATIO; i = i+1) begin
57
lsbaddr = i;
58
readB[(i+1)*minWIDTH-1 -: minWIDTH] <= RAM[{addrB, lsbaddr}];
59
end
60
end
61
end
62
assign doB = readB;
63
endmodule

powered by: WebSVN 2.1.0

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