OpenFPGA/openfpga_flow/openfpga_cell_library/verilog/dpram16k.v

57 lines
977 B
Coq
Raw Normal View History

2020-04-12 15:27:05 -05:00
//-----------------------------------------------------
// Design Name : dual_port_ram
// File Name : dpram.v
// Function : Dual port RAM 32x1024
// Coder : Aurelien
//-----------------------------------------------------
module dpram_512x32 (
input clk,
input wen,
input ren,
2022-10-27 00:28:58 -05:00
input[0:8] waddr,
input[0:8] raddr,
2020-04-12 15:27:05 -05:00
input[0:31] d_in,
output[0:31] d_out );
2022-10-26 08:27:30 -05:00
dpram_512x32_core memory_0 (
2020-04-12 15:27:05 -05:00
.wclk (clk),
.wen (wen),
.waddr (waddr),
.data_in (d_in),
.rclk (clk),
.ren (ren),
.raddr (raddr),
.d_out (d_out) );
endmodule
2022-10-26 08:27:30 -05:00
module dpram_512x32_core (
2020-04-12 15:27:05 -05:00
input wclk,
input wen,
2022-10-27 00:28:58 -05:00
input[0:8] waddr,
2020-04-12 15:27:05 -05:00
input[0:31] data_in,
input rclk,
input ren,
2022-10-27 00:28:58 -05:00
input[0:8] raddr,
2020-04-12 15:27:05 -05:00
output[0:31] d_out );
2022-10-27 00:28:58 -05:00
reg[0:31] ram[0:511];
2020-04-12 15:27:05 -05:00
reg[0:31] internal;
assign d_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