注意:我这里是共阳极的二极管,要变成共阴极,只要把所有的输出取反就行.
module changer(IN,OUT);
input [3:0]IN;
output [7:0]OUT;
reg[7:0] OUT;
always
begin
case(IN)
'b0000 : OUT = 'b11000000;
'b0001 : OUT = 'b11111001;
'b0010 : OUT = 'b10100100;
'b0011 : OUT = 'b10110000;
'b0100 : OUT = 'b10011001;
'b0101 : OUT = 'b10010010;
'b0110 : OUT = 'b10000010;
'b0111 : OUT = 'b11111000;
'b1000 : OUT = 'b10000000;
'b1001 : OUT = 'b10010000;
'b1010 : OUT = 'b10001000;
'b1011 : OUT = 'b10000011;
'b1100 : OUT = 'b11000110;
'b1101 : OUT = 'b10100001;
'b1110 : OUT = 'b10000110;
'b1111 : OUT = 'b10001110;
endcase
end
endmodule