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

Subversion Repositories altor32

[/] [altor32/] [trunk/] [rtl/] [cpu/] [altor32_ram_dp.v] - Blame information for rev 37

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 27 ultra_embe
//-----------------------------------------------------------------
2
//                           AltOR32 
3
//                Alternative Lightweight OpenRisc 
4 36 ultra_embe
//                            V2.1
5 27 ultra_embe
//                     Ultra-Embedded.com
6 36 ultra_embe
//                   Copyright 2011 - 2014
7 27 ultra_embe
//
8
//               Email: admin@ultra-embedded.com
9
//
10
//                       License: LGPL
11
//-----------------------------------------------------------------
12
//
13 37 ultra_embe
// Copyright (C) 2011 - 2014 Ultra-Embedded.com
14 27 ultra_embe
//
15
// This source file may be used and distributed without         
16
// restriction provided that this copyright statement is not    
17
// removed from the file and that any derivative work contains  
18
// the original copyright notice and the associated disclaimer. 
19
//
20
// This source file is free software; you can redistribute it   
21
// and/or modify it under the terms of the GNU Lesser General   
22
// Public License as published by the Free Software Foundation; 
23
// either version 2.1 of the License, or (at your option) any   
24
// later version.
25
//
26
// This source is distributed in the hope that it will be       
27
// useful, but WITHOUT ANY WARRANTY; without even the implied   
28
// warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR      
29
// PURPOSE.  See the GNU Lesser General Public License for more 
30
// details.
31
//
32
// You should have received a copy of the GNU Lesser General    
33
// Public License along with this source; if not, write to the 
34
// Free Software Foundation, Inc., 59 Temple Place, Suite 330, 
35
// Boston, MA  02111-1307  USA
36
//-----------------------------------------------------------------
37
 
38
//-----------------------------------------------------------------
39
// Module: altor32_ram_dp - Dual port RAM (used in cache)
40
//-----------------------------------------------------------------
41
module altor32_ram_dp
42 30 ultra_embe
#(
43
    parameter               WIDTH = 8,
44
    parameter               SIZE = 14
45
)
46 27 ultra_embe
(
47
    input                   aclk_i /*verilator public*/,
48
    output [(WIDTH - 1):0]  adat_o /*verilator public*/,
49
    input [(WIDTH - 1):0]   adat_i /*verilator public*/,
50
    input [(SIZE - 1):0]    aadr_i /*verilator public*/,
51
    input                   awr_i /*verilator public*/,
52
 
53
    input                   bclk_i /*verilator public*/,
54
    output [(WIDTH - 1):0]  bdat_o /*verilator public*/,
55
    input [(WIDTH - 1):0]   bdat_i /*verilator public*/,
56
    input [(SIZE - 1):0]    badr_i /*verilator public*/,
57
    input                   bwr_i /*verilator public*/
58
);
59
 
60
//-----------------------------------------------------------------
61
// Registers
62
//-----------------------------------------------------------------
63
/* verilator lint_off MULTIDRIVEN */
64
reg [(WIDTH - 1):0]     ram [((2<< (SIZE-1)) - 1):0] /*verilator public*/;
65
/* verilator lint_on MULTIDRIVEN */
66
 
67 37 ultra_embe
reg [(SIZE - 1):0]      rd_addr_a_q;
68
reg [(SIZE - 1):0]      rd_addr_b_q;
69 27 ultra_embe
 
70
//-----------------------------------------------------------------
71
// Processes
72
//-----------------------------------------------------------------
73
always @ (posedge aclk_i)
74
begin
75
    if (awr_i == 1'b1)
76
        ram[aadr_i] <= adat_i;
77 37 ultra_embe
    rd_addr_a_q <= aadr_i;
78 27 ultra_embe
end
79
always @ (posedge bclk_i)
80
begin
81
    if (bwr_i == 1'b1)
82
        ram[badr_i] <= bdat_i;
83 37 ultra_embe
    rd_addr_b_q <= badr_i;
84 27 ultra_embe
end
85
 
86
//-------------------------------------------------------------------
87
// Combinatorial
88
//-------------------------------------------------------------------
89 37 ultra_embe
assign adat_o = ram[rd_addr_a_q];
90
assign bdat_o = ram[rd_addr_b_q];
91 27 ultra_embe
 
92 37 ultra_embe
//-----------------------------------------------------------------
93
// Init Memory
94
//-----------------------------------------------------------------
95
`ifdef ALTOR32_CLEAR_RAM
96
    integer i;
97
    initial
98
    begin
99
        for (i=0;i<((2<< (SIZE-1)) - 1);i=i+1)
100
        begin
101
            ram[i] = 0;
102
        end
103
    end
104
`endif
105
 
106 27 ultra_embe
endmodule

powered by: WebSVN 2.1.0

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