always @ (posedge clk) begin if (btnC == 1) led[0] = 0; else begin if (sw[0] == 1) begin if (sw[1] == 1) led[0] <= ~led[0]; else led[0] <= 1; end else begin if (sw[1]) led[0] <= 0; end end end
endmodule
What I see is when sw[0] and sw[1] are both 1 and if the previous led state was 1, the led does not turn off completely (it just gets dimmer). What could be the problem here, and how would I go about fixing it? I also tried using other LEDs on the board and each had the same problem.
Question
tpg56
Hi,
I am trying to learn verilog and digital design using basys3 and vivado (webpack) tools. I implemented a jk flip flop using the following logic:
module jk_flip_flop (
input [1:0] sw,
input clk,
input btnC,
output reg [0:0] led);
always @ (posedge clk)
begin
if (btnC == 1)
led[0] = 0;
else
begin
if (sw[0] == 1)
begin
if (sw[1] == 1)
led[0] <= ~led[0];
else
led[0] <= 1;
end
else
begin
if (sw[1])
led[0] <= 0;
end
end
end
endmodule
What I see is when sw[0] and sw[1] are both 1 and if the previous led state was 1, the led does not turn off completely (it just gets dimmer). What could be the problem here, and how would I go about fixing it? I also tried using other LEDs on the board and each had the same problem.
Thanks.
Link to comment
Share on other sites
3 answers to this question
Recommended Posts
Archived
This topic is now archived and is closed to further replies.