1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
|
-- Copyright (C) 2000-2002 The University of Cincinnati.
-- All rights reserved.
-- This file is part of VESTs (Vhdl tESTs).
-- UC MAKES NO REPRESENTATIONS OR WARRANTIES ABOUT THE SUITABILITY OF THE
-- SOFTWARE, EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
-- IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE,
-- OR NON-INFRINGEMENT. UC SHALL NOT BE LIABLE FOR ANY DAMAGES SUFFERED BY
-- LICENSEE AS A RESULT OF USING, RESULT OF USING, MODIFYING OR
-- DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES.
-- By using or copying this Software, Licensee agrees to abide by the
-- intellectual property laws, and all other applicable laws of the U.S.,
-- and the terms of this license.
-- You may modify, distribute, and use the software contained in this
-- package under the terms of the "GNU GENERAL PUBLIC LICENSE" version 2,
-- June 1991. A copy of this license agreement can be found in the file
-- "COPYING", distributed with this archive.
-- You should have received a copy of the GNU General Public License
-- along with VESTs; if not, write to the Free Software Foundation,
-- Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-- ---------------------------------------------------------------------
--
-- $Id: peak_detector.ams,v 1.1 2002-03-27 22:11:19 paw Exp $
-- $Revision: 1.1 $
--
-- ---------------------------------------------------------------------
-- Change the values of res. and cap for various freq.'s
--*************************************************************************
-- Conceptual Level Model of a Peak Detector
-- VHDL-AMS implementation
-- Developed at Distributed Processing Laboratory
-- University of Cincinnati
-- by Murthy Revanuru on October 27, 2000.
--*************************************************************************
--#########################################################################
-- R2= 10.0e3
-- --------/\/\/\----------
-- | |\ |
-- .-------|-\ Diode |
-- | \________|\___|_____o V_out
-- 10K | / |/ |
-- V_in o---^^^-|+/ |--------
-- R1 |/ | |
-- _____ \
-- Cap _____ / Res
-- | \
-- | /
-- | |
-- --------- -----
-- --- -
--
--#########################################################################
PACKAGE electricalsystem IS
NATURE electrical IS real ACROSS real THROUGH ground reference;
FUNCTION SIN(X:real) RETURN real;
FUNCTION COS(X:real) RETURN real;
FUNCTION EXP(X:real) RETURN real;
FUNCTION SQRT(X:real) RETURN real;
END PACKAGE electricalsystem;
---------------------------- Diode -----------------------------
use work.electricalsystem.all;
entity diode is
port (terminal t21,t22:electrical);
end diode;
architecture behavior of diode is
quantity vd across id through t21 to t22;
constant k:real:=0.02586; -- thermal voltage
constant iss:real:=1.8104e-15;
constant gmin:real:=1.0e-12;
begin
if (vd >= (-5.0*k)) use
id == iss * (exp(vd/k)-1.0) + vd*gmin;
elsif (vd<-5.0*k) use
id == -1.0*iss + vd*gmin;
end use;
end architecture behavior;
------------------------ RESISTOR---------------------------
use work.electricalsystem.all;
entity resistor is
generic(res :real:=1.0 );
port(terminal r_in,r_out: electrical);
end entity resistor;
architecture behav of resistor is
quantity vr across ir through r_in to r_out;
begin
vr==ir*res;
end architecture behav;
------------------------ CAPACITOR---------------------------
use work.electricalsystem.all;
entity capacitor is
generic(cap :real:=1.0;v_init:real:=0.0);
port(terminal c_in,c_out: electrical);
end entity capacitor;
architecture behav of capacitor is
quantity vc across ic through c_in to c_out;
begin
break vc=>v_init;
ic==cap*vc'dot;
end architecture behav;
------------------------- OP AMP -------------------------
use work.electricalsystem.all;
entity op_amp is
port(terminal inverting_ip,non_inverting_ip,output :electrical);
end entity op_amp;
architecture struct of op_amp is
Constant R_in:real:=1.0e6;
Constant R_out:real:=1.0;
terminal t1:electrical;
quantity v_in across i_in through non_inverting_ip to inverting_ip;
quantity v_gain across i_gain through t1 to ground;
quantity v_drop across i_drop through t1 to output;
BEGIN
V_in==i_in*R_in;
V_gain==V_in*(100.0);
V_drop==i_drop*R_out;
end architecture struct;
---------------------- PEAK DETECTOR ---------------------
use work.electricalsystem.all;
entity peak_detector is
port (terminal v_in,v_out: electrical);
end entity peak_detector;
architecture struct of peak_detector is
component capacitor is
generic(cap :real:=1.0;v_init:real:=0.0);
port(terminal c_in,c_out: electrical);
end component;
for all: capacitor use entity work.capacitor(behav);
component resistor is
generic(res :real:=1.0 );
port(terminal r_in,r_out: electrical);
end component;
for all: resistor use entity work.resistor(behav);
component diode is
port (terminal t21,t22:electrical);
end component;
for all: diode use entity work.diode(behavior);
component op_amp is
port(terminal inverting_ip,non_inverting_ip,output :electrical);
end component;
for all:op_amp use entity work.op_amp(struct);
terminal t11,t12,t13,t14: electrical;
begin
D1: diode port map(t12,t13);
R1: resistor generic map(10.0e3)
port map(v_in,T11);
R2: resistor generic map(10.0e3)
port map(T13,T14);
Rs: resistor generic map(1.0e-3)
port map(T13,V_out);
C1: capacitor generic map(1.0e-9)
port map(T13,ground);
op: op_amp port map(inverting_ip=>T14,non_inverting_ip=>T11,output=>T12);
end struct;
-- ################### TEST WAVE FORMS #######################
-- Sine Source
--------------
use work.electricalsystem.all;
ENTITY sineSource IS
generic (amp:real:=1.0; freq:real:=1.0);
PORT( TERMINAL ta2,tb2 : electrical);
END sineSource;
ARCHITECTURE sinebehavior OF sineSource IS
quantity Vsine across isine through ta2 to tb2;
BEGIN
Vsine ==(amp*sin((2.0*22.0/7.0*freq)*real(time'pos(now))*1.0e-15));
END ARCHITECTURE sinebehavior;
-- AM Source
--------------
use work.electricalsystem.all;
ENTITY amSource IS
generic (amp:real:=1.0; wc:real:=1.0;wm:real:=1.0);
PORT( TERMINAL ta2,tb2 : electrical);
END amSource;
ARCHITECTURE ambehavior OF amSource IS
quantity V_am across i_am through ta2 to tb2;
BEGIN
V_am == (amp*cos((2.0*22.0/7.0*wc)*real(time'pos(now))*1.0e-15)) +(amp/2.0*cos((2.0*22.0/7.0*(wc+wm))*real(time'pos(now))*1.0e-15)) +
(cos((2.0*22.0/7.0*(wc-wm))*real(time'pos(now))*1.0e-15));
END ARCHITECTURE ambehavior;
------------------------- Test bench -------------------------
use work.electricalsystem.all;
entity rf_test_bench is
end entity rf_test_bench;
architecture basic of rf_test_bench is
terminal t1,t2,t3,t4 : electrical;
----> Components are declared here
component peak_detector is
port(terminal v_in,v_out :electrical);
end component;
for all: peak_detector use entity work.peak_detector(struct);
COMPONENT sineSource IS
generic (amp:real:=1.0; freq:real:=1.0);
PORT( TERMINAL ta2,tb2 : electrical);--Interface ports.
end COMPONENT;
for all : sinesource use entity work.sinesource(sinebehavior);
quantity volt_op across i_op through t4 to ground;
begin
op_1 : volt_op==i_op*10000.0;
peak_det : peak_detector port map(t1,t4);
sine_ip : sinesource generic map(1.0,455.0e3)
port map(t1,ground);
end architecture basic;
|