data/full_repos/permissive/510956372/src/control_machine.v
1: b"%Error-PROCASSWIRE: data/full_repos/permissive/510956372/src/control_machine.v:20: Procedural assignment to wire, perhaps intended var (IEEE 1800-2017 6.5): 'reset'\n                                                                                 : ... In instance control_machine\n      reset = 1'b0;  \n      ^~~~~\n%Error-PROCASSWIRE: data/full_repos/permissive/510956372/src/control_machine.v:21: Procedural assignment to wire, perhaps intended var (IEEE 1800-2017 6.5): 'ch_Zero'\n                                                                                 : ... In instance control_machine\n      ch_Zero = 1'b0;  \n      ^~~~~~~\n%Error-PROCASSWIRE: data/full_repos/permissive/510956372/src/control_machine.v:27: Procedural assignment to wire, perhaps intended var (IEEE 1800-2017 6.5): 'enable_counting'\n                                                                                 : ... In instance control_machine\n        enable_counting = 1'b1;\n        ^~~~~~~~~~~~~~~\n%Error-PROCASSWIRE: data/full_repos/permissive/510956372/src/control_machine.v:29: Procedural assignment to wire, perhaps intended var (IEEE 1800-2017 6.5): 'ch_Vmeasured'\n                                                                                 : ... In instance control_machine\n        ch_Vmeasured = 1'b1;\n        ^~~~~~~~~~~~\n%Error-PROCASSWIRE: data/full_repos/permissive/510956372/src/control_machine.v:31: Procedural assignment to wire, perhaps intended var (IEEE 1800-2017 6.5): 'ch_Vmeasured'\n                                                                                 : ... In instance control_machine\n        ch_Vmeasured = 1'b0;\n        ^~~~~~~~~~~~\n%Error-PROCASSWIRE: data/full_repos/permissive/510956372/src/control_machine.v:32: Procedural assignment to wire, perhaps intended var (IEEE 1800-2017 6.5): 'ch_Vref'\n                                                                                 : ... In instance control_machine\n        ch_Vref = 1'b1;\n        ^~~~~~~\n%Error-PROCASSWIRE: data/full_repos/permissive/510956372/src/control_machine.v:35: Procedural assignment to wire, perhaps intended var (IEEE 1800-2017 6.5): 'enable_counting'\n                                                                                 : ... In instance control_machine\n        enable_counting = 1'b0;\n        ^~~~~~~~~~~~~~~\n%Error-PROCASSWIRE: data/full_repos/permissive/510956372/src/control_machine.v:36: Procedural assignment to wire, perhaps intended var (IEEE 1800-2017 6.5): 'load'\n                                                                                 : ... In instance control_machine\n        load = 1'b1;\n        ^~~~\n%Error-PROCASSWIRE: data/full_repos/permissive/510956372/src/control_machine.v:37: Procedural assignment to wire, perhaps intended var (IEEE 1800-2017 6.5): 'ch_Vref'\n                                                                                 : ... In instance control_machine\n        ch_Vref = 1'b0;\n        ^~~~~~~\n%Error-PROCASSWIRE: data/full_repos/permissive/510956372/src/control_machine.v:40: Procedural assignment to wire, perhaps intended var (IEEE 1800-2017 6.5): 'load'\n                                                                                 : ... In instance control_machine\n        load = 1'b0;\n        ^~~~\n%Error-PROCASSWIRE: data/full_repos/permissive/510956372/src/control_machine.v:41: Procedural assignment to wire, perhaps intended var (IEEE 1800-2017 6.5): 'reset'\n                                                                                 : ... In instance control_machine\n        reset = 1'b1;\n        ^~~~~\n%Error-PROCASSWIRE: data/full_repos/permissive/510956372/src/control_machine.v:42: Procedural assignment to wire, perhaps intended var (IEEE 1800-2017 6.5): 'ch_Zero'\n                                                                                 : ... In instance control_machine\n        ch_Zero = 1'b1;\n        ^~~~~~~\n%Error: Exiting due to 12 error(s)\n        ... See the manual and https://verilator.org for more assistance.\n"
module control_machine( input start,
                        input clk,
                        input finished_counting,
                        input cap_discharged,
                        output ch_Vmeasured,
                        output ch_Vref,
                        output ch_Zero,
                        output load,
                        output reset,
                        output enable_counting);
  reg working;
  reg [3:0] next_phase;
  always @(posedge clk) begin

    if(start) begin
      working = 1'b1;
      next_phase = 1;
      reset = 1'b0;
      ch_Zero = 1'b0;
    end
    

    if(working == 1'b1) begin
      if(next_phase == 1) begin
        enable_counting = 1'b1;
        next_phase = 2;
        ch_Vmeasured = 1'b1;
      end else if (next_phase == 2 && finished_counting) begin
        ch_Vmeasured = 1'b0;
        ch_Vref = 1'b1;
        next_phase = 3;
      end else if (next_phase == 3 && cap_discharged) begin
        enable_counting = 1'b0;
        load = 1'b1;
        ch_Vref = 1'b0;
        next_phase = 4;
      end else if (next_phase == 4) begin
        load = 1'b0;
        reset = 1'b1;
        ch_Zero = 1'b1;
        working = 1'b0;
      end 
    end
  end
endmodule
module control_machine( input start,
                        input clk,
                        input finished_counting,
                        input cap_discharged,
                        output ch_Vmeasured,
                        output ch_Vref,
                        output ch_Zero,
                        output load,
                        output reset,
                        output enable_counting);

  reg working;
  reg [3:0] next_phase;
  always @(posedge clk) begin

    if(start) begin
      working = 1'b1;
      next_phase = 1;
      reset = 1'b0;
      ch_Zero = 1'b0;
    end
    

    if(working == 1'b1) begin
      if(next_phase == 1) begin
        enable_counting = 1'b1;
        next_phase = 2;
        ch_Vmeasured = 1'b1;
      end else if (next_phase == 2 && finished_counting) begin
        ch_Vmeasured = 1'b0;
        ch_Vref = 1'b1;
        next_phase = 3;
      end else if (next_phase == 3 && cap_discharged) begin
        enable_counting = 1'b0;
        load = 1'b1;
        ch_Vref = 1'b0;
        next_phase = 4;
      end else if (next_phase == 4) begin
        load = 1'b0;
        reset = 1'b1;
        ch_Zero = 1'b1;
        working = 1'b0;
      end 
    end
  end
endmodule