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
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
|
-- 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: inverter.ams,v 1.1 2002-03-27 22:11:18 paw Exp $
-- $Revision: 1.1 $
--
-- ---------------------------------------------------------------------
-- /**************************************************************************/
-- /* File: inverter.ams */
-- /**************************************************************************/
-- /* Author(s): Vishwashanth Kasula Reddy & Venkateswaran Krishna */
-- /* Date of creation: Mon Nov 30th 1998 */
-- /**************************************************************************/
--Roadmap:
----------
--This is a mixed signal model of an inverter... The input is a bit signal
-- which is converted to a 5/0 value realSignal. This signal is then given
-- to the input of the cmos inverter and the output of the cmos inverter is
-- then given to a atod... the final output is then a bit signal which is
-- the inverse of the input bit signal...
------------------------------------------------------------------------
-- /\ Vdd
-- |
-- o S
-- |
-- --
-- -----<-|p
-- | --
-- | |
-- --0--/\/\--0 D 0--------o--------o----------
-- + /\ | | | | /\ +
-- | | -- > | |
-- vin is | ----->-|n < --- Vout ==> atod ==> op
-- atod(inp) Vin -- > --- |
-- | | < | |
-- | o S | | |
-- - \/ | | | \/ -
-- -------------------------------------------------
-- |
-- ---
-- -
------------------------------------------------------------------------
-------*****************************************************************
-- Package definition Begins
-------*****************************************************************
PACKAGE electricalSystem IS
NATURE electrical IS real ACROSS real THROUGH;
FUNCTION SIN(X : real) RETURN real;
FUNCTION EXP(X : real) RETURN real;
FUNCTION SQRT(X : real) RETURN real;
FUNCTION POW(X,Y : real) RETURN real;
-- ALIAS GND is electrical'reference;
END PACKAGE electricalSystem;
------- Square wave generator
-------*****************************************************************
-- New Entity Begins : 1 BIT A/D CONVERTER
-------*****************************************************************
use work.electricalsystem.all;
entity a2d1bit is
generic (vlo : real := 0.0;
vhi : real := 10.0;
ped : time := 1 ns);
port (signal input : in bit;
terminal pos, neg : electrical);
end entity a2d1bit;
architecture behav of a2d1bit is
quantity vsqr across isqr through pos to neg;
signal vsig : real := 0.0;
begin
vsqr == vsig;
break on vsig;
bit2real : process
begin
if(input = '0') then
vsig <= vlo;
else
vsig <= vhi;
end if;
wait on input;
end process; --- generator;
end architecture behav;
-------*****************************************************************
-- New Entity Begins : RESISTOR
-------*****************************************************************
use work.electricalSystem.all;
entity resistor is
generic(r: real := 1.0 ); --- resistance
port( terminal tr1,tr2 : electrical); --- interface ports
end resistor;
architecture rbehavior of resistor is
quantity Vr across Ir through tr1 to tr2;
begin
Vr == Ir*r;
end architecture rbehavior; --- of resistor
-------*****************************************************************
-- New Entity Begins : PMOS TRANSISTOR
-------*****************************************************************
----- PMOS
--use std.textio.all;
use work.electricalsystem.all;
entity pmos is
port (terminal g,s,d : electrical);
end entity pmos;
architecture behav of pmos is
terminal g2, d1 : electrical;
quantity vdsg across idsgi through d1 to s;
quantity idsg through d1 to s;
quantity vdsr across idsr through d1 to d;
quantity vds across d to s;
quantity vgs_in across g to s;
quantity vgsr across igsr through g to g2;
quantity vgs across igs through g2 to s;
constant vth : real := 0.5;
constant hfe : real := 3.54e-03;
-- quantity flag : real := 1.0;
-- quantity vgs : real;
-- signal vgs_sig,vds_sig : real := 0.0;
begin
------ Setting initial conditions
-- init : break vds => 1.0;
opn : vdsg == 1.0e+06 * idsgi ; -- almost
d12_res : vdsr == idsr * 1.0;
g12res : vgsr == igsr * 1.0;
g_oup : vgs == igs * 1.0;
-- flag == 1.0;
---- Current is in Micro Amps.
------ Cut OffRegion
if((vgs <= 0.0) and (vgs >= vth)) use
gnc : idsg == 0.0;
------ Linear Region
elsif((vds >= (vgs-vth)) and (vds < 0.0)) use
gnl : idsg == -1.0*hfe*(((vgs-vth)*vds) - (pow(vds,2.0)/2.0));
------ Saturation Region
elsif((vds < (vgs-vth)) and (vgs < vth)) use
gns2 : idsg == -1.0*(hfe/2.0)*(pow((vgs-vth),2.0));
------ Other conditions
-- elsif(vgs < 0.0 or vds <= 0.0) use
elsif(1.0 = 1.0) use
temp : idsg == 0.0;
end use;
end architecture behav; --- of pmos;
-------*****************************************************************
-- New Entity Begins : NMOS TRANSISTOR
-------*****************************************************************
----- NMOS
--use std.textio.all;
use work.electricalsystem.all;
entity nmos is
port (terminal g,s,d : electrical);
end entity nmos;
architecture behav of nmos is
terminal g2, d1 : electrical;
quantity vdsg across idsgi through d1 to s;
quantity idsg through d1 to s;
quantity vdsr across idsr through d1 to d;
quantity vds across d to s;
quantity vgs_in across g to s;
quantity vgsr across igsr through g to g2;
quantity vgs across igs through g2 to s;
constant vth : real := 0.5;
constant hfe : real := 8.85e-03;
-- quantity flag : real := 1.0;
-- quantity vgs : real;
-- signal vgs_sig,vds_sig : real := 0.0;
begin
------ Setting initial conditions
-- init : break vds => 1.0;
opn : vdsg == 1.0* idsgi ; -- almost
d12_res : vdsr == idsr * 1.0e-3;
g12res : vgsr == igsr * 1.0;
g_oup : vgs == igs * 1.0;
-- flag == 1.0;
---- Current is in Micro Amps.
------ Cut OffRegion
if((vgs >= 0.0) and (vgs <= vth)) use
gnc : idsg == 0.0;
------ Linear Region
elsif((vds <= (vgs-vth)) and (vds > 0.0)) use
gnl : idsg == hfe*(((vgs-vth)*vds) - (pow(vds,2.0)/2.0));
------ Saturation Region
elsif((vds > (vgs-vth)) and (vgs > vth)) use
gns2 : idsg == (hfe/2.0)*(pow((vgs-vth),2.0));
------ Other conditions
-- elsif(vgs < 0.0 or vds <= 0.0) use
elsif(1.0 = 1.0) use
temp : idsg == 0.0;
end use;
end architecture behav; --- of nmos;
--------- Inverter Test Bench
-------*****************************************************************
-- New Entity Begins : CMOS INVERTER
-------*****************************************************************
use work.electricalsystem.all;
entity inverter is
port(inv_inp : in bit;
inv_op : out bit);
end entity inverter;
architecture behav of inverter is
terminal iin, iout, idd : electrical;
quantity vdd across idd to electrical'reference;
quantity vin across iin to electrical'reference;
quantity vout across irout through iout to electrical'reference;
constant power : real := 5.0;
component nmos is
port (terminal g,s,d : electrical);
end component;
for all : nmos use entity work.nmos(behav);
component pmos is
port (terminal g,s,d : electrical);
end component;
for all : pmos use entity work.pmos(behav);
component a2d_comp is
generic(vlo : real := 0.0;
vhi : real := 10.0;
ped : time := 1 ns);
port (signal input : in bit;
terminal pos, neg : electrical);
end component;
for all : a2d_comp use entity work.a2d1bit(behav);
component resistor_comp
generic ( r : real := 1.0);
port ( terminal tr1, tr2 : electrical );
end component;
for all : resistor_comp use entity work.resistor(rbehavior);
begin
vdd == power;
sqr : a2d_comp
generic map(0.0, 10.0, 500 ps)
port map(inv_inp, iin, electrical'reference);
nm : nmos port map(iin, electrical'reference, iout);
pm : pmos port map(iin, idd, iout);
res_out : resistor_comp
generic map(5000000.0)
port map(iout,electrical'reference);
a2d: process
begin
if(vout'above(0.003) = true) then
inv_op <= '1';
else
inv_op <= '0';
end if;
end process;
end architecture behav; ---- of inverter
-------*****************************************************************
-- New Entity Begins : TESTBENCH
-------*****************************************************************
use std.textio.all;
entity test_bench is
end test_bench;
architecture tb_arch of test_bench is
component inverter_comp
port(inv_inp : in bit;
inv_op : out bit);
end component;
for all : inverter_comp use entity work.inverter(behav);
signal ip, op : bit;
begin
i1 : inverter_comp
port map(ip, op);
inputtestbench:PROCESS
begin
ip <= '0';
wait for 100 NS;
ip <= '1';
wait for 100 NS;
ip <= '0';
wait for 100 NS;
ip <= '1';
wait for 100 NS;
ip <= '0';
wait for 100 NS;
ip <= '1';
wait for 100 NS;
ip <= '0';
wait for 100 NS;
ip <= '1';
wait for 100 NS;
ip <= '0';
wait for 100 NS;
ip <= '1';
wait for 100 NS;
ip <= '0';
wait for 100 NS;
ip <= '1';
wait for 100 NS;
ip <= '0';
wait for 100 NS;
ip <= '1';
wait for 100 NS;
ip <= '0';
wait for 100 NS;
ip <= '1';
wait for 100 NS;
ip <= '0';
wait for 100 NS;
ip <= '1';
wait for 100 NS;
ip <= '0';
wait for 100 NS;
ip <= '1';
wait for 100 NS;
ip <= '0';
wait for 100 NS;
ip <= '1';
wait for 100 NS;
ip <= '0';
wait for 100 NS;
ip <= '1';
wait for 100 NS;
END process;
testbench:PROCESS
VARIABLE outline : LINE;
VARIABLE Headline : string(1 TO 54) :=
"time inv_input inv_output";
VARIABLE seperator : string(1 TO 1) := " ";
VARIABLE flag : bit := '0';
FILE outfile: text OPEN WRITE_MODE IS "Output.out";
BEGIN
IF (flag = '0') THEN
flag := '1';
WRITE(outline,Headline);
WRITELINE(outfile,outline);
ELSE
WRITE(outline, now);
WRITE(outline,seperator);
WRITE(outline,ip);
WRITE(outline,seperator);
WRITE(outline,op);
WRITELINE(outfile,outline);
END IF;
WAIT ON ip, op;
END PROCESS;
end;
|