data/full_repos/permissive/104053853/vending.v
1: b'%Warning-WIDTH: data/full_repos/permissive/104053853/vending.v:164: Operator NEQ expects 5 bits on the RHS, but RHS\'s CONST \'4\'h0\' generates 4 bits.\n                                                                  : ... In instance top_module.controller\n      if (coin_val != 4\'b0000)\n                   ^~\n                ... Use "/* verilator lint_off WIDTH */" and lint_on around source to disable this message.\n%Error: data/full_repos/permissive/104053853/vending.v:40: Cannot find file containing module: \'frequency_divider\'\nfrequency_divider devider(clock, new_clock);\n^~~~~~~~~~~~~~~~~\n        ... Looked in:\n             data/full_repos/permissive/104053853,data/full_repos/permissive/104053853/frequency_divider\n             data/full_repos/permissive/104053853,data/full_repos/permissive/104053853/frequency_divider.v\n             data/full_repos/permissive/104053853,data/full_repos/permissive/104053853/frequency_divider.sv\n             frequency_divider\n             frequency_divider.v\n             frequency_divider.sv\n             obj_dir/frequency_divider\n             obj_dir/frequency_divider.v\n             obj_dir/frequency_divider.sv\n%Error: data/full_repos/permissive/104053853/vending.v:44: Cannot find file containing module: \'hello_printer\'\nhello_printer hello((~hold_ind & reset), new_clock, seq1, an1);\n^~~~~~~~~~~~~\n%Error: data/full_repos/permissive/104053853/vending.v:45: Cannot find file containing module: \'digit_printer\'\ndigit_printer goods(((hold_ind | coin_ind) & (~charge_ind) & (~drinktk_ind)), new_clock, goods_val_now, seq2, an2);\n^~~~~~~~~~~~~\n%Error: data/full_repos/permissive/104053853/vending.v:46: Cannot find file containing module: \'bi_printer\'\nbi_printer goods_coin(seq2, (~((~an2) >> 5)), seq3, an3, new_clock, seq2_3, an2_3);\n^~~~~~~~~~\n%Error: data/full_repos/permissive/104053853/vending.v:47: Cannot find file containing module: \'digit_printer\'\ndigit_printer coin(coin_ind, new_clock, coin_val, seq3, an3);\n^~~~~~~~~~~~~\n%Error: data/full_repos/permissive/104053853/vending.v:48: Cannot find file containing module: \'digit_printer\'\ndigit_printer charge(charge_ind, new_clock, charge_val, seq4, an4);\n^~~~~~~~~~~~~\n%Error: data/full_repos/permissive/104053853/vending.v:49: Cannot find file containing module: \'fin_printer\'\nfin_printer fin(drinktk_ind, new_clock, seq5, an5);\n^~~~~~~~~~~\n%Error: Exiting due to 7 error(s), 1 warning(s)\n'
module main_controller (input reset,
                input clock,
                input op_start,
                input [4:0] coin_val,
                input [4:0] goods_val,
                input cancel_flag,
                input drinktk_signal,
                input charge_signal,
                output reg hold_ind,
                output reg coin_ind,
                output reg drinktk_ind,
                output reg charge_ind,
                output reg [4:0] goods_val_now,
                output reg [4:0] charge_val);

reg [4:0] current_state, next_state;
reg [31:0] count;
wire delay_signal;



initial
begin
    goods_val_now = 0;
    count = 0;
end
parameter S0 = 5'b00000,
          S1 = 5'b10000,
          S2 = 5'b01000,
          S3 = 5'b00100,
          S4 = 5'b00010,
          S5 = 5'b00001;

always @ (posedge clock or negedge reset)
begin
  if (!reset)
    current_state <= S0;
  else
    current_state <= next_state;
end

always @ (*)
begin
  next_state = S0;
  case (current_state)
    S0: begin
      if (reset == 1)
        next_state = S1;
    end
    S1: begin
      if (op_start == 1)
      begin
        next_state = S2;
        goods_val_now = goods_val;
      end
      else
        next_state = S1;
    end
    S2: begin
      if (coin_val != 4'b0000)
        next_state = S3;
      else if (cancel_flag == 1)
        next_state = S5;
      else
        next_state = S2;
    end
    S3: begin
      if (cancel_flag == 1)
        next_state = S5;
      else if ((coin_val[3:0] > goods_val_now[3:0]) || ((coin_val[3:0] == goods_val_now[3:0] && (goods_val_now[4:4] == 0))))
        next_state = S4;
      else
        next_state = S3;
    end
    S4: begin
      if (drinktk_signal)
        begin
        if ((coin_val[3:0] - goods_val_now[3:0] == 4'b0000) && (goods_val_now[4:4] != 1))
          next_state = S1;
        else
          next_state = S5;
        end
      else
        next_state = S4;
    end
    S5: begin
      if (charge_signal)
        next_state = S1;
      else
        next_state = S5;
    end
    default:  begin
      next_state = S0;
    end
  endcase
end

always @ (posedge clock or negedge reset)
begin
  if (!reset) begin
    hold_ind <= 0;
    coin_ind <= 0;
    drinktk_ind <= 0;
    charge_ind <= 0;
    charge_val <= 0;
  end
  else begin
    case (next_state)
      S2: begin hold_ind <= 1; end
      S3: coin_ind <= 1;
      S4: begin drinktk_ind <= 1; coin_ind <= 0; end
      S5: begin
        drinktk_ind <= 0;
        coin_ind <= 0;
        charge_ind <= 1;

        if (coin_val[3:0] > goods_val_now[3:0])
          if (goods_val_now[4:4] == 1)
            charge_val = (coin_val[3:0] - goods_val_now[3:0] - 1) | 5'b10000;
          else
            charge_val = coin_val - goods_val_now;
        else
          charge_val <= coin_val;
      end
      default:  begin
        hold_ind <= 0;
        coin_ind <= 0;
        drinktk_ind <= 0;
        charge_ind <= 0;
        charge_val <= 0;
      end
    endcase
  end
end
endmodule
module main_controller (input reset,
                input clock,
                input op_start,
                input [4:0] coin_val,
                input [4:0] goods_val,
                input cancel_flag,
                input drinktk_signal,
                input charge_signal,
                output reg hold_ind,
                output reg coin_ind,
                output reg drinktk_ind,
                output reg charge_ind,
                output reg [4:0] goods_val_now,
                output reg [4:0] charge_val);


reg [4:0] current_state, next_state;
reg [31:0] count;
wire delay_signal;



initial
begin
    goods_val_now = 0;
    count = 0;
end
parameter S0 = 5'b00000,
          S1 = 5'b10000,
          S2 = 5'b01000,
          S3 = 5'b00100,
          S4 = 5'b00010,
          S5 = 5'b00001;

always @ (posedge clock or negedge reset)
begin
  if (!reset)
    current_state <= S0;
  else
    current_state <= next_state;
end

always @ (*)
begin
  next_state = S0;
  case (current_state)
    S0: begin
      if (reset == 1)
        next_state = S1;
    end
    S1: begin
      if (op_start == 1)
      begin
        next_state = S2;
        goods_val_now = goods_val;
      end
      else
        next_state = S1;
    end
    S2: begin
      if (coin_val != 4'b0000)
        next_state = S3;
      else if (cancel_flag == 1)
        next_state = S5;
      else
        next_state = S2;
    end
    S3: begin
      if (cancel_flag == 1)
        next_state = S5;
      else if ((coin_val[3:0] > goods_val_now[3:0]) || ((coin_val[3:0] == goods_val_now[3:0] && (goods_val_now[4:4] == 0))))
        next_state = S4;
      else
        next_state = S3;
    end
    S4: begin
      if (drinktk_signal)
        begin
        if ((coin_val[3:0] - goods_val_now[3:0] == 4'b0000) && (goods_val_now[4:4] != 1))
          next_state = S1;
        else
          next_state = S5;
        end
      else
        next_state = S4;
    end
    S5: begin
      if (charge_signal)
        next_state = S1;
      else
        next_state = S5;
    end
    default:  begin
      next_state = S0;
    end
  endcase
end

always @ (posedge clock or negedge reset)
begin
  if (!reset) begin
    hold_ind <= 0;
    coin_ind <= 0;
    drinktk_ind <= 0;
    charge_ind <= 0;
    charge_val <= 0;
  end
  else begin
    case (next_state)
      S2: begin hold_ind <= 1; end
      S3: coin_ind <= 1;
      S4: begin drinktk_ind <= 1; coin_ind <= 0; end
      S5: begin
        drinktk_ind <= 0;
        coin_ind <= 0;
        charge_ind <= 1;

        if (coin_val[3:0] > goods_val_now[3:0])
          if (goods_val_now[4:4] == 1)
            charge_val = (coin_val[3:0] - goods_val_now[3:0] - 1) | 5'b10000;
          else
            charge_val = coin_val - goods_val_now;
        else
          charge_val <= coin_val;
      end
      default:  begin
        hold_ind <= 0;
        coin_ind <= 0;
        drinktk_ind <= 0;
        charge_ind <= 0;
        charge_val <= 0;
      end
    endcase
  end
end
endmodule