这个VHDL代码设置的最大值和最小值是多少?对定点表示的解释会有所帮助

时间:2012-06-06 13:27:30

标签: vhdl

 constant MAX      : unsigned(18 downto 0) := "100" & x"0000";
 constant MIN      : unsigned(18 downto 0) := "001" & x"0000";

这个VHDL代码设置的最大值和最小值是多少?对定点表示的解释会有所帮助。

1 个答案:

答案 0 :(得分:4)

  • &运算符连接两个位向量"100"x"0000"(例如"00" & "11"等同于"0011")。
  • X"012345689ABCDEF"语法表示以下向量应解释为十六进制数字(例如X"0"实际为"0000"X"F""1111"X"0F"将是"00001111")。这允许您以更紧凑的方式编写位向量。

用于解释位矢量检查,例如http://en.wikipedia.org/wiki/Binary_numeral_system

对于十六进制数字的表示,请检查,例如http://en.wikipedia.org/wiki/Hexadecimal


编辑以澄清:我假设您使用的是unsigned包中的numeric_std类型。从该包的标题

This package defines numeric types and arithmetic functions
for use with synthesis tools. Two numeric types are defined:
-- > UNSIGNED: represents UNSIGNED number in vector form
-- > SIGNED: represents a SIGNED number in vector form
The base element type is type STD_LOGIC.
The leftmost bit is treated as the most significant bit.
Signed vectors are represented in two's complement form.

因此,您的MAX设置为2 ^ 18,而MIN设置为2 ^ 16。