//编译无错,生成配置文件后可烧进fpga/cpld芯片来验证,数码管显示“56”
module cpld_led(FIN,EN,DATAOUT);
input FIN;
output [1:0] EN;
output [6:0] DATAOUT;
LED l1(FIN,DATAOUT,EN);
endmodule
module LED(clk,dataout,en);
input clk;
output[6:0] dataout;
output[1:0] en;//COM使能输出
reg[6:0] dataout;//各段数据输出
reg[1:0] en;
reg[9:0] cnt_scan;//扫描频率计数器
reg[3:0] dataout_buf;
always@(posedge clk)
begin
cnt_scan<=cnt_scan+1;
end
always @(cnt_scan)
begin
case(cnt_scan[9])
2'b0 :
en = 4'b10;
default :
en = 4'b01;
endcase
end
always@(en) //对应COM信号给出各段数据
begin
case(en)
2'b01:
dataout_buf=8'd5;
default:
dataout_buf=8'd6;
endcase
end
always@(dataout_buf)
begin
case(dataout_buf)
4'b0000:
dataout=7'b0111111;
4'b0001:
dataout=7'b0000110;
4'b0010:
dataout=7'b1011011;
4'b0011:
dataout=7'b1001111;
4'b0100:
dataout=7'b1100110;
4'b0101:
dataout=7'b1101101;
4'b0110:
dataout=7'b1111101;
4'b0111:
dataout=7'b0000111;
4'b1000:
dataout=7'b1111111;
4'b1001:
dataout=7'b1101111;
4'b1010:
dataout=7'b1110111;
4'b1011:
dataout=7'b1111100;
4'b1100:
dataout=7'b0111001;
4'b1101:
dataout=7'b1011110;
4'b1110:
dataout=7'b1111001;
4'b1111:
dataout=7'b1110001;
default:
dataout_buf=7'bx;
endcase
end
endmodule
文章评论(0条评论)
登录后参与讨论