verilogContents method Null safety

  1. @override
String verilogContents(
  1. int indent,
  2. Map<String, String> inputsNameMap,
  3. Map<String, String> outputsNameMap,
  4. 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 conditionName = inputsNameMap[driverInput(condition).name];
  final ifContents = then
      .map((conditional) => conditional.verilogContents(
          indent + 2, inputsNameMap, outputsNameMap, assignOperator))
      .join('\n');
  final elseContents = orElse
      .map((conditional) => conditional.verilogContents(
          indent + 2, inputsNameMap, outputsNameMap, assignOperator))
      .join('\n');
  var verilog = '''
${padding}if($conditionName) begin
$ifContents
${padding}end ''';
  if (orElse.isNotEmpty) {
    verilog += '''
else begin
$elseContents
${padding}end ''';
  }

  return '$verilog\n';
}