Description
I'd like to propose adding a Multiply-Accumulate (MAC) unit to the arithmetic components library. This would be a valuable addition for users working on digital signal processing (DSP), filtering algorithms, and other applications requiring efficient multiply-accumulate operations.
Current Situation
Currently, Digital has excellent arithmetic components including:
- Adders (
Add)
- Multipliers (
Mul)
- Subtractors (
Sub)
- Dividers (
Div)
- Comparators (
Comparator)
However, there's no dedicated MAC unit that combines multiplication and accumulation in a single component.
Proposed Component
A MAC unit that performs: accumulator = accumulator + (a × b)
Key Features
-
Inputs:
- a, b: Operands (configurable bit width, n-bit)
- clr: Clear/reset accumulator
- en: Enable update (allows controlled accumulation)
- Optional: init for preset value
-
Outputs:
- mac: Accumulator value (configurable bit width, typically 2n-bit)
- ovf: Overflow flag indicating when accumulator exceeds its capacity
- Optional: ready flag for pipelined operation
-
Configuration Options:
- Operand bit width (default: 8)
- Accumulator bit width (default: operand width × 2)
- Signed/unsigned mode selection
- Saturation mode vs. wrap on overflow
- Optional pipeline stages for high-frequency designs
Example Use Cases
-
Digital Filtering: Implementing FIR/IIR filters
for each sample:
accumulator = 0
for each coefficient:
accumulator = accumulator + (sample * coefficient)
-
Matrix Multiplication: Computing dot products
-
Signal Processing: Autocorrelation, convolution
-
Neural Networks: Weighted sum calculations
Benefits
- Reduced Circuit Complexity: One component instead of multiple adders, multipliers, and registers
- Better Performance: Internal architecture can be optimized for accumulation
- Improved Readability: Makes circuit diagrams cleaner for DSP applications
- HDL Generation: Can generate optimized VHDL/Verilog for MAC operations
- Consistency: Follows the pattern of existing arithmetic components
Implementation Approach
The implementation would follow the same pattern as existing components:
public class Mac extends Node implements Element, Countable {
// Similar structure to Add.java and Mul.java
// Uses observable pattern for reactive updates
// Supports HDL generation
}
Alternative Approaches Considered
-
Manual Construction: Users can currently build MAC from separate Mul + Add + register
- Drawback: More complex, harder to optimize, less readable
- Why not preferred: DSP applications often require many MAC units
-
Parameterized Macro: Could use subcircuits
- Drawback: Not as flexible or efficient
Additional Considerations
- Backward Compatibility: New component won't affect existing circuits
- Performance: Could be optimized more than separate components
- Testing: Can be thoroughly tested with existing test framework
- Documentation: Would need to add to component documentation
Questions for Discussion
- Should the accumulator bit width be fixed at 2× operand width or configurable?
- Should we support signed/unsigned modes?
- Is saturation on overflow needed, or should it just wrap?
- Should we include a "preset" input for initial accumulator value?
- Any concerns about VHDL/Verilog generation complexity?
Additional Context
- Existing similar components:
Add, Mul, Sub, Div
- Related DSP components that could be added in future: FIR filter, CORDIC
- Would be useful for users working on digital signal processing projects
I'm willing to implement this component and submit a pull request with:
- Complete Java implementation
- Unit tests
- Documentation updates
- Example circuits demonstrating usage
Looking forward to feedback and suggestions!
Description
I'd like to propose adding a Multiply-Accumulate (MAC) unit to the arithmetic components library. This would be a valuable addition for users working on digital signal processing (DSP), filtering algorithms, and other applications requiring efficient multiply-accumulate operations.
Current Situation
Currently, Digital has excellent arithmetic components including:
Add)Mul)Sub)Div)Comparator)However, there's no dedicated MAC unit that combines multiplication and accumulation in a single component.
Proposed Component
A MAC unit that performs:
accumulator = accumulator + (a × b)Key Features
Inputs:
Outputs:
Configuration Options:
Example Use Cases
Digital Filtering: Implementing FIR/IIR filters
Matrix Multiplication: Computing dot products
Signal Processing: Autocorrelation, convolution
Neural Networks: Weighted sum calculations
Benefits
Implementation Approach
The implementation would follow the same pattern as existing components:
Alternative Approaches Considered
Manual Construction: Users can currently build MAC from separate
Mul+Add+ registerParameterized Macro: Could use subcircuits
Additional Considerations
Questions for Discussion
Additional Context
Add,Mul,Sub,DivI'm willing to implement this component and submit a pull request with:
Looking forward to feedback and suggestions!