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

Subversion Repositories altor32

[/] [altor32/] [trunk/] [rtl/] [cpu/] [altor32_ram_sp.v] - Diff between revs 36 and 37

Only display areas with differences | Details | Blame | View Log

Rev 36 Rev 37
//-----------------------------------------------------------------
//-----------------------------------------------------------------
//                           AltOR32 
//                           AltOR32 
//                Alternative Lightweight OpenRisc 
//                Alternative Lightweight OpenRisc 
//                            V2.1
//                            V2.1
//                     Ultra-Embedded.com
//                     Ultra-Embedded.com
//                   Copyright 2011 - 2014
//                   Copyright 2011 - 2014
//
//
//               Email: admin@ultra-embedded.com
//               Email: admin@ultra-embedded.com
//
//
//                       License: LGPL
//                       License: LGPL
//-----------------------------------------------------------------
//-----------------------------------------------------------------
//
//
// Copyright (C) 2011 - 2013 Ultra-Embedded.com
// Copyright (C) 2011 - 2014 Ultra-Embedded.com
//
//
// This source file may be used and distributed without         
// This source file may be used and distributed without         
// restriction provided that this copyright statement is not    
// restriction provided that this copyright statement is not    
// removed from the file and that any derivative work contains  
// removed from the file and that any derivative work contains  
// the original copyright notice and the associated disclaimer. 
// the original copyright notice and the associated disclaimer. 
//
//
// This source file is free software; you can redistribute it   
// This source file is free software; you can redistribute it   
// and/or modify it under the terms of the GNU Lesser General   
// and/or modify it under the terms of the GNU Lesser General   
// Public License as published by the Free Software Foundation; 
// Public License as published by the Free Software Foundation; 
// either version 2.1 of the License, or (at your option) any   
// either version 2.1 of the License, or (at your option) any   
// later version.
// later version.
//
//
// This source is distributed in the hope that it will be       
// This source is distributed in the hope that it will be       
// useful, but WITHOUT ANY WARRANTY; without even the implied   
// useful, but WITHOUT ANY WARRANTY; without even the implied   
// warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR      
// warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR      
// PURPOSE.  See the GNU Lesser General Public License for more 
// PURPOSE.  See the GNU Lesser General Public License for more 
// details.
// details.
//
//
// You should have received a copy of the GNU Lesser General    
// You should have received a copy of the GNU Lesser General    
// Public License along with this source; if not, write to the 
// Public License along with this source; if not, write to the 
// Free Software Foundation, Inc., 59 Temple Place, Suite 330, 
// Free Software Foundation, Inc., 59 Temple Place, Suite 330, 
// Boston, MA  02111-1307  USA
// Boston, MA  02111-1307  USA
//-----------------------------------------------------------------
//-----------------------------------------------------------------
 
 
//-----------------------------------------------------------------
//-----------------------------------------------------------------
// Module: altor32_ram_sp - Single port RAM (used in cache)
// Module: altor32_ram_sp - Single port RAM (used in cache)
//-----------------------------------------------------------------
//-----------------------------------------------------------------
module altor32_ram_sp
module altor32_ram_sp
#(
#(
    parameter  [31:0]       WIDTH = 8,
    parameter  [31:0]       WIDTH = 8,
    parameter  [31:0]       SIZE = 14
    parameter  [31:0]       SIZE = 14
)
)
(
(
    input                   clk_i /*verilator public*/,
    input                   clk_i /*verilator public*/,
    output [(WIDTH - 1):0]  dat_o /*verilator public*/,
    output [(WIDTH - 1):0]  dat_o /*verilator public*/,
    input [(WIDTH - 1):0]   dat_i /*verilator public*/,
    input [(WIDTH - 1):0]   dat_i /*verilator public*/,
    input [(SIZE - 1):0]    adr_i /*verilator public*/,
    input [(SIZE - 1):0]    adr_i /*verilator public*/,
    input                   wr_i /*verilator public*/
    input                   wr_i /*verilator public*/
);
);
 
 
//-----------------------------------------------------------------
//-----------------------------------------------------------------
// Registers
// Registers
//-----------------------------------------------------------------
//-----------------------------------------------------------------
reg [(WIDTH - 1):0]     ram [((2<< (SIZE-1)) - 1):0] /*verilator public*/;
reg [(WIDTH - 1):0]     ram [((2<< (SIZE-1)) - 1):0] /*verilator public*/;
reg [(SIZE - 1):0]      rd_addr;
reg [(SIZE - 1):0]      rd_addr_q;
 
 
//-----------------------------------------------------------------
//-----------------------------------------------------------------
// Processes
// Processes
//-----------------------------------------------------------------
//-----------------------------------------------------------------
always @ (posedge clk_i)
always @ (posedge clk_i)
begin
begin
    if (wr_i == 1'b1)
    if (wr_i == 1'b1)
        ram[adr_i] <= dat_i;
        ram[adr_i] <= dat_i;
    rd_addr <= adr_i;
    rd_addr_q <= adr_i;
end
end
 
 
//-------------------------------------------------------------------
//-------------------------------------------------------------------
// Combinatorial
// Combinatorial
//-------------------------------------------------------------------
//-------------------------------------------------------------------
assign dat_o = ram[rd_addr];
assign dat_o = ram[rd_addr_q];
 
 
 
//-----------------------------------------------------------------
 
// Init Memory
 
//-----------------------------------------------------------------
 
`ifdef ALTOR32_CLEAR_RAM
 
    integer i;
 
    initial
 
    begin
 
        for (i=0;i<((2<< (SIZE-1)) - 1);i=i+1)
 
        begin
 
            ram[i] = 0;
 
        end
 
    end
 
`endif
 
 
endmodule
endmodule
 
 

powered by: WebSVN 2.1.0

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