
 AI时代,找源码已成为过去式,纪念我过去的十年0(回)
                        64天前
AI时代,找源码已成为过去式,纪念我过去的十年0(回)
                        64天前 还有人吗2(回)
                        82天前
还有人吗2(回)
                        82天前 会python真的可以为所欲为0(回)
                        562天前
会python真的可以为所欲为0(回)
                        562天前 这里还有人吗2(回)
                        747天前
这里还有人吗2(回)
                        747天前 这里还有人吗0(回)
                        747天前
这里还有人吗0(回)
                        747天前 每天面对着电脑屏幕,敲打键盘。我所面对的并不只是代码,而是一种生活方式。0(回)
                        972天前
每天面对着电脑屏幕,敲打键盘。我所面对的并不只是代码,而是一种生活方式。0(回)
                        972天前module bin_to_bcd
(
input                 rstn    ,   
input       [4:0]     bin_code,  //需要进行BCD转码的二进制数据
output reg  [7:0]     bcd_code   //转码后的BCD码型数据输出
);
reg   [12:0]  shift_reg; 
always@(bin_code or rstn)begin
	shift_reg = {8'h0,bin_code};
	if(!rstn) bcd_code = 0; 
	else begin 
		repeat(5) begin //循环16次  
			//BCD码各位数据作满5加3操作,
			if (shift_reg[8:5] >= 5) shift_reg[8:5] = shift_reg[8:5] + 2'b11;
			if (shift_reg[12:9] >= 5) shift_reg[12:9] = shift_reg[12:9] + 2'b11;
			shift_reg = shift_reg << 1; 
		end
		bcd_code = shift_reg[35:16];   
	end  
end
endmodule



