data/full_repos/permissive/168753118/testbench/modules/BRU/BRU_tb.v
1: b'%Warning-STMTDLY: data/full_repos/permissive/168753118/testbench/modules/BRU/BRU_tb.v:126: 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/BRU/BRU_tb.v:172: 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 BRU_tb;


	parameter XLEN = 32;


	reg eachvec;


  reg bru_enable_in;
  reg bru_prediction_in;
  reg [3:0] bru_uop_in;
	reg [XLEN-1:0] bru_pc_in;
  reg [XLEN-1:0] bru_rs1_in;
  reg [XLEN-1:0] bru_rs2_in;
  reg [XLEN-1:0] bru_imm_in;


	reg bru_correction_golden;
  reg [XLEN-1:0] bru_target_golden;
  reg bru_feedback_result_golden;
  reg bru_feedback_write_en_golden;


	reg bru_correction_result;
  reg bru_target_result;
  reg bru_feedback_result_result;
  reg bru_feedback_write_en_result;


	wire bru_correction_out;
  wire [XLEN-1:0] bru_target_out;
  wire bru_feedback_result_out;
  wire bru_feedback_write_en_out;


	localparam period = 5;


	integer golden, inputs, results, status;


	BRU bru0 (
    .bru_enable_in(bru_enable_in),
    .bru_prediction_in(bru_prediction_in),
    .bru_uop_in(bru_uop_in),
    .bru_pc_in(bru_pc_in),
    .bru_rs1_in(bru_rs1_in),
    .bru_rs2_in(bru_rs2_in),
    .bru_imm_in(bru_imm_in),
    .bru_correction_out(bru_correction_out),
    .bru_target_out(bru_target_out),
    .bru_feedback_result_out(bru_feedback_result_out),
    .bru_feedback_write_en_out(bru_feedback_write_en_out)
	);


	initial begin


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


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


			$display("Opening results file");
			results = $fopen("./out/BRU_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(inputs)) begin


				status = $fscanf(
					inputs,
					"%d %d %d %d %d %d %d",
					bru_enable_in,
          bru_prediction_in,
          bru_uop_in,
          bru_pc_in,
          bru_rs1_in,
          bru_rs2_in,
          bru_imm_in
				);


				status = $fscanf(
					golden,
					"%d %d %d %d",
					bru_correction_golden,
          bru_target_golden,
          bru_feedback_result_golden,
          bru_feedback_write_en_golden
				);


				#period;


				if (bru_correction_out == bru_correction_golden)
					bru_correction_result = 1'b1;
				else begin
					bru_correction_result = 1'b0;
          $display("ERROR!");
				end

        if(bru_target_out == bru_target_golden)
          bru_target_result = 1'b1;
        else begin
          bru_target_result = 1'b0;
        end

        if(bru_feedback_result_out == bru_feedback_result_golden)
          bru_feedback_result_result = 1'b1;
        else begin
          bru_feedback_result_result = 1'b0;
          $display("ERROR: %d %d", bru_feedback_result_out, bru_feedback_result_golden);
        end

        if(bru_feedback_write_en_out == bru_feedback_write_en_golden)
          bru_feedback_write_en_result = 1'b1;
        else
          bru_feedback_write_en_result = 1'b0;


				$fwrite(
					results,
					"%d %d %d %d\n",
					bru_correction_result,
          bru_target_result,
          bru_feedback_result_result,
          bru_feedback_write_en_result
				);

			end

			$display("Simulation has ended");

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

			@eachvec;
			$finish;

		end
endmodule
module BRU_tb;



	parameter XLEN = 32;


	reg eachvec;


  reg bru_enable_in;
  reg bru_prediction_in;
  reg [3:0] bru_uop_in;
	reg [XLEN-1:0] bru_pc_in;
  reg [XLEN-1:0] bru_rs1_in;
  reg [XLEN-1:0] bru_rs2_in;
  reg [XLEN-1:0] bru_imm_in;


	reg bru_correction_golden;
  reg [XLEN-1:0] bru_target_golden;
  reg bru_feedback_result_golden;
  reg bru_feedback_write_en_golden;


	reg bru_correction_result;
  reg bru_target_result;
  reg bru_feedback_result_result;
  reg bru_feedback_write_en_result;


	wire bru_correction_out;
  wire [XLEN-1:0] bru_target_out;
  wire bru_feedback_result_out;
  wire bru_feedback_write_en_out;


	localparam period = 5;


	integer golden, inputs, results, status;


	BRU bru0 (
    .bru_enable_in(bru_enable_in),
    .bru_prediction_in(bru_prediction_in),
    .bru_uop_in(bru_uop_in),
    .bru_pc_in(bru_pc_in),
    .bru_rs1_in(bru_rs1_in),
    .bru_rs2_in(bru_rs2_in),
    .bru_imm_in(bru_imm_in),
    .bru_correction_out(bru_correction_out),
    .bru_target_out(bru_target_out),
    .bru_feedback_result_out(bru_feedback_result_out),
    .bru_feedback_write_en_out(bru_feedback_write_en_out)
	);


	initial begin


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


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


			$display("Opening results file");
			results = $fopen("./out/BRU_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(inputs)) begin


				status = $fscanf(
					inputs,
					"%d %d %d %d %d %d %d",
					bru_enable_in,
          bru_prediction_in,
          bru_uop_in,
          bru_pc_in,
          bru_rs1_in,
          bru_rs2_in,
          bru_imm_in
				);


				status = $fscanf(
					golden,
					"%d %d %d %d",
					bru_correction_golden,
          bru_target_golden,
          bru_feedback_result_golden,
          bru_feedback_write_en_golden
				);


				#period;


				if (bru_correction_out == bru_correction_golden)
					bru_correction_result = 1'b1;
				else begin
					bru_correction_result = 1'b0;
          $display("ERROR!");
				end

        if(bru_target_out == bru_target_golden)
          bru_target_result = 1'b1;
        else begin
          bru_target_result = 1'b0;
        end

        if(bru_feedback_result_out == bru_feedback_result_golden)
          bru_feedback_result_result = 1'b1;
        else begin
          bru_feedback_result_result = 1'b0;
          $display("ERROR: %d %d", bru_feedback_result_out, bru_feedback_result_golden);
        end

        if(bru_feedback_write_en_out == bru_feedback_write_en_golden)
          bru_feedback_write_en_result = 1'b1;
        else
          bru_feedback_write_en_result = 1'b0;


				$fwrite(
					results,
					"%d %d %d %d\n",
					bru_correction_result,
          bru_target_result,
          bru_feedback_result_result,
          bru_feedback_write_en_result
				);

			end

			$display("Simulation has ended");

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

			@eachvec;
			$finish;

		end
endmodule