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

Add BundleLiteralsSpec #37

Merged
merged 3 commits into from
May 15, 2019
Merged

Add BundleLiteralsSpec #37

merged 3 commits into from
May 15, 2019

Conversation

chick
Copy link
Contributor

@chick chick commented May 14, 2019

Three simple tests showing syntax and usage
Third tests showing peeking currently expects an exception

Three simple tests showing syntax and usage
Third tests showing peeking currently expects an exception
@chick chick added the enhancement New feature or request label May 14, 2019
@chick chick requested a review from ducky64 May 14, 2019 23:16
@chick chick self-assigned this May 14, 2019
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.

cloneType is an old, crappy, legacy, abstraction-breaking, and informally-deprecated API that needs to be killed with fire, then nuked from orbit. It's the only way to be sure.
(rationale: can you explain what cloneType does from the name without going into the guts of Chisel? It just seems to encourage cargo cult programming, and chiselTypeOf expresses intent much better)

Also potentially questionable style issues for the ignored test.

@@ -36,35 +25,44 @@ class BundleLiteralSpec extends FlatSpec with ChiselScalatestTester {
io.aOut := io.in.a
io.bOut := io.in.b
}) { c =>
c.io.in.poke(c.io.in.Lit(0.U, 1.U))
c.io.in.poke(c.io.in.cloneType.Lit(_.a -> 0.U, _.b -> 1.U))
Copy link
Member

Choose a reason for hiding this comment

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

cloneType is a crappy, confusing, and informally-deprecated API. Please stop using it, or encouraging people to use it, or throwing it in new code. We can't actually mark it deprecated, because some legacy code makes heavy use of it, but new code should not use it.
Use chiselTypeOf instead.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Agreed, I meant to ask you about this, but forgot about it. Fixed

}
}
}

ignore should "peek Bundle literals" in {
// TODO to be written
// peek on bundle not supported yet, this test will fail and should
Copy link
Member

Choose a reason for hiding this comment

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

Why'd you get rid of the ignore? I think the ignore is cleaner and expresses intent better than an exception intercept. The test name is also very confusing.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think getting rid of the ignore is a better way of making sure we update the test when peeking is of Bundled is enabled. I agree the test name is bad and is changed.

Copy link
Member

Choose a reason for hiding this comment

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

I'd prefer expressing intent over some confusing system that results in automated reminders. Because when you're building a new feature, you should already be thinking of writing tests for it, and the ignored should act as a flag that gets cleaned up (though perhaps eventually). And the tests are intended to essentially codify behavior, and a LiteralTypeException is not the end goal here.

I guess ideally there would be an ignore flag that checks for a test failure and suppresses it, but errors on a non-failure. Don't know if that exists in ScalaTest.

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 is now an ignore

test(new PassthroughModule(new DoubleElements)) { c =>
c.in.poke(c.in.cloneType.Lit(_.a -> 0.U, _.b -> 1.U))
val output = c.out.peek()
output.a === 0.U should be(true.B)
Copy link
Member

Choose a reason for hiding this comment

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

Uh, I really don't think that will work, since we don't do const prop in the frontend - it will just end up as a wire, and that's assuming you don't get some error for trying to invoke HCL operations outside a Builder context.

That being said, I'm not sure how we check for literal equality.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@ducky64 Can you think of a better example of a use case for peeking a Bundle?

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 is now an ignore

chick added 2 commits May 14, 2019 17:02
Use `chiselTypeOf` instead of `cloneType`.
Fix name of putative test of peeking Bundles
peeking bundles is not supported yet
@chick chick merged commit 331c16b into master May 15, 2019
@ekiwi ekiwi deleted the bundle-lit-test-1 branch December 17, 2021 21:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants