Programmable Devices
CPLDs, FPGAs, SoC FPGAs, Configuration, and Transceivers
21608 Discussions

Question with creating LED Toggle

mHaire
Beginner
514 Views

Hello,
I am learning Verilog for the first time, and following some examples in a book. I am using the Intel Cyclone 10LP Evaluation Kit. The current example is to create a design which will toggle the state of an LED on the falling edge of a switch signal.
I've written the Verilog in Quartus and I think I have my clock, and pins configured correctly. However, the state of my LED will not change and I am lost on what to do for troubleshooting.

I have tried configuring other LEDs to the flip flop outputs to debug, but they flip flop outputs do not change state. 
Could I receive some assistance on how to work through this.
I have attached my Verilog and the RTL viewer of what I have programmed.
Please let me know anything else I should attach. 

module FlipFlopToggle(
	input i_Clk,
	input switch_1,
	output led_1);
	
	reg r_led_1 	= 1'b0;
	reg r_switch_1	= 1'b0;
	
	always @(posedge i_Clk)
	begin
	r_switch_1 <= switch_1;
	
	if(switch_1 == 1'b0 && r_switch_1 == 1'b1)
	begin
	 r_led_1 <= ~r_led_1;
	 end
	end
	
	assign led_1 = r_led_1;
	
	endmodule

 

Labels (1)
0 Kudos
3 Replies
sstrell
Honored Contributor III
464 Views

What clock signal/pin are you using?  Have you made the pin assignments for the switch and LED correctly in the Quartus Pin Planner?

Also note that the clock enable on the output register is only going to be active for a single clock cycle and you're using an asynchronous switch input (the switch going low) to control when that enable signal is true, so there's no guarantee that the output register will be enabled to switch the LED output at the exact moment you flip the switch.  You may want to register the switch going low as well.

0 Kudos
RichardTanSY_Altera
439 Views

Thank you sstrell for the answer.

 

@mHaireDid sstrell's suggestion help in your case?

 

Regards,

Richard Tan

 

0 Kudos
RichardTanSY_Altera
361 Views

We noticed that we haven't received a response from you regarding the latest previous question/reply/answer, and will now transitioning your inquiry to our community support. We apologize for any inconvenience this may cause and we appreciate your understanding.


If you have any further questions or concerns, please don't hesitate to reach out. Please login to https://supporttickets.intel.com/s/?language=en_US, view details of the desire request, and post a feed/response within the next 15 days to allow me to continue to support you. After 15 days, this thread will be transitioned to community support. The community users will be able to help you on your follow-up questions.


The community users will be able to help you on your follow-up questions.


Thank you for reaching out to us!


Best Regards,

Richard Tan



0 Kudos
Reply