Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 24 additions & 10 deletions lib/src/configs/cosim_wrap_config.dart
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@

import 'dart:io';

import 'package:rohd/rohd.dart';
import 'package:rohd_cosim/rohd_cosim.dart';

/// A selection of a type of SystemVerilog Simulator.
Expand Down Expand Up @@ -139,16 +140,29 @@ class CosimWrapConfig extends CosimProcessConfig {
{String? dumpWavesString}) {
final wrapperVerilog = [
'module $_wrapperName();',
...registrees.entries
.map((registreeEntry) => registreeEntry.value.instantiationVerilog(
'dont_care',
registreeEntry.key,
{
...registreeEntry.value.inputs,
...registreeEntry.value.outputs,
...registreeEntry.value.inOuts,
}.map((key, value) => MapEntry(key, '')),
)),
...registrees.entries.map((registreeEntry) {
final instanceName = registreeEntry.key;
final module = registreeEntry.value;
final instanceType = module.definitionName;
final ports = {
...registreeEntry.value.inputs,
...registreeEntry.value.outputs,
...registreeEntry.value.inOuts,
}.map((key, value) => MapEntry(key, ''));

return module.instantiationVerilog(
instanceType,
instanceName,
ports,
) ??
SystemVerilogSynthesizer.instantiationVerilogFor(
module: module,
instanceType: instanceType,
instanceName: instanceName,
ports: ports,
forceStandardInstantiation: true,
);
}),
if (dumpWavesString != null) dumpWavesString,
'endmodule'
].join('\n');
Expand Down
13 changes: 11 additions & 2 deletions lib/src/cosim.dart
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ class _CosimMessage {
/// When applied to a [ExternalSystemVerilogModule], will configure it so that
/// it can be cosimulated in a SystemVerilog simulator along with the ROHD
/// simulator.
mixin Cosim on ExternalSystemVerilogModule {
mixin Cosim on SystemVerilog {
/// A list of verilog source files to include in the build.
///
/// The contents are put in a Makefile, so environment variables should use
Expand Down Expand Up @@ -108,6 +108,13 @@ mixin Cosim on ExternalSystemVerilogModule {
/// module to something else.
String get cosimHierarchy => registreeName;

/// If set, then this [Module] will be registered for cosimulation.
///
/// This flag can be used to determine whether additional modelling logic or
/// design should be generated within the module or if it should be left to
/// cosimulation to handle behavior.
bool get cosimEnabled => true;

/// Resets all context for cosimulation.
///
/// Note that any [Cosim]s already built will need to be reregistered via
Expand Down Expand Up @@ -163,7 +170,9 @@ mixin Cosim on ExternalSystemVerilogModule {

@override
Future<void> build() async {
cosimRegister();
if (cosimEnabled) {
cosimRegister();
}
await super.build();
}

Expand Down
Loading