/*
|
/*
|
* .--------------. .----------------. .------------.
|
* .--------------. .----------------. .------------.
|
* | .------------. | .--------------. | .----------. |
|
* | .------------. | .--------------. | .----------. |
|
* | | ____ ____ | | | ____ ____ | | | ______ | |
|
* | | ____ ____ | | | ____ ____ | | | ______ | |
|
* | ||_ || _|| | ||_ \ / _|| | | .' ___ || |
|
* | ||_ || _|| | ||_ \ / _|| | | .' ___ || |
|
* ___ _ __ ___ _ __ | | | |__| | | | | | \/ | | | |/ .' \_|| |
|
* ___ _ __ ___ _ __ | | | |__| | | | | | \/ | | | |/ .' \_|| |
|
* / _ \| '_ \ / _ \ '_ \ | | | __ | | | | | |\ /| | | | || | | |
|
* / _ \| '_ \ / _ \ '_ \ | | | __ | | | | | |\ /| | | | || | | |
|
* (_) | |_) | __/ | | || | _| | | |_ | | | _| |_\/_| |_ | | |\ `.___.'\| |
|
* (_) | |_) | __/ | | || | _| | | |_ | | | _| |_\/_| |_ | | |\ `.___.'\| |
|
* \___/| .__/ \___|_| |_|| ||____||____|| | ||_____||_____|| | | `._____.'| |
|
* \___/| .__/ \___|_| |_|| ||____||____|| | ||_____||_____|| | | `._____.'| |
|
* | | | | | | | | | | | |
|
* | | | | | | | | | | | |
|
* |_| | '------------' | '--------------' | '----------' |
|
* |_| | '------------' | '--------------' | '----------' |
|
* '--------------' '----------------' '------------'
|
* '--------------' '----------------' '------------'
|
*
|
*
|
* openHMC - An Open Source Hybrid Memory Cube Controller
|
* openHMC - An Open Source Hybrid Memory Cube Controller
|
* (C) Copyright 2014 Computer Architecture Group - University of Heidelberg
|
* (C) Copyright 2014 Computer Architecture Group - University of Heidelberg
|
* www.ziti.uni-heidelberg.de
|
* www.ziti.uni-heidelberg.de
|
* B6, 26
|
* B6, 26
|
* 68159 Mannheim
|
* 68159 Mannheim
|
* Germany
|
* Germany
|
*
|
*
|
* Contact: openhmc@ziti.uni-heidelberg.de
|
* Contact: openhmc@ziti.uni-heidelberg.de
|
* http://ra.ziti.uni-heidelberg.de/openhmc
|
* http://ra.ziti.uni-heidelberg.de/openhmc
|
*
|
*
|
* This source file is free software: you can redistribute it and/or modify
|
* This source file is free software: you can redistribute it and/or modify
|
* it under the terms of the GNU Lesser General Public License as published by
|
* it under the terms of the GNU Lesser General Public License as published by
|
* the Free Software Foundation, either version 3 of the License, or
|
* the Free Software Foundation, either version 3 of the License, or
|
* (at your option) any later version.
|
* (at your option) any later version.
|
*
|
*
|
* This source file is distributed in the hope that it will be useful,
|
* This source file is distributed in the hope that it will be useful,
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
* GNU Lesser General Public License for more details.
|
* GNU Lesser General Public License for more details.
|
*
|
*
|
* You should have received a copy of the GNU Lesser General Public License
|
* You should have received a copy of the GNU Lesser General Public License
|
* along with this source file. If not, see <http://www.gnu.org/licenses/>.
|
* along with this source file. If not, see <http://www.gnu.org/licenses/>.
|
*
|
*
|
*
|
*
|
* Module name: openhmc_ram
|
* Module name: openhmc_ram
|
*
|
*
|
*/
|
*/
|
|
|
`default_nettype none
|
`default_nettype none
|
|
|
module openhmc_ram #(
|
module openhmc_ram #(
|
parameter DATASIZE = 78, // Memory data word width
|
parameter DATASIZE = 78, // Memory data word width
|
parameter ADDRSIZE = 9, // Number of memory address bits
|
parameter ADDRSIZE = 9, // Number of memory address bits
|
parameter PIPELINED = 0
|
parameter PIPELINED = 0
|
) (
|
) (
|
//----------------------------------
|
//----------------------------------
|
//----SYSTEM INTERFACE
|
//----SYSTEM INTERFACE
|
//----------------------------------
|
//----------------------------------
|
input wire clk,
|
input wire clk,
|
|
|
//----------------------------------
|
//----------------------------------
|
//----Signals
|
//----Signals
|
//----------------------------------
|
//----------------------------------
|
input wire wen,
|
input wire wen,
|
input wire [DATASIZE-1:0] wdata,
|
input wire [DATASIZE-1:0] wdata,
|
input wire [ADDRSIZE-1:0] waddr,
|
input wire [ADDRSIZE-1:0] waddr,
|
input wire ren,
|
input wire ren,
|
input wire [ADDRSIZE-1:0] raddr,
|
input wire [ADDRSIZE-1:0] raddr,
|
output wire [DATASIZE-1:0] rdata
|
output wire [DATASIZE-1:0] rdata
|
);
|
);
|
|
|
//=====================================================================================================
|
//=====================================================================================================
|
//-----------------------------------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------------------------------
|
//---------WIRING AND SIGNAL STUFF---------------------------------------------------------------------
|
//---------WIRING AND SIGNAL STUFF---------------------------------------------------------------------
|
//-----------------------------------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------------------------------
|
//=====================================================================================================
|
//=====================================================================================================
|
|
|
wire [DATASIZE-1:0] rdata_ram;
|
wire [DATASIZE-1:0] rdata_ram;
|
|
|
generate
|
generate
|
if (PIPELINED == 0)
|
if (PIPELINED == 0)
|
begin
|
begin
|
assign rdata = rdata_ram;
|
assign rdata = rdata_ram;
|
end
|
end
|
else
|
else
|
begin
|
begin
|
reg [DATASIZE-1:0] rdata_dly;
|
reg [DATASIZE-1:0] rdata_dly;
|
reg ren_dly;
|
reg ren_dly;
|
|
|
assign rdata = rdata_dly;
|
assign rdata = rdata_dly;
|
|
|
always @(posedge clk)
|
always @(posedge clk)
|
begin
|
begin
|
ren_dly <= ren;
|
ren_dly <= ren;
|
|
|
if (ren_dly)
|
if (ren_dly)
|
rdata_dly <= rdata_ram;
|
rdata_dly <= rdata_ram;
|
end
|
end
|
end
|
end
|
endgenerate
|
endgenerate
|
|
|
reg [DATASIZE-1:0] MEM [0:(2**ADDRSIZE)-1];
|
reg [DATASIZE-1:0] MEM [0:(2**ADDRSIZE)-1];
|
|
|
reg [DATASIZE-1:0] data_out;
|
reg [DATASIZE-1:0] data_out;
|
|
|
assign rdata_ram = data_out;
|
assign rdata_ram = data_out;
|
|
|
|
|
|
|
always @(posedge clk)
|
always @(posedge clk)
|
begin
|
begin
|
if (wen)
|
if (wen)
|
MEM[waddr] <= wdata;
|
MEM[waddr] <= wdata;
|
end
|
end
|
|
|
always @(posedge clk)
|
always @(posedge clk)
|
begin
|
begin
|
if (ren)
|
if (ren)
|
data_out <= MEM[raddr];
|
data_out <= MEM[raddr];
|
end
|
end
|
|
|
endmodule
|
endmodule
|
|
|
`default_nettype wire
|
`default_nettype wire
|
|
|