7段数码管。
时间:10-02
整理:3721RD
点击:
module count10(q,d,clk,clrn,load,ent,enp);
input[3:0]d;
input clk,clrn,load,ent,enp;
output[3:0]q;
reg[3:0]q;
always@(posedge[/email] clk)
begin
if(!clrn)
q<=0;
if(!load)
q<=d;
if(!ent)
q<=q;
if(!enp)
q<=q;
else if(enp)
begin
if(q[3:0]==4'b1001)
q<=0;
else
q<=q+1;
end
end
endmodule
module decoder(d,s);
input[3:0]d;
output[6:0]s;
reg[6:0]s;
always@(d[/email])
begin
case(d)
4'b0000:s=8'b0111111;
4'b0001:s=8'b0000110;
4'b0010:s=8'b1011011;
4'b0011:s=8'b1011111;
4'b0100:s=8'b1100110;
4'b0101:s=8'b1101101;
4'b0110:s=8'b1111101;
4'b0111:s=8'b0000111;
4'b1000:s=8'b1111111;
4'b1011:s=8'b1101111;
endcase
end
endmodule
module LED(data,clk,clr,load,en,p);
input[3:0]data;
input clk,clr,load,en;
output[6:0]p;
wire[6:0]q;
count10 c10(.d(data),.clk(clk),.clrn(clr),.load(load),.ent(en),.enp(en),.q(q));
decoder d47(.d(q),.s(p));
endmodule
怎不能实现数码管从0~9循环? 怎么写测试代码? 拜托
input[3:0]d;
input clk,clrn,load,ent,enp;
output[3:0]q;
reg[3:0]q;
always@(posedge[/email] clk)
begin
if(!clrn)
q<=0;
if(!load)
q<=d;
if(!ent)
q<=q;
if(!enp)
q<=q;
else if(enp)
begin
if(q[3:0]==4'b1001)
q<=0;
else
q<=q+1;
end
end
endmodule
module decoder(d,s);
input[3:0]d;
output[6:0]s;
reg[6:0]s;
always@(d[/email])
begin
case(d)
4'b0000:s=8'b0111111;
4'b0001:s=8'b0000110;
4'b0010:s=8'b1011011;
4'b0011:s=8'b1011111;
4'b0100:s=8'b1100110;
4'b0101:s=8'b1101101;
4'b0110:s=8'b1111101;
4'b0111:s=8'b0000111;
4'b1000:s=8'b1111111;
4'b1011:s=8'b1101111;
endcase
end
endmodule
module LED(data,clk,clr,load,en,p);
input[3:0]data;
input clk,clr,load,en;
output[6:0]p;
wire[6:0]q;
count10 c10(.d(data),.clk(clk),.clrn(clr),.load(load),.ent(en),.enp(en),.q(q));
decoder d47(.d(q),.s(p));
endmodule
怎不能实现数码管从0~9循环? 怎么写测试代码? 拜托
1# bing_yl
我最近也在搞,不懂……同问
这个我也不会,期待高手的出现
正在研究这个呢
有些地方看不明白,感觉有问题。
ent,enp是做什么用的
