?? seg71.v
字號:
/*
7段數碼管測試實驗1:以動態掃描方式在8位數碼管“同時”顯示0--7
實驗的目的是向用戶介紹多個數碼管動態顯示的方法。
動態顯示的方法是,按一定的頻率輪流向各個數碼管的COM端送出低電平,同時送出對應的數據給各段。
*/
module seg71(clk,rst,dataout,en);
input clk,rst;
output[7:0] dataout;
output[7:0] en;//COM使能輸出
reg[7:0] dataout;//各段數據輸出
reg[7:0] en;
reg[15:0] cnt_scan;//掃描頻率計數器
reg[4:0] dataout_buf;
always@(posedge clk or negedge rst)
begin
if(!rst) begin
cnt_scan<=0;
end
else begin
cnt_scan<=cnt_scan+1;
end
end
always @(cnt_scan)
begin
case(cnt_scan[15:13])
3'b000 :
en = 8'b1111_1110;
3'b001 :
en = 8'b1111_1101;
3'b010 :
en = 8'b1111_1011;
3'b011 :
en = 8'b1111_0111;
3'b100 :
en = 8'b1110_1111;
3'b101 :
en = 8'b1101_1111;
3'b110 :
en = 8'b1011_1111;
3'b111 :
en = 8'b0111_1111;
default :
en = 8'b1111_1110;
endcase
end
always@(en) //對應COM信號給出各段數據
begin
case(en)
8'b1111_1110:
dataout_buf=0;
8'b1111_1101:
dataout_buf=1;
8'b1111_1011:
dataout_buf=2;
8'b1111_0111:
dataout_buf=3;
8'b1110_1111:
dataout_buf=4;
8'b1101_1111:
dataout_buf=5;
8'b1011_1111:
dataout_buf=6;
8'b0111_1111:
dataout_buf=7;
default:
dataout_buf=8;
endcase
end
always@(dataout_buf)
begin
case(dataout_buf)
4'b0000:
dataout=8'b0000_0011;
4'b0001:
dataout=8'b1001_1111;
4'b0010:
dataout=8'b0010_0101;
4'b0011:
dataout=8'b0000_1101;
4'b0100:
dataout=8'b1001_1001;
4'b0101:
dataout=8'b0100_1001;
4'b0110:
dataout=8'b0100_0001;
4'b0111:
dataout=8'b0001_1111;
4'b1000:
dataout=8'b0000_0001;
4'b1001:
dataout=8'b0001_1001;
4'b1010:
dataout=8'b0001_0001;
4'b1011:
dataout=8'b1100_0001;
4'b1100:
dataout=8'b0110_0011;
4'b1101:
dataout=8'b1000_0101;
4'b1110:
dataout=8'b0110_0001;
4'b1111:
dataout=8'b0111_0001;
endcase
end
endmodule
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -