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

Subversion Repositories qaz_libs

[/] [qaz_libs/] [trunk/] [basal/] [src/] [RAM/] [asym_ram_sdp_write_wider.v] - Blame information for rev 47

Go to most recent revision | Details | Compare with Previous | View Log

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

powered by: WebSVN 2.1.0

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