首页 > 解决方案 > VHDL:整数到 std_logic_vector 转换的问题

问题描述

在我的代码int_mm_add中被定义为 aninteger并且mm_add被定义为std_logic_vector(13 downto 0).

我尝试使用以下方法从整数转换为 std_logic_vector:

mm_add <= std_logic_vector(to_unsigned(int_mm_add, mm_add'length));

int_mm_add是使用其他一些信号计算得出的。整数计算似乎有效,但转换无效,例如在模拟时:

int_mm_add = 1 converts to mm_add = "0000000000000X"
int_mm_add = 2 converts to mm_add = "000000000000X0"

附上我认为相关的代码部分和波形快照:

process(clk, rst)
    begin
        if rst = '1' then
            "something"
        elsif rising_edge(clk) then
            int_mm_add <= ((v_cnt / 8) * (2**8)) + (h_cnt / 8);
            mm_add <= std_logic_vector(to_unsigned(((v_cnt / 8) * (2**8)) + (h_cnt / 8), mm_add'length));
        end if;
end process;

显示转换问题的波形

标签: vhdlmodelsim

解决方案


推荐阅读