2019-11-06 13:21:20 -06:00
|
|
|
//-----------------------------------------------------
|
2019-12-03 14:58:20 -06:00
|
|
|
// Design Name : dual_port_ram
|
2019-12-03 17:09:26 -06:00
|
|
|
// File Name : dpram.v
|
|
|
|
// Function : Dual port RAM 32x1024
|
2019-12-03 14:58:20 -06:00
|
|
|
// Coder : Aurelien
|
2019-11-06 13:21:20 -06:00
|
|
|
//-----------------------------------------------------
|
|
|
|
|
2019-12-03 14:58:20 -06:00
|
|
|
module dpram (
|
2019-11-06 13:21:20 -06:00
|
|
|
input clk,
|
|
|
|
input wen,
|
|
|
|
input ren,
|
2019-12-03 14:58:20 -06:00
|
|
|
input[0:9] waddr,
|
|
|
|
input[0:9] raddr,
|
2019-11-06 13:21:20 -06:00
|
|
|
input[0:31] d_in,
|
|
|
|
output[0:31] d_out );
|
|
|
|
|
2019-12-03 14:58:20 -06:00
|
|
|
dual_port_sram memory_0 (
|
|
|
|
.wclk (clk),
|
|
|
|
.wen (wen),
|
|
|
|
.waddr (waddr),
|
|
|
|
.data_in (d_in),
|
|
|
|
.rclk (clk),
|
|
|
|
.ren (ren),
|
|
|
|
.raddr (raddr),
|
|
|
|
.d_out (d_out) );
|
2019-11-06 13:21:20 -06:00
|
|
|
|
|
|
|
endmodule
|
|
|
|
|
2019-12-03 14:58:20 -06:00
|
|
|
module dual_port_sram (
|
2019-11-06 13:21:20 -06:00
|
|
|
input wclk,
|
|
|
|
input wen,
|
2019-12-03 14:58:20 -06:00
|
|
|
input[0:9] waddr,
|
2019-11-06 13:21:20 -06:00
|
|
|
input[0:31] data_in,
|
|
|
|
input rclk,
|
|
|
|
input ren,
|
2019-12-03 14:58:20 -06:00
|
|
|
input[0:9] raddr,
|
2019-11-06 13:21:20 -06:00
|
|
|
output[0:31] d_out );
|
|
|
|
|
2019-12-03 14:58:20 -06:00
|
|
|
reg[0:31] ram[0:1023];
|
2019-11-06 13:21:20 -06:00
|
|
|
reg[0:31] internal;
|
|
|
|
|
|
|
|
assign d_out = internal;
|
|
|
|
|
2019-12-03 17:09:26 -06:00
|
|
|
always @(posedge wclk) begin
|
2019-11-06 13:21:20 -06:00
|
|
|
if(wen) begin
|
|
|
|
ram[waddr] <= data_in;
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2019-12-03 17:09:26 -06:00
|
|
|
always @(posedge rclk) begin
|
2019-11-06 13:21:20 -06:00
|
|
|
if(ren) begin
|
|
|
|
internal <= ram[raddr];
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
endmodule
|