data/full_repos/permissive/168753118/testbench/modules/PC_CALC/PC_CALC_tb.v
1: b'%Warning-STMTDLY: data/full_repos/permissive/168753118/testbench/modules/PC_CALC/PC_CALC_tb.v:110: Unsupported: Ignoring delay on this delayed statement.\n    #period;\n    ^\n                  ... Use "/* verilator lint_off STMTDLY */" and lint_on around source to disable this message.\n%Error: data/full_repos/permissive/168753118/testbench/modules/PC_CALC/PC_CALC_tb.v:139: syntax error, unexpected \'@\'\n   @eachvec;\n   ^\n%Error: Exiting due to 1 error(s), 1 warning(s)\n        ... See the manual and https://verilator.org for more assistance.\n'
module PC_CALC_tb;


	parameter XLEN = 32;


	reg eachvec;


	reg pc_calc_correction_en_in;
	reg pc_calc_prediction_en_in;
	reg [XLEN-1:0] pc_calc_current_in;
	reg [XLEN-1:0] pc_calc_correction_in;
	reg [XLEN-1:0] pc_calc_prediction_in;


	reg pc_calc_pred_golden;
	reg [XLEN-1:0] pc_calc_addr_golden;


	reg pc_calc_pred_result;
	reg pc_calc_addr_result;


	wire pc_calc_pred_out;
	wire [XLEN-1:0] pc_calc_addr_out;


	localparam period = 5;


	integer golden, inputs, results, status;


	PC_CALC #(.XLEN(XLEN)) pc_calc0 (
		.pc_calc_correction_en_in(pc_calc_correction_en_in),
		.pc_calc_prediction_en_in(pc_calc_prediction_en_in),
		.pc_calc_current_in(pc_calc_current_in),
		.pc_calc_correction_in(pc_calc_correction_in),
		.pc_calc_prediction_in(pc_calc_prediction_in),
		.pc_calc_pred_out(pc_calc_pred_out),
		.pc_calc_addr_out(pc_calc_addr_out)
	);


	initial begin


			$display("Opening golden file");
			golden = $fopen("./out/PC_CALC_outputs.txt", "r");


			$display("Opening inputs file");
			inputs = $fopen("./out/PC_CALC_inputs.txt", "r");


			$display("Opening results file");
			results = $fopen("./out/PC_CALC_results.txt", "w");


			if (golden == `NULL) begin
				$display("Golden file was NULL");
				$finish;
			end


			if(inputs == `NULL) begin
				$display("Inputs file was NULL");
			end


			if(results == `NULL) begin
				$display("Results file was NULL");
			end


			while(!$feof(golden)) begin


				status = $fscanf(
					inputs,
					"%d %d %d %d %d",
					pc_calc_correction_en_in,
					pc_calc_prediction_en_in,
					pc_calc_current_in,
					pc_calc_correction_in,
					pc_calc_prediction_in
				);


				status = $fscanf(
					golden,
					"%d %d",
					pc_calc_pred_golden,
					pc_calc_addr_golden
				);


				#period;


				if (pc_calc_pred_out == pc_calc_pred_golden)
					pc_calc_pred_result = 1'b1;
				else
					pc_calc_pred_result = 1'b0;

				if (pc_calc_addr_out == pc_calc_addr_golden)
					pc_calc_addr_result = 1'b1;
				else
					pc_calc_addr_result = 1'b0;


				$fwrite(
					results,
					"%d %d\n",
					pc_calc_pred_result,
					pc_calc_addr_result
				);

			end

			$display("Simulation has ended");

			$fclose(golden);
			$fclose(inputs);
			$fclose(results);

			@eachvec;
			$finish;

		end
endmodule
module PC_CALC_tb;



	parameter XLEN = 32;


	reg eachvec;


	reg pc_calc_correction_en_in;
	reg pc_calc_prediction_en_in;
	reg [XLEN-1:0] pc_calc_current_in;
	reg [XLEN-1:0] pc_calc_correction_in;
	reg [XLEN-1:0] pc_calc_prediction_in;


	reg pc_calc_pred_golden;
	reg [XLEN-1:0] pc_calc_addr_golden;


	reg pc_calc_pred_result;
	reg pc_calc_addr_result;


	wire pc_calc_pred_out;
	wire [XLEN-1:0] pc_calc_addr_out;


	localparam period = 5;


	integer golden, inputs, results, status;


	PC_CALC #(.XLEN(XLEN)) pc_calc0 (
		.pc_calc_correction_en_in(pc_calc_correction_en_in),
		.pc_calc_prediction_en_in(pc_calc_prediction_en_in),
		.pc_calc_current_in(pc_calc_current_in),
		.pc_calc_correction_in(pc_calc_correction_in),
		.pc_calc_prediction_in(pc_calc_prediction_in),
		.pc_calc_pred_out(pc_calc_pred_out),
		.pc_calc_addr_out(pc_calc_addr_out)
	);


	initial begin


			$display("Opening golden file");
			golden = $fopen("./out/PC_CALC_outputs.txt", "r");


			$display("Opening inputs file");
			inputs = $fopen("./out/PC_CALC_inputs.txt", "r");


			$display("Opening results file");
			results = $fopen("./out/PC_CALC_results.txt", "w");


			if (golden == `NULL) begin
				$display("Golden file was NULL");
				$finish;
			end


			if(inputs == `NULL) begin
				$display("Inputs file was NULL");
			end


			if(results == `NULL) begin
				$display("Results file was NULL");
			end


			while(!$feof(golden)) begin


				status = $fscanf(
					inputs,
					"%d %d %d %d %d",
					pc_calc_correction_en_in,
					pc_calc_prediction_en_in,
					pc_calc_current_in,
					pc_calc_correction_in,
					pc_calc_prediction_in
				);


				status = $fscanf(
					golden,
					"%d %d",
					pc_calc_pred_golden,
					pc_calc_addr_golden
				);


				#period;


				if (pc_calc_pred_out == pc_calc_pred_golden)
					pc_calc_pred_result = 1'b1;
				else
					pc_calc_pred_result = 1'b0;

				if (pc_calc_addr_out == pc_calc_addr_golden)
					pc_calc_addr_result = 1'b1;
				else
					pc_calc_addr_result = 1'b0;


				$fwrite(
					results,
					"%d %d\n",
					pc_calc_pred_result,
					pc_calc_addr_result
				);

			end

			$display("Simulation has ended");

			$fclose(golden);
			$fclose(inputs);
			$fclose(results);

			@eachvec;
			$finish;

		end
endmodule