Skip to content
This repository has been archived by the owner on Aug 19, 2024. It is now read-only.

tests: check that elaboration happens only once #98

Closed
wants to merge 1 commit into from

Conversation

oharboe
Copy link
Contributor

@oharboe oharboe commented Dec 13, 2019

Build Dependencies

Build with: git-clone firrtl https://github.com/freechipsproject/firrtl.git master
Build with: git-clone chisel3 https://github.com/freechipsproject/chisel3.git master

Copy link
Member

@ducky64 ducky64 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks - the test looks structurally sane, with some style comments inline.

I think this is a useful test case, though fixing it is another thing entirely. The Verilator backend is largely legacy imported code, so it's unclear how easy fixing it will be.

If it's currently failing: I'm not sure I want a test that might stay failing for a while, maybe adding an ignore tag would be a compromise that keeps this issue somewhat visible but wouldn't block something like CI (if we started running it)?

src/test/scala/chiseltest/tests/SingleElaboration.scala Outdated Show resolved Hide resolved

var checkOnceVerilator = 0
it should ("elaborate once with Verilator") in {
new TestBuilder(() => {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you have the variable increment inside the Module body itself, like

test(new Module {
  checkOnceVerilator should be (0)
  checkOnceVerilator += 1
}) { c =>
  // empty test body
}

You can also use the test(...).withAnnotations(...) { c => ... } syntax as demonstrated in VerilatorBasicTests.scala, which I think is cleaner than creating a TestBuilder object?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

test() syntax can't be used, because it doesn't take a producer of a module, but an actual module.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you have the variable increment inside the Module body itself, like

That breaks the test...

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wait, why does it break the test? test(...) is call-by-name on the DUT argument (essentially it's the same as () => ... but without the explicit syntax), and also I don't think it's allowed to (should assert out) elaborate a Chisel module outside a special context (that gets initialized inside somewhere test(...))

@oharboe
Copy link
Contributor Author

oharboe commented Dec 18, 2019 via email

@oharboe
Copy link
Contributor Author

oharboe commented Dec 31, 2020

@ducky64 I think that there is a unit-test that verifies that elaboration doesn't happen twice? Is there? Can I close this PR?

@oharboe
Copy link
Contributor Author

oharboe commented Dec 31, 2020

I can re-open if this still has any value.

@oharboe oharboe closed this Dec 31, 2020
@oharboe oharboe deleted the elaborationonceunittest branch December 31, 2020 15:14
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants