wkun 发表于 2014-3-18 11:23:27

std_logic_vector();括号内只有一个数,难道是个函数吗?

小弟刚接触VHDL,
下面是一段ram初始化的程序,已经在用,无误。
但是,以前见到的std_logic_vector()括号内是 **DOWNTO**,下面这个用法不明白,请大神指导,多谢!!
function init_ram
                return memory_t is
                variable tmp : memory_t := (others => (others => '0'));
        begin
                for addr_pos in 0 to 2**ADDR_WIDTH - 1 loop
                        -- Initialize each address with the address itself
                        tmp(addr_pos) := std_logic_vector(to_unsigned(addr_pos, DATA_WIDTH));
                end loop;
                return tmp;
        end init_ram;       

philoman 发表于 2014-3-22 11:38:20

应该是写错了, 愿意是unsignedd到std_logic_vector的转换函数

wkun 发表于 2014-3-22 16:14:54

philoman 发表于 2014-3-22 11:38
应该是写错了, 愿意是unsignedd到std_logic_vector的转换函数

先谢谢了
页: [1]
查看完整版本: std_logic_vector();括号内只有一个数,难道是个函数吗?