You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

72 lines
1.3 KiB
Verilog

`timescale 1ns/1ns
module tb_dt();
// 我们如果上板验证, 需要再 .xdc文件中, 添加时钟约束
// create_clock -period 20.000 -name sys_clk [get_ports sys_clk]
// 创建一个时钟, 周期是20纳秒, 对应的端口是系统时钟
reg sys_clk;
reg sys_rst;
initial begin
sys_clk <= 1'b0;
// 复位
sys_rst <= 1'b0;
#200
// 结束复位
sys_rst <= 1'b1;
end
// 每20ns 产生一个时钟周期, 所以需要10ns 翻转一次
always #10 sys_clk = ~sys_clk;
reg [5:0] CNT;
always @(posedge sys_clk or negedge sys_rst) begin
if (sys_rst == 1'b0) begin
CNT <= 5'd0;
end
else if (CNT < (5'd25 - 5'd1)) begin
CNT <= CNT + 5'd1;
end
else begin
CNT <= 5'b0;
end
end
reg [7:0] data;
always @(posedge sys_clk or negedge sys_rst) begin
if (sys_rst == 1'b0) begin
data <= 8'b1_00_0_0000;
end
else if (CNT == (5'd25 - 5'd1)) begin
data[3:0] <= data[3:0] + 4'b1;
data[6:5] <= data[6:5] + 2'b1;
end
else begin
end
end
wire [7:0] D;
wire [3:0] S;
dt u_dt(
.data (data),
.A (D[0]),
.B (D[1]),
.C (D[2]),
.D (D[3]),
.E (D[4]),
.F (D[5]),
.G (D[6]),
.DP (D[7]),
.S1 (S[0]),
.S2 (S[1]),
.S3 (S[2]),
.S4 (S[3])
);
endmodule