Open bpadalino opened 1 week ago
hi, thanks for the suggestion.
A couple of things here:
The things I didn't like about your original approach:
Understood it was an exercise in rust, but I think it was still a missed opportunity. The optimal networks have been identified and the JSON created. That JSON is never changing unless some new network is found. You'd be better off writing a translation from JSON -> VHDL function similar to what I have prototyped. You rely on the external program/JSON once instead of requiring it every time. If you want to make your own sorting network, make your own comparisons matrix and pass it into the sorting network all in VHDL - no need to get other tools involved. This is how I would have approached the problem for all the optimal input networks up to 64 elements that I saw on the linked pages. The package is then static and fixed, works for all data types, and uses the same entity for all sorting networks. This can even go into a single VHDL file so it's a super easy include for anyone.
Agreed about the pipelining, though I think an array of booleans that is the size that matches the number of stages is more clear than using an slv.
Agreed that VHDL-2019 is not very well supported, but if constructs like this are never written in it and not pushed to vendors they will never support it. Chicken and egg problems. On the other hand, generic types and generic subprograms were introduced in 2008 and are mostly supported by vendors.
I'm not sure I understand the comment about the VHDL code being as simple as possible.
I mean sure, we could only have one very generic VHDL file that reads the json files and then produce the entity we want. My main issue with this is that the resulting source file for the actual rtl would be this not-so-easy-to-read VHDL file (especially for others who might not be used to these language features). I chose to outsource the complexity and let the resulting .vhd file contain primitive elements only. Both are probably valid options.
Maybe you know these register map generator tools like Airhdl or Corsair. They also generate rather simple hdl code and let the generator contain the complexity. As a user I prefer that, because I don't want to deal with the details, how to get to the solution. I just want it to be as simple as possible and instantiate it, nothing more. If anyone has questions how the module works, they can easily inspect the generated code.
I'm not sure I understand the comment about the VHDL code being as simple as possible.
The sad reality is that many HDL coders, especially some of the older generations, don't trust the more fancy features of VHDL. And to a degree, I can't blame them. With all these compilers from different vendors and also FOSS, it is not always so easy to predict which language feature will lead to what outcome on hardware. There is also the question of simulators. I am not sure if every single one of those support these language features. Maybe they do. But I am sure that they support my version of it.
Also the reality is that other languages such as Python are vastly more popular than VHDL, which means that there is more support in terms of libraries, questions answered, advanced support in editors and so on. Meanwhile VHDL, let's face it, despite having been modernized in 2008 and 2019, let's just say, in order to write software modules I would probably choose 20 other languages over VHDL. Don't get me wrong, I generally like the language. But in the end, I choose it because I have to.
I saw your reddit post and thought it's a good task to try and make into a pure generic VHDL thing, especially with VHDL-2019 constructs. I've put together the following:
It might be nice to fill it out to up to 64 inputs and add in the pipeline stages, but either way it might be nice to include a VHDL-only version instead of relying on rust to generate something.
What do you think?