新手上路
- 积分
- 24
- 金钱
- 24
- 注册时间
- 2023-5-10
- 在线时间
- 4 小时
|
楼主 |
发表于 2023-5-11 10:46:52
|
显示全部楼层
不好意思这个图片好像没上传成功
就是我的实验结果是数码管1和0来回亮
我的代码如下:
module time_count(
input clk,
input rst_n,
output reg [3:0] num
);
reg [24:0] count;
always @( posedge clk or negedge rst_n)begin
if(!rst_n)
count <= 25'd0;
else if(count < 25'd2500_0000-1)
count <= count+1;
else
count <= 25'd0;
end
always @(posedge clk or negedge rst_n)begin
if(!rst_n)
num <= 4'd0;
else if(count == 25'd2500_0000-1)begin
if(num<4'hf)
num <= num+1'b1;
else
num <= 4'd0;
end
end
endmodule
module seg_static_led(
input clk,
input rst_n,
input num,
output reg [5:0] seg_sel,
output reg [7:0] seg_led
);
always @(posedge clk or negedge rst_n)begin
if(!rst_n)
seg_sel <= 6'b111111;
else
seg_sel <= 6'b000000;
end
always @(posedge clk or negedge rst_n)begin
if(!rst_n)begin
seg_led <= 6'd0;
seg_sel <= 8'd0;
end
else begin
case(num)
4'h0 : seg_led <= 8'b1100_0000;
4'h1 : seg_led <= 8'b1111_1001;
4'h2 : seg_led <= 8'b1010_0100;
4'h3 : seg_led <= 8'b1011_0000;
4'h4 : seg_led <= 8'b1001_1001;
4'h5 : seg_led <= 8'b1001_0010;
4'h6 : seg_led <= 8'b1000_0010;
4'h7 : seg_led <= 8'b1111_1000;
4'h8 : seg_led <= 8'b1000_0000;
4'h9 : seg_led <= 8'b1001_0000;
4'ha : seg_led <= 8'b1000_1000;
4'hb : seg_led <= 8'b1000_0011;
4'hc : seg_led <= 8'b1100_0110;
4'hd : seg_led <= 8'b1010_0001;
4'he : seg_led <= 8'b1000_0110;
4'hf : seg_led <= 8'b1000_1110;
endcase
end
end
endmodule
module seg_static_led_top(
input sys_clk,
input sys_rst_n,
output [5:0] seg_sel,
output [7:0] seg_led
);
time_count time_count_n(
.clk (sys_clk),
.rst_n (sys_rst_n),
.num (num_1)
);
seg_static_led seg_static_led_n(
.clk (sys_clk),
.rst_n (sys_rst_n),
.num (num_1),
.seg_sel (seg_sel),
.seg_led (seg_led)
);
ila_0 your_instance_name (
.clk(sys_clk), // input wire clk
.probe0(num) // input wire [3:0] probe0
);
endmodule
求教大佬!非常感谢! |
|