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

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [or1200/] [rtl/] [verilog/] [or1200_dpram.v] - Blame information for rev 732

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

Line No. Rev Author Line
1 142 marcus.erl
//////////////////////////////////////////////////////////////////////
2
////                                                              ////
3
////  Generic Double-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 double-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
////  double-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_dpram
61
  (
62
   // Generic synchronous double-port RAM interface
63
   clk_a, ce_a, addr_a, do_a,
64
   clk_b, ce_b, we_b, addr_b, di_b
65
   );
66
 
67
   //
68
   // Default address and data buses width
69
   //
70
   parameter aw = 5;
71
   parameter dw = 32;
72
 
73
   //
74
   // Generic synchronous double-port RAM interface
75
   //
76
   input                        clk_a;  // Clock
77
   input                        ce_a;   // Chip enable input
78
   input [aw-1:0]                addr_a; // address bus inputs
79
   output [dw-1:0]               do_a;   // output data bus
80
   input                        clk_b;  // Clock
81
   input                        ce_b;   // Chip enable input
82
   input                        we_b;   // Write enable input
83
   input [aw-1:0]                addr_b; // address bus inputs
84
   input [dw-1:0]                di_b;   // input data bus
85
 
86
   //
87
   // Internal wires and registers
88
   //
89
 
90
   //
91
   // Generic double-port synchronous RAM model
92
   //
93
 
94
   //
95
   // Generic RAM's registers and wires
96
   //
97 151 marcus.erl
   reg [dw-1:0]          mem [(1<<aw)-1:0] /*synthesis syn_ramstyle = "no_rw_check"*/;    // RAM content
98 142 marcus.erl
   reg [aw-1:0]          addr_a_reg;             // RAM address registered
99
 
100
 
101
   // Function to access GPRs (for use by Verilator). No need to hide this one
102
   // from the simulator, since it has an input (as required by IEEE 1364-2001).
103
   function [31:0] get_gpr;
104
      // verilator public
105
      input [aw-1:0]             gpr_no;
106
 
107 258 julius
      get_gpr = mem[gpr_no];
108 142 marcus.erl
 
109
   endfunction // get_gpr
110 481 julius
 
111 639 julius
   function [31:0] set_gpr;
112 481 julius
      // verilator public
113
      input [aw-1:0]             gpr_no;
114
      input [dw-1:0]             value;
115 639 julius
      begin
116
         mem[gpr_no] = value;
117
         set_gpr = 0;
118
      end
119
   endfunction // get_gpr
120 142 marcus.erl
 
121
   //
122
   // Data output drivers
123
   //
124
   //assign do_a = (oe_a) ? mem[addr_a_reg] : {dw{1'b0}};
125
   assign do_a = mem[addr_a_reg];
126
 
127
 
128
   //
129
   // RAM read
130
   //
131
   always @(posedge clk_a)
132
     if (ce_a)
133 258 julius
       addr_a_reg <=  addr_a;
134 142 marcus.erl
 
135
   //
136
   // RAM write
137
   //
138
   always @(posedge clk_b)
139
     if (ce_b & we_b)
140 258 julius
       mem[addr_b] <=  di_b;
141 142 marcus.erl
 
142
endmodule // or1200_dpram

powered by: WebSVN 2.1.0

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