本帖最后由 mcupro 于 2011-6-15 01:04 编辑
这个是用8个数码管显示1-100M 的频率,输入频率是100M。实际效果很好。一下是TOP层文件。
module frenquenze_display_top (
input clk ,
input rst ,
output [7:0] seg7_sel,
output [7:0] seg7_data ,
input fin,
output reg fout,
input [7:0] sw
);
wire sys_clk;
pll25_100 pll25_100 (
.inclk0(clk),
.c0(sys_clk) // outpis 100Mhz
);
reg [7:0] swr;
reg [7:0] swrr;
always @ (posedge sys_clk)swr<=sw;
always @ (posedge sys_clk)swrr<=swr;
reg [7:0] div_cntr;
always @ (posedge sys_clk)if (div_cntr==swrr)div_cntr<=0;else div_cntr<=div_cntr+1;
always @ (posedge sys_clk)if (div_cntr==0)fout<=~fout;
reg [31:0] cntr ;
always @ (posedge sys_clk)
if (cntr == (100000000-1))
cntr <= 0;
else cntr <=cntr+1;
wire load = cntr==0 ;
wire clear = cntr==2 ;
reg [25:0] dis_cntr;
reg [25:0] dis_save;
always @ (posedge sys_clk)
if (load) dis_save<=dis_cntr ;
always @ (posedge fin or posedge clear)
if (clear) dis_cntr <= 0;else dis_cntr<=dis_cntr+1;
dec_display i_dec_display (
.clk(clk),
.value(dis_save) ,
.seg7_sel(seg7_sel),
.seg7_data(seg7_data)
);
endmodule |