aboutsummaryrefslogtreecommitdiffstats
path: root/techlibs/xilinx/tests/bram1.v
blob: ac7140a04438cf16580ec8656fc029ad4adf76b2 (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
39
40
41
module bram1 #(
	parameter ABITS = 8, DBITS = 8, TRANSP = 0
) (
	input clk,

	input [ABITS-1:0] WR_ADDR,
	input [DBITS-1:0] WR_DATA,
	input WR_EN,

	input [ABITS-1:0] RD_ADDR,
	output [DBITS-1:0] RD_DATA
);
	localparam [ABITS-1:0] INIT_ADDR_0 = 1234;
	localparam [ABITS-1:0] INIT_ADDR_1 = 4321;
	localparam [ABITS-1:0] INIT_ADDR_2 = 2**ABITS-1;
	localparam [ABITS-1:0] INIT_ADDR_3 = (2**ABITS-1) / 2;

	localparam [DBITS-1:0] INIT_DATA_0 = 128'h 51e152a7300e309ccb8cd06d34558f49;
	localparam [DBITS-1:0] INIT_DATA_1 = 128'h 07b1fe94a530ddf3027520f9d23ab43e;
	localparam [DBITS-1:0] INIT_DATA_2 = 128'h 3cedc6de43ef3f607af3193658d0eb0b;
	localparam [DBITS-1:0] INIT_DATA_3 = 128'h f6bc5514a8abf1e2810df966bcc13b46;

	reg [DBITS-1:0] memory [0:2**ABITS-1];
	reg [ABITS-1:0] RD_ADDR_BUF;
	reg [DBITS-1:0] RD_DATA_BUF;

	initial begin
		memory[INIT_ADDR_0] <= INIT_DATA_0;
		memory[INIT_ADDR_1] <= INIT_DATA_1;
		memory[INIT_ADDR_2] <= INIT_DATA_2;
		memory[INIT_ADDR_3] <= INIT_DATA_3;
	end

	always @(posedge clk) begin
		if (WR_EN) memory[WR_ADDR] <= WR_DATA;
		RD_ADDR_BUF <= RD_ADDR;
		RD_DATA_BUF <= memory[RD_ADDR];
	end

	assign RD_DATA = TRANSP ? memory[RD_ADDR_BUF] : RD_DATA_BUF;
endmodule
lone10lp_lcell_comb"; parameter sum_lutc_input = "datac"; reg [1:0] lut_type; reg cout_rt; reg combout_rt; wire dataa_w; wire datab_w; wire datac_w; wire datad_w; wire cin_w; assign dataa_w = dataa; assign datab_w = datab; assign datac_w = datac; assign datad_w = datad; function lut_data; input [15:0] mask; input dataa, datab, datac, datad; reg [7:0] s3; reg [3:0] s2; reg [1:0] s1; begin s3 = datad ? mask[15:8] : mask[7:0]; s2 = datac ? s3[7:4] : s3[3:0]; s1 = datab ? s2[3:2] : s2[1:0]; lut_data = dataa ? s1[1] : s1[0]; end endfunction initial begin if (sum_lutc_input == "datac") lut_type = 0; else if (sum_lutc_input == "cin") lut_type = 1; else begin $error("Error in sum_lutc_input. Parameter %s is not a valid value.\n", sum_lutc_input); $finish(); end end always @(dataa_w or datab_w or datac_w or datad_w or cin_w) begin if (lut_type == 0) begin // logic function combout_rt = lut_data(lut_mask, dataa_w, datab_w, datac_w, datad_w); end else if (lut_type == 1) begin // arithmetic function combout_rt = lut_data(lut_mask, dataa_w, datab_w, cin_w, datad_w); end cout_rt = lut_data(lut_mask, dataa_w, datab_w, cin_w, 'b0); end assign combout = combout_rt & 1'b1; assign cout = cout_rt & 1'b1; endmodule // cyclone10lp_lcell_comb /* Altera D Flip-Flop Primitive */ module dffeas (output q, input d, clk, clrn, prn, ena, input asdata, aload, sclr, sload); // Timing simulation is not covered parameter power_up="dontcare"; parameter is_wysiwyg="false"; reg q_tmp; wire reset; reg [7:0] debug_net; assign reset = (prn && sclr && ~clrn && ena); assign q = q_tmp & 1'b1; always @(posedge clk, posedge aload) begin if(reset) q_tmp <= 0; else q_tmp <= d; end assign q = q_tmp; endmodule // dffeas