1 |
92 |
simont |
//////////////////////////////////////////////////////////////////////
|
2 |
|
|
//// ////
|
3 |
|
|
//// 8051 cache ram ////
|
4 |
|
|
//// ////
|
5 |
|
|
//// This file is part of the 8051 cores project ////
|
6 |
|
|
//// http://www.opencores.org/cores/8051/ ////
|
7 |
|
|
//// ////
|
8 |
|
|
//// Description ////
|
9 |
|
|
//// 64x32 dual port ram for instruction cache ////
|
10 |
|
|
//// ////
|
11 |
|
|
//// To Do: ////
|
12 |
|
|
//// nothing ////
|
13 |
|
|
//// ////
|
14 |
|
|
//// Author(s): ////
|
15 |
|
|
//// - Simon Teran, simont@opencores.org ////
|
16 |
|
|
//// ////
|
17 |
|
|
//////////////////////////////////////////////////////////////////////
|
18 |
|
|
//// ////
|
19 |
|
|
//// Copyright (C) 2000 Authors and OPENCORES.ORG ////
|
20 |
|
|
//// ////
|
21 |
|
|
//// This source file may be used and distributed without ////
|
22 |
|
|
//// restriction provided that this copyright statement is not ////
|
23 |
|
|
//// removed from the file and that any derivative work contains ////
|
24 |
|
|
//// the original copyright notice and the associated disclaimer. ////
|
25 |
|
|
//// ////
|
26 |
|
|
//// This source file is free software; you can redistribute it ////
|
27 |
|
|
//// and/or modify it under the terms of the GNU Lesser General ////
|
28 |
|
|
//// Public License as published by the Free Software Foundation; ////
|
29 |
|
|
//// either version 2.1 of the License, or (at your option) any ////
|
30 |
|
|
//// later version. ////
|
31 |
|
|
//// ////
|
32 |
|
|
//// This source is distributed in the hope that it will be ////
|
33 |
|
|
//// useful, but WITHOUT ANY WARRANTY; without even the implied ////
|
34 |
|
|
//// warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR ////
|
35 |
|
|
//// PURPOSE. See the GNU Lesser General Public License for more ////
|
36 |
|
|
//// details. ////
|
37 |
|
|
//// ////
|
38 |
|
|
//// You should have received a copy of the GNU Lesser General ////
|
39 |
|
|
//// Public License along with this source; if not, download it ////
|
40 |
|
|
//// from http://www.opencores.org/lgpl.shtml ////
|
41 |
|
|
//// ////
|
42 |
|
|
//////////////////////////////////////////////////////////////////////
|
43 |
|
|
//
|
44 |
|
|
// CVS Revision History
|
45 |
|
|
//
|
46 |
|
|
// $Log: not supported by cvs2svn $
|
47 |
|
|
// Revision 1.2 2002/10/24 13:37:43 simont
|
48 |
|
|
// add parameters
|
49 |
|
|
//
|
50 |
|
|
// Revision 1.1 2002/10/23 16:58:21 simont
|
51 |
|
|
// initial import
|
52 |
|
|
//
|
53 |
|
|
//
|
54 |
|
|
|
55 |
|
|
// synopsys translate_off
|
56 |
|
|
`include "oc8051_timescale.v"
|
57 |
|
|
// synopsys translate_on
|
58 |
|
|
|
59 |
|
|
|
60 |
|
|
module oc8051_cache_ram (clk, rst, addr0, data0, addr1, data1_i, data1_o, wr1);
|
61 |
|
|
//
|
62 |
|
|
// this module is part of oc8051_icache
|
63 |
|
|
// it's tehnology dependent
|
64 |
|
|
//
|
65 |
|
|
// clk (in) clock
|
66 |
|
|
// addr0 (in) addres port 0
|
67 |
|
|
// data0 (out) data output port 0
|
68 |
|
|
// addr1 (in) address port 1
|
69 |
|
|
// data1_i (in) data input port 1
|
70 |
|
|
// data1_o (out) data output port 1
|
71 |
|
|
// wr1 (in) write port 1
|
72 |
|
|
//
|
73 |
|
|
|
74 |
|
|
parameter ADR_WIDTH = 7; // cache address wihth
|
75 |
|
|
parameter CACHE_RAM = 128; // cache ram x 32 (2^ADR_WIDTH)
|
76 |
|
|
|
77 |
|
|
input clk, wr1, rst;
|
78 |
|
|
input [ADR_WIDTH-1:0] addr0, addr1;
|
79 |
|
|
input [31:0] data1_i;
|
80 |
|
|
output [31:0] data0, data1_o;
|
81 |
|
|
|
82 |
|
|
`ifdef OC8051_XILINX_RAM
|
83 |
|
|
|
84 |
|
|
RAMB4_S8_S8 ram1(.DOA(data0[7:0]), .DOB(data1_o[7:0]), .ADDRA({2'b0, addr0}), .DIA(8'h00), .ENA(1'b1), .CLKA(clk), .WEA(1'b0),
|
85 |
|
|
.RSTA(rst), .ADDRB({2'b0, addr1}), .DIB(data1_i[7:0]), .ENB(1'b1), .CLKB(clk), .WEB(wr1), .RSTB(rst));
|
86 |
|
|
|
87 |
|
|
RAMB4_S8_S8 ram2(.DOA(data0[15:8]), .DOB(data1_o[15:8]), .ADDRA({2'b0, addr0}), .DIA(8'h00), .ENA(1'b1), .CLKA(clk), .WEA(1'b0),
|
88 |
|
|
.RSTA(rst), .ADDRB({2'b0, addr1}), .DIB(data1_i[15:8]), .ENB(1'b1), .CLKB(clk), .WEB(wr1), .RSTB(rst));
|
89 |
|
|
|
90 |
|
|
RAMB4_S8_S8 ram3(.DOA(data0[23:16]), .DOB(data1_o[23:16]), .ADDRA({2'b0, addr0}), .DIA(8'h00), .ENA(1'b1), .CLKA(clk), .WEA(1'b0),
|
91 |
|
|
.RSTA(rst), .ADDRB({2'b0, addr1}), .DIB(data1_i[23:16]), .ENB(1'b1), .CLKB(clk), .WEB(wr1), .RSTB(rst));
|
92 |
|
|
|
93 |
|
|
RAMB4_S8_S8 ram4(.DOA(data0[31:24]), .DOB(data1_o[31:24]), .ADDRA({2'b0, addr0}), .DIA(8'h00), .ENA(1'b1), .CLKA(clk), .WEA(1'b0),
|
94 |
|
|
.RSTA(rst), .ADDRB({2'b0, addr1}), .DIB(data1_i[31:24]), .ENB(1'b1), .CLKB(clk), .WEB(wr1), .RSTB(rst));
|
95 |
|
|
|
96 |
|
|
`else
|
97 |
|
|
|
98 |
|
|
reg [31:0] data0, data1_o;
|
99 |
|
|
|
100 |
|
|
//
|
101 |
|
|
// buffer
|
102 |
|
|
reg [31:0] buff [0:CACHE_RAM];
|
103 |
|
|
|
104 |
|
|
//
|
105 |
|
|
// port 1
|
106 |
|
|
//
|
107 |
|
|
always @(posedge clk or posedge rst)
|
108 |
|
|
begin
|
109 |
|
|
if (rst)
|
110 |
|
|
data1_o <= #1 32'h0;
|
111 |
|
|
else if (wr1) begin
|
112 |
|
|
buff[addr1] <= #1 data1_i;
|
113 |
|
|
data1_o <= #1 data1_i;
|
114 |
|
|
end else
|
115 |
|
|
data1_o <= #1 buff[addr1];
|
116 |
|
|
end
|
117 |
|
|
|
118 |
|
|
//
|
119 |
|
|
// port 0
|
120 |
|
|
//
|
121 |
|
|
always @(posedge clk or posedge rst)
|
122 |
|
|
begin
|
123 |
|
|
if (rst)
|
124 |
|
|
data0 <= #1 32'h0;
|
125 |
|
|
else if ((addr0==addr1) & wr1)
|
126 |
|
|
data0 <= #1 data1_i;
|
127 |
|
|
else
|
128 |
|
|
data0 <= #1 buff[addr0];
|
129 |
|
|
end
|
130 |
|
|
|
131 |
|
|
`endif
|
132 |
|
|
|
133 |
|
|
|
134 |
|
|
endmodule
|