data/full_repos/permissive/138254793/parser_template.v
 line:467: before: "."
1: b"%Error: data/full_repos/permissive/138254793/parser_template.v:89: Can't find definition of variable: 'NUM_OF_REG_TOFILL'\nreg [7:0] metaReg[NUM_OF_REG_TOFILL-1:0];\n                  ^~~~~~~~~~~~~~~~~\n%Error: data/full_repos/permissive/138254793/parser_template.v:90: Can't find definition of variable: 'NUM_OF_META_TOFILL'\n                                                                 : ... Suggested alternative: 'NUM_OF_REG_TOFILL'\nreg [133:0] metadata_temp[NUM_OF_META_TOFILL-1:0];\n                          ^~~~~~~~~~~~~~~~~~\n%Error: data/full_repos/permissive/138254793/parser_template.v:274: Can't find definition of variable: 'READY_COUNT_TOFILL'\n    if(count >= READY_COUNT_TOFILL) begin\n                ^~~~~~~~~~~~~~~~~~\n%Error: Exiting due to 3 error(s)\n"
module parser(
	clk,
	reset,
	metadata_in_valid,
	metadata_in,
	metadata_out_valid,
	metadata_out,
	ready_in,
	ready_out
);


input			clk;
input			reset;
input			metadata_in_valid;
input		[133:0]	metadata_in;
output	reg		metadata_out_valid;
output	reg	[133:0]	metadata_out;
input			ready_in;
output	reg		ready_out;




reg	[133:0]	data_pktBuffer;
reg		rdreq_pktBuffer;
reg		wrreq_pktBuffer;
wire		empty_pktBuffer;
wire	[133:0]	ctx_pktBuffer;

reg	[133:0]	data_meta;
reg		rdreq_meta;
reg		wrreq_meta;
wire		empty_meta;
wire	[133:0]	ctx_meta;





reg	[7:0]	metaReg[`NUM_OF_REG-1:0];
reg	[133:0]	metadata_temp[`NUM_OF_META-1:0];
reg	[3:0]	count, count_meta;
reg		reg_tag, reg_tag_temp;
reg	[3:0]	protocol_type;



reg	[3:0]	state_parser, state_readPkt, state_meta, state_input;
parameter	IDLE_S			= 4'd0,
		READ_PKT_1_S		= 4'd1,
		READ_PKT_2_S		= 4'd2,
		READ_PKT_3_S		= 4'd3,
		READ_PKT_4_S		= 4'd4,
		READ_PKT_5_S		= 4'd5,
		READ_PKT_6_S		= 4'd6,
		READ_PKT_7_S		= 4'd7,
		READ_PKT_TAIL_S	= 4'd8,
		WAIT_PADING_S	= 4'd9,
		READ_META_S		= 4'd1,
		READ_PKT_S		= 4'd2,
		WRITE_META_S		= 4'd1,
		WAIT_PKT_HEAD_S	= 4'd1,
		WAIT_PKT_TAIL_S	= 4'd2;

integer i, j;
integer meta_i, meta_j;



always @(posedge clk or negedge reset) begin
	if (!reset) begin
		for(i=0; i< `NUM_OF_REG; i = i+1)
			metaReg[i] <= 8'b0;
		count <= 4'b0;
		ready_out <= 1'b1;
		reg_tag <= 1'b0;
		protocol_type <= 4'b0;
		metadata_temp[0] <= 134'b0;
		state_parser <= IDLE_S;
	end
	else begin
		case(state_parser)
			IDLE_S: begin

				for(j=0; j< `NUM_OF_REG; j = j+1)
					metaReg[j] <= 8'b0;
				if((metadata_in_valid == 1'b1) && (ready_in == 1'b1) && 
					(metadata_in[133:132] == 2'b01))
				begin

					ready_out <= 1'b0;

					metadata_temp[0] <= metadata_in;

					count <= 4'd1;

					protocol_type <= 4'd0;
					state_parser <= READ_PKT_1_S;
				end
				else begin
					state_parser <= IDLE_S;
				end
			end
			READ_PKT_1_S: begin
				count <= count + 4'd1;


			end
			READ_PKT_2_S: begin
				count <= count + 4'd1;


			end
			READ_PKT_3_S: begin
				count <= count + 4'd1;


			end
			READ_PKT_4_S: begin
				count <= count + 4'd1;



			end
			READ_PKT_5_S: begin
				count <= count + 4'd1;

				
			end
			READ_PKT_6_S: begin
				count <= count + 4'd1;

				
			end
			READ_PKT_7_S: begin
				count <= count + 4'd1;

				
			end
			READ_PKT_TAIL_S: begin
				count <= count + 4'd1;
				if(metadata_in[133:132] == 2'b10)
					state_parser <= WAIT_PADING_S;
				else
					state_parser <= READ_PKT_TAIL_S;
			end
			WAIT_PADING_S: begin
				if(count >= `READY_COUNT) begin
					ready_out <= 1'b1;
					state_parser <= IDLE_S;
				end
				else begin
					count <= count + 4'd1;
					state_parser <= WAIT_PADING_S;
				end
			end
			default: begin
				state_parser <= IDLE_S;
			end
		endcase
	end
end



always @(posedge clk or negedge reset) begin
	if (!reset) begin
		for(meta_i = 1; meta_i < `NUM_OF_META; meta_i = meta_i + 1)
			metadata_temp[meta_i] <= 134'b0;
		reg_tag_temp <= 1'b0;
		count_meta <= 4'd0;
		wrreq_meta <= 1'b0;
		data_meta <= 134'b0;
		state_meta <= IDLE_S;
	end
	else begin
		case(state_meta)
			IDLE_S: begin
				if(reg_tag_temp != reg_tag) begin
					reg_tag_temp = reg_tag;


						
					count_meta <= 4'd0;
					state_meta <= WRITE_META_S;
				end
			end
			WRITE_META_S: begin
				count_meta <= count_meta + 4'd1;
				if(count_meta < `NUM_OF_META) begin
					wrreq_meta <= 1'b1;
					for(meta_j = 0; meta_j < `NUM_OF_META; meta_j = meta_j+1)
					begin
						if(meta_j[3:0] == count_meta)
							data_meta <= metadata_temp[meta_j];
					end
					state_meta <= WRITE_META_S;
				end
				else begin
					wrreq_meta <= 1'b0;
					state_meta <= IDLE_S;
				end
			end
			default: begin
				state_meta <= IDLE_S;
			end
		endcase		
	end
end



always @(posedge clk or negedge reset) begin
	if (!reset) begin
		metadata_out_valid <= 1'b0;
		metadata_out <= 134'b0;

		rdreq_pktBuffer <= 1'b0;
		rdreq_meta <= 1'b0;
		state_readPkt <= IDLE_S;
	end
	else begin
		case(state_readPkt)
			IDLE_S: begin
				metadata_out_valid <= 1'b0;
				if(empty_meta == 1'b0) begin
					rdreq_meta <= 1'b1;
					state_readPkt <= READ_META_S;
				end
				else
					state_readPkt <= IDLE_S;
			end
			READ_META_S: begin
				metadata_out_valid <= 1'b1;
				metadata_out <= ctx_meta;
				if(ctx_meta[133:132] == 2'b00) begin
					state_readPkt <= READ_PKT_S;
					rdreq_pktBuffer <= 1'b1;
					rdreq_meta <= 1'b0;
				end
				else begin
					state_readPkt <= READ_META_S;
				end
			end
			READ_PKT_S: begin
				metadata_out_valid <= 1'b1;
				metadata_out <= ctx_pktBuffer;
				if(ctx_pktBuffer[133:132] == 2'b10) begin
					state_readPkt <= IDLE_S;
					rdreq_pktBuffer <= 1'b0;
				end
				else begin
					state_readPkt <= READ_PKT_S;
				end
			end
			default: state_readPkt <= IDLE_S;
		endcase
	end
end




always @(posedge clk or negedge reset) begin
	if (!reset) begin
		wrreq_pktBuffer <= 1'b0;
		data_pktBuffer <= 134'b0;
		state_input <= IDLE_S;	
	end
	else begin
		case(state_input)
			IDLE_S: begin
				if((metadata_in_valid == 1'b1) && (metadata_in[133:132] == 2'b01))
				begin
					wrreq_pktBuffer <= 1'b0;

					state_input <= WAIT_PKT_HEAD_S;
				end
				else begin
					wrreq_pktBuffer <= 1'b0;
					state_input <= IDLE_S;
				end
			end
			WAIT_PKT_HEAD_S: begin
				if(metadata_in[133:132] == 2'b01) begin
					wrreq_pktBuffer <= 1'b1;
					data_pktBuffer <= metadata_in;
					state_input <= WAIT_PKT_TAIL_S;
				end
				else begin
					state_input <= WAIT_PKT_HEAD_S;
				end
			end
			WAIT_PKT_TAIL_S: begin
				wrreq_pktBuffer <= 1'b1;
				data_pktBuffer <= metadata_in;
				if(metadata_in[133:132] == 2'b10) begin
					state_input <= IDLE_S;
				end
				else begin
					state_input <= WAIT_PKT_TAIL_S;
				end
			end
			default: begin
				state_input <= IDLE_S;
			end
		endcase
	end
end



fifo packet_buffer(
.aclr(!reset),
.clock(clk),
.data(data_pktBuffer),
.rdreq(rdreq_pktBuffer),
.wrreq(wrreq_pktBuffer),
.empty(empty_pktBuffer),
.full(),
.q(ctx_pktBuffer),
.usedw()
);
defparam
	packet_buffer.width = 134,
	packet_buffer.depth = 8,
	packet_buffer.words = 256;


fifo meta_buffer(
.aclr(!reset),
.clock(clk),
.data(data_meta),
.rdreq(rdreq_meta),
.wrreq(wrreq_meta),
.empty(empty_meta),
.full(),
.q(ctx_meta),
.usedw()
);
defparam
	meta_buffer.width = 134,
	meta_buffer.depth = 5,
	meta_buffer.words = 32;

endmodule
module parser(
	clk,
	reset,
	metadata_in_valid,
	metadata_in,
	metadata_out_valid,
	metadata_out,
	ready_in,
	ready_out
);



input			clk;
input			reset;
input			metadata_in_valid;
input		[133:0]	metadata_in;
output	reg		metadata_out_valid;
output	reg	[133:0]	metadata_out;
input			ready_in;
output	reg		ready_out;




reg	[133:0]	data_pktBuffer;
reg		rdreq_pktBuffer;
reg		wrreq_pktBuffer;
wire		empty_pktBuffer;
wire	[133:0]	ctx_pktBuffer;

reg	[133:0]	data_meta;
reg		rdreq_meta;
reg		wrreq_meta;
wire		empty_meta;
wire	[133:0]	ctx_meta;





reg	[7:0]	metaReg[`NUM_OF_REG-1:0];
reg	[133:0]	metadata_temp[`NUM_OF_META-1:0];
reg	[3:0]	count, count_meta;
reg		reg_tag, reg_tag_temp;
reg	[3:0]	protocol_type;



reg	[3:0]	state_parser, state_readPkt, state_meta, state_input;
parameter	IDLE_S			= 4'd0,
		READ_PKT_1_S		= 4'd1,
		READ_PKT_2_S		= 4'd2,
		READ_PKT_3_S		= 4'd3,
		READ_PKT_4_S		= 4'd4,
		READ_PKT_5_S		= 4'd5,
		READ_PKT_6_S		= 4'd6,
		READ_PKT_7_S		= 4'd7,
		READ_PKT_TAIL_S	= 4'd8,
		WAIT_PADING_S	= 4'd9,
		READ_META_S		= 4'd1,
		READ_PKT_S		= 4'd2,
		WRITE_META_S		= 4'd1,
		WAIT_PKT_HEAD_S	= 4'd1,
		WAIT_PKT_TAIL_S	= 4'd2;

integer i, j;
integer meta_i, meta_j;



always @(posedge clk or negedge reset) begin
	if (!reset) begin
		for(i=0; i< `NUM_OF_REG; i = i+1)
			metaReg[i] <= 8'b0;
		count <= 4'b0;
		ready_out <= 1'b1;
		reg_tag <= 1'b0;
		protocol_type <= 4'b0;
		metadata_temp[0] <= 134'b0;
		state_parser <= IDLE_S;
	end
	else begin
		case(state_parser)
			IDLE_S: begin

				for(j=0; j< `NUM_OF_REG; j = j+1)
					metaReg[j] <= 8'b0;
				if((metadata_in_valid == 1'b1) && (ready_in == 1'b1) && 
					(metadata_in[133:132] == 2'b01))
				begin

					ready_out <= 1'b0;

					metadata_temp[0] <= metadata_in;

					count <= 4'd1;

					protocol_type <= 4'd0;
					state_parser <= READ_PKT_1_S;
				end
				else begin
					state_parser <= IDLE_S;
				end
			end
			READ_PKT_1_S: begin
				count <= count + 4'd1;


			end
			READ_PKT_2_S: begin
				count <= count + 4'd1;


			end
			READ_PKT_3_S: begin
				count <= count + 4'd1;


			end
			READ_PKT_4_S: begin
				count <= count + 4'd1;



			end
			READ_PKT_5_S: begin
				count <= count + 4'd1;

				
			end
			READ_PKT_6_S: begin
				count <= count + 4'd1;

				
			end
			READ_PKT_7_S: begin
				count <= count + 4'd1;

				
			end
			READ_PKT_TAIL_S: begin
				count <= count + 4'd1;
				if(metadata_in[133:132] == 2'b10)
					state_parser <= WAIT_PADING_S;
				else
					state_parser <= READ_PKT_TAIL_S;
			end
			WAIT_PADING_S: begin
				if(count >= `READY_COUNT) begin
					ready_out <= 1'b1;
					state_parser <= IDLE_S;
				end
				else begin
					count <= count + 4'd1;
					state_parser <= WAIT_PADING_S;
				end
			end
			default: begin
				state_parser <= IDLE_S;
			end
		endcase
	end
end



always @(posedge clk or negedge reset) begin
	if (!reset) begin
		for(meta_i = 1; meta_i < `NUM_OF_META; meta_i = meta_i + 1)
			metadata_temp[meta_i] <= 134'b0;
		reg_tag_temp <= 1'b0;
		count_meta <= 4'd0;
		wrreq_meta <= 1'b0;
		data_meta <= 134'b0;
		state_meta <= IDLE_S;
	end
	else begin
		case(state_meta)
			IDLE_S: begin
				if(reg_tag_temp != reg_tag) begin
					reg_tag_temp = reg_tag;


						
					count_meta <= 4'd0;
					state_meta <= WRITE_META_S;
				end
			end
			WRITE_META_S: begin
				count_meta <= count_meta + 4'd1;
				if(count_meta < `NUM_OF_META) begin
					wrreq_meta <= 1'b1;
					for(meta_j = 0; meta_j < `NUM_OF_META; meta_j = meta_j+1)
					begin
						if(meta_j[3:0] == count_meta)
							data_meta <= metadata_temp[meta_j];
					end
					state_meta <= WRITE_META_S;
				end
				else begin
					wrreq_meta <= 1'b0;
					state_meta <= IDLE_S;
				end
			end
			default: begin
				state_meta <= IDLE_S;
			end
		endcase		
	end
end



always @(posedge clk or negedge reset) begin
	if (!reset) begin
		metadata_out_valid <= 1'b0;
		metadata_out <= 134'b0;

		rdreq_pktBuffer <= 1'b0;
		rdreq_meta <= 1'b0;
		state_readPkt <= IDLE_S;
	end
	else begin
		case(state_readPkt)
			IDLE_S: begin
				metadata_out_valid <= 1'b0;
				if(empty_meta == 1'b0) begin
					rdreq_meta <= 1'b1;
					state_readPkt <= READ_META_S;
				end
				else
					state_readPkt <= IDLE_S;
			end
			READ_META_S: begin
				metadata_out_valid <= 1'b1;
				metadata_out <= ctx_meta;
				if(ctx_meta[133:132] == 2'b00) begin
					state_readPkt <= READ_PKT_S;
					rdreq_pktBuffer <= 1'b1;
					rdreq_meta <= 1'b0;
				end
				else begin
					state_readPkt <= READ_META_S;
				end
			end
			READ_PKT_S: begin
				metadata_out_valid <= 1'b1;
				metadata_out <= ctx_pktBuffer;
				if(ctx_pktBuffer[133:132] == 2'b10) begin
					state_readPkt <= IDLE_S;
					rdreq_pktBuffer <= 1'b0;
				end
				else begin
					state_readPkt <= READ_PKT_S;
				end
			end
			default: state_readPkt <= IDLE_S;
		endcase
	end
end




always @(posedge clk or negedge reset) begin
	if (!reset) begin
		wrreq_pktBuffer <= 1'b0;
		data_pktBuffer <= 134'b0;
		state_input <= IDLE_S;	
	end
	else begin
		case(state_input)
			IDLE_S: begin
				if((metadata_in_valid == 1'b1) && (metadata_in[133:132] == 2'b01))
				begin
					wrreq_pktBuffer <= 1'b0;

					state_input <= WAIT_PKT_HEAD_S;
				end
				else begin
					wrreq_pktBuffer <= 1'b0;
					state_input <= IDLE_S;
				end
			end
			WAIT_PKT_HEAD_S: begin
				if(metadata_in[133:132] == 2'b01) begin
					wrreq_pktBuffer <= 1'b1;
					data_pktBuffer <= metadata_in;
					state_input <= WAIT_PKT_TAIL_S;
				end
				else begin
					state_input <= WAIT_PKT_HEAD_S;
				end
			end
			WAIT_PKT_TAIL_S: begin
				wrreq_pktBuffer <= 1'b1;
				data_pktBuffer <= metadata_in;
				if(metadata_in[133:132] == 2'b10) begin
					state_input <= IDLE_S;
				end
				else begin
					state_input <= WAIT_PKT_TAIL_S;
				end
			end
			default: begin
				state_input <= IDLE_S;
			end
		endcase
	end
end



fifo packet_buffer(
.aclr(!reset),
.clock(clk),
.data(data_pktBuffer),
.rdreq(rdreq_pktBuffer),
.wrreq(wrreq_pktBuffer),
.empty(empty_pktBuffer),
.full(),
.q(ctx_pktBuffer),
.usedw()
);
defparam
	packet_buffer.width = 134,
	packet_buffer.depth = 8,
	packet_buffer.words = 256;


fifo meta_buffer(
.aclr(!reset),
.clock(clk),
.data(data_meta),
.rdreq(rdreq_meta),
.wrreq(wrreq_meta),
.empty(empty_meta),
.full(),
.q(ctx_meta),
.usedw()
);
defparam
	meta_buffer.width = 134,
	meta_buffer.depth = 5,
	meta_buffer.words = 32;

endmodule