Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Duplicate EDIFPortInsts - Expected behaviour? #564

Closed
jakobwenzel opened this issue Oct 26, 2022 · 2 comments
Closed

Duplicate EDIFPortInsts - Expected behaviour? #564

jakobwenzel opened this issue Oct 26, 2022 · 2 comments
Assignees
Milestone

Comments

@jakobwenzel
Copy link
Contributor

Hi,

after hours of debugging, I found out that 131331d subtly changed behaviour when there are duplicate EDIFPortInsts.

Let's use this minimal example:

@Test
    public void test() {

        String designName = "design";
        final EDIFNetlist netlist = EDIFTools.createNewNetlist(designName);

        EDIFCell ec = new EDIFCell(netlist.getWorkLibrary(), "foo");
        EDIFPort port = ec.createPort("in", EDIFDirection.INPUT, 1);


        EDIFCell top = netlist.getTopCell();
        EDIFCellInst cell = ec.createCellInst("a", top);

        EDIFNet netA = top.createNet("netA");
        EDIFNet netB = top.createNet("netB");


        netA.createPortInst(port, cell);
        netA.removePortInst(netA.getPortInsts().iterator().next());

        netB.createPortInst(port, cell);
        EDIFPortInst epi = cell.getPortInsts().iterator().next();


        Assertions.assertEquals(netB, epi.getNet());
    }

We create a cell inst and connect it to one net. Then we change our mind, disconnect and connect to a different net.
When querying the cell inst for which net its port inst connects to, we should get netB, right? Well, before 131331d we did. Now, we get null.

The reason for this change is subtle: Previously, EDIFCellInst.portInsts was a Map. When adding a duplicate entry in EDIFCellInst.addPortInst, the previous one was discarded and the new one was saved in the map. In that change EDIFPortInstList was introduced, which is now used in EDIFCellInst. In case of duplicates, EDIFPortInstList keeps the old value and discards the new one.

This change was unexpected for me and very hard to find. I believe that mirroring the previous behaviour more closely is more intuitive.

@jakobwenzel
Copy link
Contributor Author

Mirroring the previous behaviour would probably be to overwrite previously stored values with new duplicates here:

// Do not allow duplicates
if (insertionPoint >= 0) {
return false;
}

@eddieh-xlnx
Copy link
Collaborator

Fixed by #571.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants