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

Subversion Repositories oms8051mini

[/] [oms8051mini/] [trunk/] [rtl/] [8051/] [oc8051_ram_top.v] - Blame information for rev 31

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

powered by: WebSVN 2.1.0

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