VHDL常量初始化

发布于 2024-09-09 03:06:52 字数 155 浏览 1 评论 0原文

我正在研究一些 VHDL 代码,对于常量的初始化,它表示如下:

constant address: integer := 16#8E#;

我以前从未见过这种定义。有谁知道这怎么翻译 到一个普通的十进制数?

谢谢!

I am just studying some VHDL code and for the initialisation of a constant it says the following:

constant address: integer := 16#8E#;

I have never seen this kind of definition before. Does anybody know how this translates
to an ordinary number in decimal?

Thanks!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

一抹苦笑 2024-09-16 03:06:53

16#8E# 表示以 16 为基数的 8E(即十六进制)。对于二进制,您可以为相同的数字编写 2#10001110#。一旦你知道了这一点,获得十进制版本应该很容易。

16#8E# means 8E in base 16 (ie hexidecimal). For binary, you could write 2#10001110# for the same number. Once you know this, getting the decimal version should be easy.

毁虫ゝ 2024-09-16 03:06:52

要进一步扩展(如果您有 VHDL LRM,您可以阅读第 13.4.2 节中的详细信息),您可以在第一个 # 之前放置任何底数(2 到 16 之间),并在后面放置一个指数第二个#。您还可以将 _ 放入单独的数字组中。

指数始终以 10 为底数表示,并且不能为负数。
示例(VHDL 突出显示还有一些不足之处!)

entity test_numbers is
end entity test_numbers;
architecture a1 of test_numbers is
begin 
    process is
    begin  -- process
    report integer'image(16#FF#);  -- 255
    report integer'image(10#1_000#);  -- 1000
    report integer'image(10#1#e3);  -- 1000 another way
    report integer'image(2#1#e10);  -- 1024
    report integer'image(4#100#);  -- 16
    wait;
    end process;
end architecture a1;

报告:

# Loading work.test_numbers(a1)
# ** Note: 255
#    Time: 0 ns  Iteration: 0  Instance: /test_numbers
# ** Note: 1000
#    Time: 0 ns  Iteration: 0  Instance: /test_numbers
# ** Note: 1000
#    Time: 0 ns  Iteration: 0  Instance: /test_numbers
# ** Note: 1024
#    Time: 0 ns  Iteration: 0  Instance: /test_numbers
# ** Note: 16
#    Time: 0 ns  Iteration: 0  Instance: /test_numbers

To expand further (if you have the VHDL LRM, you can read the gory details in section 13.4.2) you can put any base (between 2 and 16 inclusive) before the first # and an exponent after the second #. You can also put _s in to separate sets of numbers.

The exponent is always expressed in base 10 and cannot be negative.
Example (the VHDL highlighting leaves a little to be desired!)

entity test_numbers is
end entity test_numbers;
architecture a1 of test_numbers is
begin 
    process is
    begin  -- process
    report integer'image(16#FF#);  -- 255
    report integer'image(10#1_000#);  -- 1000
    report integer'image(10#1#e3);  -- 1000 another way
    report integer'image(2#1#e10);  -- 1024
    report integer'image(4#100#);  -- 16
    wait;
    end process;
end architecture a1;

reports:

# Loading work.test_numbers(a1)
# ** Note: 255
#    Time: 0 ns  Iteration: 0  Instance: /test_numbers
# ** Note: 1000
#    Time: 0 ns  Iteration: 0  Instance: /test_numbers
# ** Note: 1000
#    Time: 0 ns  Iteration: 0  Instance: /test_numbers
# ** Note: 1024
#    Time: 0 ns  Iteration: 0  Instance: /test_numbers
# ** Note: 16
#    Time: 0 ns  Iteration: 0  Instance: /test_numbers
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文