Connecting the wrong interface to a port does not cause an error
Please see the GitHub branch for a test and a not-quite-there-yet fix: https://github.com/toddstrader/verilator-dev/tree/wrong_intfThe fix works fine for my simple example, but breaks a lot of other tests like so:
%Error: t/t_interface_gen.v:26: Expected ifc interface but got ifc interface instead
The problem seems to be that the point at which I've added the check, interfaces are being de-parameterized. This means that the port's interface reference is pointing at the general interface while the pin is pointing at the specialized interface.
I just tried changing the test to compare ifaceName() instead of ifacep(). This works (all tests pass), but with the additional string compare. Is this the preferable way to go, or can this be caught at some earlier stage (without reproducing a lot of V3Param logic) so we can avoid the string compare?
#1 Updated by Wilson Snyder over 1 year ago
- Category set to Lint
- Status changed from New to Confirmed
Seems an OK spot, I'd still compare the pointers as you do to speed things up, but then add an "&& " check on the names being different
Nits: Rename the test t_interface_wrong_bad.pl/v, put single quotes around the error names, and call AstNode::prettyName (so that a \escaped name will print right).
I think something like this makes the error clearer:
pinp->v3error("Port '"<<pinp->prettyName()<<"' expects '" <<AstNode::prettyName(portIrefp->ifaceName()) <<"' interface but pin connects '" <<AstNode::prettyName(pinIrefp->ifaceName()) <<"' interface");
Also not sure why you need a return - that will just make it miss reporting other possible errors if there's more than one interface. Think just remove it.
#2 Updated by Todd Strader over 1 year ago
I think the latest commit takes care of everything: https://github.com/toddstrader/verilator-dev/tree/wrong_intf
Also available in: Atom