Closed youngar closed 2 years ago
There was a similar problem with the symCache here: https://github.com/llvm/circt/commit/3257cb6594ffeccafa07ba38843a00580ec2ff55
The issue also hits when ports share the same name as the module:
circuit Test : %[[
{
"class":"fake",
"target":"~Test|Test/other:Other>Other"
}
]]
module Test:
inst other of Other
module Other :
input Other: UInt<1>
The port reference is changed into a module reference:
module {
firrtl.circuit "Test" {
firrtl.nla @nla_1 [#hw.innerNameRef<@Test::@other>, @Other]
firrtl.module @Test() {
%other_Other = firrtl.instance other sym @other {annotations = [{circt.nonlocal = @nla_1, class = "circt.nonlocal"}]} @Other(in Other: !firrtl.uint<1>)
}
firrtl.module @Other(in %Other: !firrtl.uint<1> sym @Other [{circt.nonlocal = @nla_1, class = "fake"}]) {
}
}
}
this is due to this weird assumption that the module name will not be the same as anything in the module itself. https://github.com/llvm/circt/blob/main/lib/Dialect/FIRRTL/Import/FIRAnnotations.cpp#L142
When trying to run this test, it creates a bad NLA. The
@Test
FlatSymbolRefAttr should be anhw.innerNameRef<@Test::@Test>
.