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

Subversion Repositories thor

[/] [thor/] [trunk/] [rtl/] [verilog/] [Thor_dcachemem_1w1r.v] - Blame information for rev 3

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 3 robfinch
// ============================================================================
2
//        __
3
//   \\__/ o\    (C) 2013  Robert Finch, Stratford
4
//    \  __ /    All rights reserved.
5
//     \/_//     robfinch<remove>@finitron.ca
6
//       ||
7
//
8
// This source file is free software: you can redistribute it and/or modify 
9
// it under the terms of the GNU Lesser General Public License as published 
10
// by the Free Software Foundation, either version 3 of the License, or     
11
// (at your option) any later version.                                      
12
//                                                                          
13
// This source file is distributed in the hope that it will be useful,      
14
// but WITHOUT ANY WARRANTY; without even the implied warranty of           
15
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the            
16
// GNU General Public License for more details.                             
17
//                                                                          
18
// You should have received a copy of the GNU General Public License        
19
// along with this program.  If not, see <http://www.gnu.org/licenses/>.    
20
//
21
//
22
// Tri-ported data cache memory. (2 read, 1 write)
23
//
24
// ============================================================================
25
//
26
module Thor_dcachemem_1w1r(wclk, wce, wr, sel, wa, wd, rclk, rce, ra, o);
27
parameter DBW=64;
28
input wclk;
29
input wce;
30
input wr;
31
input [DBW/8-1:0] sel;
32
input [DBW-1:0] wa;
33
input [DBW-1:0] wd;
34
input rclk;
35
input rce;
36
input [DBW-1:0] ra;
37
output [DBW-1:0] o;
38
 
39
wire [DBW-1:0] o0, o1, o2;
40
genvar n;
41
 
42
generate
43
 
44
for (n = 0; n < DBW/8; n = n + 1)
45
begin : BRAMS
46
        if (DBW==64)
47
                syncRam2kx8_1rw1r uga (
48
                        .wclk(wclk),
49
                        .wce(wce),
50
                        .wr(wr & sel[n]),
51
                        .wa(wa[13:3]),
52
                        .wd(wd[n*8+7:n*8]),
53
                        .rclk(rclk),
54
                        .rce(rce),
55
                        .ra(ra[13:3]),
56
                        .o(o[n*8+7:n*8])
57
                );
58
        else begin
59
                syncRam2kx8_1rw1r uga (
60
                        .wclk(wclk),
61
                        .wce(wce),
62
                        .wr(wr & sel[n]),
63
                        .wa(wa[12:2]),
64
                        .wd(wd[n*8+7:n*8]),
65
                        .rclk(rclk),
66
                        .rce(rce),
67
                        .ra(ra[12:2]),
68
                        .o(o0[n*8+7:n*8])
69
                );
70
    end
71
end
72
endgenerate
73
 
74
assign o = o0;
75
always @(posedge wclk)
76
begin
77
    if (wce & wr & |sel) begin
78
        $display("*************************");
79
        $display("*************************");
80
        $display("Writing to DCACHE %h=%h", wa, wd);
81
        $display("*************************");
82
        $display("*************************");
83
    end
84
end
85
 
86
endmodule
87
 
88
module syncRam2kx8_1rw1r (wclk, wce, wr, wa, wd, rclk, rce, ra, o);
89
input wclk;
90
input wce;
91
input wr;
92
input [10:0] wa;
93
input [7:0] wd;
94
input rclk;
95
input rce;
96
input [10:0] ra;
97
output [7:0] o;
98
 
99
reg [7:0] mem [0:2047];
100
reg [10:0] rra;
101
integer n;
102
initial begin
103
    for (n = 0; n < 2048; n = n + 1)
104
        mem[n] <= 0;
105
end
106
 
107
always @(posedge wclk)
108
        if (wce & wr) mem[wa] <= wd;
109
always @(posedge rclk)
110
        if (rce) rra <= ra;
111
 
112
assign o = mem[rra];
113
 
114
endmodule

powered by: WebSVN 2.1.0

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