data/full_repos/permissive/163602545/NoCSimp/NoCSimp_Modelsim/ConIP.v
data/verilator_xmls/92f306e5-e61a-4eb5-8892-4e8b2fe00cec.xml
module IP_consumer
   #(
      parameter DATA_WIDTH = 37,
      parameter POSITION = 4'b0101
   )
(
DataInIP,
Inr,
Inw,
clk,

reset
);

input [DATA_WIDTH-1 : 0] DataInIP;
output Inw;
input Inr;
input clk;
input reset;



reg Inw;
regstep;
reg [5:0] point;
reg [2:0] count;

initial
begin
  step=0;
  point=0;
  Inw=0;

end

always @(posedge reset or posedge clk)

begin
	if (reset == 1'b1)
    begin
      step<=0;
      Inw<=0;
      count<=0;
    end
    else
    begin

      case (step)
        
        1'b0:  begin
            if (Inr == 1'b1) 
                  begin
                    Inw=1'b1;
                    step=1'b1;
                  end
            end							
        1'b1:  begin
            if (Inr == 1'b0) 
              begin 

				if (DataInIP[3:0]!=POSITION) $display("ERROR: Received not suited flit. Aim is %b, but position is %b", DataInIP[3:0], POSITION);
                if (DataInIP[4]==1'b1) 
                  begin

                    $display("Recv pos: %d len: %d time: %t", POSITION, count+1, $time);


                    count=0;
                  end
                  else 
                    begin

                      count=count+1;
                    end
                Inw=1'b0;
                step=1'b0; 									
              end
            end
      endcase
    end
end
endmodule
module IP_consumer
   #(
      parameter DATA_WIDTH = 37,
      parameter POSITION = 4'b0101
   )
(
DataInIP,
Inr,
Inw,
clk,

reset
);


input [DATA_WIDTH-1 : 0] DataInIP;
output Inw;
input Inr;
input clk;
input reset;



reg Inw;
regstep;
reg [5:0] point;
reg [2:0] count;

initial
begin
  step=0;
  point=0;
  Inw=0;

end

always @(posedge reset or posedge clk)

begin
	if (reset == 1'b1)
    begin
      step<=0;
      Inw<=0;
      count<=0;
    end
    else
    begin

      case (step)
        
        1'b0:  begin
            if (Inr == 1'b1) 
                  begin
                    Inw=1'b1;
                    step=1'b1;
                  end
            end							
        1'b1:  begin
            if (Inr == 1'b0) 
              begin 

				if (DataInIP[3:0]!=POSITION) $display("ERROR: Received not suited flit. Aim is %b, but position is %b", DataInIP[3:0], POSITION);
                if (DataInIP[4]==1'b1) 
                  begin

                    $display("Recv pos: %d len: %d time: %t", POSITION, count+1, $time);


                    count=0;
                  end
                  else 
                    begin

                      count=count+1;
                    end
                Inw=1'b0;
                step=1'b0; 									
              end
            end
      endcase
    end
end
endmodule