1
2-- Copyright (C) 2002 Morgan Kaufmann Publishers, Inc
3
4-- This file is part of VESTs (Vhdl tESTs).
5
6-- VESTs is free software; you can redistribute it and/or modify it
7-- under the terms of the GNU General Public License as published by the
8-- Free Software Foundation; either version 2 of the License, or (at
9-- your option) any later version.
10
11-- VESTs is distributed in the hope that it will be useful, but WITHOUT
12-- ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13-- FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
14-- for more details.
15
16-- You should have received a copy of the GNU General Public License
17-- along with VESTs; if not, write to the Free Software Foundation,
18-- Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
19
20library ieee;  use ieee.math_real.all;
21library ieee_proposed;  use ieee_proposed.electrical_systems.all;
22
23entity v_source is
24  generic ( DC : voltage := 1.0;        -- output peak amplitude
25            min_freq : real := 10.0;	-- minimum frequency for spectral source
26            max_freq : real := 1.0e4;	-- maximum frequency for spectral source
27            ac_mag : voltage := 1.0;    -- AC magnitude
28            ac_phase : real := 0.0 );   -- AC phase [degree]
29  port ( terminal pos, neg : electrical );
30end entity v_source;
31
32----------------------------------------------------------------
33
34architecture behavior of v_source is
35
36  function g (freq : real) return real is
37  begin
38    if (freq > min_freq and freq < max_freq) then
39      return 1.0;
40    else
41      return 0.0;
42    end if;
43  end function g;
44
45  quantity vout across iout through pos to neg;
46  -- declare quantity in frequency domain for AC analysis
47  quantity ac_spec : real spectrum ac_mag*g(frequency),
48		          math_2_pi*ac_phase/360.0;
49
50begin
51
52  if domain = quiescent_domain or domain = time_domain use
53    vout == DC;
54  else
55    vout == ac_spec;  -- used for frequency (AC) analysis
56  end use;
57
58end architecture behavior;
59