问题描述
module Subtask_A(
input CLOCK,input BTNC,output reg [15:0]led
);
wire clock0p168;
reg [24:0]SET_COUNT = 8400000; //0.168s
reg [3:0]counter = 4'b0000;
wire BTNC_pulse;
Clock_0p168 clk1 (CLOCK,SET_COUNT,clock0p168);
Singlepulse dev1 (BTNC,CLOCK,BTNC_pulse);
always @ (posedge clock0p168) begin
if (BTNC_pulse == 1) begin
led[counter] <= 1;
counter <= counter + 1;
end
end
endmodule
module Singlepulse(
input BTNC,input CLOCK,output pulse
);
wire Q1;
wire Q2;
reg[25:0] SET_COUNT2 = 16666666;
wire slow_clock;
clock_singlepulse clk1 (CLOCK,SET_COUNT2,slow_clock);
D_flipflop dev1 (slow_clock,BTNC,Q1);
D_flipflop dev2 (slow_clock,Q1,Q2);
assign pulse = Q1;
endmodule
module D_flipflop(
input CLOCK,input D,output reg Q,input NRESET
);
always @ (posedge CLOCK or negedge NRESET) begin
if (! NRESET)
Q <= 0;
else
Q <= D;
end
endmodule
module Clock_0p168(
input CLOCK,input [23:0] SET_COUNT,//number of bits must change accordingly
output reg set_freq = 0
);
reg [23:0] COUNT = 0;
always @( posedge CLOCK ) begin
COUNT = COUNT + 1;
set_freq <= ( COUNT == SET_COUNT )? ~set_freq: set_freq;
COUNT <= ( COUNT == SET_COUNT )? 0: COUNT;
end
endmodule
module clock_singlepulse(
input CLOCK,input [25:0] SET_COUNT,//number of bits must change accordingly
output reg set_freq = 0
);
reg [25:0] COUNT = 0;
always @( posedge CLOCK ) begin
COUNT = COUNT + 1;
set_freq <= ( COUNT == SET_COUNT )? ~set_freq: set_freq;
COUNT <= ( COUNT == SET_COUNT )? 0: COUNT;
end
endmodule
以上是我使用的代码和模块,任何帮助将不胜感激!! 当我尝试将它运行到 basys 3 板时,我所有的 LED 都亮了,而我没有触摸任何按钮 我正在考虑使用修改后的去抖动单脉冲信号作为输入,这样做是为了消除按下按钮时产生的任何“噪音”。接下来使用分频器,我控制每个 LED 点亮所需的时间为 0.168 秒。所以我希望它会起作用,但它不会。
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)