module led8_display(clk,rst,comsel,en,play);
input clk;
input rst;
input comsel;
output[7:0] en;
output[7:0] play;
reg[30:0] count;
reg[7:0] en;
reg[7:0] play;
always@(posedge clk or negedge rst)
begin
if(!rst)
begin
if(comsel)//共阳译码
begin
count<=0;
en<=1;
play<=8'b00111111;
end
else
begin
count<=0;
en<=0;
play<=8'b11000000;
end
end
else
begin
count<=count+1;
case(count[30:28])
3'b000:
begin
if(consel)
begin
en<=8'b00000001;
play<=8'b00111111;
end
else
begin
en<=8'b11111110;
play<=8'b11000000;
end
end
3'罩早b001:
begin
if(comsel)
begin
en<=8'b00000010;
play<=8'b00000110;
end
else
begin
en<=8'b11111101;
play<=8'b11111001;
end
end
3'b010:
begin
if(consel)
begin
en<=8'b00000100;
play<=8'b01011011;
end
else
begin
en<=8'b11111011;
play<=8'b10100100;
end
end
4'b011:
begin
if(consel)
begin
en<=8'b00001000;
play<=8'b01001111;
end
else
begin
en<=8'b11110111;
play<=8'b10110000;
end
end
endcase
end
end
endmodule
这个物羡雀是我刚刚写的4位7段数码管流水灯显示1---4的程序,希望对你有用,按题目要求,你只需把代码中时钟分频器寄存器变量count删派埋去、output reg[7:0] en;改成“output reg en,4位动态case显示改成单数码管静态显示就行了……