Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Issue-133] simcompare calculate signaltowidth instead of manual input #211

Merged
Show file tree
Hide file tree
Changes from 8 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
8 changes: 4 additions & 4 deletions lib/src/utilities/simcompare.dart
Original file line number Diff line number Diff line change
Expand Up @@ -144,19 +144,19 @@ abstract class SimCompare {

/// Executes [vectors] against the Icarus Verilog simulator.
static bool iverilogVector(
Module module,
String generatedVerilog,
quekyj marked this conversation as resolved.
Show resolved Hide resolved
String topModule,
quekyj marked this conversation as resolved.
Show resolved Hide resolved
List<Vector> vectors, {
bool dontDeleteTmpFiles = false,
bool dumpWaves = false,
Map<String, int> signalToWidthMap = const {},
List<String> iverilogExtraArgs = const [],
bool allowWarnings = false,
}) {
String signalDeclaration(String signalName) {
if (signalToWidthMap.containsKey(signalName)) {
final width = signalToWidthMap[signalName]!;
return '[${width - 1}:0] $signalName';
final signals = module.signals.firstWhere((e) => e.name == signalName);
quekyj marked this conversation as resolved.
Show resolved Hide resolved
if (signals.width != 1) {
return '[${signals.width - 1}:0] $signalName';
} else {
return signalName;
}
Expand Down
1 change: 1 addition & 0 deletions test/assignment_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ void main() {
];
await SimCompare.checkFunctionalVector(exampleModule, vectors);
final simResult = SimCompare.iverilogVector(
exampleModule,
exampleModule.generateSynth(),
exampleModule.runtimeType.toString(),
vectors,
Expand Down
76 changes: 11 additions & 65 deletions test/bus_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -252,49 +252,6 @@ void main() {
});

group('simcompare', () {
final signalToWidthMap = {
'a': 8,
'b': 8,
'a_bar': 8,
'a_and_b': 8,
'a_b_joined': 16,
'a_plus_b': 8,

// Slicing
'a_shrunk1': 3,
'a_shrunk2': 2,
'a_shrunk3': 1,
'a_neg_shrunk1': 3,
'a_neg_shrunk2': 2,
'a_neg_shrunk3': 1,
// Reverse Slicing
'a_rsliced1': 5,
'a_rsliced2': 2,
'a_rsliced3': 1,
'a_r_neg_sliced1': 5,
'a_r_neg_sliced2': 2,
'a_r_neg_sliced3': 1,

// getRange
'a_range1': 3,
'a_range2': 2,
'a_range3': 1,
'a_neg_range1': 3,
'a_neg_range2': 2,
'a_neg_range3': 1,

// operator[]
'a_operator_indexing1': 1,
'a_operator_indexing2': 1,
'a_operator_indexing3': 1,
'a_operator_neg_indexing1': 1,
'a_operator_neg_indexing2': 1,
'a_operator_neg_indexing3': 1,

// Logic bus value Reversed
'a_reversed': 8,
'expression_bit_select': 4,
};
test('NotGate bus', () async {
final gtm = BusTestModule(Logic(width: 8), Logic(width: 8));
await gtm.build();
Expand All @@ -306,8 +263,7 @@ void main() {
];
await SimCompare.checkFunctionalVector(gtm, vectors);
final simResult = SimCompare.iverilogVector(
gtm.generateSynth(), gtm.runtimeType.toString(), vectors,
signalToWidthMap: signalToWidthMap);
gtm, gtm.generateSynth(), gtm.runtimeType.toString(), vectors);
expect(simResult, equals(true));
});

Expand All @@ -324,8 +280,7 @@ void main() {

await SimCompare.checkFunctionalVector(gtm, vectors);
final simResult = SimCompare.iverilogVector(
gtm.generateSynth(), gtm.runtimeType.toString(), vectors,
signalToWidthMap: signalToWidthMap);
gtm, gtm.generateSynth(), gtm.runtimeType.toString(), vectors);
expect(simResult, equals(true));
});

Expand All @@ -343,8 +298,7 @@ void main() {

await SimCompare.checkFunctionalVector(gtm, vectors);
final simResult = SimCompare.iverilogVector(
gtm.generateSynth(), gtm.runtimeType.toString(), vectors,
signalToWidthMap: signalToWidthMap);
gtm, gtm.generateSynth(), gtm.runtimeType.toString(), vectors);
expect(simResult, equals(true));
});

Expand Down Expand Up @@ -382,8 +336,7 @@ void main() {
];
await SimCompare.checkFunctionalVector(gtm, vectors);
final simResult = SimCompare.iverilogVector(
gtm.generateSynth(), gtm.runtimeType.toString(), vectors,
signalToWidthMap: signalToWidthMap);
gtm, gtm.generateSynth(), gtm.runtimeType.toString(), vectors);
expect(simResult, equals(true));
});

Expand Down Expand Up @@ -421,8 +374,7 @@ void main() {
];
await SimCompare.checkFunctionalVector(gtm, vectors);
final simResult = SimCompare.iverilogVector(
gtm.generateSynth(), gtm.runtimeType.toString(), vectors,
signalToWidthMap: signalToWidthMap);
gtm, gtm.generateSynth(), gtm.runtimeType.toString(), vectors);
expect(simResult, equals(true));
});

Expand All @@ -436,8 +388,7 @@ void main() {
];
await SimCompare.checkFunctionalVector(gtm, vectors);
final simResult = SimCompare.iverilogVector(
gtm.generateSynth(), gtm.runtimeType.toString(), vectors,
signalToWidthMap: signalToWidthMap);
gtm, gtm.generateSynth(), gtm.runtimeType.toString(), vectors);
expect(simResult, equals(true));
});

Expand Down Expand Up @@ -475,8 +426,7 @@ void main() {
];
await SimCompare.checkFunctionalVector(gtm, vectors);
final simResult = SimCompare.iverilogVector(
gtm.generateSynth(), gtm.runtimeType.toString(), vectors,
signalToWidthMap: signalToWidthMap);
gtm, gtm.generateSynth(), gtm.runtimeType.toString(), vectors);
expect(simResult, equals(true));
});

Expand All @@ -492,8 +442,7 @@ void main() {
];
await SimCompare.checkFunctionalVector(gtm, vectors);
final simResult = SimCompare.iverilogVector(
gtm.generateSynth(), gtm.runtimeType.toString(), vectors,
signalToWidthMap: signalToWidthMap);
gtm, gtm.generateSynth(), gtm.runtimeType.toString(), vectors);
expect(simResult, equals(true));
});

Expand All @@ -507,8 +456,7 @@ void main() {
];
await SimCompare.checkFunctionalVector(gtm, vectors);
final simResult = SimCompare.iverilogVector(
gtm.generateSynth(), gtm.runtimeType.toString(), vectors,
signalToWidthMap: signalToWidthMap);
gtm, gtm.generateSynth(), gtm.runtimeType.toString(), vectors);
expect(simResult, equals(true));
});

Expand All @@ -524,8 +472,7 @@ void main() {
];
await SimCompare.checkFunctionalVector(gtm, vectors);
final simResult = SimCompare.iverilogVector(
gtm.generateSynth(), gtm.runtimeType.toString(), vectors,
signalToWidthMap: signalToWidthMap);
gtm, gtm.generateSynth(), gtm.runtimeType.toString(), vectors);
expect(simResult, equals(true));
});

Expand All @@ -537,8 +484,7 @@ void main() {
];
await SimCompare.checkFunctionalVector(gtm, vectors);
final simResult = SimCompare.iverilogVector(
gtm.generateSynth(), gtm.runtimeType.toString(), vectors,
signalToWidthMap: signalToWidthMap);
gtm, gtm.generateSynth(), gtm.runtimeType.toString(), vectors);
expect(simResult, equals(true));
});
});
Expand Down
2 changes: 1 addition & 1 deletion test/collapse_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ void main() {
];
await SimCompare.checkFunctionalVector(mod, vectors);
final simResult = SimCompare.iverilogVector(
mod.generateSynth(), mod.runtimeType.toString(), vectors);
mod, mod.generateSynth(), mod.runtimeType.toString(), vectors);
expect(simResult, equals(true));
});

Expand Down
15 changes: 5 additions & 10 deletions test/comb_math_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -128,8 +128,7 @@ void main() {
await SimCompare.checkFunctionalVector(mod, vectors);

final simResult = SimCompare.iverilogVector(
mod.generateSynth(), mod.runtimeType.toString(), vectors,
signalToWidthMap: {'codepoint': 21, 'bytes': 32});
mod, mod.generateSynth(), mod.runtimeType.toString(), vectors);
expect(simResult, equals(true));
});

Expand All @@ -147,8 +146,7 @@ void main() {

await SimCompare.checkFunctionalVector(mod, vectors);
final simResult = SimCompare.iverilogVector(
mod.generateSynth(), mod.runtimeType.toString(), vectors,
signalToWidthMap: {'codepoint': 21, 'bytes': 32});
mod, mod.generateSynth(), mod.runtimeType.toString(), vectors);
expect(simResult, equals(true));
});

Expand All @@ -162,8 +160,7 @@ void main() {
];
await SimCompare.checkFunctionalVector(mod, vectors);
final simResult = SimCompare.iverilogVector(
mod.generateSynth(), mod.runtimeType.toString(), vectors,
signalToWidthMap: {'a': 8, 'b': 8});
mod, mod.generateSynth(), mod.runtimeType.toString(), vectors);
expect(simResult, equals(true));
});

Expand All @@ -177,8 +174,7 @@ void main() {
];
await SimCompare.checkFunctionalVector(mod, vectors);
final simResult = SimCompare.iverilogVector(
mod.generateSynth(), mod.runtimeType.toString(), vectors,
signalToWidthMap: {'a': 8, 'b': 8});
mod, mod.generateSynth(), mod.runtimeType.toString(), vectors);
expect(simResult, equals(true));
});

Expand All @@ -192,8 +188,7 @@ void main() {
];
await SimCompare.checkFunctionalVector(mod, vectors);
final simResult = SimCompare.iverilogVector(
mod.generateSynth(), mod.runtimeType.toString(), vectors,
signalToWidthMap: {'a': 8, 'b': 8});
mod, mod.generateSynth(), mod.runtimeType.toString(), vectors);
expect(simResult, equals(true));
});
}
6 changes: 2 additions & 4 deletions test/comb_mod_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,7 @@ void main() {
];
await SimCompare.checkFunctionalVector(mod, vectors);
final simResult = SimCompare.iverilogVector(
mod.generateSynth(), mod.runtimeType.toString(), vectors,
signalToWidthMap: {'a': 8, 'b': 8});
mod, mod.generateSynth(), mod.runtimeType.toString(), vectors);
expect(simResult, equals(true));
});

Expand All @@ -83,8 +82,7 @@ void main() {
];
await SimCompare.checkFunctionalVector(mod, vectors);
final simResult = SimCompare.iverilogVector(
mod.generateSynth(), mod.runtimeType.toString(), vectors,
signalToWidthMap: {'a': 8, 'b': 8});
mod, mod.generateSynth(), mod.runtimeType.toString(), vectors);
expect(simResult, equals(true));
});
}
8 changes: 1 addition & 7 deletions test/comparison_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -51,11 +51,6 @@ void main() {
tearDown(Simulator.reset);

group('simcompare', () {
final signalToWidthMap = {
'a': 8,
'b': 8,
};

test('compares', () async {
final gtm = ComparisonTestModule(Logic(width: 8), Logic(width: 8));
await gtm.build();
Expand Down Expand Up @@ -108,8 +103,7 @@ void main() {
];
await SimCompare.checkFunctionalVector(gtm, vectors);
final simResult = SimCompare.iverilogVector(
gtm.generateSynth(), gtm.runtimeType.toString(), vectors,
signalToWidthMap: signalToWidthMap);
gtm, gtm.generateSynth(), gtm.runtimeType.toString(), vectors);
expect(simResult, equals(true));
});
});
Expand Down
12 changes: 5 additions & 7 deletions test/conditionals_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -185,8 +185,7 @@ void main() {
];
await SimCompare.checkFunctionalVector(mod, vectors);
final simResult = SimCompare.iverilogVector(
mod.generateSynth(), mod.runtimeType.toString(), vectors,
signalToWidthMap: {'d': 10, 'q': 10});
mod, mod.generateSynth(), mod.runtimeType.toString(), vectors);
expect(simResult, equals(true));
});

Expand All @@ -201,7 +200,7 @@ void main() {
];
await SimCompare.checkFunctionalVector(mod, vectors);
final simResult = SimCompare.iverilogVector(
mod.generateSynth(), mod.runtimeType.toString(), vectors);
mod, mod.generateSynth(), mod.runtimeType.toString(), vectors);
expect(simResult, equals(true));
});

Expand All @@ -216,7 +215,7 @@ void main() {
];
await SimCompare.checkFunctionalVector(mod, vectors);
final simResult = SimCompare.iverilogVector(
mod.generateSynth(), mod.runtimeType.toString(), vectors);
mod, mod.generateSynth(), mod.runtimeType.toString(), vectors);
expect(simResult, equals(true));
});

Expand All @@ -231,7 +230,7 @@ void main() {
];
await SimCompare.checkFunctionalVector(mod, vectors);
final simResult = SimCompare.iverilogVector(
mod.generateSynth(), mod.runtimeType.toString(), vectors);
mod, mod.generateSynth(), mod.runtimeType.toString(), vectors);
expect(simResult, equals(true));
});

Expand All @@ -248,8 +247,7 @@ void main() {
];
await SimCompare.checkFunctionalVector(mod, vectors);
final simResult = SimCompare.iverilogVector(
mod.generateSynth(), mod.runtimeType.toString(), vectors,
signalToWidthMap: {'d': 8, 'q': 8});
mod, mod.generateSynth(), mod.runtimeType.toString(), vectors);
expect(simResult, equals(true));
});
});
Expand Down
5 changes: 2 additions & 3 deletions test/counter_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -72,9 +72,8 @@ void main() {
Vector({'en': 0, 'reset': 0}, {'val': 5}),
];
await SimCompare.checkFunctionalVector(counter, vectors);
final simResult = SimCompare.iverilogVector(
counter.generateSynth(), counter.runtimeType.toString(), vectors,
signalToWidthMap: {'val': 8});
final simResult = SimCompare.iverilogVector(counter,
counter.generateSynth(), counter.runtimeType.toString(), vectors);
expect(simResult, equals(true));
});
});
Expand Down
3 changes: 1 addition & 2 deletions test/counter_wintf_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,7 @@ void main() {
];
await SimCompare.checkFunctionalVector(mod, vectors);
final simResult = SimCompare.iverilogVector(
mod.generateSynth(), mod.runtimeType.toString(), vectors,
signalToWidthMap: {'val': 8});
mod, mod.generateSynth(), mod.runtimeType.toString(), vectors);
expect(simResult, equals(true));
});
});
Expand Down
6 changes: 2 additions & 4 deletions test/extend_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,7 @@ void main() {
await mod.build();
await SimCompare.checkFunctionalVector(mod, vectors);
final simResult = SimCompare.iverilogVector(
mod.generateSynth(), mod.runtimeType.toString(), vectors,
signalToWidthMap: {'a': originalWidth, 'b': newWidth});
mod, mod.generateSynth(), mod.runtimeType.toString(), vectors);
expect(simResult, equals(true));
}

Expand Down Expand Up @@ -116,8 +115,7 @@ void main() {
await mod.build();
await SimCompare.checkFunctionalVector(mod, vectors);
final simResult = SimCompare.iverilogVector(
mod.generateSynth(), mod.runtimeType.toString(), vectors,
signalToWidthMap: {'a': 8, 'b': updateWidth, 'c': 8});
mod, mod.generateSynth(), mod.runtimeType.toString(), vectors);
expect(simResult, equals(true));
}

Expand Down
Loading