1
我有一個VHDL保護類型,它實現了初始化函數或過程。我應該在VHDL中調用受保護類型的初始化函數?
這裏是我的代碼有一個初始化過程:
type T_SIM_STATUS is protected
procedure init;
procedure fail(Message : in STRING := "") ;
procedure simAssert(condition : BOOLEAN; Message : STRING := "") ;
procedure simReport;
end protected;
type T_SIM_STATUS is protected body
variable NotImplemented : BOOLEAN := TRUE;
variable Passed : BOOLEAN := TRUE;
procedure init is
begin
NotImplemented := FALSE;
end procedure;
procedure fail(Message : in STRING := "") is
begin
if (Message'length > 0) then
report Message severity error;
end if;
Passed := FALSE;
end procedure;
procedure simAssert(condition : BOOLEAN; Message : STRING := "") is
begin
if (condition = FALSE) then
fail(Message);
end if;
end procedure;
procedure simReport is
variable l : LINE;
begin
write(l, STRING'("SIMULATION RESULT = "));
if (NotImplemented = TRUE) then
write(l, STRING'("NOT IMPLEMENTED"));
elsif (Passed = TRUE) then
write(l, STRING'("PASSED"));
else
write(l, STRING'("FAILED"));
end if;
end procedure;
end protected body;
shared variable simStatus : T_SIM_STATUS;
應該在哪裏我叫init
程序?
我目前的解決方案在測試平臺的架構體一個單獨的進程調用init
:
architecture rtl of test is
-- ...
begin
procInit : process
begin
simStatus.init;
wait;
end process;
procGenerator : process
begin
-- generate stimuli
wait;
end process;
procTester : process
begin
-- check results by using simStatus.simAssert
simStatus.simReport;
wait;
end process;
end architecture;
有沒有更好的辦法呢?基於您的代碼