data/full_repos/permissive/109846502/bin2bcd.v
data/verilator_xmls/3c386508-fe4d-42bc-a5b4-b80c6c9dd8fe.xml
module bin2bcd(
	input [13:0] bin,
	output reg [3:0] thousands, hundreds, tens, ones
    );

integer i;

always @* begin
	thousands = 4'd0;
	hundreds = 4'd0;
	tens = 4'd0;
	ones = 4'd0;
	
	for(i = 13; i >= 0; i = i-1) begin
		if(thousands >= 5)
			thousands = thousands + 3;
		if(hundreds >= 5)
			hundreds = hundreds + 3;
		if(tens >= 5)
			tens = tens + 3;
		if(ones >= 5)
			ones = ones + 3;
			
		thousands = thousands << 1;
		thousands[0] = hundreds[3];
		
		hundreds = hundreds << 1;
		hundreds[0] = tens[3];
		
		tens = tens << 1;
		tens[0] = ones[3];
		
		ones = ones << 1;
		ones[0] = bin[i];
	end
end

endmodule
module bin2bcd(
	input [13:0] bin,
	output reg [3:0] thousands, hundreds, tens, ones
    );


integer i;

always @* begin
	thousands = 4'd0;
	hundreds = 4'd0;
	tens = 4'd0;
	ones = 4'd0;
	
	for(i = 13; i >= 0; i = i-1) begin
		if(thousands >= 5)
			thousands = thousands + 3;
		if(hundreds >= 5)
			hundreds = hundreds + 3;
		if(tens >= 5)
			tens = tens + 3;
		if(ones >= 5)
			ones = ones + 3;
			
		thousands = thousands << 1;
		thousands[0] = hundreds[3];
		
		hundreds = hundreds << 1;
		hundreds[0] = tens[3];
		
		tens = tens << 1;
		tens[0] = ones[3];
		
		ones = ones << 1;
		ones[0] = bin[i];
	end
end

endmodule