-
Notifications
You must be signed in to change notification settings - Fork 154
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 Xilinx dual clock FIFO primitive to clash-cores
#2270
Conversation
a3ee6e2
to
a5eee15
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In general this looks good!
I don't think you're leveraging Hedgehog as well as you could, so I've left a few comments on that.
796b9a1
to
44a2205
Compare
clash-cores
@DigitalBrains1 and I just talked a little about the tests that are currently there. Peter noticed that we only test the happy path; that is, when both the write side and the read side behave properly with regards to the full/empty signals:
We should add two basic tests:
|
Oh fair! I will get on that. |
Ok just pushed those two. It now tests that ordering remains upon overflow, and it tests that the simulation completes when it underflows, that is, the DcFifo doesn't depend on undefined values to progress! |
What I have now is inelegant - it has multiple modules since I can't simulate multiple top-level entities in vivado. This is because of #2264 (which I would like to put off for the moment). I still need to see what happens in RTL when the driver circuit doesn't respect the |
Seems sensible |
5e07b7f
to
4061ccd
Compare
This depends on my hack here, but now has the thorough tests (RTL) |
Ok, the RTL tests:
|
That's not the only reason. If you want to have multiple top-level entities simulated from the same clash (gen) then those will need separate temporary directories and obviously also separate test names. I was planning on adding that anyway since I want to use it for Xilinx Floating in Our SymbiYosys and Vivado CI environments both only support a single element in the list Note: I did not understand #2264 at a glance, so I might be missing something you think is obvious ;-) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looking good, almost done! 👀
{ writeReset :: Signal write ResetBusy -- ^ @wr_rst@ | ||
, isFull :: Signal write Full -- ^ @full@ | ||
, isOverflow :: Signal write Bool -- ^ @overflow@ | ||
, writeCount :: Signal write (DataCount depth) -- ^ @wr_data_count@ | ||
, readReset :: Signal read ResetBusy -- ^ @rd_rst@ | ||
, isEmpty :: Signal read Empty -- ^ @empty@ | ||
, isUnderflow :: Signal read Bool -- ^ @underflow@ | ||
, readCount :: Signal read (DataCount depth) -- ^ @rd_data_count@ | ||
, fifoData :: Signal read (BitVector n) -- ^ @dout@ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you copy+paste+reformat the documentation in de datasheet for these signals?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have found a problem I think - the rd_rst_busy
signal is available only for built-in FIFOs. Which is not what we use!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Erm you mean they are only available for BlockRAM implementations, right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removed comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah we're not using common clock, right? We are using dual-clock.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll just note a few things that are no longer an issue now that we only do Independent_Clocks_Block_RAM
:
- Not all variants have
wr_rst_busy
andrd_rst_busy
, even depending on the chip family (UltraScale or not). - The UltraScale variant of builtin FIFO has no input named
rst
; it has ansrst
synchronous to the write clock. - Buitin FIFO requires you to specify the properties
CONFIG.Read_Clock_Frequency
andCONFIG.Write_Clock_Frequency
(values in MHz). - Builtin FIFO does not support data counts.
Instantiating a FIFO that has no ..._rst_busy
signals does not simulate:
ERROR: [VRFC 10-718] formal port <wr_rst_busy> does not exist in entity <dcfifo>. Please compare the definition of block <dcfifo> to its component declaration and its instantion to detect the mismatch. [/tmp/clash-test-d6df6e43cacf34db/DcFifo0.topEntity/topEntity.vhdl:67]
When I edit one of the tests in the test bench to instantiate an Independent_Clocks_Builtin_FIFO
, the test bench fails.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll simply have a look whether
full
is asserted in simulation.
Yes, it is asserted during the reset phase. I don't think we need the busy
signals.
[edit]
Ah, found a section on reset behaviour in the product guide. For Independent Clock BlockRAM, it asserts full
by default, but some modes do not have this option.
[/edit]
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I tried to disable the reset_busy signals but this tripped up one of the examples (the one where we don't check overflows). I need to rethink that test.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we should have a test for the behaviour of full
and empty
during the reset phase, but it isn't trivial at all. I think I did come up with a fair test, but I'd like to make an issue for it that we need to add such a test rather than hold up this PR.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure. I've removed DcFifoBroken
; I think that's fine if there's a plan for an RTL test.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah the big one! It looks good!
A general comment: to what line length did you confgure your editor? I see multi-line comments, flowed paragraphs, with lines up to a 100 columns. Please flow those comments to 80 chars. Lines over 80 need a good reason to exist; they're not forbidden but they are discouraged.
@martijnbastiaan yes! I added the changelog entry that mentioned records but I was confused by @DigitalBrains1's comment:
I don't see how the new code allows us to process type-level naturals. |
8cc5f00
to
ffe5f8d
Compare
It was loose phrasing to refer to the fact we can now do data DcConfig depth = DcConfig { dcDepth :: !depth, ... } and then supply an I suppose your confusion is that you thought I referred to the problematic formulation of: data DcConfig' depth = DcConfig' { dcDepth' :: !(SNat depth), ... } which unfortunately doesn't work? |
ffe5f8d
to
21d37e1
Compare
Oh yes I see, thank you! I have just pushed the full changelog. |
21d37e1
to
a30641b
Compare
clash-cores/src/Clash/Cores/Xilinx/DcFifo/Internal/Instances.hs
Outdated
Show resolved
Hide resolved
3a03c2d
to
f15a75c
Compare
61a1e6d
to
1b64f65
Compare
71fffc6
to
3a869ec
Compare
15d0b00
to
7451e8f
Compare
@vmchale The current commit message isn't valuable for future code archeology. A good commit body should mention:
These aren't strict rules - sometimes reasons are completely obvious (like adding support for a Xilinx IP). Sometimes the change is fully explained in the code diff itself (do not assume code is self-explanatory though!). Sometimes there's no future work the author can think of. Finally, in the footer it should refer to:
|
Ah I'm so sorry I didn't realize the |
fb4d7aa
to
688a002
Compare
What do you mean? It's in the test bench, right? I have to admit those are only run automatically in Vivado, which is a shortcoming we should one day fix, but I did run them manually in Haskell as well. Do you mean the test bench doesn't check cross-domain timing? That reminds me. The Haddock mentions
and the original PR cover letter said
I think a message to this effect should be in the commit message. |
Only a limited number of configurations are supported; see module documentation. The Haskell model does not correspond exactly to RTL. This closes bittide/bittide-hardware#59 Co-authored-by: Martijn Bastiaan <martijn@hmbastiaan.nl> Co-authored-by: Peter Lebbing <peter@digitalbrains.com>
688a002
to
aed4587
Compare
This adds Xilinx's DcFifo to clash-cores. The Haskell model and the IP are both tested.
Past discussion is here; it is bit cluttered.
It's a draft PR because it depends on #2257
Still TODO:
Write a changelog entry (see changelog/README.md)(clash-cores isn't on Hackage)full
behavior and add a test for itoverflow
behavior and add a test for it