data/full_repos/permissive/128497744/fsm_calculator_part2/fsm_integer_divider/fsm_integer_divider.srcs/sources_1/new/BIN_to_BCD.v
data/verilator_xmls/d0da04ad-1675-4760-928e-07fcf91f1e9e.xml
module BIN_to_BCD(
    input [3:0] binary,
    output reg [3:0] tens, ones
);

integer i;

always @(binary)
begin
  tens = 4'b0;
  ones = 4'b0;

  for (i = 3; i >= 0; i = i - 1)
    begin
        if (tens >= 5)
            tens = tens + 3;
        if (ones >= 5)
            ones = ones + 3;

        tens = tens << 1;
        tens[0] = ones[3];
        ones = ones << 1;
        ones[0] = binary[i];
    end
end
endmodule
module BIN_to_BCD(
    input [3:0] binary,
    output reg [3:0] tens, ones
);


integer i;

always @(binary)
begin
  tens = 4'b0;
  ones = 4'b0;

  for (i = 3; i >= 0; i = i - 1)
    begin
        if (tens >= 5)
            tens = tens + 3;
        if (ones >= 5)
            ones = ones + 3;

        tens = tens << 1;
        tens[0] = ones[3];
        ones = ones << 1;
        ones[0] = binary[i];
    end
end
endmodule