data/full_repos/permissive/420501560/fpga/electronic-geartrain.srcs/sources_1/new/controller.v
1: b'%Warning-IMPLICIT: data/full_repos/permissive/420501560/fpga/electronic-geartrain.srcs/sources_1/new/controller.v:76: Signal definition not found, creating implicitly: \'out_step\'\n  assign out_step = step_select(mode, rpm_step, axis_step, divider_step);\n         ^~~~~~~~\n                   ... Use "/* verilator lint_off IMPLICIT */" and lint_on around source to disable this message.\n%Warning-WIDTH: data/full_repos/permissive/420501560/fpga/electronic-geartrain.srcs/sources_1/new/controller.v:79: Operator CASE expects 32 or 2 bits on the Case expression, but Case expression\'s VARREF \'mode\' generates 1 bits.\n                                                                                                                 : ... In instance controller\n    case (mode)\n    ^~~~\n%Warning-WIDTH: data/full_repos/permissive/420501560/fpga/electronic-geartrain.srcs/sources_1/new/controller.v:76: Operator FUNCREF \'step_select\' expects 1 bits on the Function Argument, but Function Argument\'s VARREF \'mode\' generates 2 bits.\n                                                                                                                 : ... In instance controller\n  assign out_step = step_select(mode, rpm_step, axis_step, divider_step);\n                    ^~~~~~~~~~~\n%Error: Exiting due to 3 warning(s)\n'
module controller
#(
  parameter debounce_time = 2
)
(
  input spindle_hall,
  input[1:0] spindexer_quad,
  input[1:0] axis_quad,
  input[1:0] mode,
  input system_clk,
  output step,
  output reg step_direction
);
  wire spindexer_step;
  wire spindexer_direction;
  wire[31:0] spindexer_pos;


  wire clk;
  clock_divider #(100000) local_clock(system_clk, clk);

  quadrature_decoder #(debounce_time) spindexer_signal(spindexer_quad, clk, spindexer_direction, spindexer_step);
  track_position spindexer_pos_tracker(spindexer_step, spindexer_direction, spindexer_pos);


  wire db_spindle_signal;
  wire rpm_step;
  debounce #(debounce_time) spindle_signal(spindle_hall, clk, db_spindle_signal);
  rpm_match gear_hob(db_spindle_signal, spindexer_step, clk, rpm_step);


  wire axis_step;
  wire axis_direction;
  wire[31:0] axis_pos;
  quadrature_decoder #(debounce_time) axis_signal(axis_quad, clk, axis_direction, axis_step);
  track_position axis_pos_tracker(axis_step, axis_direction, axis_pos);


  wire divider_direction;
  wire divider_step;


  always @(*) begin
    case (mode)
      0: step_direction = 1'b0;
      1: step_direction = axis_direction;
      2: step_direction = divider_direction;
      default: step_direction = 1'bz;
    endcase
  end


  assign out_step = step_select(mode, rpm_step, axis_step, divider_step);
  function step_select;
    input mode, mode0, mode1, mode2;
    case (mode)
      0: step_select = mode0;
      1: step_select = mode1;
      2: step_select = mode2;
      default: step_select = 1'bz;
    endcase
  endfunction


  trigger_pulse #(debounce_time) step_pulse(out_step, clk, step);
endmodule
module controller
#(
  parameter debounce_time = 2
)
(
  input spindle_hall,
  input[1:0] spindexer_quad,
  input[1:0] axis_quad,
  input[1:0] mode,
  input system_clk,
  output step,
  output reg step_direction
);

  wire spindexer_step;
  wire spindexer_direction;
  wire[31:0] spindexer_pos;


  wire clk;
  clock_divider #(100000) local_clock(system_clk, clk);

  quadrature_decoder #(debounce_time) spindexer_signal(spindexer_quad, clk, spindexer_direction, spindexer_step);
  track_position spindexer_pos_tracker(spindexer_step, spindexer_direction, spindexer_pos);


  wire db_spindle_signal;
  wire rpm_step;
  debounce #(debounce_time) spindle_signal(spindle_hall, clk, db_spindle_signal);
  rpm_match gear_hob(db_spindle_signal, spindexer_step, clk, rpm_step);


  wire axis_step;
  wire axis_direction;
  wire[31:0] axis_pos;
  quadrature_decoder #(debounce_time) axis_signal(axis_quad, clk, axis_direction, axis_step);
  track_position axis_pos_tracker(axis_step, axis_direction, axis_pos);


  wire divider_direction;
  wire divider_step;


  always @(*) begin
    case (mode)
      0: step_direction = 1'b0;
      1: step_direction = axis_direction;
      2: step_direction = divider_direction;
      default: step_direction = 1'bz;
    endcase
  end


  assign out_step = step_select(mode, rpm_step, axis_step, divider_step);
  function step_select;
    input mode, mode0, mode1, mode2;
    case (mode)
      0: step_select = mode0;
      1: step_select = mode1;
      2: step_select = mode2;
      default: step_select = 1'bz;
    endcase
  endfunction


  trigger_pulse #(debounce_time) step_pulse(out_step, clk, step);
endmodule