module SEG7_Driver(oSEG,oCOM,iDIG,iCLK,iRST_n);
input [15:0] iDIG; // 4 Digital Hex
input iCLK,iRST_n;
output reg [7:0] oSEG; // 7-SEG LED output
output reg [3:0] oCOM; // 7-SEG COM output
reg [31:0] Cont_DIV; // Scan Clock DIV Counter
reg [3:0] mDEC_in; // Hex To 7-SEG Dec reg
reg [1:0] mSCAN; // Scan Order Counter
reg mSCAN_CLK; // Scan Clock
parameter iCLK_Freq = 50000000; // 50 MHz
//parameter iCLK_Freq = 27000000; // 27 MHz
// Scan Clock Generator
always@(posedge iCLK or negedge iRST_n)
begin
if(!iRST_n)
begin
Cont_DIV<=0;
mSCAN_CLK<=0;
end
else
begin
if(Cont_DIV < (iCLK_Freq>>10) )
Cont_DIV<=Cont_DIV+1;
else
begin
Cont_DIV<=0;
mSCAN_CLK<=~mSCAN_CLK;
end
end
end
reg [1:0] mSCAN;
// Scan Order Generator
always@(posedge mSCAN_CLK)
begin
mSCAN <= mSCAN + 1'b1;
end
// Hex To 7-SEG Decoder
always@(mSCAN)
begin
case(mSCAN)
0: mDEC_in <= iDIG[3:0];
1: mDEC_in <= iDIG[7:4];
2: mDEC_in <= iDIG[11:8];
3: mDEC_in <= iDIG[15:12];
endcase
case(mSCAN)
0: oCOM <= 4'b1110;
1: oCOM <= 4'b1101;
2: oCOM <= 4'b1011;
3: oCOM <= 4'b0111;
endcase
end
always@(mDEC_in or oCOM)
begin
case(mDEC_in)
4'h0: oSEG = 8'h90; //8'b11010111; // ---t---
4'h1: oSEG = 8'h9f; //b01001100; // | |
4'h2: oSEG = 8'h58; //b01000101; // lt rt
4'h3: oSEG = 8'h19; //b10000111; // | |
4'h4: oSEG = 8'h17; //b00100101; // ---m---
4'h5: oSEG = 8'h31; //b00100100; // | |
4'h6: oSEG = 8'h30; //01010111; // lb rb
4'h7: oSEG = 8'h9d; //b00000100; // | |
4'h8: oSEG = 8'h10; //b00000111; // ---b---
4'h9: oSEG = 8'h15; //b00000110;
4'ha: oSEG = 8'h14; //b10100100;
4'hb: oSEG = 8'h32; //b00111100;
4'hc: oSEG = 8'hf0; //b11000100;
4'hd: oSEG = 8'h1a; //b00101100;
4'he: oSEG = 8'h70; //b00101110;
4'hf: oSEG = 8'h74; //b00010100;
endcase
end
endmodule
在quartus 中能不能把 这个模块例化,就像library中的元器件那样,随时能掉出来;能实现这样的操作么?谢谢 求大侠指教。
此帖出自
小平头技术问答
一周热门 更多>