Replies: 4 comments 2 replies
-
|
These are all possible in BSV, in various ways. The examples are vague, though, so I'm not sure what to suggest, beyond looking at typeclasses, provisos, and numeric type constructors. Perhaps you can make it more concrete by giving an example of code that you want to write, even if the types or syntax doesn't work? For example, here is one way of generating a new type using provisos: Here, the numeric size In the In the above example, the To make the example more concrete, Are those the kind of things that you're asking for? You can also do things like this: Inside the case arms, you can instantiate things of any size. However, there are limitations, in that any types they touch from outside the case arm has to match. So, for example, Does that help? |
Beta Was this translation helpful? Give feedback.
-
|
I apologize for not providing clear examples. ex1. MergeSort Staging and Type-Level Calculation However, the required FIFO depth varies at each stage. While the FIFO itself can be configured using an Integer fifoDepth, if I want to optimize the counter within each stage, I need to implement different widths of them. At this point, I am unable to determine the size based on stageIdx, nor can I use num to know which stage I am currently at. Perhaps this problem can be simplified as follows: What I mean is, I wish to perform complex type-level calculations, similar to what we can do with Integer values. Is this possible now, or planned for the future? ex2. Parameterized AXIS Port Generation Below is a simplified version of the example: Before python preprocessing: After python preprocessing: Any suggestions or best practices for achieving this kind of type-level computation or parameterization in BSV? |
Beta Was this translation helpful? Give feedback.
-
|
Thank you for providing the induction method. I believe this can solve most of my problems and is very practical. Additionally, your reminder about using Regarding my initial |
Beta Was this translation helpful? Give feedback.
-
|
Recently, I discovered a more relevant example. When using MIMO(To be more specific, I used mkMIMOV), I need to determine the size. However, in some cases, the size can be roughly calculated as max_in + max_out + (max_in - gcd(max_in, max_out)). When I want to package this into a module that automatically infers the size, I cannot find a good approach to do so. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Since I started using BSV, I have truly enjoyed working with it as my development HDL.
However, I have encountered a somewhat unfortunate limitation regarding dynamic generation capabilities. Languages like Chisel3 and even traditional Verilog can dynamically generate corresponding hardware types, whereas in BSV, everything is static. The advantage of this approach is clear: it provides excellent design control and reduces errors.
Although it is possible to use preprocessing tools like Python to assist with dynamic generation, it does not seem as direct or straightforward.
As BSV continues to evolve, I wonder if there is any possibility of adding syntax specifically for generating numeric types, types, or even interfaces. While I understand this may not be easy, such a feature would greatly enhance parameterization and make hardware generation even more powerful.
ex1.
Within a module, multiple submodules may need to be instantiated, each with a different type. However, all these types can be determined based on a specific type or numeric type parameter.
ex2.
The types used in an interface could also be determined by an input numeric type, which specifies both the number of elements and their respective types.
Beta Was this translation helpful? Give feedback.
All reactions