概述
实现的效果:
(1)、能够自动倒计时,初始值可以在程序中设置;
(2)、能够通过按键改变初始值(秒、分、时都可以);
(3)、可以根据时钟进行相应的LED灯闪烁;
相应参数:
(1)、使用芯片:Cyclone IV EP4CE10F17C8N
(2)、输入时钟:50MHz
首先我们先来看一看设计流程图(从左到右):
输入:(1)、时钟输入;(2)、按键输入;(3)、复位键输入;
模块:(1)锁相环模块;(2)、按键转换模块;(3)、计数模块;(4)、译码模块;(5)、位选模块;(6)、时钟闪烁模块;
输出:(1)、位选;(2)、段选;(3)、LED
设计思路:
(1)、首先我们将输入的时钟通过锁相环,(50MHz->50MHz),以此来获得一个更加稳定的时钟;
(2)、我们将按键的值传入按键转换模块,将键值转换为,对秒的加or减,分的加or减,时的加or减;
(3)、然后将相应的值传入计数模块来改变计数的值;
(4)、然后将相应的计数值传入译码模块,以此来获得数码管需要的段选值;
(5)、通过1KHz的时钟来位选,显示时钟到数码管上;
(6)、将计数值输入到LED灯模块,根据相应的要求进行闪烁;
硬件设计:
段选是低电平有效,那么相应的数字转换为数码管的显示就如下:
1:1111_1001;
2:1010_0100;
3:1011_0000;
4:1001_1001;
5:1001_0010;
6:1000_0010;
7:1111_1000;
8:1000_0000;
9:1001_0000;
我们发现位选模块是通过PNP三极管来控制的,所以低电平时有效。
程序源码:
(1)、锁相环,锁相环通过如下的IP核创建即可,这里不再详细介绍。(锁相环可以去除掉)。
(2)、按键转换模块
module key_set(
input clk,
input reset,
input [2:0] key,
output reg [1:0] count, //定义对秒、分、时的控制
output reg [1:0] key_choose //定义控制加、减
);
reg [31:0] cnt;
reg clk_Hz;
//产生一个5Hz的时钟,用来检测按键的按下,这样可以去除抖动带来的误差
always@(posedge clk or negedge reset)
begin
if(!reset)
begin
cnt <= 32'd0;
clk_Hz <= 1'b0;
end
else if(cnt == 32'd5000_000)
begin
clk_Hz <= ~clk_Hz;
cnt <= 32'd0;
end
else
begin
cnt <= cnt + 32'd1;
end
end
reg key_flag;
//键值的转换
always@(posedge clk_Hz or negedge reset)
begin
if(!reset)
begin
key_flag <= 1'b1;
key_choose <= 2'b00;
count <= 2'b00;
end
else if(key_flag && key!=3'b111)
begin
case(key)
3'b110:
begin
count <= count+2'b1;
key_flag <= 1'b0;
end
3'b101:
begin
key_choose <= 2'b10;
key_flag <= 1'b0;
end
3'b011:
begin
key_choose <= 2'b11;
key_flag <= 1'b0;
end
default:
begin
key_choose <= 2'b00;
key_flag <= 1'b1;
end
endcase
end
else if(key == 3'b111)
begin
key_flag <= 1'b1;
key_choose <= 2'b00;
end
else
begin
key_choose <= 2'b00;
key_flag <= 1'b1;
end
end
endmodule
count:代表的是选择秒、分、时;
choose:代表的加or减;
(3)、计数模块
module count(
input clk,
input reset,
input [1:0]choose,
input [1:0]count,
output [3:0] count_miao_ge,
output [2:0] count_miao_shi,
output [3:0] count_fen_ge,
output [2:0] count_fen_shi,
output [3:0] count_shi_ge,
output [1:0] count_shi_shi
);
reg [31:0]cnt_1;
reg flag_1_second;
//该模块用来控制加减的速度变化
always@(posedge clk or negedge reset)
begin
if(!reset)
begin
cnt_1 <= 32'd0;
flag_1_second <= 1'b0;
end
else if(cnt_1 == 32'd1200_0000)
begin
flag_1_second <= 1'b1;
cnt_1 <= 32'd0;
end
else
begin
flag_1_second <= 1'b0;
cnt_1 <= cnt_1 + 32'd1;
end
end
reg [31:0] cnt;
reg [3:0] count_miao_ge_reg;
reg [2:0] count_miao_shi_reg;
reg [3:0] count_fen_ge_reg;
reg [2:0] count_fen_shi_reg;
reg [3:0] count_shi_ge_reg;
reg [1:0] count_shi_shi_reg;
assign count_miao_ge = count_miao_ge_reg; //秒的个位
assign count_miao_shi = count_miao_shi_reg;//秒的十位
assign count_fen_ge = count_fen_ge_reg;//分的个位
assign count_fen_shi = count_fen_shi_reg;//分的十位
assign count_shi_ge = count_shi_ge_reg;//时的个位
assign count_shi_shi = count_shi_shi_reg;//时的十位
always@(posedge clk or negedge reset)
begin
if(!reset)
begin
cnt <= 32'd0;
count_miao_ge_reg <= 4'd5;
count_miao_shi_reg <= 3'd4;
count_fen_ge_reg <= 4'd6;
count_fen_shi_reg <= 3'd5;
count_shi_ge_reg <= 4'd8;
count_shi_shi_reg <= 2'd1;
end
//当计满一秒并且秒的个位小于0时,秒的个位减一
else if(cnt == 32'd5000_0000 && count_miao_ge_reg>4'd0 && count == 2'b00)
begin
count_miao_ge_reg <= count_miao_ge_reg - 4'd1;
cnt <= 32'd0;
end
//当计满一秒并且秒的个位等于0时,秒的十位减一,秒的个位变九
else if(cnt == 32'd5000_0000 && count_miao_ge_reg==4'd0 && count_miao_shi_reg>3'd0 && count == 2'b00)
begin
count_miao_shi_reg <= count_miao_shi_reg - 3'd1;
count_miao_ge_reg <= 4'd9;
cnt <= 32'd0;
end
//当计满一秒,秒到达00并且分的个位大于0时,分的个位减1
else if(cnt == 32'd5000_0000 && count_miao_ge_reg==4'd0 && count_miao_shi_reg==3'd0 && count_fen_ge_reg>4'd0 && count == 2'b00)
begin
count_fen_ge_reg <= count_fen_ge_reg - 4'd1;
count_miao_shi_reg <= 3'd5;
count_miao_ge_reg <= 4'd9;
cnt <= 32'd0;
end
//当计满一秒,秒到达00并且分的个位等于0时,分的十位减1
else if(cnt == 32'd5000_0000 && count_miao_ge_reg==4'd0 && count_miao_shi_reg==3'd0 && count_fen_ge_reg==4'd0 && count_fen_shi_reg > 3'd0 && count == 2'b00)
begin
count_fen_shi_reg <= count_fen_shi_reg - 3'd1;
count_fen_ge_reg <= 4'd9;
count_miao_shi_reg <= 3'd5;
count_miao_ge_reg <= 4'd9;
cnt <= 32'd0;
end
//当计满一秒,秒到达00,分等于00时,时的个位>0,时的个位减一
else if(cnt == 32'd5000_0000 && count_miao_ge_reg==4'd0 && count_miao_shi_reg==3'd0 && count_fen_ge_reg==4'd0 && count_fen_shi_reg ==3'd0 && count_shi_ge_reg >4'd0 && count == 2'b00)
begin
count_shi_ge_reg <= count_shi_ge_reg - 4'd1;
count_fen_shi_reg <= 3'd5;
count_fen_ge_reg <= 4'd9;
count_miao_shi_reg <= 3'd5;
count_miao_ge_reg <= 4'd9;
cnt <= 32'd0;
end
//当计满一秒,秒到达00,分等于00时,时的个位等于0时,时的十位>0,时的十位减一
else if(cnt == 32'd5000_0000 && count_miao_ge_reg==4'd0 && count_miao_shi_reg==3'd0&& count_fen_ge_reg==4'd0 && count_fen_shi_reg ==3'd0 && count_shi_ge_reg == 4'd0 && count_shi_shi_reg > 2'd0 && count_shi_shi_reg< 2'd2 && count == 2'b00)
begin
count_shi_shi_reg <= count_shi_shi_reg - 2'd1;
count_shi_ge_reg <= 4'd9;
count_fen_shi_reg <= 3'd5;
count_fen_ge_reg <= 4'd9;
count_miao_shi_reg <= 3'd5;
count_miao_ge_reg <= 4'd9;
cnt <= 32'd0;
end
//当计满一秒,秒到达00,分等于00时,时等于00,所有变回初值
else if(cnt == 32'd5000_0000 && count_miao_ge_reg==4'd0 && count_miao_shi_reg==3'd0 && count_fen_ge_reg==4'd0 && count_fen_shi_reg ==3'd0 && count_shi_ge_reg == 4'd0 && count_shi_shi_reg == 2'd0 && count == 2'b00)
begin
count_shi_shi_reg <= 2'd2;
count_shi_ge_reg <= 4'd3;
count_fen_shi_reg <= 3'd5;
count_fen_ge_reg <= 4'd9;
count_miao_shi_reg <= 3'd5;
count_miao_ge_reg <= 4'd9;
cnt <= 32'd0;
end
/**用按键进行秒的控制加**/
else if(count == 2'b01 && choose == 2'b10 && flag_1_second && count_miao_ge_reg < 4'd9 )
begin
count_miao_ge_reg <= count_miao_ge_reg + 4'd1;
end
else if(count == 2'b01 && choose == 2'b10 && flag_1_second && count_miao_ge_reg==4'd9 && count_miao_shi_reg<3'd5)
begin
count_miao_shi_reg <= count_miao_shi_reg + 3'd1;
count_miao_ge_reg <= 4'd0;
end
else if(count == 2'b01 && choose == 2'b10 && flag_1_second && count_miao_ge_reg==4'd9 && count_miao_shi_reg==3'd5)
begin
count_miao_shi_reg <= 3'd0;
count_miao_ge_reg <= 4'd0;
end
/**用按键进行秒的控制减**/
else if(count == 2'b01 && choose == 2'b11 && flag_1_second && count_miao_ge_reg>4'd0 )
begin
count_miao_ge_reg <= count_miao_ge_reg - 4'd1;
end
else if(count == 2'b01 && choose == 2'b11 && flag_1_second && count_miao_ge_reg==4'd0 && count_miao_shi_reg>3'd0)
begin
count_miao_shi_reg <= count_miao_shi_reg - 3'd1;
count_miao_ge_reg <= 4'd9;
end
else if(count == 2'b01 && choose == 2'b11 && flag_1_second && count_miao_ge_reg==4'd0 && count_miao_shi_reg==3'd0)
begin
count_miao_shi_reg <= 3'd5;
count_miao_ge_reg <= 4'd9;
end
/**用按键进行分的控制加**/
else if(count == 2'b10 && choose == 2'b10 && flag_1_second && count_fen_ge_reg<4'd9)
begin
count_fen_ge_reg <= count_fen_ge_reg + 4'd1;
end
else if(count == 2'b10 && choose == 2'b10 && flag_1_second && count_fen_ge_reg==4'd9 && count_fen_shi_reg < 3'd5)
begin
count_fen_shi_reg <= count_fen_shi_reg + 3'd1;
count_fen_ge_reg <= 4'd0;
end
else if(count == 2'b10 && choose == 2'b10 && flag_1_second && count_fen_ge_reg==4'd9)
begin
count_fen_shi_reg <= 3'd0;
count_fen_ge_reg <= 4'd0;
end
/**用按键进行分的控制减**/
else if(count == 2'b10 && choose == 2'b11 && flag_1_second && count_fen_ge_reg> 4'd0)
begin
count_fen_ge_reg <= count_fen_ge_reg - 4'd1;
end
else if(count == 2'b10 && choose == 2'b11 && flag_1_second && count_fen_ge_reg== 4'd0 && count_fen_shi_reg > 3'd0 )
begin
count_fen_shi_reg <= count_fen_shi_reg - 3'd1;
count_fen_ge_reg <= 4'd9;
end
else if(count == 2'b10 && choose == 2'b11 && flag_1_second && count_fen_ge_reg== 4'd0 && count_fen_shi_reg ==3'd0)
begin
count_fen_shi_reg <= 3'd5;
count_fen_ge_reg <= 4'd9;
end
/**用按键进行时的控制加**/
else if(count == 2'b11 && choose == 2'b10 && flag_1_second && count_shi_ge_reg < 4'd9 && count_shi_shi_reg < 2'd2)
begin
count_shi_ge_reg <= count_shi_ge_reg + 4'd1;
end
else if(count == 2'b11 && choose == 2'b10 && flag_1_second && count_shi_ge_reg == 4'd9 && count_shi_shi_reg < 2'd2)
begin
count_shi_shi_reg <= count_shi_shi_reg + 2'd1;
count_shi_ge_reg <= 4'd0;
end
else if(count == 2'b11 && choose == 2'b10 && flag_1_second && count_shi_ge_reg < 4'd3 && count_shi_shi_reg == 2'd2)
begin
count_shi_ge_reg <= count_shi_ge_reg + 4'd1;
end
else if(count == 2'b11 && choose == 2'b10 && flag_1_second && count_shi_ge_reg == 4'd3 && count_shi_shi_reg == 2'd2)
begin
count_shi_shi_reg <= 2'd0;
count_shi_ge_reg <= 4'd0;
end
/**用按键进行时的控制减**/
else if(count == 2'b11 && choose == 2'b11 && flag_1_second && count_shi_ge_reg >4'd0 )
begin
count_shi_ge_reg <= count_shi_ge_reg - 4'd1;
end
else if(count == 2'b11 && choose == 2'b11 && flag_1_second && count_shi_ge_reg == 4'd0 && count_shi_shi_reg > 2'd0)
begin
count_shi_shi_reg <= count_shi_shi_reg - 2'd1;
count_shi_ge_reg <= 4'd9;
end
else if(count == 2'b11 && choose == 2'b11 && flag_1_second && count_shi_ge_reg == 4'd0 && count_shi_shi_reg == 2'd0)
begin
count_shi_shi_reg <= 2'd2;
count_shi_ge_reg <= 4'd3;
end
else if(count == 2'b00)
begin
cnt <= cnt + 32'd1;
end
else
begin
cnt <= cnt;
end
end
endmodule
(4)、译码模块
module decoding(
input clk,
input reset,
input [3:0] count_miao_ge,
input [2:0] count_miao_shi,
input [3:0] count_fen_ge,
input [2:0] count_fen_shi,
input [3:0] count_shi_ge,
input [1:0] count_shi_shi,
output reg [7:0] code_miao_ge,
output reg [7:0] code_miao_shi,
output reg [7:0] code_fen_ge,
output reg [7:0] code_fen_shi,
output reg [7:0] code_shi_ge,
output reg [7:0] code_shi_shi
);
always@(posedge clk or negedge reset)
begin
if(!reset)
code_miao_ge <= 8'b1111_1111;
else
begin
case(count_miao_ge)
4'd0:code_miao_ge <= 8'b1100_0000;
4'd1:code_miao_ge <= 8'b1111_1001;
4'd2:code_miao_ge <= 8'b1010_0100;
4'd3:code_miao_ge <= 8'b1011_0000;
4'd4:code_miao_ge <= 8'b1001_1001;
4'd5:code_miao_ge <= 8'b1001_0010;
4'd6:code_miao_ge <= 8'b1000_0010;
4'd7:code_miao_ge <= 8'b1111_1000;
4'd8:code_miao_ge <= 8'b1000_0000;
4'd9:code_miao_ge <= 8'b1001_0000;
default:code_miao_ge <= 8'b1011_1111;
endcase
end
end
always@(posedge clk or negedge reset)
begin
if(!reset)
code_miao_shi <= 8'b1111_1111;
else
begin
case(count_miao_shi)
3'd0:code_miao_shi <= 8'b1100_0000;
3'd1:code_miao_shi <= 8'b1111_1001;
3'd2:code_miao_shi <= 8'b1010_0100;
3'd3:code_miao_shi <= 8'b1011_0000;
3'd4:code_miao_shi <= 8'b1001_1001;
3'd5:code_miao_shi <= 8'b1001_0010;
default:code_miao_shi <= 8'b1011_1111;
endcase
end
end
always@(posedge clk or negedge reset)
begin
if(!reset)
code_fen_ge <= 8'b1111_1111;
else
begin
case(count_fen_ge)
4'd0:code_fen_ge <= 8'b0100_0000;
4'd1:code_fen_ge <= 8'b0111_1001;
4'd2:code_fen_ge <= 8'b0010_0100;
4'd3:code_fen_ge <= 8'b0011_0000;
4'd4:code_fen_ge <= 8'b0001_1001;
4'd5:code_fen_ge <= 8'b0001_0010;
4'd6:code_fen_ge <= 8'b0000_0010;
4'd7:code_fen_ge <= 8'b0111_1000;
4'd8:code_fen_ge <= 8'b0000_0000;
4'd9:code_fen_ge <= 8'b0001_0000;
default:code_fen_ge <= 8'b1011_1111;
endcase
end
end
always@(posedge clk or negedge reset)
begin
if(!reset)
code_fen_shi <= 8'b1111_1111;
else
begin
case(count_fen_shi)
3'd0:code_fen_shi <= 8'b1100_0000;
3'd1:code_fen_shi <= 8'b1111_1001;
3'd2:code_fen_shi <= 8'b1010_0100;
3'd3:code_fen_shi <= 8'b1011_0000;
3'd4:code_fen_shi <= 8'b1001_1001;
3'd5:code_fen_shi <= 8'b1001_0010;
default:code_fen_shi <= 8'b1011_1111;
endcase
end
end
always@(posedge clk or negedge reset)
begin
if(!reset)
code_shi_ge <= 8'b1111_1111;
else
begin
case(count_shi_ge)
4'd0:code_shi_ge <= 8'b0100_0000;
4'd1:code_shi_ge <= 8'b0111_1001;
4'd2:code_shi_ge <= 8'b0010_0100;
4'd3:code_shi_ge <= 8'b0011_0000;
4'd4:code_shi_ge <= 8'b0001_1001;
4'd5:code_shi_ge <= 8'b0001_0010;
4'd6:code_shi_ge <= 8'b0000_0010;
4'd7:code_shi_ge <= 8'b0111_1000;
4'd8:code_shi_ge <= 8'b0000_0000;
4'd9:code_shi_ge <= 8'b0001_0000;
default:code_shi_ge <= 8'b1011_1111;
endcase
end
end
always@(posedge clk or negedge reset)
begin
if(!reset)
code_shi_shi <= 8'b1111_1111;
else
begin
case(count_shi_shi)
2'd0:code_shi_shi <= 8'b1100_0000;
2'd1:code_shi_shi <= 8'b1111_1001;
2'd2:code_shi_shi <= 8'b1010_0100;
default:code_shi_shi <= 8'b1011_1111;
endcase
end
end
endmodule
(5)、位选模块
module sel_show(
input clk,
input reset,
input [7:0] code_miao_ge,
input [7:0] code_miao_shi,
input [7:0] code_fen_ge,
input [7:0] code_fen_shi,
input [7:0] code_shi_ge,
input [7:0] code_shi_shi,
output reg [7:0] led,
output reg [5:0] sel
);
reg [15:0] cnt;
reg flag;
//产生1000Hz的时钟
always@(posedge clk or negedge reset)
begin
if(!reset)
begin
cnt <=16'd0;
flag <= 1'b0;
end
else if(cnt == 16'd500_00)
begin
cnt <= 16'd0;
flag <= 1'b1;
end
else
begin
cnt <= cnt + 16'd1;
flag <= 1'b0;
end
end
reg [2:0] state;
parameter start = 3'd0; //开始状态
parameter sel_1 = 3'd1; //位选1
parameter sel_2 = 3'd2; //位选2
parameter sel_3 = 3'd3; //位选3
parameter sel_4 = 3'd4; //位选4
parameter sel_5 = 3'd5; //位选5
parameter sel_6 = 3'd6; //位选6
parameter ending = 3'd7;//结束
always@(posedge clk or negedge reset)
begin
if(!reset)
begin
state <= 3'd0;
sel <= 6'b000_000;
end
else
case(state)
start:
begin
if(flag == 1'b1)
state <= sel_1;
else
state <= state;
end
sel_1:
begin
if(flag == 1'b1)
begin
state <= sel_2;
sel <= 6'b111_110;
led <= code_miao_ge;
end
else
state <= state;
end
sel_2:
begin
if(flag == 1'b1)
begin
state <= sel_3;
sel <= 6'b111_101;
led <= code_miao_shi;
end
else
state <= state;
end
sel_3:
begin
if(flag == 1'b1)
begin
state <= sel_4;
sel <= 6'b111_011;
led <= code_fen_ge;
end
else
state <= state;
end
sel_4:
begin
if(flag == 1'b1)
begin
state <= sel_5;
sel <= 6'b110_111;
led <= code_fen_shi;
end
else
state <= state;
end
sel_5:
begin
if(flag == 1'b1)
begin
state <= sel_6;
sel <= 6'b101_111;
led <= code_shi_ge;
end
else
state <= state;
end
sel_6:
begin
if(flag == 1'b1)
begin
state <= ending;
sel <= 6'b011_111;
led <= code_shi_shi;
end
else
state <= state;
end
ending:
state <= start;
default:
state <= start;
endcase
end
endmodule
通过一个简单的状态机来进行位选。
(6)、LED灯闪烁模块
module led_flash(
input clk,
input reset,
input [3:0] count_miao_ge,
input [2:0] count_miao_shi,
input [3:0] count_fen_ge,
input [2:0] count_fen_shi,
output reg Led
);
reg [31:0] cnt_2Hz;
reg [31:0] cnt_5Hz;
reg clk_2Hz;
reg clk_5Hz;
parameter flash_2Hz = 32'd1250_0000;
parameter flash_5Hz = 32'd5000_000;
//产生2Hz的时钟5000_0000/2/2 = 1250_0000
always@(posedge clk or negedge reset)
begin
if(!reset)
begin
cnt_2Hz <= 32'd0;
end
else if(cnt_2Hz == flash_2Hz)
begin
clk_2Hz <= ~clk_2Hz;
cnt_2Hz <= 32'd0;
end
else
cnt_2Hz <= cnt_2Hz + 32'd1;
end
//产生5Hz的时钟5000_0000/5/2 = 500_0000
always@(posedge clk or negedge reset)
begin
if(!reset)
begin
cnt_5Hz <= 32'd0;
end
else if(cnt_5Hz == flash_5Hz)
begin
clk_5Hz <= ~clk_5Hz;
cnt_5Hz <= 32'd0;
end
else
cnt_5Hz <= cnt_5Hz + 32'd1;
end
//判断相应的范围并且选取相应的时钟。
always@(posedge clk or negedge reset)
begin
if(!reset)
begin
Led <= 1'b0;
end
else if(count_fen_shi == 3'd5 && count_fen_ge == 4'd9 && count_miao_shi == 3'd5 && count_miao_ge >= 4'd0 && count_miao_ge < 4'd5)
Led <= clk_2Hz;
else if(count_fen_shi == 3'd5 && count_fen_ge == 4'd9 && count_miao_shi == 3'd5 && count_miao_ge >= 4'd5 && count_miao_ge <= 4'd9)
Led <= clk_5Hz;
else
Led <= 1'b0;
end
endmodule
(7)、顶层函数
module top(
input clk,
input reset,
input [2:0]key,
output [7:0] led,
output [5:0] sel,
output Led
);
wire clk_50MHz;
wire locked;
pll u1(
.inclk0(clk),
.c0(clk_50MHz),
.locked(locked)
);
wire [1:0] count;
wire [1:0] key_choose;
key_set u2(
.clk(clk_50MHz),
.reset(reset),
.key(key),
.count(count),
.key_choose(key_choose)
);
wire [3:0] count_miao_ge;
wire [2:0] count_miao_shi;
wire [3:0] count_fen_ge;
wire [2:0] count_fen_shi;
wire [3:0] count_shi_ge;
wire [1:0] count_shi_shi;
count u3(
.clk(clk_50MHz),
.reset(reset),
.choose(key_choose),
.count(count),
.count_miao_ge(count_miao_ge),
.count_miao_shi(count_miao_shi),
.count_fen_ge(count_fen_ge),
.count_fen_shi(count_fen_shi),
.count_shi_ge(count_shi_ge),
.count_shi_shi(count_shi_shi)
);
wire [7:0] code_miao_ge;
wire [7:0] code_miao_shi;
wire [7:0] code_fen_ge;
wire [7:0] code_fen_shi;
wire [7:0] code_shi_ge;
wire [7:0] code_shi_shi;
decoding u4(
.clk(clk_50MHz),
.reset(reset),
.count_miao_ge(count_miao_ge),
.count_miao_shi(count_miao_shi),
.count_fen_ge(count_fen_ge),
.count_fen_shi(count_fen_shi),
.count_shi_ge(count_shi_ge),
.count_shi_shi(count_shi_shi),
.code_miao_ge(code_miao_ge),
.code_miao_shi(code_miao_shi),
.code_fen_ge(code_fen_ge),
.code_fen_shi(code_fen_shi),
.code_shi_ge(code_shi_ge),
.code_shi_shi(code_shi_shi)
);
sel_show u5(
.clk(clk_50MHz),
.reset(reset),
.code_miao_ge(code_miao_ge),
.code_miao_shi(code_miao_shi),
.code_fen_ge(code_fen_ge),
.code_fen_shi(code_fen_shi),
.code_shi_ge(code_shi_ge),
.code_shi_shi(code_shi_shi),
.led(led),
.sel(sel)
);
led_flash u6(
.clk(clk),
.reset(reset),
.count_miao_ge(count_miao_ge),
.count_miao_shi(count_miao_shi),
.count_fen_ge(count_fen_ge),
.count_fen_shi(count_fen_shi),
.Led(Led)
);
endmodule
下载代码之后,我们通过Signal Tap进行简单的仿真。
观察这个我们可以看到程序运行正确。
最后
以上就是自信战斗机为你收集整理的基于FPGA的可控倒计时计数器的全部内容,希望文章能够帮你解决基于FPGA的可控倒计时计数器所遇到的程序开发问题。
如果觉得靠谱客网站的内容还不错,欢迎将靠谱客网站推荐给程序员好友。
发表评论 取消回复