[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Gnucap-devel] another assertion 'bug'
From: |
Felix Salfelder |
Subject: |
Re: [Gnucap-devel] another assertion 'bug' |
Date: |
Thu, 13 Dec 2012 13:31:38 +0100 |
User-agent: |
Mutt/1.5.20 (2009-06-14) |
On Thu, Dec 13, 2012 at 06:43:15AM -0500, al davis wrote:
> It is correct, in parsing, to set_dev_type to the 'device'
> attribute, but incorrect to make them all subcircuits.
i've worked this out some more. i think the following is desirable:
- if there is a device attribute and (some_dispatcher[device] ||
find_looking_out(device)), use that device
- else, instanciate a fake sckt that collects the parameters. this wont
simulate, but set_dev_type makes the list command happy.
unfortunately savant's find_type_in_string has no access to the body of
the device. for example find_type_in_string on
C 1 2 3 4 some-symbol.sym
{
device=some-other
}
will not know about some-other.
so (my approach, not changing the parser much) looks a bit more involved:
- instanciate a fake-sckt
- if the symbol has a device attribute the device_dispatcher knows
(and it matches the pincount whatsoever) use that device as type
- otherwise instanciate that fake-sckt and set-dev-type
the first case is simple, but doesnt allow the user override the device
attribute (*). in the second case, a device is instanciated and
potentially set_type to some-other. this way the user may override the
device attribute if a subckt matching the pins is present.
> The correct procedure is to use the 'device' attribute to
> determine what kind of device to instanciate, not necessarily a
> subckt. It might be, for example, a resistor.
i'm not sure whether (*) is bad. but it is a place to start.
for translation, this should be not an issue. for simulation, i've got
some other problems to solve first.
> In this case, the code should be changed to:
> assert(find_looking_out(c->modelname()) == _parent);
> [..]
this looks much better.
> Back to the original question ... If I understand correctly,
> the problem is that he always starts with a subckt. The correct
> way is for find_type_in_string to find the device attribute,
> which specifies the type.
you do. yes, my code approximates this:
if(_componentmod){ // read: "do _!-fake-sckt first"
type = "C"; // C is a command that declares the fake-sckt
}else{
type = _componentname; // name of the fake-sckt
string X, basename;
cmd>>X>>" ">>X>>" ">>X>>" ">>X>>" ">>X>>" ">>basename;
GEDA_SYMBOL sym = _symbol[basename];
if(sym.has_key("device")){
if (CARD* c = device_dispatcher[sym["device"]]){
COMPONENT* d = prechecked_cast<COMPONENT*>(c);
if ( d->max_nodes() >= sym.pincount()
&& d->min_nodes() <= sym.pincount()){
type = sym["device"];
}
}
} else if(sym.has_key("net")){
if (CARD* c = device_dispatcher["rail"]){
COMPONENT* d = prechecked_cast<COMPONENT*>(c);
if ( d->max_nodes() >= sym.pincount()
&& d->min_nodes() <= sym.pincount()){
type = "rail"; // something
like this is needed to
// connect GND nets and the like
}
}
}
}
regards
felix