
๐๐ฎ๐๐ฌ๐ญ๐ข๐จ๐ง: How can you assign integer literals (such as 24, 100, etc) to a std_logic_vector type signal in ๐๐๐๐?
๐๐ง๐ฌ๐ฐ๐๐ซ: Assigning integer literals directly to std_logic_vector or unsigned type signals is not allowed and you will get this error from Vivado:
[๐๐ฆ๐๐กโ 8-2774] ๐ก๐ฆ๐๐ ๐ ๐ก๐_๐๐๐๐๐_๐ฃ๐๐๐ก๐๐ ๐๐๐๐ ๐๐๐ก ๐๐๐ก๐โ ๐ค๐๐กโ ๐กโ๐ ๐๐๐ก๐๐๐๐ ๐๐๐ก๐๐๐๐
[๐๐ฆ๐๐กโ 8-2774] ๐ก๐ฆ๐๐ ๐ข๐๐ ๐๐๐๐๐ ๐๐๐๐ ๐๐๐ก ๐๐๐ก๐โ ๐ค๐๐กโ ๐กโ๐ ๐๐๐ก๐๐๐๐ ๐๐๐ก๐๐๐๐
You need conversion function defined in IEEE ๐๐๐๐๐๐๐_๐๐๐ package. You can assign an integer literal to a ๐ฌ๐ญ๐_๐ฅ๐จ๐ ๐ข๐_๐ฏ๐๐๐ญ๐จ๐ซ with โ๐ญ๐จ_๐ฎ๐ง๐ฌ๐ข๐ ๐ง๐๐โ function and โ๐ฌ๐ญ๐_๐ฅ๐จ๐ ๐ข๐_๐ฏ๐๐๐ญ๐จ๐ซโ type conversion.
๐ ๐๐๐๐๐ ๐๐ข๐_๐ย : ๐ ๐ก๐_๐๐๐๐๐_๐ฃ๐๐๐ก๐๐ (7 ๐๐๐ค๐๐ก๐ 0); ๐๐ข๐_๐ <= ๐ ๐ก๐_๐๐๐๐๐_๐ฃ๐๐๐ก๐๐(๐ก๐_๐ข๐๐ ๐๐๐๐๐(255, ๐๐ข๐_๐โ๐๐๐๐๐กโ)); โ ๐๐ข๐_๐ ๐๐๐ก๐ ๐๐ ๐ ๐๐๐๐๐ ๐ก๐ 255
But what if you try to assign an integer literal which is more than 8-bits? Then, Vivado trims the upper bits and assign only the lower 8-bits.
๐ ๐๐๐๐๐ ๐๐ข๐_๐ย : ๐ ๐ก๐_๐๐๐๐๐_๐ฃ๐๐๐ก๐๐ (7 ๐๐๐ค๐๐ก๐ 0); ๐๐ข๐_๐ <= ๐ ๐ก๐_๐๐๐๐๐_๐ฃ๐๐๐ก๐๐(๐ก๐_๐ข๐๐ ๐๐๐๐๐(511, ๐๐ข๐_๐โ๐๐๐๐๐กโ)); โ ๐๐ข๐_๐ ๐๐๐ก๐ ๐๐ ๐ ๐๐๐๐๐ ๐ก๐ 255
What is your method to assign integer literals to ๐ฌ๐ญ๐_๐ฅ๐จ๐ ๐ข๐_๐ฏ๐๐๐ญ๐จ๐ซ types?
Please share your thoughts in comment section.
โ๐บ๐๐๐๐๐๐ ๐๐๐๐๐๐๐ ๐๐ ๐๐ ๐๐๐ ๐๐๐๐ ๐๐๐๐๐๐๐๐๐ ๐๐๐๐๐๐๐๐ ๐๐๐๐๐๐ โ
