Author Topic: Indexed pins in constraints file?  (Read 2068 times)

0 Members and 1 Guest are viewing this topic.

Offline ShimonuTopic starter

  • Newbie
  • Posts: 2
  • Country: se
Indexed pins in constraints file?
« on: February 11, 2024, 12:33:35 am »
Just started using an FPGA recently and got the master file for my development board. Something I noticed was how the pins were declared there using brackets, like this

Code: [Select]
set_property -dict { PACKAGE_PIN "K12"   IOSTANDARD LVCMOS33}   SLEW FAST} [get_ports { LED[0] }];                     
set_property -dict { PACKAGE_PIN "K13"   IOSTANDARD LVCMOS33    SLEW FAST} [get_ports { LED[1] }];                     
set_property -dict { PACKAGE_PIN "R10"   IOSTANDARD LVCMOS33    SLEW FAST} [get_ports { LED[2] }];                     
set_property -dict { PACKAGE_PIN "R13"   IOSTANDARD LVCMOS33    SLEW FAST} [get_ports { LED[3] }];                     
set_property -dict { PACKAGE_PIN "T13"   IOSTANDARD LVCMOS33    SLEW FAST} [get_ports { LED[4] }];                     
set_property -dict { PACKAGE_PIN "R12"   IOSTANDARD LVCMOS33    SLEW FAST} [get_ports { LED[5] }];                     
set_property -dict { PACKAGE_PIN "T12"   IOSTANDARD LVCMOS33    SLEW FAST} [get_ports { LED[6] }];                     
set_property -dict { PACKAGE_PIN "R11"   IOSTANDARD LVCMOS33    SLEW FAST} [get_ports { LED[7] }]; 

But how am I supposed to use them? I can't just declare LED[0] as an output, I get an error that I can't declare LED as an array. I'm assuming this is to easily use the LEDs as a group but can I still just bring one LED into a top file? So are my options to rename them or use LED as a bus?
 

Offline langwadt

  • Super Contributor
  • ***
  • Posts: 4427
  • Country: dk
Re: Indexed pins in constraints file?
« Reply #1 on: February 11, 2024, 12:43:38 am »
you declare LED as an 8bit output port
 
The following users thanked this post: Shimonu

Offline glenenglish

  • Frequent Contributor
  • **
  • Posts: 265
  • Country: au
  • RF engineer. AI6UM / VK1XX . Aviation pilot. MTBr.
Re: Indexed pins in constraints file?
« Reply #2 on: February 11, 2024, 01:45:50 am »
yep
like this. now the tool will be able to connect the dots.
(VHDL)
GENERIC (
   NLEDS      :    integer :=8
   );
    Port (
      LEDS : out STD_LOGIC_VECTOR(NLEDS-1 downto 0)

   
 

Offline hamster_nz

  • Super Contributor
  • ***
  • Posts: 2803
  • Country: nz
Re: Indexed pins in constraints file?
« Reply #3 on: February 11, 2024, 05:58:46 am »
yep
like this. now the tool will be able to connect the dots.
(VHDL)
GENERIC (
   NLEDS      :    integer :=8
   );
    Port (
      LEDS : out STD_LOGIC_VECTOR(NLEDS-1 downto 0)

Note that the signal name must match in upper/lower case, as well as in singular vs plural  (note how the constrains used "LED", but this code snippet uses "LEDS". ;)
Gaze not into the abyss, lest you become recognized as an abyss domain expert, and they expect you keep gazing into the damn thing.
 

Offline ejeffrey

  • Super Contributor
  • ***
  • Posts: 3721
  • Country: us
Re: Indexed pins in constraints file?
« Reply #4 on: February 11, 2024, 05:53:54 pm »
I'm assuming this is to easily use the LEDs as a group but can I still just bring one LED into a top file? So are my options to rename them or use LED as a bus?

I don't quite get what you are wanting to do.  You declare LED as a bus in the top level module but you can access them individually which the module body.
 

Offline pcprogrammer

  • Super Contributor
  • ***
  • Posts: 3710
  • Country: nl
Re: Indexed pins in constraints file?
« Reply #5 on: February 11, 2024, 07:29:28 pm »
In verilog you also list them as a bus like below.

Code: [Select]
module MyModule
(
  output wire [7:0] LED
);

Within the code you can use either the whole bus or parts of it or just a single one.

Code: [Select]
assign LED[0] = 0;

assign LED[7:4] = 1;

More on this can be found here or here.

Offline glenenglish

  • Frequent Contributor
  • **
  • Posts: 265
  • Country: au
  • RF engineer. AI6UM / VK1XX . Aviation pilot. MTBr.
Re: Indexed pins in constraints file?
« Reply #6 on: February 15, 2024, 11:29:54 pm »
verilog : "assign LED[7:4] = 1"  ???

VHDL would never allow such a thing ! More reasons VHDL is the real mans HDL.

 

Offline langwadt

  • Super Contributor
  • ***
  • Posts: 4427
  • Country: dk
Re: Indexed pins in constraints file?
« Reply #7 on: February 15, 2024, 11:42:56 pm »
verilog : "assign LED[7:4] = 1"  ???

VHDL would never allow such a thing ! More reasons VHDL is the real mans HDL.

you like fishing?
 

Online SiliconWizard

  • Super Contributor
  • ***
  • Posts: 14487
  • Country: fr
Re: Indexed pins in constraints file?
« Reply #8 on: February 16, 2024, 12:36:43 am »
yep
like this. now the tool will be able to connect the dots.
(VHDL)
GENERIC (
   NLEDS      :    integer :=8
   );
    Port (
      LEDS : out STD_LOGIC_VECTOR(NLEDS-1 downto 0)

Note that the signal name must match in upper/lower case, as well as in singular vs plural  (note how the constrains used "LED", but this code snippet uses "LEDS". ;)

The plural thing was fun. ;D

Regarding case, VHDL is actually case-insensitive so it doesn't matter. Still, for style and consistency reasons, I strongly suggest always writing a given identifier in exactly the same way case-wise. But it's not required.
 

Offline AK6DN

  • Regular Contributor
  • *
  • Posts: 55
  • Country: us
Re: Indexed pins in constraints file?
« Reply #9 on: February 17, 2024, 08:09:59 pm »
In verilog you also list them as a bus like below.

Code: [Select]
module MyModule
(
  output wire [7:0] LED
);

Within the code you can use either the whole bus or parts of it or just a single one.

Code: [Select]
assign LED[0] = 0;

assign LED[7:4] = 1;

More on this can be found here or here.

Better to write:
Code: [Select]
assign LED[7:4] = {4{1'b1}};

or

assign LED[7:4] = 4'b1111;

as what you have written is really:

assign LED[7:4] = 4'b0001;
 
The following users thanked this post: pcprogrammer, Rainwater


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf