viminfo
[gnucap-felix.git] / lib / d_logicmod.cc
blob86fedc6fd43a73819513364a2c60c5241005dd7a
1 /*$Id: d_logicmod.cc,v 26.127 2009/11/09 16:06:11 al Exp $ -*- C++ -*-
2 * Copyright (C) 2001 Albert Davis
3 * Author: Albert Davis <aldavis@gnu.org>
5 * This file is part of "Gnucap", the Gnu Circuit Analysis Package
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 3, or (at your option)
10 * any later version.
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
20 * 02110-1301, USA.
21 *------------------------------------------------------------------
22 * logic model and device.
23 * netlist syntax:
24 * device: mxxxx vdd out in1 in2 ... family gatetype
25 * model: .model mname LOGIC <args>
27 //testing=script 2006.07.17
28 #include "d_logic.h"
29 /*--------------------------------------------------------------------------*/
30 MODEL_LOGIC::MODEL_LOGIC(const DEV_LOGIC* p)
31 :MODEL_CARD(p),
32 delay (1e-9),
33 vmax (5.),
34 vmin (0.),
35 unknown((vmax+vmin)/2),
36 rise (delay / 2),
37 fall (delay / 2),
38 rs (100.),
39 rw (1e9),
40 th1 (.75),
41 th0 (.25),
42 mr (5.),
43 mf (5.),
44 over (.1),
45 range (vmax - vmin)
47 ++_count;
49 /*--------------------------------------------------------------------------*/
50 MODEL_LOGIC::MODEL_LOGIC(const MODEL_LOGIC& p)
51 :MODEL_CARD(p),
52 delay (p.delay),
53 vmax (p.vmax),
54 vmin (p.vmin),
55 unknown(p.unknown),
56 rise (p.rise),
57 fall (p.fall),
58 rs (p.rs),
59 rw (p.rw),
60 th1 (p.th1),
61 th0 (p.th0),
62 mr (p.mr),
63 mf (p.mf),
64 over (p.over),
65 range (p.range)
67 ++_count;
69 /*--------------------------------------------------------------------------*/
70 void MODEL_LOGIC::precalc_first()
72 MODEL_CARD::precalc_first();
74 const CARD_LIST* par_scope = scope();
75 assert(par_scope);
77 delay.e_val(1e-9, par_scope);
78 vmax.e_val(5., par_scope);
79 vmin.e_val(0., par_scope);
80 unknown.e_val((vmax+vmin)/2, par_scope);
81 rise.e_val(delay / 2, par_scope);
82 fall.e_val(delay / 2, par_scope);
83 rs.e_val(100., par_scope);
84 rw.e_val(1e9, par_scope);
85 th1.e_val(.75, par_scope);
86 th0.e_val(.25, par_scope);
87 mr.e_val(5., par_scope);
88 mf.e_val(5., par_scope);
89 over.e_val(.1, par_scope);
91 range = vmax - vmin;
93 /*--------------------------------------------------------------------------*/
94 void MODEL_LOGIC::set_param_by_index(int i, std::string& value, int offset)
96 switch (MODEL_LOGIC::param_count() - 1 - i) {
97 case 0: delay = value; break;
98 case 1: vmax = value; break;
99 case 2: vmin = value; break;
100 case 3: unknown = value; break;
101 case 4: rise = value; break;
102 case 5: fall = value; break;
103 case 6: rs = value; break;
104 case 7: rw = value; break;
105 case 8: th1 = value; break;
106 case 9: th0 = value; break;
107 case 10: mr = value; break;
108 case 11: mf = value; break;
109 case 12: over = value; break;
110 default: MODEL_CARD::set_param_by_index(i, value, offset); break;
113 /*--------------------------------------------------------------------------*/
114 bool MODEL_LOGIC::param_is_printable(int i)const
116 switch (MODEL_LOGIC::param_count() - 1 - i) {
117 case 0:
118 case 1:
119 case 2:
120 case 3:
121 case 4:
122 case 5:
123 case 6:
124 case 7:
125 case 8:
126 case 9:
127 case 10:
128 case 11:
129 case 12: return true;
130 default: return MODEL_CARD::param_is_printable(i);
133 /*--------------------------------------------------------------------------*/
134 std::string MODEL_LOGIC::param_name(int i)const
136 switch (MODEL_LOGIC::param_count() - 1 - i) {
137 case 0: return "delay";
138 case 1: return "vmax";
139 case 2: return "vmin";
140 case 3: return "unknown";
141 case 4: return "rise";
142 case 5: return "fall";
143 case 6: return "rs";
144 case 7: return "rw";
145 case 8: return "thh";
146 case 9: return "thl";
147 case 10: return "mr";
148 case 11: return "mf";
149 case 12: return "over";
150 default: return MODEL_CARD::param_name(i);
153 /*--------------------------------------------------------------------------*/
154 std::string MODEL_LOGIC::param_name(int i, int j)const
156 if (j == 0) {
157 return param_name(i);
158 }else if (i >= MODEL_CARD::param_count()) {
159 return "";
160 }else{
161 return MODEL_CARD::param_name(i, j);
164 /*--------------------------------------------------------------------------*/
165 std::string MODEL_LOGIC::param_value(int i)const
167 switch (MODEL_LOGIC::param_count() - 1 - i) {
168 case 0: return delay.string();
169 case 1: return vmax.string();
170 case 2: return vmin.string();
171 case 3: return unknown.string();
172 case 4: return rise.string();
173 case 5: return fall.string();
174 case 6: return rs.string();
175 case 7: return rw.string();
176 case 8: return th1.string();
177 case 9: return th0.string();
178 case 10: return mr.string();
179 case 11: return mf.string();
180 case 12: return over.string();
181 default: return MODEL_CARD::param_value(i);
184 /*--------------------------------------------------------------------------*/
185 /*--------------------------------------------------------------------------*/
186 // vim:ts=8:sw=2:noet: