Jump to content
  • 0

Basys3 lighting leds


aladinsane

Question

I'm a beginner to fpga programming and working on BASYS3. In my System Verilog code I have 2 2 bit outputs: la and lb. Assuming these are two traffic lights and 00 means red, 10 means yellow, 11 means green. If output is red, 3 leds will light. But I don't know how to implement it in constraint file. Normally, when an output is 1, I want to led to light and I write this kind of code:

set_property PACKAGE_PIN U14 [get_ports {la[0]}]                      
     set_property IOSTANDARD LVCMOS33 [get_ports {la[0]}]

But this time I want the led to light when output 0. Maybe I can write 2 more outputs that will become the opposite of my real outputs and I can use them in constraint but I wonder can I directly implement what I want in constraint file.  

Link to comment
Share on other sites

1 answer to this question

Recommended Posts

The easy answer to your question is that it's not a constraint file deal.  The constraint file only describes how the FPGA connects to the hardware.  In the case of the Basys3 board, there are 16 LEDs, and the master constraint file reflects this.  These LEDs can be turned on (output 1), or off (output 2).  They are that simple.  Nothing more may be done with them.

How then do you do anything more?

You add more logic to your program.  If your module is constrained to have two output variables, then place that module within another module that maps those two outputs to the 1 and 0 outputs of the board that you want.  For example (in Verilog):
 

always @(posedge clk)
begin
	led[0] <= ({ la, lb } == 2'b00);
	led[1] <= ({ la, lb } == 2'b01);
	led[2] <= ({ la, lb } == 2'b10);
	led[3] <= ({ la, lb } == 2'b11);
end

Dan

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...