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

clash-testsuite ... Ram/RMultiTop includes top entity in test bench #2192

Closed
DigitalBrains1 opened this issue May 6, 2022 · 4 comments · Fixed by #2195
Closed

clash-testsuite ... Ram/RMultiTop includes top entity in test bench #2192

DigitalBrains1 opened this issue May 6, 2022 · 4 comments · Fixed by #2195
Assignees

Comments

@DigitalBrains1
Copy link
Member

Instead of creating a test bench named e.g. vhdl/RMultiTop.testBench/testBench.vhdl that tests a vhdl/RMultiTop.topEntity/topEntity.vhdl, the former includes a copy of the latter.

It is rather odd that this faulty version of the code ended up in the commit and I know what to do to fix it.

I don't know the repercussions of the fault. I only know that for instance an Enable input on a top entity that is driven by enableGen in the test bench might get the enable elided from the final HDL. This will never happen with a properly declared top entity / test bench relation. But since it is generally expected that test benches do not include a copy of the top entities they test, there might be other repercussions? Alternatively it's just about sharing of work and it has no functional differences (other than the Enable).

@DigitalBrains1 DigitalBrains1 self-assigned this May 6, 2022
@martijnbastiaan
Copy link
Member

I'm not sure I entirely understand. testBench doesn't seem to use topEntity:

testBench
:: Signal P10 Bool
testBench = tb $(listToVecTH $ sampleN 20 $ tbOutput clockGen clockGen)
{-# NOINLINE testBench #-}

It only uses tb which is explicitly marked INLINE:

tb
:: ( KnownNat n
, 1 <= n)
=> Vec n (Unsigned 2)
-> Signal P10 Bool
tb expectedSamples = done
where
output = tbOutput wClk rClk
expectedOutput = outputVerifier' rClk noReset expectedSamples
done = expectedOutput output
(rClk, wClk) = biTbClockGen (not <$> done) :: (Clock P10, Clock P20)
noReset = unsafeFromHighPolarity @P10 (pure False)
{-# INLINE tb #-}

Am I missing something? :)

@DigitalBrains1
Copy link
Member Author

But tb indirectly includes a copy of ram and topEntity is just another copy of ram. So tb is testing something that is functionally topEntity but is not actually topEntity.

DigitalBrains1 added a commit that referenced this issue May 8, 2022
Instead of `testBench` testing `topEntity`, the former included a
functionally indentical copy of the latter.

Fixes #2192
@DigitalBrains1
Copy link
Member Author

DigitalBrains1 commented May 8, 2022

Here, lemme show you what I mean. That PR should fix the issue. But I'm going to let it wait for a while until my brain is in a high enough gear to pick all the glaring mistakes from it (all might be zero).

Note that it seems that you need a trail of INLINE from testBench down to the function that "finally" includes topEntity. Omitting an INLINE will once again create a fresh copy of topEntity inside the test bench. It's rather brittle really.

@DigitalBrains1
Copy link
Member Author

I've just created an issue about the INLINE thing: #2196.

alex-mckenna pushed a commit that referenced this issue Jun 14, 2022
Instead of `testBench` testing `topEntity`, the former included a
functionally indentical copy of the latter.

Fixes #2192
mergify bot pushed a commit that referenced this issue Jun 14, 2022
Instead of `testBench` testing `topEntity`, the former included a
functionally indentical copy of the latter.

Fixes #2192

(cherry picked from commit 4174d58)
alex-mckenna pushed a commit that referenced this issue Jun 14, 2022
Instead of `testBench` testing `topEntity`, the former included a
functionally indentical copy of the latter.

Fixes #2192

(cherry picked from commit 4174d58)

Co-authored-by: Peter Lebbing <[email protected]>
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

Successfully merging a pull request may close this issue.

2 participants