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

Subversion Repositories openrisc_me

[/] [openrisc/] [trunk/] [orpsocv2/] [rtl/] [verilog/] [or1200/] [or1200_spram.v] - Blame information for rev 482

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

Line No. Rev Author Line
1 350 julius
//////////////////////////////////////////////////////////////////////
2
////                                                              ////
3
////  Generic Single-Port Synchronous RAM                         ////
4
////                                                              ////
5
////  This file is part of memory library available from          ////
6
////  http://www.opencores.org/cvsweb.shtml/generic_memories/     ////
7
////                                                              ////
8
////  Description                                                 ////
9
////  This block is a wrapper with common single-port             ////
10
////  synchronous memory interface for different                  ////
11
////  types of ASIC and FPGA RAMs. Beside universal memory        ////
12
////  interface it also provides behavioral model of generic      ////
13
////  single-port synchronous RAM.                                ////
14
////  It should be used in all OPENCORES designs that want to be  ////
15
////  portable accross different target technologies and          ////
16
////  independent of target memory.                               ////
17
////                                                              ////
18
////  Author(s):                                                  ////
19
////      - Michael Unneback, unneback@opencores.org              ////
20
////                                                              ////
21
//////////////////////////////////////////////////////////////////////
22
////                                                              ////
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: or1200_dpram_32x32.v,v $
51
// Revision 2.0  2010/06/30 11:00:00  ORSoC
52
// New 
53
//
54
 
55
// synopsys translate_off
56
`include "timescale.v"
57
// synopsys translate_on
58
`include "or1200_defines.v"
59
 
60
module or1200_spram
61
  (
62
`ifdef OR1200_BIST
63
   // RAM BIST
64
   mbist_si_i, mbist_so_o, mbist_ctrl_i,
65
`endif
66
   // Generic synchronous single-port RAM interface
67
   clk, ce, we, addr, di, doq
68 482 julius
`ifdef OR1200_RAM_PARITY
69
   , p_err
70
`endif
71 350 julius
   );
72
 
73
   //
74
   // Default address and data buses width
75
   //
76
   parameter aw = 10;
77
   parameter dw = 32;
78
 
79
`ifdef OR1200_BIST
80
   //
81
   // RAM BIST
82
   //
83
   input mbist_si_i;
84
   input [`OR1200_MBIST_CTRL_WIDTH - 1:0] mbist_ctrl_i;
85 482 julius
   output                                 mbist_so_o;
86 350 julius
`endif
87
 
88
   //
89
   // Generic synchronous single-port RAM interface
90
   //
91
   input                                  clk;  // Clock
92
   input                                  ce;   // Chip enable input
93
   input                                  we;   // Write enable input
94
   input [aw-1:0]                          addr; // address bus inputs
95
   input [dw-1:0]                          di;   // input data bus
96
   output [dw-1:0]                         doq;  // output data bus
97 482 julius
`ifdef OR1200_RAM_PARITY
98
   output                                 p_err; // parity error indicator
99
`endif
100 350 julius
 
101
   //
102
   // Internal wires and registers
103
   //
104
 
105
   //
106
   // Generic single-port synchronous RAM model
107
   //
108
 
109
   //
110
   // Generic RAM's registers and wires
111
   //
112 482 julius
`ifdef OR1200_RAM_PARITY
113
   reg [(dw+(dw/8))-1:0]                   mem [(1<<aw)-1:0] /*synthesis syn_ramstyle = "no_rw_check"*/;
114
`else
115 350 julius
   reg [dw-1:0]                    mem [(1<<aw)-1:0] /*synthesis syn_ramstyle = "no_rw_check"*/;
116 482 julius
`endif
117
 
118
   reg [aw-1:0]                    addr_reg;             // RAM address register
119
 
120
`ifdef OR1200_RAM_PARITY
121
   wire [(dw+(dw/8))-1:0]        doq_wire;
122
   wire [(dw/8)-1:0]             di_p;
123
   wire [(dw/8)-1:0]             do_p;
124
   wire [(dw/8)-1:0]             parity_err;
125 350 julius
`else
126 482 julius
   wire [dw-1:0]                 doq_wire;
127 350 julius
`endif
128 482 julius
 
129
`ifdef OR1200_RAM_PARITY
130
   genvar                       i;
131
   generate
132
      for (i=0;i<(dw/8);i=i+1) begin: paritygen
133
         or1200_parity_gen pgen(.d_i(di[(i*8)+7:(i*8)]), .p_o(di_p[i]));
134
         or1200_parity_chk pchk(.d_i(doq_wire[(i*8)+7:(i*8)]),
135
                                .p_i(do_p[i]), .err_o(parity_err[i]));
136
      end
137
   endgenerate
138
 
139
   // Extract parity bits of data out
140
   assign do_p = doq_wire[(dw+(dw/8))-1:dw];
141 350 julius
 
142 482 julius
   // Indicate error
143
   assign p_err = (|parity_err);
144
 
145
   // Inject a parity error. Can specify GPR number to affect,
146
   // and which parity or data bit to switch.
147
   task gen_parity_err;
148
      input [aw-1:0]             gpr_no;
149
      input [31:0]               parity_bit_no;
150
      input [31:0]               data_bit_no;
151
      reg [(dw+(dw/8))-1:0]      do_temp;
152
      begin
153
         do_temp = mem[gpr_no];
154
         // Switch parity bit
155
         if (parity_bit_no > 0 && parity_bit_no <= (dw/8))
156
           do_temp[dw+(parity_bit_no-1)] = ~do_temp[dw+(parity_bit_no-1)];
157
         // Switch data bit
158
         if (data_bit_no > 0 && data_bit_no <= dw)
159
           do_temp[data_bit_no-1] = ~do_temp[data_bit_no-1];
160
         // Write word back
161
         mem[gpr_no] = do_temp;
162
      end
163
   endtask // gen_parity_err
164
 
165
 
166
`endif
167
 
168
 
169 350 julius
   //
170
   // Data output drivers
171
   //
172 482 julius
   assign doq_wire = mem[addr_reg];
173
   assign doq = doq_wire[dw-1:0];
174 350 julius
 
175
   //
176
   // RAM read address register
177
   //
178
   always @(posedge clk)
179
     if (ce)
180
       addr_reg <=  addr;
181
 
182
   //
183
   // RAM write
184
   //
185
   always @(posedge clk)
186
     if (we && ce)
187 482 julius
`ifdef OR1200_RAM_PARITY
188
       mem[addr] <=  {di_p,di};
189
`else
190 350 julius
       mem[addr] <=  di;
191 482 julius
`endif
192 350 julius
 
193
endmodule // or1200_spram

powered by: WebSVN 2.1.0

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