Skip to content

Split elastic buffers from the control/autocenter functions - #1346

Draft
rslawson wants to merge 3 commits into
mainfrom
rs/ebInterface
Draft

rslawson wants to merge 3 commits into
mainfrom
rs/ebInterface

Conversation

@rslawson

Copy link
Copy Markdown
Collaborator

What (what did you do)
The previous xilinxElasticBufferWb and xilinxElasticBuffer functions have been replaced by a set of new functions: elasticBufferAutoCenter, elasticBufferControlWb, and joinEbAndControl, as well as the DcFifoC n readDom writeDom a vendorEbConstraints type alias. joinEbAndControl joins a control circuit to any DcFifoC with the appropriate type parameters.

Why (context, issues, etc.)
Issue #1298.

Dear reviewer (anything you'd like the reviewer to pay close attention to?)
I'm not certain of the interface for joinEbAndControl at the moment. I'd like some thoughts on whether this is an appropriate degree of separation as mentioned in the linked issue, and if so, whether there's any ways that I could possibly improve the interface. At the moment it's not the neatest thing to use, but I haven't come up with a better way to do it yet.

AI disclaimer (heads-up for more than inline autocomplete)
None.

TODO

Cross-out any that do not apply

  • Write (regression) test
  • Update documentation, including docs/
  • Link to existing issue

@hiddemoll hiddemoll left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I find this PR very hard to review in the current state because circuits are being constructed and deconstructed multile times. I've left some minor comments, but I've also asked @martijnbastiaan to take a look.

-}
xilinxElasticBuffer ::
forall n readDom writeDom a.
elasticBufferAutoCenter ::

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Why is this not directly part of elasticBufferControlWb?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

That's something @lmbollen and I discussed, and we ended up deciding to split them. I can't remember the reasoning at the moment - maybe it was that in the diagram the autocentering is split from the control?

Comment thread bittide/src/Bittide/ElasticBuffer.hs Outdated
Comment on lines +265 to +272
Circuit go
where
go (wbFwd, (dcFifoOut, _)) =
let
isFirstRising :: Signal readDom Bool -> Signal readDom Bool
isFirstRising = E.isRising clkRead flagsReset enableGen False . stickyE clkRead flagsReset

flagsReset :: Reset readDom
flagsReset = E.orReset rstRead (unsafeFromActiveHigh (clearStatusRegisters .== Just (BusWrite True)))

localCounterUnderflow <- shutter (isFirstRising underflow) -< Fwd localCounter
localCounterOverflow <- shutter (isFirstRising overflow1) -< Fwd localCounter
fn = toSignals goC
(wbBwd, dcFifoIn) = fn (wbFwd, dcFifoOut)
in
(wbBwd, (dcFifoIn, relDataCount))

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I'm getting really confused by the mixture of circuit notation and non-circuit notation.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

The problem here is that I need access to the backwards channel of the DcFifoIO, which is the DcFifoOut stuff. I couldn't figure out a way to do that within the circuit notation section, so I wrote a wrapper Circuit that lets me access it and its fields where I need to.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Perhaps you can get some inspiration from CInputs and COutputs from Bittide.Transceiver. Those 2 are not merged into a single protocol, like you do with DcFifoIO.

Comment thread bittide/src/Bittide/ElasticBuffer.hs
Comment thread bittide/src/Clash/Cores/Xilinx/ElasticBuffer.hs Outdated
Comment thread bittide/src/Clash/Cores/Xilinx/ElasticBuffer.hs Outdated
@rslawson rslawson changed the title Rs/eb interface Split elastic buffers from the control/autocenter functions Jun 30, 2026
@rslawson
rslawson requested a review from hiddemoll June 30, 2026 14:12

@hiddemoll hiddemoll left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I think you might have forgotten to push your fixes. You marked 2 comments as resolved, but the code didn't change

Comment on lines +265 to +272
Circuit go
where
go (wbFwd, (dcFifoOut, _)) =
let
isFirstRising :: Signal readDom Bool -> Signal readDom Bool
isFirstRising = E.isRising clkRead flagsReset enableGen False . stickyE clkRead flagsReset

flagsReset :: Reset readDom
flagsReset = E.orReset rstRead (unsafeFromActiveHigh (clearStatusRegisters .== Just (BusWrite True)))

localCounterUnderflow <- shutter (isFirstRising underflow) -< Fwd localCounter
localCounterOverflow <- shutter (isFirstRising overflow1) -< Fwd localCounter
fn = toSignals goC
(wbBwd, dcFifoIn) = fn (wbFwd, dcFifoOut)
in
(wbBwd, (dcFifoIn, relDataCount))

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Perhaps you can get some inspiration from CInputs and COutputs from Bittide.Transceiver. Those 2 are not merged into a single protocol, like you do with DcFifoIO.

Comment thread bittide/src/Clash/Cores/Xilinx/ElasticBuffer.hs Outdated
Comment thread bittide/src/Bittide/ElasticBuffer.hs
Comment on lines +145 to +147
instance Protocol (DcFifoOutput n readDom writeDom a) where
type Fwd (DcFifoOutput n readDom writeDom a) = DcFifoOutput n readDom writeDom a
type Bwd (DcFifoOutput _ _ _ _) = ()

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Do you use this?

@rslawson rslawson Jul 1, 2026

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

I do, yes. It's part of the right side of the output circuit from joinEbAndControl.

Comment thread bittide-instances/src/Bittide/Instances/Hitl/GenericDemo/Core.hs Outdated
Comment thread bittide/src/Bittide/ElasticBuffer.hs Outdated
Comment on lines +151 to +153
instance Protocol (DcFifoIO n readDom writeDom a) where
type Fwd (DcFifoIO n readDom writeDom a) = DcFifoInput readDom writeDom a
type Bwd (DcFifoIO n readDom writeDom a) = DcFifoOutput n readDom writeDom a

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Just saw that @hiddemoll also left a comment, but can you use DcFifoIn and DcFifoOut directly in your Circuit's? I think this would side step your Bwd issue.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

I don't think it would, since I would still need the DcFifoOutput to be backpressure from another circuit, which would still make me unable to bind it in circuit notation.

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 this pull request may close these issues.

3 participants