[HDL] Add dual-port RAM 1024x8 bit HDL decription as a primitive module of OpenFPGA cells

This commit is contained in:
tangxifan 2021-03-17 15:15:22 -06:00
parent 08a86e056a
commit f9dc7c1b54
1 changed files with 61 additions and 0 deletions

View File

@ -0,0 +1,61 @@
//-----------------------------------------------------
// Design Name : dpram_1024x8
// File Name : dpram8.v
// Function : Wrapper module of dual port RAM 1024 addresses x 8 bit
// Coder : Xifan tang
//-----------------------------------------------------
module dpram_1024x8 (
input clk,
input wen,
input ren,
input[0:9] waddr,
input[0:9] raddr,
input[0:7] data_in,
output[0:7] data_out );
dpram_1024x8_core memory_0 (
.wclk (clk),
.wen (wen),
.waddr (waddr),
.data_in (data_in),
.rclk (clk),
.ren (ren),
.raddr (raddr),
.data_out (data_out) );
endmodule
//-----------------------------------------------------
// Design Name : dpram_1024x8_core
// File Name : dpram8.v
// Function : Core module of dual port RAM 1024 addresses x 8 bit
// Coder : Xifan tang
//-----------------------------------------------------
module dpram_1024x8_core (
input wclk,
input wen,
input [0:9] waddr,
input [0:7] data_in,
input rclk,
input ren,
input [0:9] raddr,
output [0:7] data_out );
reg[0:7] ram[0:1023];
reg[0:7] internal;
assign data_out = internal;
always @(posedge wclk) begin
if(wen) begin
ram[waddr] <= data_in;
end
end
always @(posedge rclk) begin
if(ren) begin
internal <= ram[raddr];
end
end
endmodule