IterativeDividerEngine constructor
Creates a direct-control iterative divider.
Implementation
IterativeDividerEngine({
required Logic clk,
required Logic reset,
required Logic start,
required Logic dividend,
required Logic divisor,
required Logic isSigned,
String name = 'iterative_divider_engine',
}) : dataWidth = dividend.width,
super(
definitionName: 'IterativeDividerEngine_W${dividend.width}',
name: name,
) {
if (dividend.width != divisor.width) {
throw ArgumentError('Dividend and divisor widths must match.');
}
clk = addInput('clk', clk);
reset = addInput('reset', reset);
start = addInput('start', start);
dividend = addInput('dividend', dividend, width: dividend.width);
divisor = addInput('divisor', divisor, width: divisor.width);
isSigned = addInput('isSigned', isSigned);
final dividerInterface = MultiCycleDividerInterface(dataWidth: dataWidth);
dividerInterface.clk <= clk;
dividerInterface.reset <= reset;
dividerInterface.validIn <= start;
dividerInterface.dividend <= dividend;
dividerInterface.divisor <= divisor;
dividerInterface.isSigned <= isSigned;
dividerInterface.readyOut <= Const(1);
final divider = MultiCycleDivider(dividerInterface, name: '${name}_core');
addOutput('quotient', width: dataWidth) <= divider.quotient;
addOutput('remainder', width: dataWidth) <= divider.remainder;
addOutput('divZero') <= divider.divZero;
addOutput('busy') <= ~divider.readyIn;
addOutput('done') <= divider.validOut;
}