-- voltage. -- 2003-10-20 1.2 Mentor Graphics Changed ac_mag default to 0.0 ------------------------------------------------------------------------------- library IEEE; use IEEE.MATH_REAL.all; --use IEEE.STD_LOGIC_1164.all; -- Use IEEE natures and packages use IEEE.ELECTRICAL_SYSTEMS.all; library VNOISY; use VNOISY.MATHS.all; entity Vnoisy is generic ( freq : real; -- frequency [Hertz] amplitude : voltage; -- amplitude [Volts] vnoise_rms : Voltage; -- Amplitude noise phinoise_rms : REAL; -- phase noise TSAMPL : REAL; -- uncorrelated values after tsampl [s] phase : real := 0.0; -- initial phase [Degrees] offset : voltage := 0.0; -- DC value [Volts] df : real := 0.0; -- damping factor [1/second] ac_mag : voltage := 0.0; -- AC magnitude [Volts] ac_phase : real := 0.0; -- AC phase [Degrees] seed1_ini : positive:= 354; -- Seed1 for random number calculations seed2_ini : positive:= 30345 -- Seed2 for random number calculations ); port ( terminal pos, neg : electrical); begin assert TSAMPL > 0.0 report "TSAMPL > 0.0 required."; end entity Vnoisy; ------------------------------------------------------------------------------- -- Ideal Architecture ------------------------------------------------------------------------------- architecture default of Vnoisy is -- Declare Branch Quantities quantity v across i through pos to neg; -- Declare Quantity for Phase in radians (calculated below) quantity phase_rad : real; -- Declare Quantity in frequency domain for AC analysis quantity ac_spec : real spectrum ac_mag, math_2_pi*ac_phase/360.0; --noise quantity voltage_off : real := 0.0; quantity phase_off : real := 0.0; signal voltage_offs:real:= 0.0; signal phase_offs:real:= 0.0; begin -- Convert phase to radians -- Declare variables needed for noise process is variable v_off : real := 0.0; variable p_off : real := 0.0; variable sigma_v : real := vnoise_rms; variable sigma_p : real := phinoise_rms; variable mu : real := 0.0; variable seed1 : positive := seed1_ini; variable seed2 : positive := seed2_ini; begin gaussian_pos(seed1,seed2,mu,sigma_v,v_off); gaussian_pos(seed1,seed2,mu,sigma_p,p_off); voltage_offs <= v_off; phase_offs <= p_off; wait for TSAMPL; end process; phase_off == phase_offs'ramp(TSAMPL); voltage_off == voltage_offs'ramp(TSAMPL); phase_rad == math_2_pi *(freq * NOW + phase / 360.0 + phase_off/360.0); if domain = quiescent_domain or domain = time_domain use v == offset + amplitude * sin(phase_rad) * EXP(-NOW * df) + voltage_off; else v == ac_spec; -- used for Frequency (AC) analysis end use; end architecture default; ------------------------------------------------------------------------------- -- Copyright (c) 2001 Mentor Graphics Corporation -------------------------------------------------------------------------------