Comments (8)
You can write a function sop
yourself. This does not need to be an Amaranth built-in.
from amaranth.
True, but you can also write any()
and all()
yourself. mux()
is another thing you can do yourself.
Sum of products/product of sums are common operations; I also considered sending a pull request for this but it was late and it's not immediately obvious to me the correct way to iterate over an array passed to a function to carry out the sop()
or pos()
functions. Maybe any([all(x) for x in inputarray])
or is that not how amaranth works? I think it should work, maybe? Probably.
Given how common the operation is, I actually went looking through the docs and codebase before making a feature request, since it wasn't obvious I wasn't just missing something.
from amaranth.
True, but you can also write
any()
andall()
yourself.mux()
is another thing you can do yourself.
any()
and all()
are standard Python functions. Mux()
is the Amaranth equivalent of the standard Python x if y else z
construct. sop()
and pos()
do not have a Python correspondence.
Sum of products/product of sums are common operations
That's not really the case in my experience. You're the first person who wanted a first-class sum-of-product operation that I'm aware of.
In any case, additions to the public API have to go through the RFC process.
from amaranth.
That makes sense
True, but you can also write
any()
andall()
yourself.mux()
is another thing you can do yourself.
any()
andall()
are standard Python functions.Mux()
is the Amaranth equivalent of the standard Pythonx if y else z
construct.sop()
andpos()
do not have a Python correspondence.
That makes sense.
Sum of products/product of sums are common operations
That's not really the case in my experience. You're the first person who wanted a first-class sum-of-product operation that I'm aware of.
I'm not sure those two things are equivalent, but fair enough. Large functions are impossible to k-map anyway since you need to do them in an n-dimensional hypercube for 2n inputs (k-mapping is an optimization technique used to minimize logic by finding the optimal sum-of-products/product-of-sums equation; the other method is Quine-McClusky, which is np-hard because you need to solve the set covering problem, and that outputs sop/pos too).
In any case, additions to the public API have to go through the RFC process.
Thanks, I'll look through that.
from amaranth.
Amaranth primarily targets FPGAs and ASICs and the open toolchain uses AIG-based synthesis for either, meaning neither K-maps nor Quine-McClusky are relevant at all for any of the main flows. CPLDs used to use those heavily but there is no CPLD toolchain explicitly supported at the moment (I think you could do some weird things with ISE but I'm not aware of anyone who has done that on a more than curiosity basis).
Even if K-maps were used, Amaranth is a high-level frontend that leaves all of the mapping work to the underlying toolchain, so even then I don't see the relevance of SOP/POS in the frontend.
from amaranth.
Sum of products/product of sums are common operations
That's not really the case in my experience. You're the first person who wanted a first-class sum-of-product operation that I'm aware of.
Minimizing SOP/POS equations with Amaranth can be useful to implement complex instruction decoders. For example, Chisel provides one in its libraries, where minimization is done with QMC or by shelling out to Espresso.
This is probably too niche for Amaranth stdlib, but such functionality could make a good downstream library.
from amaranth.
Minimizing SOP/POS equations with Amaranth can be useful to implement complex instruction decoders. For example, Chisel provides one in its libraries, where minimization is done with QMC or by shelling out to Espresso.
This is probably too niche for Amaranth stdlib, but such functionality could make a good downstream library.
Fair point. I've used similar things when writing a RISC-V decoder or a Gameboy Color MMU emulator, with ugly things like (x & 'b0101 == 'b0101) | (x & 'b1011 == 'b1010))
(i.e. (b&d)|(a&c&~d)
) and so forth in verilog long ago. Lots of overly complex case
statements I'd rather replace with something more elegant. ...thinking about that code kind of makes me not feel so bad my SSD died without backups.
Wonder what else would go in such a library, but that's probably a conversation for somewhere other than here.
from amaranth.
I'm going to close this because there isn't enough interest in the feature that I've seen over the years to continue tracking it. It is still open for commenting, and of course anyone can submit an RFC for this feature or any other one.
from amaranth.
Related Issues (20)
- Tracking issue for RFC 61: Minimal stream interface
- `execute_local_docker()` does not forward SIGINT/ctrl+c to docker subprocess HOT 4
- Bit width of `Signal(range(1))` HOT 2
- verilog output error: syntax error in left side of continuous assignment. HOT 2
- Wrong verilog for combinatorial module HOT 2
- pysim LHS compiler miscompiles `Slice` of `SwitchValue`
- `Signal.like` is not fully functional with `ShapeCastable`-based signals
- Tracking issue for RFC 63: Remove `amaranth.lib.coding`
- Tracking issue for RFC 65: Special formatting for structures and enums
- Question: Combinational vs Combinatorial HOT 7
- Pyright errors on `m.[If/Elif/Else]`: No `__enter__` or `__exit__` HOT 1
- Unclear error message on `m.domains.cd_tx = ClockDomain()`
- Can't emit Verilog/RTLIL with Signature array members HOT 1
- Add `AMDPlatform`, aliasing `XilinxPlatform`
- Make `Module` explode if you try to modify it after it's elaborated
- Extremely slow Verilog generation HOT 5
- Pysim should reject async generators
- Constraint generation from platform resource with `DiffPairs` of type LVDS incorrect. HOT 1
- Adding simulator processes after starting the simulation is not well-defined HOT 2
- Indexing into signals with layouts could be improved HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from amaranth.