Conversation
|
For me a key functionality of a SerDes is that it also adapts between in phase clock domains. So for example if you have an My "ideal" deseralizer would have function type(ignoring clocks and other pesky constraints):
I'm not a fan of the magic conversion of types and resizing it does currently. That can be fixed by the user explicitly imo if they want that. And with such a footgun I rather make the user type it out explicitly. |
|
Thanks Rowan. That's exactly the feedback I was looking for.
|
|
So if the goal for you is not to write a serdes as I described then I would say doing 1. is overkill, unless, of course, you'd like to do it :). In your case I would call this a up/downconverter. In clash-protocols we have that naming for a similar component for packet streams regarding the resize. I would keep make the signature Then users need to handle conversion separately, before or after this function. In the case of simple bit like things it could just be a |
|
Yea, I've noticed this is a common pattern in Haskell - why use one function when three will do. Put another way, Haskell really likes composing unopinionated functions rather than defining "opinionated functions that are what you want 85% of the time". So it naturally occurred to me to write the helper function that you PROBABLY want (because I'm used to non-Haskell), not realizing the problem can be pretty elegantly decomposed into a couple functions, so that parts can be swapped out (the conversion function, as you mention). Pretty cool imo. I'll have a bit of a think about how I'd like to break it down. What are your thoughts on the verb "accumulate" instead of upConvert? Would that also work as a name or does that have a different definition already in hardware? (still learning the terminology) |
|
For such generic functions it would be nice if they have a configuration option that allows you to shift either LSb first or MSb first. |
|
I’m not against having opinionated functions, but I prefer building them on top of non-opinionated ones. A function that performs both resize and unpack, however, feels like a footgun. It makes it too easy to accidentally convert an accumulated The circuit itself is definitely useful, but given the potential for misuse and how concise the manual conversion already is, I’d rather have users spell it out explicitly. If the width conversion and unpacking were more cumbersome, I’d lean the other way. In that case the function would need very clear documentation warning that it can produce malformed values if used carelessly. |
kleinreact
left a comment
There was a problem hiding this comment.
You forgot to reference the origin of these sources. Please add the following remark:
This work has been supported in part by funding from the Agentur für Innovation in der Cybersicherheit GmbH (Cyberagentur).
|
The main issue for me (why I originally made the impl. opinionated) is the work one has to do on the type level. Specifically, when you have a circuit So maybe I've just talked myself into agreeing with you. |
Serializing from/to an arbitrary
ais a common enough glue circuit that I figured I'd just add it to cores.Right now, I'm looking for feedback on the type signatures and implementation of
deserialize,serialize, andserializeWithInitialState. I'm not particularly looking for feedback on the wording of comments (subject to change) or the unit tests, which I plan to flesh out with HedgeHog etc.I figure the more "glue" circuits we add to cores, the more users can focus on the business logic of their circuits.