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

Subversion Repositories turbo8051

[/] [turbo8051/] [trunk/] [rtl/] [8051/] [oc8051_ram_top.v] - Blame information for rev 70

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

Line No. Rev Author Line
1 2 dinesha
//////////////////////////////////////////////////////////////////////
2
////                                                              ////
3
////  8051 data ram                                               ////
4
////                                                              ////
5
////  This file is part of the 8051 cores project                 ////
6
////  http://www.opencores.org/cores/8051/                        ////
7
////                                                              ////
8
////  Description                                                 ////
9
////   data ram                                                   ////
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.10  2003/06/20 13:36:37  simont
48
// ram modules added.
49
//
50
// Revision 1.9  2003/06/17 14:17:22  simont
51
// BIST signals added.
52
//
53
// Revision 1.8  2003/04/02 16:12:04  simont
54
// generic_dpram used
55
//
56
// Revision 1.7  2003/04/02 11:26:21  simont
57
// updating...
58
//
59
// Revision 1.6  2003/01/26 14:19:22  rherveille
60
// Replaced oc8051_ram by generic_dpram.
61
//
62
// Revision 1.5  2003/01/13 14:14:41  simont
63
// replace some modules
64
//
65
// Revision 1.4  2002/09/30 17:33:59  simont
66
// prepared header
67
//
68
//
69
 
70
// synopsys translate_off
71
`include "oc8051_timescale.v"
72
// synopsys translate_on
73
 
74
`include "oc8051_defines.v"
75
 
76
 
77
module oc8051_ram_top (clk,
78
                       rst,
79
                       rd_addr,
80
                       rd_data,
81
                       wr_addr,
82
                       bit_addr,
83
                       wr_data,
84
                       wr,
85
                       bit_data_in,
86
                       bit_data_out
87
`ifdef OC8051_BIST
88
         ,
89
         scanb_rst,
90
         scanb_clk,
91
         scanb_si,
92
         scanb_so,
93
         scanb_en
94
`endif
95
                       );
96
 
97
// on-chip ram-size (2**ram_aw bytes)
98
parameter ram_aw = 8; // default 256 bytes
99
 
100
 
101
//
102
// clk          (in)  clock
103
// rd_addr      (in)  read addres [oc8051_ram_rd_sel.out]
104
// rd_data      (out) read data [oc8051_ram_sel.in_ram]
105
// wr_addr      (in)  write addres [oc8051_ram_wr_sel.out]
106
// bit_addr     (in)  bit addresable instruction [oc8051_decoder.bit_addr -r]
107
// wr_data      (in)  write data [oc8051_alu.des1]
108
// wr           (in)  write [oc8051_decoder.wr -r]
109
// bit_data_in  (in)  bit data input [oc8051_alu.desCy]
110
// bit_data_out (out)  bit data output [oc8051_ram_sel.bit_in]
111
//
112
 
113
input clk, wr, bit_addr, bit_data_in, rst;
114
input [7:0] wr_data;
115
input [7:0] rd_addr, wr_addr;
116
output bit_data_out;
117
output [7:0] rd_data;
118
 
119
`ifdef OC8051_BIST
120
input   scanb_rst;
121
input   scanb_clk;
122
input   scanb_si;
123
output  scanb_so;
124
input   scanb_en;
125
`endif
126
 
127
// rd_addr_m    read address modified
128
// wr_addr_m    write address modified
129
// wr_data_m    write data modified
130
reg [7:0] wr_data_m;
131
reg [7:0] rd_addr_m, wr_addr_m;
132
 
133
 
134
wire       rd_en;
135
reg        bit_addr_r,
136
           rd_en_r;
137
reg  [7:0] wr_data_r;
138
wire [7:0] rd_data_m;
139
reg  [2:0] bit_select;
140
 
141
assign bit_data_out = rd_data[bit_select];
142
 
143
 
144
assign rd_data = rd_en_r ? wr_data_r: rd_data_m;
145
assign rd_en   = (rd_addr_m == wr_addr_m) & wr;
146
 
147
oc8051_ram_256x8_two_bist oc8051_idata(
148
                           .clk     ( clk        ),
149
                           .rst     ( rst        ),
150
                           .rd_addr ( rd_addr_m  ),
151
                           .rd_data ( rd_data_m  ),
152
                           .rd_en   ( !rd_en     ),
153
                           .wr_addr ( wr_addr_m  ),
154
                           .wr_data ( wr_data_m  ),
155
                           .wr_en   ( 1'b1       ),
156
                           .wr      ( wr         )
157
`ifdef OC8051_BIST
158
         ,
159
         .scanb_rst(scanb_rst),
160
         .scanb_clk(scanb_clk),
161
         .scanb_si(scanb_si),
162
         .scanb_so(scanb_so),
163
         .scanb_en(scanb_en)
164
`endif
165
                           );
166
 
167
always @(posedge clk or posedge rst)
168
  if (rst) begin
169
    bit_addr_r <= #1 1'b0;
170
    bit_select <= #1 3'b0;
171
  end else begin
172
    bit_addr_r <= #1 bit_addr;
173
    bit_select <= #1 rd_addr[2:0];
174
  end
175
 
176
 
177
always @(posedge clk or posedge rst)
178
  if (rst) begin
179
    rd_en_r    <= #1 1'b0;
180
    wr_data_r  <= #1 8'h0;
181
  end else begin
182
    rd_en_r    <= #1 rd_en;
183
    wr_data_r  <= #1 wr_data_m;
184
  end
185
 
186
 
187
always @(rd_addr or bit_addr)
188
  casex ( {bit_addr, rd_addr[7]} ) // synopsys full_case parallel_case
189
      2'b0?: rd_addr_m = rd_addr;
190
      2'b10: rd_addr_m = {4'b0010, rd_addr[6:3]};
191
      2'b11: rd_addr_m = {1'b1, rd_addr[6:3], 3'b000};
192
  endcase
193
 
194
 
195
always @(wr_addr or bit_addr_r)
196
  casex ( {bit_addr_r, wr_addr[7]} ) // synopsys full_case parallel_case
197
      2'b0?: wr_addr_m = wr_addr;
198
      2'b10: wr_addr_m = {8'h00, 4'b0010, wr_addr[6:3]};
199
      2'b11: wr_addr_m = {8'h00, 1'b1, wr_addr[6:3], 3'b000};
200
  endcase
201
 
202
 
203
always @(rd_data or bit_select or bit_data_in or wr_data or bit_addr_r)
204
  casex ( {bit_addr_r, bit_select} ) // synopsys full_case parallel_case
205
      4'b0_???: wr_data_m = wr_data;
206
      4'b1_000: wr_data_m = {rd_data[7:1], bit_data_in};
207
      4'b1_001: wr_data_m = {rd_data[7:2], bit_data_in, rd_data[0]};
208
      4'b1_010: wr_data_m = {rd_data[7:3], bit_data_in, rd_data[1:0]};
209
      4'b1_011: wr_data_m = {rd_data[7:4], bit_data_in, rd_data[2:0]};
210
      4'b1_100: wr_data_m = {rd_data[7:5], bit_data_in, rd_data[3:0]};
211
      4'b1_101: wr_data_m = {rd_data[7:6], bit_data_in, rd_data[4:0]};
212
      4'b1_110: wr_data_m = {rd_data[7], bit_data_in, rd_data[5:0]};
213
      4'b1_111: wr_data_m = {bit_data_in, rd_data[6:0]};
214
  endcase
215
 
216
 
217
endmodule

powered by: WebSVN 2.1.0

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