用Verilog语言怎么写一个60进制的计数器然后显示在数码管上
好吧 自己的事自己解决 我参照别人的程序已经弄好了 贴程序 附加一句 永远别指望别人 能靠的住的只有自己
顶层模块 产生0~59数字 并例化下面的exp07_top模块
module exp07_demo
(
CLK, RSTn,
Row_Scan_Sig, Column_Scan_Sig
);
input CLK;
input RSTn;
output [7:0]Row_Scan_Sig;
output [1:0]Column_Scan_Sig;
/************************************/
parameter T1S = 26'd49_999_999;
/************************************/
reg [26:0]Count1;
always @ ( posedge CLK or negedge RSTn )
if( !RSTn )
Count1 = 10)||(data_dot_reg >= 1);
end
led2:
begin
led7_decoder((data_num_reg/100)%10,led7_out_reg[7:1]);
led7_out_reg[0] = 100)||(data_dot_reg >= 2);
end
led3:
begin
led7_decoder((data_num_reg/1000)%10,led7_out_reg[7:1]);
led7_out_reg[0] = 1000)||(data_dot_reg >= 3);
end
led4:
begin
led7_decoder((data_num_reg/10000)%10,led7_out_reg[7:1]);
led7_out_reg[0] = 10000)||(data_dot_reg >= 4);
end
led5:
begin
led7_decoder((data_num_reg/100000)%10,led7_out_reg[7:1]);
led7_out_reg[0] = 100000)||(data_dot_reg >= 5);
end
led6:
begin
led7_decoder((data_num_reg/1000000)%10,led7_out_reg[7:1]);
led7_out_reg[0] = 1000000)||(data_dot_reg >= 6);
end
led7:
begin
led7_decoder((data_num_reg/10000000)%10,led7_out_reg[7:1]);
led7_out_reg[0] = 10000000)||(data_dot_reg >= 7);
end
endcase
end
end
assign DSEL = DSEL_cnt_reg;
assign DEN = DEN_reg;
assign led7_out = led7_out_reg;
task led7_decoder //7段数码管 译码电路
(
input logic [3:0] data,
output logic [6:0] data_decoder
);
case(data)
0: data_decoder = 7'b1000000;
1: data_decoder = 7'b1111001;
2: data_decoder = 7'b0100100;
3: data_decoder = 7'b0110000;
4: data_decoder = 7'b0011001;
5: data_decoder = 7'b0010010;
6: data_decoder = 7'b0000010;
7: data_decoder = 7'b1111000;
8: data_decoder = 7'b0000000;
9: data_decoder = 7'b0010000;
default: data_decoder = 7'b0110110;
endcase
endtask
endmodule
虽然这种写法严重浪费硬件资源,不过功能还算正确,大家凑合着看吧。