📄 mms.vhd
字号:
variable EdgeDetect : boolean; begin if (not CHECK_ON) or (SETUP = 0 ns and HOLD = 0 ns) then wait; end if; if SETUP + HOLD <= 0 ns then assert FALSE report "Impossible check on " & PATH & ". Setup : " & ToString(SETUP) & ". Hold : " & ToString(HOLD) severity warning; wait; end if; SkipInitProblems : loop wait on Ref until (EDGE = RISING and rising_edge(Ref)) or (EDGE = FALLING and falling_edge(Ref)); -- nothing before first edge of Ref LastEdge := now; if HOLD >= 0 ns then exit when Data'event or Data'last_event > 0 ns; else exit when DelayedData'event or DelayedData'last_event > 0 ns; end if; end loop SkipInitProblems; Infinite : loop EdgeDetect := (EDGE = RISING and rising_edge(Ref)) or (EDGE = FALLING and falling_edge(Ref)); -------------------- if SETUP > 0 ns and HOLD >= 0 ns and EdgeDetect then DeltaT := Data'last_event; assert not(DeltaT <= SETUP) report "Setup violation on " & PATH & " at time " & ToString(now) & ". Observed : " & ToString(DeltaT) & ". Setup : " & ToString(SETUP) severity warning; end if; if HOLD > 0 ns and SETUP >= 0 ns and Data'event then DeltaT := now - LastEdge; assert not(DeltaT <= HOLD) report "Hold violation on " & PATH & " at time " & ToString(now) & ". Observed : " & ToString(DeltaT) & ". Hold : " & ToString(HOLD) severity warning; end if; -------------------- if SETUP < 0 ns and Data'event then DeltaT := now - LastEdge; assert not(-SETUP <= DeltaT and DeltaT <= HOLD) report "Timing violation on " & PATH & " at time " & ToString(now) & ". Observed : " & ToString(DeltaT) & ". Setup : " & ToString(SETUP) & ". Hold : " & ToString(HOLD) severity warning; end if; -- nothing if no data event -------------------- if HOLD < 0 ns and EdgeDetect then DeltaT := HOLD - DelayedData'last_event; assert not(-SETUP <= DeltaT and DeltaT <= HOLD) report "Timing violation on " & PATH & " at time " & ToString(now) & ". Observed : " & ToString(DeltaT) & ". Setup : " & ToString(SETUP) & ". Hold : " & ToString(HOLD) severity warning; end if; -- nothing if no edge detected -------------------- if EdgeDetect then LastEdge := now; end if; wait on Ref, Data; end loop Infinite; end SetupHoldCheck; -- procedure -------------------------------------------- procedure SetupHoldCheck ( signal Data : std_logic_vector; signal Ref : std_ulogic; constant EDGE : edge_type := RISING; constant SETUP, HOLD : time := 0 ns; constant PATH : string := ""; signal DelayedData : std_logic_vector) is -- DelayedData must be set to Data'Delayed(abs(HOLD)) variable LastEdge : time := 0 ns; variable DeltaT : time; variable EdgeDetect : boolean; begin if (not CHECK_ON) or (SETUP = 0 ns and HOLD = 0 ns) then wait; end if; if SETUP + HOLD <= 0 ns then assert FALSE report "Impossible check on " & PATH & ". Setup : " & ToString(SETUP) & ". Hold : " & ToString(HOLD) severity warning; wait; end if; SkipInitProblems : loop wait on Ref until (EDGE = RISING and rising_edge(Ref)) or (EDGE = FALLING and falling_edge(Ref)); -- nothing before first edge of Ref LastEdge := now; if HOLD >= 0 ns then exit when Data'event or Data'last_event > 0 ns; else exit when DelayedData'event or DelayedData'last_event > 0 ns; end if; end loop SkipInitProblems; Infinite : loop EdgeDetect := (EDGE = RISING and rising_edge(Ref)) or (EDGE = FALLING and falling_edge(Ref)); -------------------- if SETUP > 0 ns and HOLD >= 0 ns and EdgeDetect then DeltaT := Data'last_event; assert not(DeltaT <= SETUP) report "Setup violation on " & PATH & " at time " & ToString(now) & ". Observed : " & ToString(DeltaT) & ". Setup : " & ToString(SETUP) severity warning; end if; if HOLD > 0 ns and SETUP >= 0 ns and Data'event then DeltaT := now - LastEdge; assert not(DeltaT <= HOLD) report "Hold violation on " & PATH & " at time " & ToString(now) & ". Observed : " & ToString(DeltaT) & ". Hold : " & ToString(HOLD) severity warning; end if; -------------------- if SETUP < 0 ns and Data'event then DeltaT := now - LastEdge; assert not(-SETUP <= DeltaT and DeltaT <= HOLD) report "Timing violation on " & PATH & " at time " & ToString(now) & ". Observed : " & ToString(DeltaT) & ". Setup : " & ToString(SETUP) & ". Hold : " & ToString(HOLD) severity warning; end if; -- nothing if no data event -------------------- if HOLD < 0 ns and EdgeDetect then DeltaT := HOLD - DelayedData'last_event; assert not(-SETUP <= DeltaT and DeltaT <= HOLD) report "Timing violation on " & PATH & " at time " & ToString(now) & ". Observed : " & ToString(DeltaT) & ". Setup : " & ToString(SETUP) & ". Hold : " & ToString(HOLD) severity warning; end if; -- nothing if no edge detected -------------------- if EdgeDetect then LastEdge := now; end if; wait on Ref, Data; end loop Infinite; end SetupHoldCheck; -- procedure ------------------------------------- procedure CondSetupHoldCheck ( signal Data : std_ulogic; signal Ref : std_ulogic; constant EDGE : edge_type := RISING; constant SETUP, HOLD : time := 0 ns; constant PATH : string := ""; signal DelayedData : std_ulogic; signal EN_CHECKING : boolean) is variable LastEdge : time; variable DeltaT : time; variable EdgeDetect : boolean; begin if (not CHECK_ON) or (SETUP = 0 ns and HOLD = 0 ns) then wait; end if; if SETUP + HOLD <= 0 ns then assert FALSE report "Impossible check on " & PATH & ". Setup : " & ToString(SETUP) & ". Hold : " & ToString(HOLD) severity warning; wait; end if; SkipInitProblems : loop wait on Ref until (EDGE = RISING and rising_edge(Ref)) or (EDGE = FALLING and falling_edge(Ref)); -- nothing before first edge of Ref LastEdge := now; wait for SETUP; if HOLD >= 0 ns then exit when Data'event or Data'last_event > 0 ns; else exit when DelayedData'event or DelayedData'last_event > 0 ns; end if; end loop SkipInitProblems; Infinite : loop EdgeDetect := (EDGE = RISING and rising_edge(Ref)) or (EDGE = FALLING and falling_edge(Ref)); if EN_CHECKING then -------------------- if SETUP > 0 ns and HOLD >= 0 ns and EdgeDetect then DeltaT := Data'last_event; assert not(DeltaT <= SETUP) report "Setup violation on " & PATH & " at time " & ToString(now) & ". Observed : " & ToString(DeltaT) & ". Setup : " & ToString(SETUP) severity warning; end if; if HOLD > 0 ns and SETUP >= 0 ns and Data'event then DeltaT := now - LastEdge; assert not(DeltaT <= HOLD) report "Hold violation on " & PATH & " at time " & ToString(now) & ". Observed : " & ToString(DeltaT) & ". Hold : " & ToString(HOLD) severity warning; end if; -------------------- if SETUP < 0 ns and Data'event then DeltaT := now - LastEdge; assert not(-SETUP <= DeltaT and DeltaT <= HOLD) report "Timing violation on " & PATH & " at time " & ToString(now) & ". Observed : " & ToString(DeltaT) & ". Setup : " & ToString(SETUP) & ". Hold : " & ToString(HOLD) severity warning; end if; -- nothing if no data event -------------------- if HOLD < 0 ns and EdgeDetect then DeltaT := HOLD - DelayedData'last_event; assert not(-SETUP <= DeltaT and DeltaT <= HOLD) report "Timing violation on " & PATH & " at time " & ToString(now) & ". Observed : " & ToString(DeltaT) & ". Setup : " & ToString(SETUP) & ". Hold : " & ToString(HOLD) severity warning; end if; -- nothing if no edge detected -------------------- end if; if EdgeDetect then LastEdge := now; end if; wait on Ref, Data; end loop Infinite; end CondSetupHoldCheck; -- procedure ------------------------------------- procedure CondSetupHoldCheck (signal Data : std_logic_vector; signal Ref : std_ulogic; constant EDGE : edge_type := RISING; constant SETUP, HOLD : time := 0 ns; constant PATH : string := ""; signal DelayedData : std_logic_vector; signal EN_CHECKING : boolean) is variable LastEdge : time; variable DeltaT : time; variable EdgeDetect : boolean; begin if (not CHECK_ON) or (SETUP = 0 ns and HOLD = 0 ns) then wait; end if; if SETUP + HOLD <= 0 ns then assert FALSE report "Impossible check on " & PATH & ". Setup : " & ToString(SETUP) & ". Hold : " & ToString(HOLD) severity warning; wait; end if; SkipInitProblems : loop wait on Ref until (EDGE = RISING and rising_edge(Ref)) or (EDGE = FALLING and falling_edge(Ref)); -- nothing before first edge of Ref LastEdge := now; if HOLD >= 0 ns then exit when Data'event or Data'last_event > 0 ns; else exit when DelayedData'event or DelayedData'last_event > 0 ns; end if; end loop SkipInitProblems; Infinite : loop EdgeDetect := (EDGE = RISING and rising_edge(Ref)) or (EDGE = FALLING and falling_edge(Ref)); if EN_CHECKING then -------------------- if SETUP > 0 ns and HOLD >= 0 ns and EdgeDetect then DeltaT := Data'last_event; assert not(DeltaT <= SETUP) report "Setup violation on " & PATH & " at time " & ToString(now) & ". Observed : " & ToString(DeltaT) & ". Setup : " & ToString(SETUP) severity warning; end if; if HOLD > 0 ns and SETUP >= 0 ns and Data'event then DeltaT := now - LastEdge; assert not(DeltaT <= HOLD) report "Hold violation on " & PATH & " at time " & ToString(now) & ". Observed : " & ToString(DeltaT) & ". Hold : " & ToString(HOLD) severity warning; end if; -------------------- if SETUP < 0 ns and Data'event then DeltaT := now - LastEdge; assert not(-SETUP <= DeltaT and DeltaT <= HOLD) report "Timing violation on " & PATH & " at time " & ToString(now) & ". Observed : " & ToString(DeltaT) & ". Setup : " & ToString(SETUP) & ". Hold : " & ToString(HOLD) severity warning; end if; -- nothing if no data event -------------------- if HOLD < 0 ns and EdgeDetect then DeltaT := HOLD - DelayedData'last_event; assert not(-SETUP <= DeltaT and DeltaT <= HOLD) report "Timing violation on " & PATH & " at time " & ToString(now) & ". Observed : " & ToString(DeltaT) & ". Setup : " & ToString(SETUP) & ". Hold : " & ToString(HOLD) severity warning; end if; -- nothing if no edge detected -------------------- end if; if EdgeDetect then LastEdge := now; end if; wait on Ref, Data; end loop Infinite; end CondSetupHoldCheck; -- procedure ----------------------------------------------------------- procedure PulseCheck ( signal Pin : std_ulogic; constant LEVEL : std_ulogic; constant WIDTH : time := 0 ns; constant SENSE : sense_type := MINIMUM; constant PATH : string := "") is variable PreviousEvent : time := 0 ns; variable Detection : boolean := FALSE; variable DeltaT : time; begin if (not CHECK_ON) or WIDTH = 0 ns then wait; end if; if WIDTH < 0 ns then assert FALSE report "Impossible check on " & PATH & ". WIDTH : " & ToString(WIDTH) severity warning; wait; end if; wait on Pin; -- no check before first event on Pin loop DeltaT := now - PreviousEvent; case SENSE is when MINIMUM => assert not(Detection and (DeltaT < WIDTH)) report "Min pulse width violation on " & PATH & " for level " & ToString(LEVEL) & " at time " & ToString(now) & ". Observed : " & ToString(DeltaT) & ". Required : " & ToString(WIDTH) severity warning; when MAXIMUM => assert not(Detection and (DeltaT > WIDTH)) report "Max pulse width violation on " & PATH & " for level " & ToString(LEVEL) & " at time " & ToString(now) & ". Observed : " & ToString(DeltaT) & ". Required : " & ToString(WIDTH) severity warning; end case; PreviousEvent := now; Detection := (Pin = LEVEL) and (PreviousEvent /= 0 ns); wait on Pin; end loop; -- Infinite loop end PulseCheck; -- procedure ----------------------------------------------------------- -- function CurveValue : used by CalcDelay function CurveValue ( REF : curve_parameter; VALUE : real) return real is variable Res : real := 0.0; begin for i in Ref'high downto Ref'low loop Res := Ref(i) + Res*Value; end loop; return Res; end CurveValue; ----------------------------------------------------------- function CalcDelay ( BASE : time; TECH : technology; T : temperature; V : voltage; PROCES : proces_type; LOAD : capacitance := 50 pF) return time is constant CAPADEFAULT : capacitance := 50 pF; variable Kp : real; begin case PROCES is when WORST => Kp := TECH.KpMax; when BEST => Kp := TECH.KpMin; when TYPICAL => Kp := 1.0; end case; return ((BASE + 1 ns * ((LOAD - CAPADEFAULT)/ (TECH.LoadSlope * 1 pF) ) ) * CurveValue(TECH.TCurve, real(T / 1 Celsius) ) * CurveValue(TECH.VCurve, real(0.001 * (V / 1 mV) ) ) * Kp) / (TECH.KpMax * CurveValue(TECH.TCurve, real(125 Celsius / 1 Celsius) ) * CurveValue(TECH.VCurve, real(0.001 * (4500 mV / 1 mV) ) ) ); end CalcDelay; ----------------------------------------------------------- function TpDelay (NewData : std_ulogic; TPLH
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -