data/full_repos/permissive/129989088/L4_Parser.v
 line:305: before: "."
1: b"%Error: data/full_repos/permissive/129989088/L4_Parser.v:293: Cannot find file containing module: 'fifo'\nfifo pkt_buffer(\n^~~~\n        ... Looked in:\n             data/full_repos/permissive/129989088,data/full_repos/permissive/129989088/fifo\n             data/full_repos/permissive/129989088,data/full_repos/permissive/129989088/fifo.v\n             data/full_repos/permissive/129989088,data/full_repos/permissive/129989088/fifo.sv\n             fifo\n             fifo.v\n             fifo.sv\n             obj_dir/fifo\n             obj_dir/fifo.v\n             obj_dir/fifo.sv\n%Error: Exiting due to 1 error(s)\n"
module L4_Parser(
	clk,
	reset,

	pktin_data_wr,
	pktin_data,
	pktin_data_valid_wr,
	pktin_data_valid,
	pktin_ready,
	pktout_data_wr,
	pktout_data,
	pktout_data_valid_wr,
	pktout_data_valid,
	pktout_ready,
	pfv_wr,
	pfv,

	cin_data_wr,
	cin_data,
	cin_ready,
	cout_data_wr,
	cout_data,
	cout_ready
);

parameter 	w_pkt = 139,
			w_pfv = 248;




input								clk;
input								reset;
input								pktin_data_wr;
input			[w_pkt-1:0]			pktin_data;
input								pktin_data_valid_wr;
input								pktin_data_valid;
output	reg							pktin_ready;
output	reg							pktout_data_wr;	
output	reg		[w_pkt-1:0]			pktout_data;
output	reg							pktout_data_valid_wr;
output	reg							pktout_data_valid;
input								pktout_ready;
output	reg 							pfv_wr;
output	reg 		[w_pfv-1:0]			pfv;

input								cin_data_wr;
input			[w_pkt-1:0]			cin_data;
output	reg							cin_ready;
output	reg							cout_data_wr;
output	reg		[w_pkt-1:0]			cout_data;
input								cout_ready;




reg						rdreq_pkt;
wire	[w_pkt-1:0]		q_pkt;
wire					empty_pkt;


reg		[31:0]			src_ip, dst_ip, sendSeq, ackSeq, httpType;
reg 		[15:0]			src_port, dst_port, content_length, pkt_length, window;
reg 		[7:0]			protocol, ingressPort, egressPort, winScale, tcpFlag;
reg 		[3:0]			tcpH_length;


reg 						pfv_wr_tag;



reg 		[3:0]	state_parser;
parameter		IDLE_S					= 4'd0,
				READ_META_0_S		= 4'd1,
				READ_META_1_S		= 4'd2,
				PARSE_ETH_S			= 4'd3,
				PARSE_IP_S			= 4'd4,
				PARSE_TCP_UDP_ICMP_S = 4'd5,
				PARSE_TCP_S			= 4'd6,
				WAIT_PKT_TAIL_S		= 4'd7,
				OUTPUT_PFV_S		= 4'd8;




always @(posedge clk or negedge reset) begin
	if (!reset) begin
		cin_ready <= 1'b1;
		cout_data_wr <= 1'b0;
		cout_data <= {w_pkt{1'b0}};
	end
	else begin
		cin_ready <= cout_ready;
		cout_data_wr <= cin_data_wr;
		cout_data <= cin_data;
	end
end



always @(posedge clk or negedge reset) begin
	if (!reset) begin

		pfv_wr <= 1'b0;
		pfv <= 248'b0;
		pktout_data_wr <= 1'b0;
		pktout_data <= {w_pkt{1'b0}};
		pktout_data_valid_wr <= 1'b0;
		pktout_data_valid <= 1'b0;
		pktin_ready <= 1'b1;

		pfv_wr_tag <= 1'b0;
		{ingressPort, egressPort, protocol, dst_port, src_port, dst_ip, src_ip, content_length, 
			tcpFlag, sendSeq, ackSeq, window, winScale, httpType} <= 264'b0;
		pkt_length <= 16'b0;
		tcpH_length <= 4'b0;

		rdreq_pkt <= 1'b0;

		state_parser <= IDLE_S;
	end
	else begin
		case(state_parser)
			IDLE_S: begin

				pktout_data_wr <= 1'b0;
				pfv_wr <= 1'b0;
				pfv_wr_tag <= 1'b0;
				{ingressPort, egressPort, protocol, dst_port, src_port, dst_ip, src_ip, content_length, 
					tcpFlag, sendSeq, ackSeq, window, winScale, httpType} <= 264'b0;
				pkt_length <= 16'b0;
				tcpH_length <= 4'b0;

				if(empty_pkt == 1'b0) begin
					rdreq_pkt <= 1'b1;
					state_parser <= PARSE_ETH_S;
				end
				else begin
					rdreq_pkt <= 1'b0;
					state_parser <= IDLE_S;
				end
			end
			READ_META_0_S: begin
				pktout_data_wr <= 1'b1;
				pktout_data <= q_pkt;

				ingressPort <= q_pkt[127:120];
				egressPort <= q_pkt[119:112];
				state_parser <= READ_META_1_S;
			end
			READ_META_1_S: begin
				pktout_data <= q_pkt;

				state_parser <= PARSE_ETH_S;
			end
			PARSE_ETH_S: begin
				pktout_data_wr <= 1'b1;
				pktout_data <= q_pkt;


				if(q_pkt[31:16] == 16'h0800) state_parser <= PARSE_IP_S;
				else 	state_parser <= WAIT_PKT_TAIL_S;
			end
			PARSE_IP_S: begin
				pktout_data <= q_pkt;


				{src_ip,dst_ip[31:16]} <= q_pkt[47:0];
				pkt_length <= q_pkt[127:112];

				if((q_pkt[71:64] == 8'h11) || (q_pkt[71:64] == 8'h06) || (q_pkt[71:64] == 8'h1))
					protocol <= q_pkt[71:64];
				else
					protocol <= 8'b0;
				state_parser <= PARSE_TCP_UDP_ICMP_S;
			end
			PARSE_TCP_UDP_ICMP_S: begin
				pktout_data <= q_pkt;


				if(protocol == 8'h06) begin
					{dst_ip[15:0],src_port,dst_port,sendSeq,ackSeq} <= q_pkt[127:16];

					content_length <= pkt_length - {10'b0,q_pkt[15:12],2'b0} - 16'd20;
					tcpH_length <= q_pkt[15:12];
					tcpFlag <= {2'b0,q_pkt[5:0]};
					state_parser <= PARSE_TCP_S;
				end
				else if(protocol == 8'h11) begin
					{dst_ip[15:0],src_port,dst_port} <= q_pkt[127:80];
					state_parser <= WAIT_PKT_TAIL_S;
				end
				else if(protocol == 8'h1) begin
					dst_ip[15:0] <= q_pkt[127:112];
					src_port <= {8'b0,q_pkt[111:104]};
					dst_port <= {8'b0,q_pkt[103:96]};
					state_parser <= WAIT_PKT_TAIL_S;
				end
				else begin
					dst_ip[15:0] <= q_pkt[127:112];
					state_parser <= WAIT_PKT_TAIL_S;
				end
			end
			PARSE_TCP_S: begin
				pktout_data <= q_pkt;


				window <= q_pkt[127:112];


				if((dst_port == 16'd80) && (tcpH_length == 4'd5) && (content_length > 16'd0))	
					httpType <= q_pkt[79:48];


				if((tcpFlag == 8'h02) && (tcpH_length > 4'd5)) begin

					if(q_pkt[47:24] == 24'h010303)	winScale <= q_pkt[23:16];
					else begin

					end
				end
				

				if(q_pkt[138:136] == 3'b110) begin
					state_parser <= OUTPUT_PFV_S;
					rdreq_pkt <= 1'b0;
				end
				else begin
					state_parser <= WAIT_PKT_TAIL_S;
				end
			end
			WAIT_PKT_TAIL_S: begin
				pktout_data <= q_pkt;

				if(q_pkt[138:136] == 3'b110) begin 

					rdreq_pkt <= 1'b0;
					state_parser <= IDLE_S;
				end
				else begin
					state_parser <= WAIT_PKT_TAIL_S;
				end

				if(pfv_wr_tag == 1'b0) begin
					pfv_wr_tag <= 1'b1;
					pfv_wr <= 1'b1;
					pfv <= {protocol, dst_port, src_port, dst_ip, src_ip, content_length, 
							tcpFlag, sendSeq, ackSeq, window, winScale, httpType};
				end
				else begin
					pfv_wr <= 1'b0;
				end
			end
			OUTPUT_PFV_S: begin
				pktout_data_wr <= 1'b0;

				pfv_wr <= 1'b1;
				pfv <= {protocol, dst_port, src_port, dst_ip, src_ip, content_length, tcpFlag, 
						sendSeq, ackSeq, window, winScale, httpType};
				state_parser <= IDLE_S;
			end
			default: begin
				state_parser <= IDLE_S;
			end
		endcase
	end
end

fifo pkt_buffer(
.aclr(!reset),
.clock(clk),
.data(pktin_data),
.rdreq(rdreq_pkt),
.wrreq(pktin_data_wr),
.empty(empty_pkt),
.full(),
.q(q_pkt),
.usedw()
);
defparam
	pkt_buffer.width = 139,
	pkt_buffer.depth = 8,
	pkt_buffer.words = 256;


endmodule
module L4_Parser(
	clk,
	reset,

	pktin_data_wr,
	pktin_data,
	pktin_data_valid_wr,
	pktin_data_valid,
	pktin_ready,
	pktout_data_wr,
	pktout_data,
	pktout_data_valid_wr,
	pktout_data_valid,
	pktout_ready,
	pfv_wr,
	pfv,

	cin_data_wr,
	cin_data,
	cin_ready,
	cout_data_wr,
	cout_data,
	cout_ready
);


parameter 	w_pkt = 139,
			w_pfv = 248;




input								clk;
input								reset;
input								pktin_data_wr;
input			[w_pkt-1:0]			pktin_data;
input								pktin_data_valid_wr;
input								pktin_data_valid;
output	reg							pktin_ready;
output	reg							pktout_data_wr;	
output	reg		[w_pkt-1:0]			pktout_data;
output	reg							pktout_data_valid_wr;
output	reg							pktout_data_valid;
input								pktout_ready;
output	reg 							pfv_wr;
output	reg 		[w_pfv-1:0]			pfv;

input								cin_data_wr;
input			[w_pkt-1:0]			cin_data;
output	reg							cin_ready;
output	reg							cout_data_wr;
output	reg		[w_pkt-1:0]			cout_data;
input								cout_ready;




reg						rdreq_pkt;
wire	[w_pkt-1:0]		q_pkt;
wire					empty_pkt;


reg		[31:0]			src_ip, dst_ip, sendSeq, ackSeq, httpType;
reg 		[15:0]			src_port, dst_port, content_length, pkt_length, window;
reg 		[7:0]			protocol, ingressPort, egressPort, winScale, tcpFlag;
reg 		[3:0]			tcpH_length;


reg 						pfv_wr_tag;



reg 		[3:0]	state_parser;
parameter		IDLE_S					= 4'd0,
				READ_META_0_S		= 4'd1,
				READ_META_1_S		= 4'd2,
				PARSE_ETH_S			= 4'd3,
				PARSE_IP_S			= 4'd4,
				PARSE_TCP_UDP_ICMP_S = 4'd5,
				PARSE_TCP_S			= 4'd6,
				WAIT_PKT_TAIL_S		= 4'd7,
				OUTPUT_PFV_S		= 4'd8;




always @(posedge clk or negedge reset) begin
	if (!reset) begin
		cin_ready <= 1'b1;
		cout_data_wr <= 1'b0;
		cout_data <= {w_pkt{1'b0}};
	end
	else begin
		cin_ready <= cout_ready;
		cout_data_wr <= cin_data_wr;
		cout_data <= cin_data;
	end
end



always @(posedge clk or negedge reset) begin
	if (!reset) begin

		pfv_wr <= 1'b0;
		pfv <= 248'b0;
		pktout_data_wr <= 1'b0;
		pktout_data <= {w_pkt{1'b0}};
		pktout_data_valid_wr <= 1'b0;
		pktout_data_valid <= 1'b0;
		pktin_ready <= 1'b1;

		pfv_wr_tag <= 1'b0;
		{ingressPort, egressPort, protocol, dst_port, src_port, dst_ip, src_ip, content_length, 
			tcpFlag, sendSeq, ackSeq, window, winScale, httpType} <= 264'b0;
		pkt_length <= 16'b0;
		tcpH_length <= 4'b0;

		rdreq_pkt <= 1'b0;

		state_parser <= IDLE_S;
	end
	else begin
		case(state_parser)
			IDLE_S: begin

				pktout_data_wr <= 1'b0;
				pfv_wr <= 1'b0;
				pfv_wr_tag <= 1'b0;
				{ingressPort, egressPort, protocol, dst_port, src_port, dst_ip, src_ip, content_length, 
					tcpFlag, sendSeq, ackSeq, window, winScale, httpType} <= 264'b0;
				pkt_length <= 16'b0;
				tcpH_length <= 4'b0;

				if(empty_pkt == 1'b0) begin
					rdreq_pkt <= 1'b1;
					state_parser <= PARSE_ETH_S;
				end
				else begin
					rdreq_pkt <= 1'b0;
					state_parser <= IDLE_S;
				end
			end
			READ_META_0_S: begin
				pktout_data_wr <= 1'b1;
				pktout_data <= q_pkt;

				ingressPort <= q_pkt[127:120];
				egressPort <= q_pkt[119:112];
				state_parser <= READ_META_1_S;
			end
			READ_META_1_S: begin
				pktout_data <= q_pkt;

				state_parser <= PARSE_ETH_S;
			end
			PARSE_ETH_S: begin
				pktout_data_wr <= 1'b1;
				pktout_data <= q_pkt;


				if(q_pkt[31:16] == 16'h0800) state_parser <= PARSE_IP_S;
				else 	state_parser <= WAIT_PKT_TAIL_S;
			end
			PARSE_IP_S: begin
				pktout_data <= q_pkt;


				{src_ip,dst_ip[31:16]} <= q_pkt[47:0];
				pkt_length <= q_pkt[127:112];

				if((q_pkt[71:64] == 8'h11) || (q_pkt[71:64] == 8'h06) || (q_pkt[71:64] == 8'h1))
					protocol <= q_pkt[71:64];
				else
					protocol <= 8'b0;
				state_parser <= PARSE_TCP_UDP_ICMP_S;
			end
			PARSE_TCP_UDP_ICMP_S: begin
				pktout_data <= q_pkt;


				if(protocol == 8'h06) begin
					{dst_ip[15:0],src_port,dst_port,sendSeq,ackSeq} <= q_pkt[127:16];

					content_length <= pkt_length - {10'b0,q_pkt[15:12],2'b0} - 16'd20;
					tcpH_length <= q_pkt[15:12];
					tcpFlag <= {2'b0,q_pkt[5:0]};
					state_parser <= PARSE_TCP_S;
				end
				else if(protocol == 8'h11) begin
					{dst_ip[15:0],src_port,dst_port} <= q_pkt[127:80];
					state_parser <= WAIT_PKT_TAIL_S;
				end
				else if(protocol == 8'h1) begin
					dst_ip[15:0] <= q_pkt[127:112];
					src_port <= {8'b0,q_pkt[111:104]};
					dst_port <= {8'b0,q_pkt[103:96]};
					state_parser <= WAIT_PKT_TAIL_S;
				end
				else begin
					dst_ip[15:0] <= q_pkt[127:112];
					state_parser <= WAIT_PKT_TAIL_S;
				end
			end
			PARSE_TCP_S: begin
				pktout_data <= q_pkt;


				window <= q_pkt[127:112];


				if((dst_port == 16'd80) && (tcpH_length == 4'd5) && (content_length > 16'd0))	
					httpType <= q_pkt[79:48];


				if((tcpFlag == 8'h02) && (tcpH_length > 4'd5)) begin

					if(q_pkt[47:24] == 24'h010303)	winScale <= q_pkt[23:16];
					else begin

					end
				end
				

				if(q_pkt[138:136] == 3'b110) begin
					state_parser <= OUTPUT_PFV_S;
					rdreq_pkt <= 1'b0;
				end
				else begin
					state_parser <= WAIT_PKT_TAIL_S;
				end
			end
			WAIT_PKT_TAIL_S: begin
				pktout_data <= q_pkt;

				if(q_pkt[138:136] == 3'b110) begin 

					rdreq_pkt <= 1'b0;
					state_parser <= IDLE_S;
				end
				else begin
					state_parser <= WAIT_PKT_TAIL_S;
				end

				if(pfv_wr_tag == 1'b0) begin
					pfv_wr_tag <= 1'b1;
					pfv_wr <= 1'b1;
					pfv <= {protocol, dst_port, src_port, dst_ip, src_ip, content_length, 
							tcpFlag, sendSeq, ackSeq, window, winScale, httpType};
				end
				else begin
					pfv_wr <= 1'b0;
				end
			end
			OUTPUT_PFV_S: begin
				pktout_data_wr <= 1'b0;

				pfv_wr <= 1'b1;
				pfv <= {protocol, dst_port, src_port, dst_ip, src_ip, content_length, tcpFlag, 
						sendSeq, ackSeq, window, winScale, httpType};
				state_parser <= IDLE_S;
			end
			default: begin
				state_parser <= IDLE_S;
			end
		endcase
	end
end

fifo pkt_buffer(
.aclr(!reset),
.clock(clk),
.data(pktin_data),
.rdreq(rdreq_pkt),
.wrreq(pktin_data_wr),
.empty(empty_pkt),
.full(),
.q(q_pkt),
.usedw()
);
defparam
	pkt_buffer.width = 139,
	pkt_buffer.depth = 8,
	pkt_buffer.words = 256;


endmodule