data/full_repos/permissive/502764644/mpeg_audio_video/MP2_Decode/tb_MP2_Decode_16.v
1: b'%Error: data/full_repos/permissive/502764644/mpeg_audio_video/MP2_Decode/tb_MP2_Decode_16.v:17: Cannot find include file: defines.v\n`include "defines.v" \n         ^~~~~~~~~~~\n        ... Looked in:\n             data/full_repos/permissive/502764644/mpeg_audio_video/MP2_Decode,data/full_repos/permissive/502764644/defines.v\n             data/full_repos/permissive/502764644/mpeg_audio_video/MP2_Decode,data/full_repos/permissive/502764644/defines.v.v\n             data/full_repos/permissive/502764644/mpeg_audio_video/MP2_Decode,data/full_repos/permissive/502764644/defines.v.sv\n             defines.v\n             defines.v.v\n             defines.v.sv\n             obj_dir/defines.v\n             obj_dir/defines.v.v\n             obj_dir/defines.v.sv\n%Error: data/full_repos/permissive/502764644/mpeg_audio_video/MP2_Decode/tb_MP2_Decode_16.v:79: Define or directive not defined: \'`CLOCK_PERIOD\'\nalways begin #(0.5*`CLOCK_PERIOD) clock = ~clock; end\n                   ^~~~~~~~~~~~~\n%Error: data/full_repos/permissive/502764644/mpeg_audio_video/MP2_Decode/tb_MP2_Decode_16.v:79: syntax error, unexpected \')\', expecting TYPE-IDENTIFIER\nalways begin #(0.5*`CLOCK_PERIOD) clock = ~clock; end\n                                ^\n%Warning-STMTDLY: data/full_repos/permissive/502764644/mpeg_audio_video/MP2_Decode/tb_MP2_Decode_16.v:80: Unsupported: Ignoring delay on this delayed statement.\nalways begin #41.67 audio_bit_clock = ~audio_bit_clock; end\n             ^\n                  ... Use "/* verilator lint_off STMTDLY */" and lint_on around source to disable this message.\n%Error: data/full_repos/permissive/502764644/mpeg_audio_video/MP2_Decode/tb_MP2_Decode_16.v:86: Unsupported or unknown PLI call: $timeformat\n $timeformat(-3, 2, " ms", 10);\n ^~~~~~~~~~~\n%Error: data/full_repos/permissive/502764644/mpeg_audio_video/MP2_Decode/tb_MP2_Decode_16.v:102: Define or directive not defined: \'`CLOCK_PERIOD\'\n #(2*`CLOCK_PERIOD) resetn = 1\'b1; \n     ^~~~~~~~~~~~~\n%Error: data/full_repos/permissive/502764644/mpeg_audio_video/MP2_Decode/tb_MP2_Decode_16.v:102: syntax error, unexpected \')\', expecting TYPE-IDENTIFIER\n #(2*`CLOCK_PERIOD) resetn = 1\'b1; \n                  ^\n%Error: data/full_repos/permissive/502764644/mpeg_audio_video/MP2_Decode/tb_MP2_Decode_16.v:105: Unsupported: wait statements\n wait(ETH_ZBT_emulator.ZBT_buffer_interface.In_Buffer_Full == 1\'b1);\n ^~~~\n%Error: data/full_repos/permissive/502764644/mpeg_audio_video/MP2_Decode/tb_MP2_Decode_16.v:106: Define or directive not defined: \'`CLOCK_PERIOD\'\n #(10*`CLOCK_PERIOD) Audio_start = 1\'b1; \n      ^~~~~~~~~~~~~\n%Error: data/full_repos/permissive/502764644/mpeg_audio_video/MP2_Decode/tb_MP2_Decode_16.v:106: syntax error, unexpected \')\', expecting TYPE-IDENTIFIER\n #(10*`CLOCK_PERIOD) Audio_start = 1\'b1; \n                   ^\n%Error: data/full_repos/permissive/502764644/mpeg_audio_video/MP2_Decode/tb_MP2_Decode_16.v:108: Define or directive not defined: \'`CLOCK_PERIOD\'\n #(`CLOCK_PERIOD) Audio_start = 1\'b0;\n   ^~~~~~~~~~~~~\n%Error: data/full_repos/permissive/502764644/mpeg_audio_video/MP2_Decode/tb_MP2_Decode_16.v:108: syntax error, unexpected \')\', expecting TYPE-IDENTIFIER\n #(`CLOCK_PERIOD) Audio_start = 1\'b0;\n                ^\n%Error: Exiting due to 11 error(s), 1 warning(s)\n'
module tb_MP2_Decode_16();



reg 						resetn;
reg 						clock, audio_bit_clock;

reg 						Audio_start;
wire 		[15:0]		Audio_data;
wire 						Audio_shift_busy;
wire 						Audio_byte_allign;
wire 		[4:0]			Audio_shift;

integer frame_counter;

wire audio_en_flag, video_en_flag;
assign audio_en_flag = 1'b1;
assign video_en_flag = 1'b0;

MP2_Decode_16 Audio_Decoder(
	.resetn(resetn),
	.audio_decoder_clock(clock),
	.Decode_Start_I(Audio_start),
	.Decode_Done_O(),
	.Bitstream_Byte_Allign_I(Audio_byte_allign),
	.Bitstream_Data_I(Audio_data),
	.Shift_Busy_I(Audio_shift_busy),
	.Shift_En_O(Audio_shift),
	.AC97_RESETN_I(resetn),
	.AC97_BIT_CLOCK_I(audio_bit_clock),
	.SAMPLE_FREQUENCY_I(2'b00),
	.SOURCE_SELECT_I(1'b0),
	.AC97_SYNCH_O(),
	.AC97_DATA_IN_I(1'b0),
	.AC97_DATA_OUT_O(),
	.AC97_BEEP_TONE_O(),
	.STARTUP_O(),
	.Header_found(),
	.Audio_Sync_I(1'b1),
	.Audio_Sync_O
);

tb_ETH_ZBT_emulator ETH_ZBT_emulator(
   .resetn(resetn),
   .clock(clock),
   .audio_clock(clock),
	.ZBT_Reset_I(1'b0),
	.ZBT_Initial_Fill_O(),
   .Video_Empty_O(),
   .Video_Shift_1_En_I(1'b0),
   .Video_Shift_8_En_I(1'b0),
   .Video_Shift_Busy_O(),
   .Video_Byte_Allign_O(),
   .Video_Bitstream_Data_O(),
   .Audio_Shift_En_I(Audio_shift),
	.Audio_Shift_Busy_O(Audio_shift_busy),
	.Audio_Byte_Allign_O(Audio_byte_allign),
   .Audio_Bitstream_Data_O(Audio_data)
,.debug({audio_en_flag,video_en_flag})
);

always begin #(0.5*`CLOCK_PERIOD) clock = ~clock; end
always begin #41.67 audio_bit_clock = ~audio_bit_clock; end

integer outfile;

initial begin 

	$timeformat(-3, 2, " ms", 10);
	$write("Simulation started at %t\n\n", $realtime);

`ifdef PCM_VALIDATE `else





`endif

	clock = 1'b0; resetn = 1'b0; 
	audio_bit_clock = 1'b0;
	Audio_start = 1'b0;
	

	#(2*`CLOCK_PERIOD) resetn = 1'b1;	
	

	wait(ETH_ZBT_emulator.ZBT_buffer_interface.In_Buffer_Full == 1'b1);
	#(10*`CLOCK_PERIOD) Audio_start = 1'b1;	
	$write("Sequence decode started at %t\n", $realtime);
	#(`CLOCK_PERIOD) Audio_start = 1'b0;

end

reg [15:0] samples [1:0][1023:0];
integer sample_count, left_count, right_count;
initial begin sample_count = 0; left_count = 0; right_count = 0; end

always @(posedge Audio_Decoder.Header_done) begin
	if (resetn) $write("Header Decoded, sample freq %d, format_check %b, Table %d\n", 
		Audio_Decoder.Decode_Header_unit.Sample_Freq_O,
		Audio_Decoder.Decode_Header_unit.Format_Check_O,
		Audio_Decoder.Decode_Header_unit.Table_O);
end

always @(posedge clock) begin




















end



`ifdef TRACE
integer temp;
always @(posedge clock) begin
	if (Audio_Decoder.Header_start) $write("Starting header parse\n");	
	if (Audio_Decoder.Synth_start) $write("Starting subband synthesis\n");
	if (Audio_Decoder.SubBandSynthesis_unit.Sample_Write_En_O) begin	
		temp = {{16{Audio_Decoder.SubBandSynthesis_unit.Sample_Data_O[15]}},
			Audio_Decoder.SubBandSynthesis_unit.Sample_Data_O};
		$write("%x -> %d\n", 
			Audio_Decoder.SubBandSynthesis_unit.next_sum, temp);
	end
end












































`endif

`ifdef PCM_VALIDATE
integer ref_file;
integer mismatches;

integer scale_block_counter;
integer block_counter;
integer total_sample_counter;

initial begin 
	total_sample_counter = 0;
	frame_counter = -1;
	mismatches = 0;
	ref_file = $fopen("software/matrix_small_2_FIX16.pcm", "rb");

end
	
always @(posedge clock) begin
	if (Audio_Decoder.Header_start) begin
		frame_counter = frame_counter + 1;
		$write("Frame %d start - %d mismatches\n", 
			frame_counter, mismatches);
		scale_block_counter = 0;
		block_counter = 0;
	end
end

task pcm_compare; 
	integer i;
	reg [15:0] ref_sample, abs_dif;
begin	
	for (i = 0; i < 32; i = i + 1) begin

		ref_sample[15:8] = $fgetc(ref_file);
		ref_sample[7:0] = $fgetc(ref_file);
		abs_dif = (samples[0][i] > ref_sample) ? 
			samples[0][i] - ref_sample : 
			ref_sample - samples[0][i]; 
		if (abs_dif != 0) mismatches = mismatches + 1;
		if (abs_dif > 2) 
			$write("mismatch on frame %d, scaleblock %d, block %d, sample %d L (%d) : got %x expect %x\n", 
				frame_counter, scale_block_counter, block_counter, 
				i, total_sample_counter, samples[0][i], ref_sample);
		total_sample_counter = total_sample_counter + 1;


		ref_sample[15:8] = $fgetc(ref_file);
		ref_sample[7:0] = $fgetc(ref_file);
		abs_dif = (samples[1][i] > ref_sample) ? 
			samples[1][i] - ref_sample : 
			ref_sample - samples[1][i]; 
		if (abs_dif != 0) mismatches = mismatches + 1;
		if (abs_dif > 2) 
			$write("mismatch on frame %d, scaleblock %d, block %d, sample %d R (%d) : got %x expect %x\n", 
				frame_counter, scale_block_counter, block_counter, 
				i, total_sample_counter, samples[1][i], ref_sample);
		total_sample_counter = total_sample_counter + 1;
	end

	if (block_counter == 2) begin
		scale_block_counter = scale_block_counter + 1;
		block_counter = 0;
	end else block_counter = block_counter + 1;
	
end endtask
`endif

task AIFF_header; begin

	$fwrite(outfile, "%02h %02h %02h %02h %02h %02h %02h %02h ",
		8'h46, 8'h4f, 8'h52, 8'h4d, 8'h00, 8'h6e, 8'h0a, 8'h22);
	$fwrite(outfile, "%02h %02h %02h %02h %02h %02h %02h %02h\n",
		8'h41, 8'h49, 8'h46, 8'h46, 8'h43, 8'h4f, 8'h4d, 8'h4d); 
	$fwrite(outfile, "%02h %02h %02h %02h %02h %02h %02h %02h ",
		8'h00, 8'h00, 8'h00, 8'h12, 8'h00, 8'h02, 8'h00, 8'h1b);
	$fwrite(outfile, "%02h %02h %02h %02h %02h %02h %02h %02h\n",
		8'h82, 8'h80, 8'h00, 8'h10, 8'h40, 8'h0e, 8'hbb, 8'h80);
	$fwrite(outfile, "%02h %02h %02h %02h %02h %02h %02h %02h ",
		8'h00, 8'h00, 8'h00, 8'h00, 8'h00, 8'h00, 8'h53, 8'h53); 
	$fwrite(outfile, "%02h %02h %02h %02h %02h %02h %02h %02h\n\n",
		8'h4e, 8'h44, 8'h00, 8'h6e, 8'h0a, 8'h08, 8'h00, 8'h00);

end endtask

endmodule
module tb_MP2_Decode_16();




reg 						resetn;
reg 						clock, audio_bit_clock;

reg 						Audio_start;
wire 		[15:0]		Audio_data;
wire 						Audio_shift_busy;
wire 						Audio_byte_allign;
wire 		[4:0]			Audio_shift;

integer frame_counter;

wire audio_en_flag, video_en_flag;
assign audio_en_flag = 1'b1;
assign video_en_flag = 1'b0;

MP2_Decode_16 Audio_Decoder(
	.resetn(resetn),
	.audio_decoder_clock(clock),
	.Decode_Start_I(Audio_start),
	.Decode_Done_O(),
	.Bitstream_Byte_Allign_I(Audio_byte_allign),
	.Bitstream_Data_I(Audio_data),
	.Shift_Busy_I(Audio_shift_busy),
	.Shift_En_O(Audio_shift),
	.AC97_RESETN_I(resetn),
	.AC97_BIT_CLOCK_I(audio_bit_clock),
	.SAMPLE_FREQUENCY_I(2'b00),
	.SOURCE_SELECT_I(1'b0),
	.AC97_SYNCH_O(),
	.AC97_DATA_IN_I(1'b0),
	.AC97_DATA_OUT_O(),
	.AC97_BEEP_TONE_O(),
	.STARTUP_O(),
	.Header_found(),
	.Audio_Sync_I(1'b1),
	.Audio_Sync_O
);

tb_ETH_ZBT_emulator ETH_ZBT_emulator(
   .resetn(resetn),
   .clock(clock),
   .audio_clock(clock),
	.ZBT_Reset_I(1'b0),
	.ZBT_Initial_Fill_O(),
   .Video_Empty_O(),
   .Video_Shift_1_En_I(1'b0),
   .Video_Shift_8_En_I(1'b0),
   .Video_Shift_Busy_O(),
   .Video_Byte_Allign_O(),
   .Video_Bitstream_Data_O(),
   .Audio_Shift_En_I(Audio_shift),
	.Audio_Shift_Busy_O(Audio_shift_busy),
	.Audio_Byte_Allign_O(Audio_byte_allign),
   .Audio_Bitstream_Data_O(Audio_data)
,.debug({audio_en_flag,video_en_flag})
);

always begin #(0.5*`CLOCK_PERIOD) clock = ~clock; end
always begin #41.67 audio_bit_clock = ~audio_bit_clock; end

integer outfile;

initial begin 

	$timeformat(-3, 2, " ms", 10);
	$write("Simulation started at %t\n\n", $realtime);

`ifdef PCM_VALIDATE `else





`endif

	clock = 1'b0; resetn = 1'b0; 
	audio_bit_clock = 1'b0;
	Audio_start = 1'b0;
	

	#(2*`CLOCK_PERIOD) resetn = 1'b1;	
	

	wait(ETH_ZBT_emulator.ZBT_buffer_interface.In_Buffer_Full == 1'b1);
	#(10*`CLOCK_PERIOD) Audio_start = 1'b1;	
	$write("Sequence decode started at %t\n", $realtime);
	#(`CLOCK_PERIOD) Audio_start = 1'b0;

end

reg [15:0] samples [1:0][1023:0];
integer sample_count, left_count, right_count;
initial begin sample_count = 0; left_count = 0; right_count = 0; end

always @(posedge Audio_Decoder.Header_done) begin
	if (resetn) $write("Header Decoded, sample freq %d, format_check %b, Table %d\n", 
		Audio_Decoder.Decode_Header_unit.Sample_Freq_O,
		Audio_Decoder.Decode_Header_unit.Format_Check_O,
		Audio_Decoder.Decode_Header_unit.Table_O);
end

always @(posedge clock) begin




















end



`ifdef TRACE
integer temp;
always @(posedge clock) begin
	if (Audio_Decoder.Header_start) $write("Starting header parse\n");	
	if (Audio_Decoder.Synth_start) $write("Starting subband synthesis\n");
	if (Audio_Decoder.SubBandSynthesis_unit.Sample_Write_En_O) begin	
		temp = {{16{Audio_Decoder.SubBandSynthesis_unit.Sample_Data_O[15]}},
			Audio_Decoder.SubBandSynthesis_unit.Sample_Data_O};
		$write("%x -> %d\n", 
			Audio_Decoder.SubBandSynthesis_unit.next_sum, temp);
	end
end












































`endif

`ifdef PCM_VALIDATE
integer ref_file;
integer mismatches;

integer scale_block_counter;
integer block_counter;
integer total_sample_counter;

initial begin 
	total_sample_counter = 0;
	frame_counter = -1;
	mismatches = 0;
	ref_file = $fopen("software/matrix_small_2_FIX16.pcm", "rb");

end
	
always @(posedge clock) begin
	if (Audio_Decoder.Header_start) begin
		frame_counter = frame_counter + 1;
		$write("Frame %d start - %d mismatches\n", 
			frame_counter, mismatches);
		scale_block_counter = 0;
		block_counter = 0;
	end
end

task pcm_compare; 
	integer i;
	reg [15:0] ref_sample, abs_dif;
begin	
	for (i = 0; i < 32; i = i + 1) begin

		ref_sample[15:8] = $fgetc(ref_file);
		ref_sample[7:0] = $fgetc(ref_file);
		abs_dif = (samples[0][i] > ref_sample) ? 
			samples[0][i] - ref_sample : 
			ref_sample - samples[0][i]; 
		if (abs_dif != 0) mismatches = mismatches + 1;
		if (abs_dif > 2) 
			$write("mismatch on frame %d, scaleblock %d, block %d, sample %d L (%d) : got %x expect %x\n", 
				frame_counter, scale_block_counter, block_counter, 
				i, total_sample_counter, samples[0][i], ref_sample);
		total_sample_counter = total_sample_counter + 1;


		ref_sample[15:8] = $fgetc(ref_file);
		ref_sample[7:0] = $fgetc(ref_file);
		abs_dif = (samples[1][i] > ref_sample) ? 
			samples[1][i] - ref_sample : 
			ref_sample - samples[1][i]; 
		if (abs_dif != 0) mismatches = mismatches + 1;
		if (abs_dif > 2) 
			$write("mismatch on frame %d, scaleblock %d, block %d, sample %d R (%d) : got %x expect %x\n", 
				frame_counter, scale_block_counter, block_counter, 
				i, total_sample_counter, samples[1][i], ref_sample);
		total_sample_counter = total_sample_counter + 1;
	end

	if (block_counter == 2) begin
		scale_block_counter = scale_block_counter + 1;
		block_counter = 0;
	end else block_counter = block_counter + 1;
	
end endtask
`endif

task AIFF_header; begin

	$fwrite(outfile, "%02h %02h %02h %02h %02h %02h %02h %02h ",
		8'h46, 8'h4f, 8'h52, 8'h4d, 8'h00, 8'h6e, 8'h0a, 8'h22);
	$fwrite(outfile, "%02h %02h %02h %02h %02h %02h %02h %02h\n",
		8'h41, 8'h49, 8'h46, 8'h46, 8'h43, 8'h4f, 8'h4d, 8'h4d); 
	$fwrite(outfile, "%02h %02h %02h %02h %02h %02h %02h %02h ",
		8'h00, 8'h00, 8'h00, 8'h12, 8'h00, 8'h02, 8'h00, 8'h1b);
	$fwrite(outfile, "%02h %02h %02h %02h %02h %02h %02h %02h\n",
		8'h82, 8'h80, 8'h00, 8'h10, 8'h40, 8'h0e, 8'hbb, 8'h80);
	$fwrite(outfile, "%02h %02h %02h %02h %02h %02h %02h %02h ",
		8'h00, 8'h00, 8'h00, 8'h00, 8'h00, 8'h00, 8'h53, 8'h53); 
	$fwrite(outfile, "%02h %02h %02h %02h %02h %02h %02h %02h\n\n",
		8'h4e, 8'h44, 8'h00, 8'h6e, 8'h0a, 8'h08, 8'h00, 8'h00);

end endtask

endmodule