<_florent_>
whitequark[cis]: When using "do_finalize" method of a Migen Module, the submodules are finalized (and I use this when I need logic to be dynamically generated, sophisticated preprocessing), but concepts are indeed different and only doing one elaboration phase in Amaranth is probably simpler/cleaner.
<whitequark[cis]>
_florent_: What doesn't work is adding a submodule *somewhere else in the design tree*
<whitequark[cis]>
That was one of the bugs in Migen that led me to abandoning that design entirely, because there is no way to meaningfully resolve this and have a well defined finalization order still
<whitequark[cis]>
jersey99: there is no AutoCSR in Amaranth. the syntax for creating and adding a CSR is lightweight enough introspection isn't necessary
<_florent_>
whitequark[cis]: ok thanks, do you have practical example for the this limitation? (sorry still waking up and not sure I encountered this limitation).
<whitequark[cis]>
iirc it was in Glasgow where an applet would run do_finalize, and it held a reference to a multiplexer elsewhere, which would create a per applet module
<whitequark[cis]>
so if the applet would finalize before the multiplexer, everything worked out fine
<whitequark[cis]>
and if it was after, the wires would silently be disconnected
<whitequark[cis]>
after debugging that I was incensed and together with the issue where there was no async reset (another thing that made one of core Glasgow features outright impossible) decided to just rewrite the whole thing more competently
<whitequark[cis]>
though it took some more time to actually do it
<whitequark[cis]>
the core problem with Migen (and MiSoC) is that they were never designed, it is just an amalgamation of features someone needed (in some cases just once) rather than a coherent system with a high-level goal and structure
<whitequark[cis]>
core technological problem, that is
cr1901_ has joined #litex
cr1901 has quit [Ping timeout: 248 seconds]
<_florent_>
whitequark[cis]: ok I see. For Migen/MiSoC, let's say that LiteX or Amaranth would not even exist without this amalgamation, this was a completely different approach in HDL design that had to be explored and now improved or re-designed through newer projects. At the time, it was also mostly self-funding development and funding was also coming almost exclusively from projects created with the tools.
<whitequark[cis]>
considering that I worked for Sebastien Bourdeauducq, I wish it did not existed, because people like him should not either.
<whitequark[cis]>
if anything, the purpose of Amaranth is to recoup the very personal cost I paid by spending a chunk of my life at M-Labs, a cost that no one should pay
<whitequark[cis]>
I wish you warned me when you've seen him courting me back at #qi-hardware of the kind of person he is, and I wish I never touched any part of this space in my life
<whitequark[cis]>
I don't expect you to understand. I only want to make it clear where I stand.
<_florent_>
I perfectly understand, I also hard times with him, but only started to realized the situation when you were already involved for quite some time.
<whitequark[cis]>
I would not describe being treated worse than an object (people typically care about their tools, you see) as "hard times"
<whitequark[cis]>
I do not think you actually understand, to be honest
acathla has quit [Ping timeout: 246 seconds]
<whitequark[cis]>
if you did, you would not come and defend him to my face.
<_florent_>
hard time is probably not the appropriate description indeed, but each time I was receiving a mail from him, it ruined my day and I was completely stressed for a few hours/days.
<whitequark[cis]>
now imagine how it would feel to have your life be completely dependent on him, to the point where he (and his transphobic south african buddy) are the only people you know in the entire country
<whitequark[cis]>
this was intentional, of course; so was paying just enough to stay alive, but never to save enough to be able to easily move on in life
<whitequark[cis]>
(I know because he bragged to one of the people I know--who he also abused--how much money his company has)
<whitequark[cis]>
it's a really straightforward strategy: find technically competent but socially isolated young people, hire, exploit until nothing left, throw in the trash, repeat
<whitequark[cis]>
pay lip service to being queer-friendly while in public and treat us like meat when he thinks no one is listening, too, while at it
<whitequark[cis]>
he made a point out of calling me "Catherine" because I have a large following, while calling a trans friend (who isn't well known) by the name she hates over and over. you have to be really narcissistic to believe no one would notice
<_florent_>
hmm, I'm not defending him. I also paid enough personally from this "experience". I'm just saying: OK, he created Migen/MiSoC and introduced a different approached to HDL design, now let's just learn from this (technical and behavioral issues) and do something better!
<whitequark[cis]>
all right. I can get behind that
<whitequark[cis]>
the last ... year or so of Amaranth's evolution has consisted mostly of replacing behavior inherited from Migen with something that's much closer to what traditional programming languages do
<whitequark[cis]>
actually, one of my goals when making the very first draft of Amaranth was to do this back in 2018
<whitequark[cis]>
some of the things I genuinely did not anticipate being a problem and thought they were fine. some others I was pressured to ship ASAP
<whitequark[cis]>
the build/platform system suffered especially badly. I know it's one of the sticking points for LiteX migrating to Amaranth and I entirely agree, it sucks. I did my best to build something that works well in the very limited timeframe but wasn't especially successful
<whitequark[cis]>
one other component that has been a source of a huge amount of the technical debt is the fragment / AST rewriting system
<whitequark[cis]>
and the associated clock domain propagation logic
<whitequark[cis]>
this is actually a potential problem for LiteX migration because I plan to get rid of the clever Migen rules entirely and use a straightforward variable binding system instead, which is as old as ALGOL 60
<whitequark[cis]>
in short: in the elaboration hierarchy, every scope (not module; scope) has a dictionary of "domain name" to "clock", "sync reset", "enable", "async reset" associated with it
<whitequark[cis]>
instead of modifying what's passed to it, things like DomainRenamer, ResetInserter, EnableInserter would all bind names in this dictionary (rebind in case of renaming, bind to old_rst|inserted_rst in case of ResetInserter, bind to old_en&inserted_en in case of EnableInserter)
<whitequark[cis]>
this makes it really easy to introduce local "clock domains" that are used just inside of one module (maybe you need to resynchronize something and that's it, like in AsyncResetSynchronizer which is expressible in Amaranth without any custom primitives), and also makes the whole thing a lot more structured
<_florent_>
interesting, I think that's close to what I was also experimenting when doing some tests for an alternative HDL.
<whitequark[cis]>
it's very obvious if you have a good background in programming languages
<whitequark[cis]>
a lot of what I'm doing with Amaranth can be described as "making it boring"
<whitequark[cis]>
I think it's good to have a language that's as boring and usual as possible because then you can rely on this solid base to build exciting things
<whitequark[cis]>
which is I guess why you like the idea of it as a base for LiteX
<whitequark[cis]>
I've done a fair share of experiments myself, e.g. my Yumewatari PCIe stack that used a language-integrated parser, but they never went into Amaranth because they were too complicated and hard to use
<whitequark[cis]>
so for global clock domains, there would at least be a separate pass that plucks out all of the clock domains declared global (i.e. propagating up in the hierarchy) and defines them on the top module, while resolving naming conflicts
<whitequark[cis]>
which is necessary for compatibility
<whitequark[cis]>
the broad approach that Migen used for clock domains isn't that difficult to preserve but there are a lot of edge cases and I'm not thinking of investing too much effort into compatibility with something I think isn't designed very well in first place
<whitequark[cis]>
which is the part where LiteX could have issues in the future
cr1901__ has joined #litex
cr1901_ has quit [Ping timeout: 246 seconds]
<_florent_>
thanks, all your efforts to simplify things are indeed going in the right direction. trabucayre just started working with me this week and together we should be able to spend more time on tests with Amaranth.
<whitequark[cis]>
thank you, I appreciate your feedback and the trust you place in me
<whitequark[cis]>
I'm pretty busy getting 0.4 out the door but after that I should be able to look into preserving the compat layer in a reliable way
<whitequark[cis]>
do you think it should be a part of the Amaranth org or of LiteX?
<whitequark[cis]>
I'm happy to offer/donate this work to the LiteX org since then you would be free to hack it to any of your needs or desires
<whitequark[cis]>
I also don't mind having it as a separate package in the Amaranth org
<_florent_>
having it in LiteX could make senses yes, as you say to have the customize it/maintain it without taking using your time for this. And having control on this is also interesting to speed up adapting things when required.
<whitequark[cis]>
yes, exactly, especially the control aspect I think could really benefit LiteX
<whitequark[cis]>
I can see LiteX continuing to use the old syntax but adjusting semantics to have its own dialect and I think this could be beneficial in a number of ways, potentially
<whitequark[cis]>
okay, in that case, I will prepare the module as a standalone artifact and donate it to LiteX
<whitequark[cis]>
then you can do whatever you want with it, and the technical contract would only have upstream Amaranth in it
<whitequark[cis]>
this is also beneficial to me as the Amaranth language lead
<_florent_>
great, having control on this intermediate layer is indeed an important aspect and this could also ease potential conversion to native Amaranth (would make it progressive).
<whitequark[cis]>
fwiw, the core idea with the 'new' compat layer is that it won't inherit from Amaranth's classes which at this point resemble Migen's more and more distantly
<whitequark[cis]>
but instead it would have entirely its own class hierarchy which uses Amaranth's ValueCastable to adapt it to what LiteX code expects from the HDL
<whitequark[cis]>
ValueCastable and ShapeCastable are a really powerful technique that let you use the HDL as a LEGO kit and assemble whatever you want out of it, even a completely different HDL
<whitequark[cis]>
I think it might be the single most important Amaranth innovation (though not the most important thing overall; for that I would say it is the diagnostics)
<whitequark[cis]>
for example, it allows having type-safe(-ish) enums, where the toolchain will error out if you are assinging to the wrong enum type without an explicit cast
<whitequark[cis]>
e.g. foo = Signal(EnumA); m.d.comb += foo.eq(EnumB.X) is prohibited if EnumA is an Amaranth enum and not a normal Python one
<whitequark[cis]>
I think complex codebases like LiteX could really benefit from additional safety like this
<whitequark[cis]>
I will most likely throw out the existing amaranth.compat layer entirely and instead take Migen's core modules and rework them to desugar down to Amaranth expressions
<_florent_>
thanks, having you involved in this will clearly help a lot. BTW, as discussed during the call, happy to see how I can fund or help funding this work.
<whitequark[cis]>
that would certainly help; I have a lot on my plate but I'll work out how this can fit into the overall roadmap and in consideration of other responsibilities