(cyclone4)助学版_v120之数码管一:
操作系统:64位 Wins7编译软件:Quartus II 12.1
系统版:助学板V120
先不动态扫了吧,4位一起显示0~9
1秒加一下!
code 如下:
module seg(
input clk,
output reg[7:0] segment,
output reg[3:0] wei
);
reg clk_dis;
reg[4:0] dis;//2^11=2048
reg[24:0] clk_cnt;//2^25=33_554_432
parameter div_clk = 24_000_000;
always @(posedge clk)//分频1Hz
begin
if(clk_cnt == div_clk)
begin
clk_cnt <= 0;
clk_dis <= ~clk_dis;
end
else
clk_cnt <= clk_cnt + 1'b1;
end
always @(posedge clk_dis)
begin
if(dis == 4'd9)
begin
dis <= 0;
end
else
dis <= dis + 1'b1;
end
always @(dis)
begin
segment <= display(dis);
wei <= 4'b0000;
end
function[7:0] display;//其中不能包含非阻塞赋值
input[3:0] number;
case(number)
4'b0000:display = 8'b00111111;
4'b0001:display = 8'b00000110;
4'b0010:display = 8'b01011011;
4'b0011:display = 8'b01001111;
4'b0100:display = 8'b01100110;
4'b0101:display = 8'b01101101;
4'b0110:display = 8'b01111101;
4'b0111:display = 8'b00000111;
4'b1000:display = 8'b01111111;
4'b1001:display = 8'b01101111;
default:display = 8'b00000000;//共阴极数码显示
endcase
endfunction
endmodule