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)
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
21 *------------------------------------------------------------------
22 * logic model and device.
24 * device: mxxxx vdd out in1 in2 ... family gatetype
25 * model: .model mname LOGIC <args>
27 //testing=script 2006.07.17
29 /*--------------------------------------------------------------------------*/
30 MODEL_LOGIC::MODEL_LOGIC(const DEV_LOGIC
* p
)
35 unknown((vmax
+vmin
)/2),
49 /*--------------------------------------------------------------------------*/
50 MODEL_LOGIC::MODEL_LOGIC(const MODEL_LOGIC
& p
)
69 /*--------------------------------------------------------------------------*/
70 void MODEL_LOGIC::precalc_first()
72 MODEL_CARD::precalc_first();
74 const CARD_LIST
* par_scope
= 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
);
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
) {
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";
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
157 return param_name(i
);
158 }else if (i
>= MODEL_CARD::param_count()) {
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: