data/full_repos/permissive/162338081/main.v
'utf-8' codec can't decode byte 0xe7 in position 153: invalid continuation byte
1: b'%Warning-LITENDIAN: data/full_repos/permissive/162338081/main.v:10: Little bit endian vector: MSB < LSB of bit range: 1:4\n    input [1:4]membpeg;  \n          ^\n                    ... Use "/* verilator lint_off LITENDIAN */" and lint_on around source to disable this message.\n%Warning-LITENDIAN: data/full_repos/permissive/162338081/main.v:25: Little bit endian vector: MSB < LSB of bit range: 1:4\n    output  [1:4]membsai;\n            ^\n%Error: data/full_repos/permissive/162338081/main.v:46: Cannot find file containing module: \'tecladinho\'\n tecladinho tec(clk,membpeg,membsai,pegui,pegui2);\n ^~~~~~~~~~\n        ... Looked in:\n             data/full_repos/permissive/162338081,data/full_repos/permissive/162338081/tecladinho\n             data/full_repos/permissive/162338081,data/full_repos/permissive/162338081/tecladinho.v\n             data/full_repos/permissive/162338081,data/full_repos/permissive/162338081/tecladinho.sv\n             tecladinho\n             tecladinho.v\n             tecladinho.sv\n             obj_dir/tecladinho\n             obj_dir/tecladinho.v\n             obj_dir/tecladinho.sv\n%Error: data/full_repos/permissive/162338081/main.v:49: Cannot find file containing module: \'separa\'\n separa princ(counter,n0,n1,n2,n3);\n ^~~~~~\n%Error: data/full_repos/permissive/162338081/main.v:50: Cannot find file containing module: \'separa\'\n separa dois(pegui2,m0,m1,m2,m3);\n ^~~~~~\n%Error: data/full_repos/permissive/162338081/main.v:52: Cannot find file containing module: \'decot\'\n decot dois0(m0,fio1);\n ^~~~~\n%Error: data/full_repos/permissive/162338081/main.v:53: Cannot find file containing module: \'decot\'\n decot dois1(m1,fio2);\n ^~~~~\n%Error: data/full_repos/permissive/162338081/main.v:54: Cannot find file containing module: \'decot\'\n decot dois2(m2,fio3);\n ^~~~~\n%Error: data/full_repos/permissive/162338081/main.v:55: Cannot find file containing module: \'decot\'\n decot dois3(m3,fio4);\n ^~~~~\n%Error: data/full_repos/permissive/162338081/main.v:57: Cannot find file containing module: \'decot\'\n decot dig0(n0,filete1);\n ^~~~~\n%Error: data/full_repos/permissive/162338081/main.v:58: Cannot find file containing module: \'decot\'\n decot dig1(n1,filete2);\n ^~~~~\n%Error: data/full_repos/permissive/162338081/main.v:59: Cannot find file containing module: \'decot\'\n decot dig2(n2,filete3);\n ^~~~~\n%Error: data/full_repos/permissive/162338081/main.v:60: Cannot find file containing module: \'decot\'\n decot dig3(n3,filete4);\n ^~~~~\n%Warning-WIDTH: data/full_repos/permissive/162338081/main.v:94: Operator ADD expects 4 bits on the LHS, but LHS\'s VARREF \'funcao\' generates 1 bits.\n                                                              : ... In instance main\n                estado <= funcao + 1\'d1;  \n                                 ^\n%Error: Exiting due to 11 error(s), 3 warning(s)\n'
module main( clk , enable , funcao , reset , para , filete1 , filete2 , filete3 , filete4 , membpeg ,membsai,fio1,fio2,fio3,fio4);
   
    

    input clk;
    input funcao;
    input enable;
    input reset;
    input para;
    input [1:4]membpeg;
   
    

    parameter CONF = 4'b0000, CRON = 4'b0001, TEMP = 4'b0010, PARAR = 4'b0011;
       

    output  [6:0]filete1;
    output  [6:0]filete2;
    output  [6:0]filete3;
    output  [6:0]filete4;
    output  [6:0]fio1;
    output  [6:0]fio2;
    output  [6:0]fio3;
    output  [6:0]fio4;
    output  [1:4]membsai;
    
    

    reg [3:0]estado;
    reg [13:0]counter,counterAux;
    reg [26:0] pulsos,pulsosAux;
    reg [13:0]numero;
    wire [13:0]pegui;
    wire [3:0]n0;
    wire [3:0]n1;
    wire [3:0]n2;
    wire [3:0]n3;
    wire [3:0]mempegfilt;
    reg flag;
    reg flag2;
    wire [13:0]pegui2;
    wire [3:0]m0,m1,m2,m3;
    
	
	
	tecladinho tec(clk,membpeg,membsai,pegui,pegui2);
	

	separa princ(counter,n0,n1,n2,n3);
	separa dois(pegui2,m0,m1,m2,m3);
	
	decot dois0(m0,fio1);
	decot dois1(m1,fio2);
	decot dois2(m2,fio3);
	decot dois3(m3,fio4);
	
	decot dig0(n0,filete1);
	decot dig1(n1,filete2);
	decot dig2(n2,filete3);
	decot dig3(n3,filete4);
	

    initial begin
        estado <= CONF;
        counter <= 14'd0;
        pulsos <= 27'd0;
        counterAux <= 14'd0;
        flag<=1;
        flag2<=1;
        pulsosAux <= 27'd0;
    end
   

    always@ (posedge clk) begin
   
				if(reset == 0)begin
					if( (estado == CRON) || (estado == PARAR && funcao == 0))begin
						if(estado == PARAR)
							estado <= CRON;
										   
					end
					else if( (estado == TEMP) || (estado == PARAR && funcao == 1))begin
						if(estado == PARAR)
							estado <= TEMP;              
					end  
				end


        if (!para && flag2) begin
            if(  (estado == CRON) || (estado == TEMP) )begin
                estado <= PARAR;
            end
            else if(estado == PARAR) begin
                estado <= funcao + 1'd1;
            end			
        end

       if(!para && flag2)
		flag2<=0;
		else if(para && !flag2)
			flag2<=1;
        case(estado)
       

            CONF: begin
            
                if( enable==1 && funcao == 0)begin
                    estado <= CRON;
                end
               
                else if(enable == 1 && funcao == 1 )begin
                    estado <= TEMP;
                end
                
                
            end
           

            TEMP:begin
                if(enable==1'd0) begin
                    estado <= CONF;
                end

            end
           

            CRON:begin
                if(enable==1'd0)begin
                    estado<=CONF;
                end

            end
           

            PARAR:begin
                if(enable==1'd0)begin
                    estado<=CONF;
                end


               
            end
           
        endcase
    end
   

    always@ (posedge clk ) begin
   
        if(!reset)begin
            if( (estado == CRON) || (estado == PARAR && funcao == 0))begin
                pulsos <= 27'd0;
                counter <= 14'd0;
                pulsosAux <= 27'd0;
                counterAux <= 14'd0;
               
            end
            else if( (estado == TEMP) || (estado == PARAR && funcao == 1))begin        
                pulsos <= 27'd0;
                counter <= pegui;
                pulsosAux <= 27'd0;
                counterAux <= 14'd0;      
               
            end  
        end

        if (!para && flag) begin
            if(  (estado == CRON) || (estado == TEMP) )begin
           
                counterAux <= counter;
                pulsosAux <= pulsos;
           
            end
            else if(estado == PARAR) begin
                counter <= counterAux;
                pulsos <= pulsosAux;
            end
           
        end
   	if(!para && flag)
		flag<=0;
		else if(para && !flag)
			flag<=1;
        case(estado)
       
            CONF: begin
               
				counter <=pegui;
             
                
                if(enable==1'd1 && funcao==1'd1)begin
                    counter <= pegui;
                    pulsos <= 27'd0;
                end
               
                else if(enable==1'd1 && funcao==1'd0)begin
                    counter <= 14'd0;
                    pulsos <= 27'd0;
                end
                
            end
       

            TEMP:begin
				if(counter != 0)begin
					if(pulsos == 27'd50000000) begin
						pulsos <= 27'd0;
						if(counter > 0)begin
							counter <= counter - 1'd1;
						end
					   
					end
					else
						pulsos <= pulsos + 1'd1;
				end
            end
           

            CRON: begin
				if(counter != pegui) begin
					if(pulsos == 27'd50000000) begin
							pulsos <= 27'd0;
							if(counter < pegui )begin
								counter <= counter+1'd1;
							end
					end
					else
						pulsos <= pulsos + 1'd1;
				end
             
            end
           

            PARAR:begin
                if(funcao == 0 && counterAux != pegui) begin
                    if(pulsosAux == 27'd50000000) begin
                        pulsosAux <= 27'd0;
                        if(counterAux < pegui)begin
                            counterAux <= counterAux +1'd1;
                        end
                    end
                    else
                        pulsosAux <= pulsosAux + 1'd1;
                end
               
                if(funcao == 1 && counterAux != 0) begin  
                    if(pulsosAux == 27'd50000000) begin
                        pulsosAux <= 27'd0;
                        if(counterAux > 0)begin
                            counterAux <= counterAux - 1'd1;
                        end
                    end
                        else
                            pulsosAux <= pulsosAux + 1'd1;    
                end
            end
       
        endcase
    end
   
   
    endmodule
module main( clk , enable , funcao , reset , para , filete1 , filete2 , filete3 , filete4 , membpeg ,membsai,fio1,fio2,fio3,fio4);

   
    

    input clk;
    input funcao;
    input enable;
    input reset;
    input para;
    input [1:4]membpeg;
   
    

    parameter CONF = 4'b0000, CRON = 4'b0001, TEMP = 4'b0010, PARAR = 4'b0011;
       

    output  [6:0]filete1;
    output  [6:0]filete2;
    output  [6:0]filete3;
    output  [6:0]filete4;
    output  [6:0]fio1;
    output  [6:0]fio2;
    output  [6:0]fio3;
    output  [6:0]fio4;
    output  [1:4]membsai;
    
    

    reg [3:0]estado;
    reg [13:0]counter,counterAux;
    reg [26:0] pulsos,pulsosAux;
    reg [13:0]numero;
    wire [13:0]pegui;
    wire [3:0]n0;
    wire [3:0]n1;
    wire [3:0]n2;
    wire [3:0]n3;
    wire [3:0]mempegfilt;
    reg flag;
    reg flag2;
    wire [13:0]pegui2;
    wire [3:0]m0,m1,m2,m3;
    
	
	
	tecladinho tec(clk,membpeg,membsai,pegui,pegui2);
	

	separa princ(counter,n0,n1,n2,n3);
	separa dois(pegui2,m0,m1,m2,m3);
	
	decot dois0(m0,fio1);
	decot dois1(m1,fio2);
	decot dois2(m2,fio3);
	decot dois3(m3,fio4);
	
	decot dig0(n0,filete1);
	decot dig1(n1,filete2);
	decot dig2(n2,filete3);
	decot dig3(n3,filete4);
	

    initial begin
        estado <= CONF;
        counter <= 14'd0;
        pulsos <= 27'd0;
        counterAux <= 14'd0;
        flag<=1;
        flag2<=1;
        pulsosAux <= 27'd0;
    end
   

    always@ (posedge clk) begin
   
				if(reset == 0)begin
					if( (estado == CRON) || (estado == PARAR && funcao == 0))begin
						if(estado == PARAR)
							estado <= CRON;
										   
					end
					else if( (estado == TEMP) || (estado == PARAR && funcao == 1))begin
						if(estado == PARAR)
							estado <= TEMP;              
					end  
				end


        if (!para && flag2) begin
            if(  (estado == CRON) || (estado == TEMP) )begin
                estado <= PARAR;
            end
            else if(estado == PARAR) begin
                estado <= funcao + 1'd1;
            end			
        end

       if(!para && flag2)
		flag2<=0;
		else if(para && !flag2)
			flag2<=1;
        case(estado)
       

            CONF: begin
            
                if( enable==1 && funcao == 0)begin
                    estado <= CRON;
                end
               
                else if(enable == 1 && funcao == 1 )begin
                    estado <= TEMP;
                end
                
                
            end
           

            TEMP:begin
                if(enable==1'd0) begin
                    estado <= CONF;
                end

            end
           

            CRON:begin
                if(enable==1'd0)begin
                    estado<=CONF;
                end

            end
           

            PARAR:begin
                if(enable==1'd0)begin
                    estado<=CONF;
                end


               
            end
           
        endcase
    end
   

    always@ (posedge clk ) begin
   
        if(!reset)begin
            if( (estado == CRON) || (estado == PARAR && funcao == 0))begin
                pulsos <= 27'd0;
                counter <= 14'd0;
                pulsosAux <= 27'd0;
                counterAux <= 14'd0;
               
            end
            else if( (estado == TEMP) || (estado == PARAR && funcao == 1))begin        
                pulsos <= 27'd0;
                counter <= pegui;
                pulsosAux <= 27'd0;
                counterAux <= 14'd0;      
               
            end  
        end

        if (!para && flag) begin
            if(  (estado == CRON) || (estado == TEMP) )begin
           
                counterAux <= counter;
                pulsosAux <= pulsos;
           
            end
            else if(estado == PARAR) begin
                counter <= counterAux;
                pulsos <= pulsosAux;
            end
           
        end
   	if(!para && flag)
		flag<=0;
		else if(para && !flag)
			flag<=1;
        case(estado)
       
            CONF: begin
               
				counter <=pegui;
             
                
                if(enable==1'd1 && funcao==1'd1)begin
                    counter <= pegui;
                    pulsos <= 27'd0;
                end
               
                else if(enable==1'd1 && funcao==1'd0)begin
                    counter <= 14'd0;
                    pulsos <= 27'd0;
                end
                
            end
       

            TEMP:begin
				if(counter != 0)begin
					if(pulsos == 27'd50000000) begin
						pulsos <= 27'd0;
						if(counter > 0)begin
							counter <= counter - 1'd1;
						end
					   
					end
					else
						pulsos <= pulsos + 1'd1;
				end
            end
           

            CRON: begin
				if(counter != pegui) begin
					if(pulsos == 27'd50000000) begin
							pulsos <= 27'd0;
							if(counter < pegui )begin
								counter <= counter+1'd1;
							end
					end
					else
						pulsos <= pulsos + 1'd1;
				end
             
            end
           

            PARAR:begin
                if(funcao == 0 && counterAux != pegui) begin
                    if(pulsosAux == 27'd50000000) begin
                        pulsosAux <= 27'd0;
                        if(counterAux < pegui)begin
                            counterAux <= counterAux +1'd1;
                        end
                    end
                    else
                        pulsosAux <= pulsosAux + 1'd1;
                end
               
                if(funcao == 1 && counterAux != 0) begin  
                    if(pulsosAux == 27'd50000000) begin
                        pulsosAux <= 27'd0;
                        if(counterAux > 0)begin
                            counterAux <= counterAux - 1'd1;
                        end
                    end
                        else
                            pulsosAux <= pulsosAux + 1'd1;    
                end
            end
       
        endcase
    end
   
   
    endmodule