在VHDL中使用new
作为访问类型时,在使用deallocate()
之前,我必须new
吗?
我知道您需要使用deallocate()
来防止在完成访问类型后泄露,我不确定在new
之前是否使用它是多余的还是需要的。
e.g。
testAccess : process
type string_ptr is access string;
variable tmpString : string_ptr;
variable loopNum : natural := 0;
begin
tmpString := new string'("Test Loop: " & to_string(loopNum));
report "String = " & tmpString.all;
deallocate(tmpString); --is this neccessary?
tmpString := new string'("New String Usage");
report "String = " & tmpString.all;
loopNum := loopNum + 1;
deallocate(tmpString); --is this neccessary? (assuming we always loop back to first new)
wait for 1 us;
end process;