Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixed crash in debug when compiling $limit()
Crash took place when compiling $limit(). It was caused by an incorrect assert.
- Loading branch information
42026b1
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does your fix address the issue that $limit(V(a,b)) -- that is, with 1 argument -- will crash? The VAMS LRM only requires one argument, though usually one will supply a function and one or more parameters (eg, "pnjlim" and vcrit).
See #133
42026b1
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does this occur only for $limit using a user-defined function?
42026b1
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I do see a crash when trying to compile the diode example from the Verilog-AMS LRM. It has
analog function real spicepnjlim;
input vnew, vold, vt, vcrit;
and then
vdio = $limit(V(a,c), spicepnjlim, $vt, vcrit);
When I check the values in the assertion, db.function_data(self.id).args.len() is 4 and idx is 0, so the original assertion fails, and the revision passes. I don't understand what this is checking; I would expect a comparison that the call to $limit has the same number of arguments as the user-defined function -- V(a,c) becomes vnew when passed to the function, the second argument is vold instead of the function name, and the last two arguments are passed right over.
42026b1
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wonder if this line:
debug_assert!(db.function_data(self.id).args.len() >= idx);
should instead be
debug_assert!(db.function_data(self.id).args.len() > idx);
As I mentioned in the example above, args.len() is 4, and idx is 0. If I use the patch, then I see a second call with len=4 and idx=1. Since idx is zero-based, I think the inequality should be strictly greater than.
42026b1
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You are probably right. Anyway, this is a debug assertion so it does not affect Release version.