aboutsummaryrefslogtreecommitdiffstats
path: root/tests/memlib/memlib_block_tdp.v
blob: c6b8763600b2a12fb300d7fd651475bfc9b0b6d0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
module RAM_BLOCK_TDP(
	input PORT_A_CLK,
	input PORT_A_WR_EN,
	input [9:0] PORT_A_ADDR,
	input [15:0] PORT_A_WR_DATA,
	output reg [15:0] PORT_A_RD_DATA,
	input PORT_B_CLK,
	input PORT_B_WR_EN,
	input [9:0] PORT_B_ADDR,
	input [15:0] PORT_B_WR_DATA,
	output reg [15:0] PORT_B_RD_DATA
);

parameter INIT = 0;
parameter PORT_A_WIDTH = 1;
parameter PORT_B_WIDTH = 1;
parameter PORT_A_CLK_POL = 0;
parameter PORT_B_CLK_POL = 0;

reg [2**10-1:0] mem = INIT;

always @(negedge (PORT_A_CLK ^ PORT_A_CLK_POL)) begin
	if (PORT_A_WR_EN) begin
		mem[PORT_A_ADDR+:PORT_A_WIDTH] <= PORT_A_WR_DATA;
	end else begin
		PORT_A_RD_DATA <= mem[PORT_A_ADDR+:PORT_A_WIDTH];
	end
end

always @(negedge (PORT_B_CLK ^ PORT_B_CLK_POL)) begin
	if (PORT_B_WR_EN) begin
		mem[PORT_B_ADDR+:PORT_B_WIDTH] <= PORT_B_WR_DATA;
	end else begin
		PORT_B_RD_DATA <= mem[PORT_B_ADDR+:PORT_B_WIDTH];
	end
end

endmodule