moduleled8_display(clk,rst,comsel,en,play);
inputclk;
inputrst;
inputcomsel;
output[7:0]en;
output[7:0]play;
reg[30:0]count;
reg[7:0]en;
reg[7:0]play;
always@(posedgeclkornegedgerst)
begin
if(!rst)
if(comsel)//共陽譯碼
count<=0;
en<=1;
play<=8"b00111111;
end
else
en<=0;
play<=8"b11000000;
count<=count+1;
case(count[30:28])
3"b000:
if(consel)
en<=8"b00000001;
en<=8"b11111110;
3"b001:
if(comsel)
en<=8"b00000010;
play<=8"b00000110;
en<=8"b11111101;
play<=8"b11111001;
3"b010:
if(consel)
en<=8"b00000100;
play<=8"b01011011;
en<=8"b11111011;
play<=8"b10100100;
4"b011:
en<=8"b00001000;
play<=8"b01001111;
en<=8"b11110111;
play<=8"b10110000;
endcase
endmodule
這個是我剛剛寫的4位7段數碼管流水燈顯示1---4的程式,希望對你有用,按題目要求,你只需把程式碼中時鐘分頻器暫存器變數count刪去、outputreg[7:0]en;改成“outputregen,4位動態case顯示改成單數碼管靜態顯示就行了……
moduleled8_display(clk,rst,comsel,en,play);
inputclk;
inputrst;
inputcomsel;
output[7:0]en;
output[7:0]play;
reg[30:0]count;
reg[7:0]en;
reg[7:0]play;
always@(posedgeclkornegedgerst)
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刪去、outputreg[7:0]en;改成“outputregen,4位動態case顯示改成單數碼管靜態顯示就行了……