NewANADOLOGIC Hardware Academy is live: 240 free, AI-graded FPGA & SoC questions.Start learning

FPGA & VHDL KnowHow Series1 min read

FPGA Anadologic

๐๐ฎ๐ž๐ฌ๐ญ๐ข๐จ๐ง: Is it a problem to add all numeric_std, std_logic_arith and std_logic_unsigned packages in a module?

๐€๐ง๐ฌ๐ฐ๐ž๐ซ: Both the std_logic_arith and the numeric_std packages declare unsigned & signed types. When you use both packages and declare unsigned/signed signals, Vivado sees the conflict and gives error during synthesis with the messages:

[๐‘†๐‘ฆ๐‘›๐‘กโ„Ž 8-2361] ๐‘š๐‘ข๐‘™๐‘ก๐‘–๐‘๐‘™๐‘’ ๐‘‘๐‘’๐‘๐‘™๐‘Ž๐‘Ÿ๐‘Ž๐‘ก๐‘–๐‘œ๐‘›๐‘  ๐‘œ๐‘“ ๐‘ข๐‘›๐‘ ๐‘–๐‘”๐‘›๐‘’๐‘‘ ๐‘–๐‘›๐‘๐‘™๐‘ข๐‘‘๐‘’๐‘‘ ๐‘ฃ๐‘–๐‘Ž ๐‘š๐‘ข๐‘™๐‘ก๐‘–๐‘๐‘™๐‘’ ๐‘ข๐‘ ๐‘’ ๐‘๐‘™๐‘Ž๐‘ข๐‘ ๐‘’๐‘ ; ๐‘›๐‘œ๐‘›๐‘’ ๐‘Ž๐‘Ÿ๐‘’ ๐‘š๐‘Ž๐‘‘๐‘’ ๐‘‘๐‘–๐‘Ÿ๐‘’๐‘๐‘ก๐‘™๐‘ฆ ๐‘ฃ๐‘–๐‘ ๐‘–๐‘๐‘™๐‘’

Most prefer using numeric_std when working with arithmetic operations, especially if you need to define explicitly signed or unsigned numbers. If you are working with both signed and unsigned numbers in a module then numeric_std and unsigned/signed is the preferred way.

Sometimes in practice using std_logic_arith with std_logic_unsigned seems to be easier, since you donโ€™t need to declare extra signals typed unsigned or signed, but you can use arithmetic operations on std_logic_vector types.

Do not forget numeric_std is an IEEE standard, while std_logic_arith and std_logic_unsigned/signed are Synopsys packages, not IEEE standard packages.

What is your preference? ๐ง๐ฎ๐ฆ๐ž๐ซ๐ข๐œ_๐ฌ๐ญ๐ or ๐ฌ๐ญ๐_๐ฅ๐จ๐ ๐ข๐œ_๐š๐ซ๐ข๐ญ๐ก?

โ€œ๐‘บ๐’‰๐’‚๐’“๐’Š๐’๐’ˆ ๐’Œ๐’๐’๐’˜๐’๐’†๐’…๐’ˆ๐’† ๐’Š๐’” ๐’•๐’‰๐’† ๐’Ž๐’๐’”๐’• ๐’†๐’‡๐’‡๐’Š๐’„๐’Š๐’†๐’๐’• ๐’๐’†๐’‚๐’“๐’๐’Š๐’๐’ˆ ๐’Ž๐’†๐’•๐’‰๐’๐’…โ€

โ† All posts