Reputation: 43
On my BASYS-3 board I want to use 4 of the switches and output different things depending on the combination of these switches. For example, if switch 12 is turned on I want a value assigned to a signal. I managed to upload my code onto the board but when I flicked through the switches nothing happened on the display.
Below is part of my constraints file for this segment of code:
#Switches
#SW12
set_property -dict { PACKAGE_PIN W2 IOSTANDARD LVCMOS33 } [get_ports {i_SW[0]}]
#SW13
set_property -dict { PACKAGE_PIN U1 IOSTANDARD LVCMOS33 } [get_ports {i_SW[1]}]
#SW14
set_property -dict { PACKAGE_PIN T1 IOSTANDARD LVCMOS33 } [get_ports {i_SW[2]}]
#SW15
set_property -dict { PACKAGE_PIN R2 IOSTANDARD LVCMOS33 } [get_ports {i_SW[3]}]
and this is how I have written it in the port map of my top level entity:
i_SW : in STD_LOGIC_VECTOR (3 downto 0)
to then be called in this fashion in a separate entity:
case i_SW is
when "1000" => -- data select 0
--doesn't matter ;
--doesn't matter ;
This code is supposed to read the switch values and store it in the STD_LOGIC_VECTOR and then read it for the case statement. For example, if SW12 was flicked on I would expect the vector to hold "1000" and so it would go into that case.
I am wondering whether I have written this in the incorrect format and there's a different way to do it? Should I store it in an array and the declare that array in the port map to then use in other entities?
Thank you
EDIT: When I simulate the code it shows me that i_SW is 'U' which I believe means uninitialized but that is probably just a problem with my testbench.
Upvotes: 0
Views: 888
Reputation: 29618
The vector is declared with downto
, so the order of elements is 3,2,1,0 and "1000"
corresponds to SW15, not SW12.
Also, the switches may be low-active, a lot of development boards are wired like this -- then you'd have to invert the values as well.
Upvotes: 1