Re: problem with clone_instance

Felix Salfelder <[email protected]>
Newsgroups gmane.comp.gnu.gnucap.devel
Message-ID <[email protected]>
On Sun, Nov 17, 2013 at 02:33:43PM -0500, al davis wrote:
> Immediately, my suggestion followed in that same email.

i didn't get it, and i still fail to see the connection to "pulse".
the example in d_logic looks more instructive.

> An assert in the code is documentation of some condition that is 
> assumed to be true.  An assert fail is not a bug in itself, but 
> rather a hint at where the bug really is.o

i'm now considerably successful with something like

/*--------------------------------------------------------------------------*/
class NOTHING : public COMPONENT { //
public:
  NOTHING():COMPONENT(){ }
  CARD* clone() const { return new(NOTHING);}
private:
  std::string value_name()const { return "error";}
  int max_nodes()const {return 0;}
  std::string dev_type()const {return "error";}
  std::string port_name(int)const {untested(); return "error";}
  bool print_type_in_spice()const {return 0;}
};
/*--------------------------------------------------------------------------*/
static NOTHING p0;
static MODEL_SEMI_RESISTOR  p1(&p0); // <= fix the corresponding constructors
static MODEL_SEMI_CAPACITOR p2(&p0); // <= fix the corresponding constructors
static DISPATCHER<MODEL_CARD>::INSTALL
  d1(&model_dispatcher, "r|res", &p1),
  d2(&model_dispatcher, "c|cap", &p2);
/*--------------------------------------------------------------------------*/

in bmm_semi.cc. but it segfaults because of what i consider a bug in
COMPONENT::set_port_by_index(..). the comparison "num <= max_nodes()" seems to
be off by one.

try
gnucap>verilog
gnucap-verilog>resistor r(1,2);
gnucap-verilog>resistor r(1,2,3);
gnucap-verilog>resistor r(1,2,3,4);
resistor r(1,2,3,4);
                 ^ ? too many: requested=3 max=2

it should read "num < max_nodes()" in COMPONENT::set_port_*, no?

and, while i'm at it. in e_compon.h i found
[..]
public:  // obsolete -- do not use in new code
  virtual bool print_type_in_spice()const = 0;
[..]
which should read
  virtual bool print_type_in_spice()const{return some_default;},
if that member is really obsolete.

regards
felix
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.