data/full_repos/permissive/120518070/main/source/tb_sids.sv
 line:11: before: "ns"
1: b'%Error: data/full_repos/permissive/120518070/main/source/tb_sids.sv:11: syntax error, unexpected TIME NUMBER, expecting TYPE-IDENTIFIER\n  localparam CLK_PERIOD = 20ns; \n                          ^~~~\n%Warning-STMTDLY: data/full_repos/permissive/120518070/main/source/tb_sids.sv:28: Unsupported: Ignoring delay on this delayed statement.\n   #(CLK_PERIOD / 2.0);\n   ^\n                  ... Use "/* verilator lint_off STMTDLY */" and lint_on around source to disable this message.\n%Warning-STMTDLY: data/full_repos/permissive/120518070/main/source/tb_sids.sv:30: Unsupported: Ignoring delay on this delayed statement.\n   #(CLK_PERIOD / 2.0);\n   ^\n%Error: data/full_repos/permissive/120518070/main/source/tb_sids.sv:65: syntax error, unexpected TIME NUMBER, expecting TYPE-IDENTIFIER\n localparam CHECK_DELAY  = 1ns;        \n                           ^~~\n%Error: data/full_repos/permissive/120518070/main/source/tb_sids.sv:132: syntax error, unexpected \'@\'\n  @(negedge tb_clk);\n  ^\n%Error: data/full_repos/permissive/120518070/main/source/tb_sids.sv:250: Unsupported: Dynamic array new\n  tb_input_image_ED = new[num_rows];\n                      ^~~\n%Error: data/full_repos/permissive/120518070/main/source/tb_sids.sv:256: Unsupported: Dynamic array new\n   tb_input_image_ED[r] = new[num_cols];\n                          ^~~\n%Warning-STMTDLY: data/full_repos/permissive/120518070/main/source/tb_sids.sv:309: Unsupported: Ignoring delay on this delayed statement.\n  #(CLK_PERIOD);\n  ^\n%Warning-STMTDLY: data/full_repos/permissive/120518070/main/source/tb_sids.sv:325: Unsupported: Ignoring delay on this delayed statement.\n  #(CLK_PERIOD);\n  ^\n%Warning-STMTDLY: data/full_repos/permissive/120518070/main/source/tb_sids.sv:327: Unsupported: Ignoring delay on this delayed statement.\n  #(CLK_PERIOD);\n  ^\n%Error: data/full_repos/permissive/120518070/main/source/tb_sids.sv:331: syntax error, unexpected \'@\'\n  @(posedge tb_clk);\n  ^\n%Error: data/full_repos/permissive/120518070/main/source/tb_sids.sv:334: syntax error, unexpected IDENTIFIER, expecting "\'{"\n  reg [31:0] tb_SI_rdata;\n             ^~~~~~~~~~~\n%Error: data/full_repos/permissive/120518070/main/source/tb_sids.sv:336: syntax error, unexpected IDENTIFIER, expecting "\'{"\n  reg [31:0] tb_ED_rdata;\n             ^~~~~~~~~~~\n%Error: data/full_repos/permissive/120518070/main/source/tb_sids.sv:337: syntax error, unexpected IDENTIFIER, expecting "\'{"\n  reg [19:0] tb_SI_rpixNum;\n             ^~~~~~~~~~~~~\n%Error: data/full_repos/permissive/120518070/main/source/tb_sids.sv:341: syntax error, unexpected IDENTIFIER\n  if(tb_SI_mode == 2b\'01)\n                    ^\n%Warning-STMTDLY: data/full_repos/permissive/120518070/main/source/tb_sids.sv:345: Unsupported: Ignoring delay on this delayed statement.\n   #(CLK_PERIOD)\n   ^\n%Error: data/full_repos/permissive/120518070/main/source/tb_sids.sv:349: syntax error, unexpected \'#\'\n  #(CLK_PERIOD)\n  ^\n%Error: Cannot continue\n'
module tb_sample_image_data_storage();

		localparam CLK_PERIOD	= 20ns;	
		reg tb_clk;
		reg tb_n_rst;

		reg tb_SI_dfb;
		reg [31:0] tb_SI_rdata;
		reg [19:0] tb_ED_rpixnum;
		reg tb_fill_buff;
		reg tb_buff_filled;
		reg [95:0] tb_ED_rdata;
		reg [19:0] tb_SI_rpixNum;
		reg [1:0] tb_SI_mode;


		always
		begin : CLK_GEN
			tb_clk = 1'b0;
			#(CLK_PERIOD / 2.0);
			tb_clk = 1'b1;
			#(CLK_PERIOD / 2.0);
		end



	
	parameter	INPUT1_FILENAME		= "./images/encrypted_fruits.bmp";
	parameter	INT1_FILENAME		= "./docs/decrypted_fruits.bmp";
	parameter	RESULT1_FILENAME	= "./docs/edge_detected_fruits.bmp";
	
	parameter	INPUT2_FILENAME		= "./images/encrypted_girl.bmp";
	parameter	INT2_FILENAME		= "./docs/decrypted_girl.bmp";
	parameter	RESULT2_FILENAME	= "./docs/edge_detected_girl.bmp";
	
	parameter	INPUT3_FILENAME		= "./images/Marked_enc.bmp";
	parameter	INT3_FILENAME		= "./docs/decrypted_marked.bmp";
	parameter	RESULT3_FILENAME	= "./docs/edge_detected_marked.bmp";


	localparam SEEK_START		= 0;
	localparam SEEK_CUR		= 1;
	localparam SEEK_END		= 2;
	

	localparam BMP_HEADER_SIZE_BYTES	= 14;
	localparam PIXEL_ARR_PTR_ADDR		= BMP_HEADER_SIZE_BYTES - 4;
	localparam DIB_HEADER_C1_SIZE		= 40;
	localparam DIB_HEADER_C2_SIZE		= 12;
	localparam NO_COMPRESSION 		= 0;


	localparam NUM_VAL_BITS		= 16;
	localparam MAX_VAL_BIT		= NUM_VAL_BITS - 1;
	localparam CHECK_DELAY		= 1ns;


	integer r;
	integer c;
	reg [7:0] tmp_byte;
	integer in_file;
	integer res_file;
	string  curr_res_filename;
	integer num_rows;
	integer num_cols;
	integer num_pad_bytes;
	reg [7:0] in_pixel_val;
	reg [7:0] res_pixel_val;
	integer i;
	integer quiet_catch;
	integer count;
	integer testCase;
	

	reg [(BMP_HEADER_SIZE_BYTES - 1):0][7:0] in_bmp_file_header;
	reg [(BMP_HEADER_SIZE_BYTES - 1):0][7:0] res_bmp_file_header;
	reg [31:0] in_image_data_ptr;
	reg [31:0] res_image_data_ptr;
	

	reg [(DIB_HEADER_C1_SIZE - 1):0][7:0] dib_header;
	reg [31:0] dib_header_size;
	reg [31:0] image_width;
	reg [31:0] image_height;
	reg [15:0] num_pixel_bits;
	reg [31:0] compression_mode;
	

	reg [7:0] tb_input_image_RC4 [][];
	reg [7:0] tb_input_image_ED [][];
	reg [7:0] tb_output_image_RC4 [][];
	reg [7:0] tb_output_image_ED [][];

	integer row,col;
	reg [3:0][7:0] buffer;
	reg [95:0] input_buffer;	


	integer row_size_bytes;
	

	sample_image_data_storage DUT_BUFF(
		.clk(tb_clk),
		.n_rst(tb_n_rst),
		.image_width(image_width),
		.SI_dfb(tb_SI_dfb),
		.SI_rdata(tb_SI_rdata),
		.ED_rpixNum(tb_ED_rpixnum),
		.fill_buff(tb_fill_buff),
		.buff_filled(tb_buff_filled),
		.ED_rdata(tb_ED_rdata),
		.SI_rpixNum(tb_SI_rpixNum),
		.SI_mode(tb_SI_mode)
	);




	task send_buffer_ED;
	begin

		@(negedge tb_clk);

	


		row = tb_SI_rpixNum / image_width;
		col = tb_SI_rpixNum % image_width;
		buffer[0] = tb_input_image_ED[row][col];
		buffer[1] = tb_input_image_ED[row][col + 1];
		buffer[2] = tb_input_image_ED[row][col + 2];
		buffer[3] = tb_input_image_ED[row][col + 3];
		
	end
	endtask
	



	task read_input_header;
		input string filename;
	begin
		$display("########################################");
		$display("ImageFile : %s",filename);
		$display("########################################");
			

		in_file = $fopen(filename, "rb");
		

		for(i = 0; i < BMP_HEADER_SIZE_BYTES; i = i + 1)
		begin

			quiet_catch = $fscanf(in_file,"%c" , in_bmp_file_header[i]);
		end
		

		in_image_data_ptr[31:0] = in_bmp_file_header[(BMP_HEADER_SIZE_BYTES - 1):PIXEL_ARR_PTR_ADDR];
		

		quiet_catch = $fscanf(in_file,"%c" , dib_header[0]);
		quiet_catch = $fscanf(in_file,"%c" , dib_header[1]);
		quiet_catch = $fscanf(in_file,"%c" , dib_header[2]);
		quiet_catch = $fscanf(in_file,"%c" , dib_header[3]);
		dib_header_size = dib_header[3:0];
		if(DIB_HEADER_C1_SIZE == dib_header_size)
		begin
			$display("Input bitmap file uses the BITMAPINFOHEADER type of DIB header");
			for(i = 4; i < dib_header_size; i = i + 1)
			begin

				quiet_catch = $fscanf(in_file,"%c" , dib_header[i]);
			end
			

			image_width		= dib_header[7:4];
			image_height		= dib_header[11:8];
			num_pixel_bits		= dib_header[15:14];
			compression_mode	= dib_header[19:16];
			
			
			$info("%d %d %d %d %d", image_width , image_height, num_pixel_bits, dib_header[35:32], in_file);

			if(16'd8 != num_pixel_bits)
				$fatal("This input file is using a pixel size (%0d)that is not supported, only 24bpp is supported", num_pixel_bits);
			
			if(NO_COMPRESSION != compression_mode)
				$fatal("This input file is using compression, this is not supported by this test bench");
		end
		else if(DIB_HEADER_C2_SIZE == dib_header_size)
		begin
			$display("Input bitmap file uses the BITMAPCOREHEADER  type of DIB header");
			for(i = 4; i < dib_header_size; i = i + 1)
			begin

				quiet_catch = $fscanf(in_file,"%c" , dib_header[i]);
			end
			

			image_width			= {16'd0,dib_header[5:4]};
			image_height			= {16'd0,dib_header[7:6]};
			num_pixel_bits			= dib_header[11:10];
			
			if(16'd8 != num_pixel_bits)
				$fatal("This input file is using a pixel size (%0d)that is not supported, only 24bpp is supported", num_pixel_bits);
		end
		else
		begin
			$fatal("Unsupported DIB header size of %0d found in input file", dib_header_size);
		end
		

		res_image_data_ptr = BMP_HEADER_SIZE_BYTES + dib_header_size;
		$info("res_image_data_ptr = %d", res_image_data_ptr);
		


		if($ftell(in_file) != in_image_data_ptr)
			quiet_catch = $fseek(in_file, in_image_data_ptr, SEEK_START);
	end
	endtask




	task extract_input_image_ED;
	begin

		row_size_bytes = (((num_pixel_bits * image_width) + 31) / 32) * 4;
		

		num_rows = image_height;
		

		num_cols = image_width;
		

		num_pad_bytes	= row_size_bytes - (num_cols);
		$info("num_pad_bytes in Decrpyted image = %d", num_pad_bytes);
		tb_input_image_ED = new[num_rows];



		for(r = num_rows - 1; r >= 0 ; r = r - 1)
		begin
			tb_input_image_ED[r] = new[num_cols];
			for(c = 0; c < num_cols; c = c + 1)
			begin

				quiet_catch = $fscanf(in_file, "%c", tb_input_image_ED[r][c]);
			end


			
			quiet_catch = $fseek(in_file, num_pad_bytes, SEEK_CUR);

		end
		


		$fclose(in_file);
	end
	endtask




	task resetSignals;
	begin
		
	end
	endtask





	task printOutputArray;
		input reg imageArray [][];
	begin
		for(r = 0; r < num_rows - 2 ; r = r + 1)
		begin
			for(c = 0; c < num_cols - 2; c = c + 1)
			begin
				$display("%d",imageArray[r][c]);
			end
		end
	end
	endtask



	initial
	begin


		#(CLK_PERIOD);

		



		testCase = 0;
		

		read_input_header(INT1_FILENAME);
		

		extract_input_image_ED;


		tb_n_rst = 1;
		#(CLK_PERIOD);
		tb_n_rst = 0;
		#(CLK_PERIOD);
		tb_n_rst = 1;

		testCase = 1;
		@(posedge tb_clk);
		
		reg tb_SI_dfb;
		reg [31:0] tb_SI_rdata;
		reg tb_buff_filled;
		reg [31:0] tb_ED_rdata;
		reg [19:0] tb_SI_rpixNum;

		tb_fill_buff = 1;
		tb_ED_rpixNum = 0;
		if(tb_SI_mode == 2b'01)
		begin
			send_buffer_ED();
			tb_SI_dfb = 1;
			#(CLK_PERIOD)
			input_buffer[31:0] = buffer;
			tb_SI_dfb = 0;
		end
		#(CLK_PERIOD)
		if(tb_SI_mode == 2b'01)
		begin
			send_buffer_ED();
			tb_SI_dfb = 1;
			#(CLK_PERIOD)
			input_buffer[63:32] = buffer;
			tb_SI_dfb = 0;
		end
		#(CLK_PERIOD)
		if(tb_SI_mode == 2b'01)
		begin
			send_buffer_ED();
			tb_SI_dfb = 1;
			#(CLK_PERIOD)
			input_buffer[95:64] = buffer;
			tb_SI_dfb = 0;
		end
		#(CLK_PERIOD)
		if(tb_buff_filled == 1)
		begin
			$display("%s %s"input_buffer, )
			if(input_buffer == tb_ED_rdata)
				$display("TEST PASSED")
		end

	end
endmodule
module tb_sample_image_data_storage();


		localparam CLK_PERIOD	= 20ns;	
		reg tb_clk;
		reg tb_n_rst;

		reg tb_SI_dfb;
		reg [31:0] tb_SI_rdata;
		reg [19:0] tb_ED_rpixnum;
		reg tb_fill_buff;
		reg tb_buff_filled;
		reg [95:0] tb_ED_rdata;
		reg [19:0] tb_SI_rpixNum;
		reg [1:0] tb_SI_mode;


		always
		begin : CLK_GEN
			tb_clk = 1'b0;
			#(CLK_PERIOD / 2.0);
			tb_clk = 1'b1;
			#(CLK_PERIOD / 2.0);
		end



	
	parameter	INPUT1_FILENAME		= "./images/encrypted_fruits.bmp";
	parameter	INT1_FILENAME		= "./docs/decrypted_fruits.bmp";
	parameter	RESULT1_FILENAME	= "./docs/edge_detected_fruits.bmp";
	
	parameter	INPUT2_FILENAME		= "./images/encrypted_girl.bmp";
	parameter	INT2_FILENAME		= "./docs/decrypted_girl.bmp";
	parameter	RESULT2_FILENAME	= "./docs/edge_detected_girl.bmp";
	
	parameter	INPUT3_FILENAME		= "./images/Marked_enc.bmp";
	parameter	INT3_FILENAME		= "./docs/decrypted_marked.bmp";
	parameter	RESULT3_FILENAME	= "./docs/edge_detected_marked.bmp";


	localparam SEEK_START		= 0;
	localparam SEEK_CUR		= 1;
	localparam SEEK_END		= 2;
	

	localparam BMP_HEADER_SIZE_BYTES	= 14;
	localparam PIXEL_ARR_PTR_ADDR		= BMP_HEADER_SIZE_BYTES - 4;
	localparam DIB_HEADER_C1_SIZE		= 40;
	localparam DIB_HEADER_C2_SIZE		= 12;
	localparam NO_COMPRESSION 		= 0;


	localparam NUM_VAL_BITS		= 16;
	localparam MAX_VAL_BIT		= NUM_VAL_BITS - 1;
	localparam CHECK_DELAY		= 1ns;


	integer r;
	integer c;
	reg [7:0] tmp_byte;
	integer in_file;
	integer res_file;
	string  curr_res_filename;
	integer num_rows;
	integer num_cols;
	integer num_pad_bytes;
	reg [7:0] in_pixel_val;
	reg [7:0] res_pixel_val;
	integer i;
	integer quiet_catch;
	integer count;
	integer testCase;
	

	reg [(BMP_HEADER_SIZE_BYTES - 1):0][7:0] in_bmp_file_header;
	reg [(BMP_HEADER_SIZE_BYTES - 1):0][7:0] res_bmp_file_header;
	reg [31:0] in_image_data_ptr;
	reg [31:0] res_image_data_ptr;
	

	reg [(DIB_HEADER_C1_SIZE - 1):0][7:0] dib_header;
	reg [31:0] dib_header_size;
	reg [31:0] image_width;
	reg [31:0] image_height;
	reg [15:0] num_pixel_bits;
	reg [31:0] compression_mode;
	

	reg [7:0] tb_input_image_RC4 [][];
	reg [7:0] tb_input_image_ED [][];
	reg [7:0] tb_output_image_RC4 [][];
	reg [7:0] tb_output_image_ED [][];

	integer row,col;
	reg [3:0][7:0] buffer;
	reg [95:0] input_buffer;	


	integer row_size_bytes;
	

	sample_image_data_storage DUT_BUFF(
		.clk(tb_clk),
		.n_rst(tb_n_rst),
		.image_width(image_width),
		.SI_dfb(tb_SI_dfb),
		.SI_rdata(tb_SI_rdata),
		.ED_rpixNum(tb_ED_rpixnum),
		.fill_buff(tb_fill_buff),
		.buff_filled(tb_buff_filled),
		.ED_rdata(tb_ED_rdata),
		.SI_rpixNum(tb_SI_rpixNum),
		.SI_mode(tb_SI_mode)
	);




	task send_buffer_ED;
	begin

		@(negedge tb_clk);

	


		row = tb_SI_rpixNum / image_width;
		col = tb_SI_rpixNum % image_width;
		buffer[0] = tb_input_image_ED[row][col];
		buffer[1] = tb_input_image_ED[row][col + 1];
		buffer[2] = tb_input_image_ED[row][col + 2];
		buffer[3] = tb_input_image_ED[row][col + 3];
		
	end
	endtask
	



	task read_input_header;
		input string filename;
	begin
		$display("########################################");
		$display("ImageFile : %s",filename);
		$display("########################################");
			

		in_file = $fopen(filename, "rb");
		

		for(i = 0; i < BMP_HEADER_SIZE_BYTES; i = i + 1)
		begin

			quiet_catch = $fscanf(in_file,"%c" , in_bmp_file_header[i]);
		end
		

		in_image_data_ptr[31:0] = in_bmp_file_header[(BMP_HEADER_SIZE_BYTES - 1):PIXEL_ARR_PTR_ADDR];
		

		quiet_catch = $fscanf(in_file,"%c" , dib_header[0]);
		quiet_catch = $fscanf(in_file,"%c" , dib_header[1]);
		quiet_catch = $fscanf(in_file,"%c" , dib_header[2]);
		quiet_catch = $fscanf(in_file,"%c" , dib_header[3]);
		dib_header_size = dib_header[3:0];
		if(DIB_HEADER_C1_SIZE == dib_header_size)
		begin
			$display("Input bitmap file uses the BITMAPINFOHEADER type of DIB header");
			for(i = 4; i < dib_header_size; i = i + 1)
			begin

				quiet_catch = $fscanf(in_file,"%c" , dib_header[i]);
			end
			

			image_width		= dib_header[7:4];
			image_height		= dib_header[11:8];
			num_pixel_bits		= dib_header[15:14];
			compression_mode	= dib_header[19:16];
			
			
			$info("%d %d %d %d %d", image_width , image_height, num_pixel_bits, dib_header[35:32], in_file);

			if(16'd8 != num_pixel_bits)
				$fatal("This input file is using a pixel size (%0d)that is not supported, only 24bpp is supported", num_pixel_bits);
			
			if(NO_COMPRESSION != compression_mode)
				$fatal("This input file is using compression, this is not supported by this test bench");
		end
		else if(DIB_HEADER_C2_SIZE == dib_header_size)
		begin
			$display("Input bitmap file uses the BITMAPCOREHEADER  type of DIB header");
			for(i = 4; i < dib_header_size; i = i + 1)
			begin

				quiet_catch = $fscanf(in_file,"%c" , dib_header[i]);
			end
			

			image_width			= {16'd0,dib_header[5:4]};
			image_height			= {16'd0,dib_header[7:6]};
			num_pixel_bits			= dib_header[11:10];
			
			if(16'd8 != num_pixel_bits)
				$fatal("This input file is using a pixel size (%0d)that is not supported, only 24bpp is supported", num_pixel_bits);
		end
		else
		begin
			$fatal("Unsupported DIB header size of %0d found in input file", dib_header_size);
		end
		

		res_image_data_ptr = BMP_HEADER_SIZE_BYTES + dib_header_size;
		$info("res_image_data_ptr = %d", res_image_data_ptr);
		


		if($ftell(in_file) != in_image_data_ptr)
			quiet_catch = $fseek(in_file, in_image_data_ptr, SEEK_START);
	end
	endtask




	task extract_input_image_ED;
	begin

		row_size_bytes = (((num_pixel_bits * image_width) + 31) / 32) * 4;
		

		num_rows = image_height;
		

		num_cols = image_width;
		

		num_pad_bytes	= row_size_bytes - (num_cols);
		$info("num_pad_bytes in Decrpyted image = %d", num_pad_bytes);
		tb_input_image_ED = new[num_rows];



		for(r = num_rows - 1; r >= 0 ; r = r - 1)
		begin
			tb_input_image_ED[r] = new[num_cols];
			for(c = 0; c < num_cols; c = c + 1)
			begin

				quiet_catch = $fscanf(in_file, "%c", tb_input_image_ED[r][c]);
			end


			
			quiet_catch = $fseek(in_file, num_pad_bytes, SEEK_CUR);

		end
		


		$fclose(in_file);
	end
	endtask




	task resetSignals;
	begin
		
	end
	endtask





	task printOutputArray;
		input reg imageArray [][];
	begin
		for(r = 0; r < num_rows - 2 ; r = r + 1)
		begin
			for(c = 0; c < num_cols - 2; c = c + 1)
			begin
				$display("%d",imageArray[r][c]);
			end
		end
	end
	endtask



	initial
	begin


		#(CLK_PERIOD);

		



		testCase = 0;
		

		read_input_header(INT1_FILENAME);
		

		extract_input_image_ED;


		tb_n_rst = 1;
		#(CLK_PERIOD);
		tb_n_rst = 0;
		#(CLK_PERIOD);
		tb_n_rst = 1;

		testCase = 1;
		@(posedge tb_clk);
		
		reg tb_SI_dfb;
		reg [31:0] tb_SI_rdata;
		reg tb_buff_filled;
		reg [31:0] tb_ED_rdata;
		reg [19:0] tb_SI_rpixNum;

		tb_fill_buff = 1;
		tb_ED_rpixNum = 0;
		if(tb_SI_mode == 2b'01)
		begin
			send_buffer_ED();
			tb_SI_dfb = 1;
			#(CLK_PERIOD)
			input_buffer[31:0] = buffer;
			tb_SI_dfb = 0;
		end
		#(CLK_PERIOD)
		if(tb_SI_mode == 2b'01)
		begin
			send_buffer_ED();
			tb_SI_dfb = 1;
			#(CLK_PERIOD)
			input_buffer[63:32] = buffer;
			tb_SI_dfb = 0;
		end
		#(CLK_PERIOD)
		if(tb_SI_mode == 2b'01)
		begin
			send_buffer_ED();
			tb_SI_dfb = 1;
			#(CLK_PERIOD)
			input_buffer[95:64] = buffer;
			tb_SI_dfb = 0;
		end
		#(CLK_PERIOD)
		if(tb_buff_filled == 1)
		begin
			$display("%s %s"input_buffer, )
			if(input_buffer == tb_ED_rdata)
				$display("TEST PASSED")
		end

	end
endmodule