小编eso*_*ton的帖子

高位设置时的 VHDL/GHDL 二进制 32 位写溢出

我有一个 VHDL 测试平台,我想将 32 位二进制字写入文件进行测试。下面是一个最小的、完整的、可验证的示例。

当使用 GHDL(下面的命令)执行时,会在指定的行产生溢出。如果该行被注释掉,则执行成功完成并写入文件。任何时候设置高位都会发生溢出。

library ieee;
use ieee.std_logic_1164.all;
use ieee.numeric_std.all;
use std.textio.all;
use std.env.stop;

entity u32_file_write is
end entity;

architecture rtl of u32_file_write is
    type intFileType is file of natural;
    file fh : intFileType;
begin
    run: process
        variable no_high_bit : std_logic_vector(31 downto 0) := x"7FFFFFFF";
        variable with_high_bit : std_logic_vector(31 downto 0) := x"FFFFFFFF";
    begin
        file_open(fh, "out.bin", write_mode);
        write(fh, to_integer(unsigned(no_high_bit)));
        write(fh, to_integer(unsigned(with_high_bit))); -- Overflow here.
        file_close(fh);
        stop;
    end process;
end architecture;
Run Code Online (Sandbox Code Playgroud)

我运行以下 GHDL 命令来运行 VHDL 代码(另存为u32_file_write.vhd): …

vhdl ghdl

2
推荐指数
1
解决办法
976
查看次数

标签 统计

ghdl ×1

vhdl ×1