VHDL:纯函数代码没有覆盖,但函数调用被覆盖

时间:2017-03-10 21:08:33

标签: vhdl code-coverage modelsim pure-function

我有以下VHDL代码:

pure function sInitSyncSupport( sState: TYPE_STATE; sCssi: TYPE_CSS_TO_SSM ) return TYPE_STATE is
    variable sStateOut:           TYPE_STATE;
begin
    sStateOut                     := sState;

    sStateOut.bAccWndOpen         := false;
    sStateOut.iCorrValue          := 0;
    sStateOut.nClockCorrected     := 3*sCssi.nSwAcceptanceWindowHalf + 1;
    sStateOut.nMsCountMax         := 0;

    return sStateOut;
end function sInitSyncSupport;

pure function sStartSync( sState: TYPE_STATE; sCssi: TYPE_CSS_TO_SSM; sFp2i: TYPE_FP2_TO_SSM; eState: TYPE_SSM_FSM ) return TYPE_STATE is
    variable sStateOut:           TYPE_STATE;
begin
    sStateOut                     := sState;

    sStateOut.nClock              := sCssi.nSwAcceptanceWindowHalf + sFp2i.nError + 1;
    sStateOut.nIntegrationCycle   := sFp2i.sPcf.nIntegrationCycle;
    sStateOut.uvMembershipComp    := sFp2i.sPcf.uvMembership;
    sStateOut.eState              := eState;

    sStateOut.bAccWndOpen         := true;
    sStateOut.nMsCountMax         := sState.nMsCount;

    return sStateOut;
end function sStartSync;

sync: process (bReset, uClk)
    variable s1:                   TYPE_STATE;
    variable s2:                   TYPE_STATE;
begin
    s1 := sInitSyncSupport( s, sCssi );
    s2 := sStartSync( s, sCssi, sFp2i, SW_SYNC );
end process sync;

行s1:=与纯函数sInitSyncSupport中的所有语句一样。

在ModelSim_10.1c生成的代码覆盖率报告中,行s2:= ...被覆盖了数十次,但纯函数sStartSync中的所有语句都显示为未覆盖。

有人知道为什么会这样吗?谢谢。

更新:

这是一个更完整的代码:

library IEEE;
  use IEEE.std_logic_1164.all;

library work;
   ...

entity SSM is
  port (
    bReset:                       in boolean;
    uClk:                         in std_ulogic;
    ...
    sFp2i:                        in TYPE_FP2_TO_SSM;
    sCssi:                        in TYPE_CSS_TO_SSM;
    ...
  );
end SSM;

library work;
   ...

architecture RTL of SSM is

  type TYPE_STATE is record
    auvAsyncMembershipComp:       TYPE_ASYNC_MS_COUNT_ARRAY;
    bAccWndOpen:                  boolean;
    bAccWndToClose:               boolean;
    bAppliedCorrection:           boolean;
    bFsmError:                    boolean;
    ...
  end record;

  constant CONST_TYPE_STATE_RESET: TYPE_STATE := (
    auvAsyncMembershipComp        => CONST_TYPE_ASYNC_MS_COUNT_ARRAY_RESET,
    bAccWndOpen                   => false,
    bAccWndToClose                => false,
    bAppliedCorrection            => false,
    bFsmError                     => false,
    ...
  );

  signal r:                       TYPE_STATE
  -- pragma synthesis_off
                                             := CONST_TYPE_STATE_RESET
  -- pragma synthesis_on
  ;

  ---------------------------------------------------------------------------
  -- Function: sInitSyncSupport
  ---------------------------------------------------------------------------
  -- Purpose:
  --   This function initializes the support registers for time difference
  --   capturing 
  ---------------------------------------------------------------------------
  pure function sInitSyncSupport( sState: TYPE_STATE; sCssi: TYPE_CSS_TO_SSM ) return TYPE_STATE is
  ---------------------------------------------------------------------------
    variable sStateOut:           TYPE_STATE;
  begin
    sStateOut                     := sState; -- !!! all lines are covered
    sStateOut.bAccWndOpen         := false;
    sStateOut.iCorrValue          := 0;
    sStateOut.nClockCorrected     := 3*sCssi.nSwAcceptanceWindowHalf + 1;
    sStateOut.nMsCountMax         := 0;
    return sStateOut;
  end function sInitSyncSupport;

  ---------------------------------------------------------------------------
  -- Function: sStartSync
  ---------------------------------------------------------------------------
  -- Purpose:
  --   This function initializes the clock synchronization registers 
  ---------------------------------------------------------------------------
  pure function sStartSync( sState: TYPE_STATE; sCssi: TYPE_CSS_TO_SSM; sFp2i: TYPE_FP2_TO_SSM; eState: TYPE_SSM_FSM ) return TYPE_STATE is
  ---------------------------------------------------------------------------
    variable sStateOut:           TYPE_STATE;
  begin
    sStateOut                     := sState; -- !!! NONE of the lines are covered
    sStateOut.nClock              := sCssi.nSwAcceptanceWindowHalf + sFp2i.nError + 1;
    sStateOut.nIntegrationCycle   := sFp2i.sPcf.nIntegrationCycle;
    sStateOut.uvMembershipComp    := sFp2i.sPcf.uvMembership;
    sStateOut.eState              := eState;
    sStateOut.bAccWndOpen         := true;
    sStateOut.nMsCountMax         := sState.nMsCount;
    return sStateOut;
  end function sStartSync;

begin

  sync: process (bReset, uClk)
    variable s:                   TYPE_STATE;
    variable v:                   TYPE_VAR;
  begin
    if (bReset) then
      r                           <= CONST_TYPE_STATE_RESET;
    elsif ((uClk = '1') and uClk'event) then
      s                           := r;

      v                           := CONST_TYPE_VAR_RESET;
      v.bMembershipExceedsMax     := (r.bNextMembershipExceedsMax and (r.nClock >= sFp2i.nError));
      v.bInScheduleFrame          := (r.bNextInScheduleFrame and (r.nClock >= sFp2i.nError));
      v.bOutOfScheduleFrame       := (r.bNextOutOfScheduleFrame or (r.bNextInScheduleFrame and not v.bInScheduleFrame));

      s.nTimer      := nDecNoWrap( r.nTimer, 1 );
      s.bTimerEvent := (r.nTimer = 1);
      s             := sInitSyncSupport( s, sCssi );           -- !!! covered
      s             := sStartSync( s, sCssi, sFp2i, SW_SYNC ); -- !!! covered, but content of sStartSync not covered

      r                           <= s;
    end if;
  end process sync;

  sCsso                           <= r.sCsso;
  sSdo                            <= r.sSdo;
  sScho                           <= r.sScho;
  sPfgo                           <= r.sPfgo;
  bFsmErro                        <= r.bFsmError;

end RTL;

我标有!!!敏感的线条。非常感谢你。

0 个答案:

没有答案