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 quadrature_decoder
#(
  parameter debounce_time = 100000
)
(
  input[1:0] quad_input,
  input clk,
  output direction,
  output count
);

reg [15:0] db_count = 0;


reg[1:0] quadA_delayed, quadB_delayed;
reg quadA_prev, quadB_prev;

always @(posedge clk)
begin
  quadA_delayed = {quadA_delayed[0],quad_input[0]};
  quadB_delayed = {quadB_delayed[0],quad_input[1]};
  if((quadA_delayed[0]^quadA_delayed[1])|(quadB_delayed[0]^quadB_delayed[1]))
    db_count <= 0;
  else if(db_count < debounce_time)
    db_count <= db_count+1;

  if(db_count >= debounce_time)
  begin
    quadA_prev = quadA_delayed[1];
    quadB_prev = quadB_delayed[1];
  end
end

assign count = (quadA_delayed[1]^quadA_prev)|(quadB_delayed[1]^quadB_prev);
assign direction = quadA_delayed[1] ^ quadB_prev;
endmodule
module quadrature_decoder
#(
  parameter debounce_time = 100000
)
(
  input[1:0] quad_input,
  input clk,
  output direction,
  output count
);


reg [15:0] db_count = 0;


reg[1:0] quadA_delayed, quadB_delayed;
reg quadA_prev, quadB_prev;

always @(posedge clk)
begin
  quadA_delayed = {quadA_delayed[0],quad_input[0]};
  quadB_delayed = {quadB_delayed[0],quad_input[1]};
  if((quadA_delayed[0]^quadA_delayed[1])|(quadB_delayed[0]^quadB_delayed[1]))
    db_count <= 0;
  else if(db_count < debounce_time)
    db_count <= db_count+1;

  if(db_count >= debounce_time)
  begin
    quadA_prev = quadA_delayed[1];
    quadB_prev = quadB_delayed[1];
  end
end

assign count = (quadA_delayed[1]^quadA_prev)|(quadB_delayed[1]^quadB_prev);
assign direction = quadA_delayed[1] ^ quadB_prev;
endmodule