generateModelSystemCHierarchy function

ModelSystemCHierarchy generateModelSystemCHierarchy(
  1. Module top, {
  2. required ModelSystemCSelector select,
  3. SystemCUnknownOutputPolicy unknownOutputs = SystemCUnknownOutputPolicy.error,
})

Generates a two-state SystemC hierarchy with explicit behavioral leaves.

Every selected module must expose a portable model with exactly matching input and output names and widths. Unselected modules use ROHD's normal SystemC synthesizer and its normal unsupported-module checks.

Implementation

ModelSystemCHierarchy generateModelSystemCHierarchy(
  Module top, {
  required ModelSystemCSelector select,
  SystemCUnknownOutputPolicy unknownOutputs = SystemCUnknownOutputPolicy.error,
}) {
  final synthesizer = _BehavioralSystemCSynthesizer(select, unknownOutputs);
  final builder = SynthBuilder(top, synthesizer);
  final topClassName = builder.instanceTypeOf(top);
  if (topClassName == null) {
    throw UnsupportedError('Top module ${top.uniqueInstanceName} does not '
        'produce a SystemC definition.');
  }
  return ModelSystemCHierarchy._(
    topClassName,
    '#include <systemc.h>\n'
    '${builder.getSynthFileContents().map((file) => file.contents).join('\n')}',
  );
}