回答:
BCD英文是binary coded decimal,是一种用二进制表示十进制的数码。BCD译码器使用4位二进制表示十个数,所以也叫做4-10线译码器。
图:4-10译码器原理图
Module decoder4_10(
Input [3:0] indata ;
Output [9:0] outdata ;
);
//方法1
always@(*)
begin
case(indata)
4’b0000: outdata = 10’1111_1111_10;
4’b0001: outdata = 10’1111_1111_01;
4’b0010: outdata = 10’1111_1110_11;
4’b0011: outdata = 10’1111_1101_11;
4’b0100: outdata = 10’1111_1011_11;
4’b0101: outdata = 10’1111_0111_11;
4’b0110: outdata = 10’1110_1111_11;
4’b0111: outdata = 10’1101_1111_11;
4’b1000: outdata = 10’1011_1111_11;
4’b1001: outdata = 10’0111_1111_11;
Default: outdata = 10’1111_1111_11;
endcase
end
//方法2
Assign outdata[0]=~( ~indata[3] & ~indata[2] & ~indata[1] & ~indata[0]);
Assign outdata[1]=~( ~indata[3] & ~indata[2] & ~indata[1] & indata[0]);
Assign outdata[2]=~( ~indata[3] & ~indata[2] & indata[1] & ~indata[0]);
Assign outdata[3]=~( ~indata[3] & ~indata[2] & ~indata[1] & ~indata[0]);
Assign outdata[4]=~( ~indata[3] & indata[2] & ~indata[1] & ~indata[0]);
Assign outdata[5]=~( ~indata[3] & indata[2] & ~indata[1] & indata[0]);
Assign outdata[6]=~( ~indata[3] & indata[2] & indata[1] & ~indata[0]);
Assign outdata[7]=~( ~indata[3] & indata[2] & indata[1] & indata[0]);
Assign outdata[8]=~(indata[3] & ~indata[2] & ~indata[1] & ~indata[0]);
Assign outdata[9]=~(indata[3] & ~indata[2] & ~indata[1] & indata[0]);
endmodule