verilogContents method
- int indent,
- Map<
String, String> inputsNameMap, - Map<
String, String> outputsNameMap, - String assignOperator,
override
Returns a String of SystemVerilog to be used in generated output.
The indent
is used for pretty-printing, and should generally be
incremented for sub-Conditionals. The inputsNameMap
and
outputsNameMap
are a mapping from port names to SystemVerilog variable
names for inputs and outputs, respectively. The assignOperator
is the
SystemVerilog operator that should be used for any assignments within
this Conditional.
Implementation
@override
String verilogContents(int indent, Map<String, String> inputsNameMap,
Map<String, String> outputsNameMap, String assignOperator) {
final padding = Conditional.calcPadding(indent);
final verilog = StringBuffer();
for (final iff in iffs) {
final header = iff == iffs.first
? 'if'
: iff is Else
? 'else'
: 'else if';
final conditionName = inputsNameMap[driverInput(iff.condition).name];
final ifContents = iff.then
.map((conditional) => conditional.verilogContents(
indent + 2, inputsNameMap, outputsNameMap, assignOperator))
.join('\n');
final condition = iff is! Else ? '($conditionName)' : '';
verilog.write('''
$padding$header$condition begin
$ifContents
${padding}end ''');
}
verilog.write('\n');
return verilog.toString();
}