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

Subversion Repositories turbo8051

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

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 76 dinesha
////  http://www.opencores.org/cores/turb08051/                   ////
7 2 dinesha
////                                                              ////
8
////  Description                                                 ////
9
////   data ram                                                   ////
10
////                                                              ////
11
////  To Do:                                                      ////
12
////   nothing                                                    ////
13
////                                                              ////
14
////  Author(s):                                                  ////
15
////      - Simon Teran, simont@opencores.org                     ////
16 76 dinesha
////      - Dinesh Annayya, dinesha@opencores.org                 ////
17 2 dinesha
////                                                              ////
18
//////////////////////////////////////////////////////////////////////
19
////                                                              ////
20
//// Copyright (C) 2000 Authors and OPENCORES.ORG                 ////
21
////                                                              ////
22
//// This source file may be used and distributed without         ////
23
//// restriction provided that this copyright statement is not    ////
24
//// removed from the file and that any derivative work contains  ////
25
//// the original copyright notice and the associated disclaimer. ////
26
////                                                              ////
27
//// This source file is free software; you can redistribute it   ////
28
//// and/or modify it under the terms of the GNU Lesser General   ////
29
//// Public License as published by the Free Software Foundation; ////
30
//// either version 2.1 of the License, or (at your option) any   ////
31
//// later version.                                               ////
32
////                                                              ////
33
//// This source is distributed in the hope that it will be       ////
34
//// useful, but WITHOUT ANY WARRANTY; without even the implied   ////
35
//// warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR      ////
36
//// PURPOSE.  See the GNU Lesser General Public License for more ////
37
//// details.                                                     ////
38
////                                                              ////
39
//// You should have received a copy of the GNU Lesser General    ////
40
//// Public License along with this source; if not, download it   ////
41
//// from http://www.opencores.org/lgpl.shtml                     ////
42
////                                                              ////
43
//////////////////////////////////////////////////////////////////////
44
//
45
// CVS Revision History
46
//
47
// $Log: not supported by cvs2svn $
48
// Revision 1.10  2003/06/20 13:36:37  simont
49
// ram modules added.
50
//
51
// Revision 1.9  2003/06/17 14:17:22  simont
52
// BIST signals added.
53
//
54
// Revision 1.8  2003/04/02 16:12:04  simont
55
// generic_dpram used
56
//
57
// Revision 1.7  2003/04/02 11:26:21  simont
58
// updating...
59
//
60
// Revision 1.6  2003/01/26 14:19:22  rherveille
61
// Replaced oc8051_ram by generic_dpram.
62
//
63
// Revision 1.5  2003/01/13 14:14:41  simont
64
// replace some modules
65
//
66
// Revision 1.4  2002/09/30 17:33:59  simont
67
// prepared header
68
//
69
//
70
 
71
 
72 76 dinesha
`include "top_defines.v"
73 2 dinesha
 
74
 
75
module oc8051_ram_top (clk,
76
                       rst,
77
                       rd_addr,
78
                       rd_data,
79
                       wr_addr,
80
                       bit_addr,
81
                       wr_data,
82
                       wr,
83
                       bit_data_in,
84
                       bit_data_out
85
`ifdef OC8051_BIST
86
         ,
87
         scanb_rst,
88
         scanb_clk,
89
         scanb_si,
90
         scanb_so,
91
         scanb_en
92
`endif
93
                       );
94
 
95
// on-chip ram-size (2**ram_aw bytes)
96
parameter ram_aw = 8; // default 256 bytes
97
 
98
 
99
//
100
// clk          (in)  clock
101
// rd_addr      (in)  read addres [oc8051_ram_rd_sel.out]
102
// rd_data      (out) read data [oc8051_ram_sel.in_ram]
103
// wr_addr      (in)  write addres [oc8051_ram_wr_sel.out]
104
// bit_addr     (in)  bit addresable instruction [oc8051_decoder.bit_addr -r]
105
// wr_data      (in)  write data [oc8051_alu.des1]
106
// wr           (in)  write [oc8051_decoder.wr -r]
107
// bit_data_in  (in)  bit data input [oc8051_alu.desCy]
108
// bit_data_out (out)  bit data output [oc8051_ram_sel.bit_in]
109
//
110
 
111
input clk, wr, bit_addr, bit_data_in, rst;
112
input [7:0] wr_data;
113
input [7:0] rd_addr, wr_addr;
114
output bit_data_out;
115
output [7:0] rd_data;
116
 
117
`ifdef OC8051_BIST
118
input   scanb_rst;
119
input   scanb_clk;
120
input   scanb_si;
121
output  scanb_so;
122
input   scanb_en;
123
`endif
124
 
125
// rd_addr_m    read address modified
126
// wr_addr_m    write address modified
127
// wr_data_m    write data modified
128
reg [7:0] wr_data_m;
129
reg [7:0] rd_addr_m, wr_addr_m;
130
 
131
 
132
wire       rd_en;
133
reg        bit_addr_r,
134
           rd_en_r;
135
reg  [7:0] wr_data_r;
136
wire [7:0] rd_data_m;
137
reg  [2:0] bit_select;
138
 
139
assign bit_data_out = rd_data[bit_select];
140
 
141
 
142
assign rd_data = rd_en_r ? wr_data_r: rd_data_m;
143
assign rd_en   = (rd_addr_m == wr_addr_m) & wr;
144
 
145
oc8051_ram_256x8_two_bist oc8051_idata(
146
                           .clk     ( clk        ),
147
                           .rst     ( rst        ),
148
                           .rd_addr ( rd_addr_m  ),
149
                           .rd_data ( rd_data_m  ),
150
                           .rd_en   ( !rd_en     ),
151
                           .wr_addr ( wr_addr_m  ),
152
                           .wr_data ( wr_data_m  ),
153
                           .wr_en   ( 1'b1       ),
154
                           .wr      ( wr         )
155
`ifdef OC8051_BIST
156
         ,
157
         .scanb_rst(scanb_rst),
158
         .scanb_clk(scanb_clk),
159
         .scanb_si(scanb_si),
160
         .scanb_so(scanb_so),
161
         .scanb_en(scanb_en)
162
`endif
163
                           );
164
 
165
always @(posedge clk or posedge rst)
166
  if (rst) begin
167
    bit_addr_r <= #1 1'b0;
168
    bit_select <= #1 3'b0;
169
  end else begin
170
    bit_addr_r <= #1 bit_addr;
171
    bit_select <= #1 rd_addr[2:0];
172
  end
173
 
174
 
175
always @(posedge clk or posedge rst)
176
  if (rst) begin
177
    rd_en_r    <= #1 1'b0;
178
    wr_data_r  <= #1 8'h0;
179
  end else begin
180
    rd_en_r    <= #1 rd_en;
181
    wr_data_r  <= #1 wr_data_m;
182
  end
183
 
184
 
185
always @(rd_addr or bit_addr)
186
  casex ( {bit_addr, rd_addr[7]} ) // synopsys full_case parallel_case
187
      2'b0?: rd_addr_m = rd_addr;
188
      2'b10: rd_addr_m = {4'b0010, rd_addr[6:3]};
189
      2'b11: rd_addr_m = {1'b1, rd_addr[6:3], 3'b000};
190
  endcase
191
 
192
 
193
always @(wr_addr or bit_addr_r)
194
  casex ( {bit_addr_r, wr_addr[7]} ) // synopsys full_case parallel_case
195
      2'b0?: wr_addr_m = wr_addr;
196
      2'b10: wr_addr_m = {8'h00, 4'b0010, wr_addr[6:3]};
197
      2'b11: wr_addr_m = {8'h00, 1'b1, wr_addr[6:3], 3'b000};
198
  endcase
199
 
200
 
201
always @(rd_data or bit_select or bit_data_in or wr_data or bit_addr_r)
202
  casex ( {bit_addr_r, bit_select} ) // synopsys full_case parallel_case
203
      4'b0_???: wr_data_m = wr_data;
204
      4'b1_000: wr_data_m = {rd_data[7:1], bit_data_in};
205
      4'b1_001: wr_data_m = {rd_data[7:2], bit_data_in, rd_data[0]};
206
      4'b1_010: wr_data_m = {rd_data[7:3], bit_data_in, rd_data[1:0]};
207
      4'b1_011: wr_data_m = {rd_data[7:4], bit_data_in, rd_data[2:0]};
208
      4'b1_100: wr_data_m = {rd_data[7:5], bit_data_in, rd_data[3:0]};
209
      4'b1_101: wr_data_m = {rd_data[7:6], bit_data_in, rd_data[4:0]};
210
      4'b1_110: wr_data_m = {rd_data[7], bit_data_in, rd_data[5:0]};
211
      4'b1_111: wr_data_m = {bit_data_in, rd_data[6:0]};
212
  endcase
213
 
214
 
215
endmodule

powered by: WebSVN 2.1.0

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