Skip to content

Commit

Permalink
Allow const Z driving to show up in SV without error (intel#441)
Browse files Browse the repository at this point in the history
  • Loading branch information
mkorbel1 authored and mjayasim9 committed Dec 1, 2023
1 parent b0c2958 commit 06c8d87
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 2 deletions.
2 changes: 0 additions & 2 deletions lib/src/synthesizers/systemverilog.dart
Original file line number Diff line number Diff line change
Expand Up @@ -854,8 +854,6 @@ class _SynthLogic {

/// Finds the best name from the collection of [Logic]s.
String _findName(Uniquifier uniquifier) {
assert(!isFloatingConstant, 'Should not be using floating constants.');

// check for const
if (_constLogic != null) {
if (!_constNameDisallowed) {
Expand Down
32 changes: 32 additions & 0 deletions test/logic_name_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,18 @@ class BusSubsetNaming extends Module {
}
}

class DrivenOutputModule extends Module {
Logic get x => output('x');
DrivenOutputModule(Logic? toDrive) {
final a = addInput('a', Logic());
addOutput('x');

final internal = toDrive ?? Logic(name: 'internal');

x <= mux(a, internal, a);
}
}

void main() {
test(
'GIVEN logic name is valid '
Expand Down Expand Up @@ -148,4 +160,24 @@ void main() {
expect(sv, contains('c = b[3]'));
});
});

group('floating signals', () {
test('unconnected floating', () async {
final mod = DrivenOutputModule(null);
await mod.build();
final sv = mod.generateSynth();

// shouldn't add a Z in there if left floating
expect(!sv.contains('z'), true);
});

test('driven to z', () async {
final mod = DrivenOutputModule(Const('z'));
await mod.build();
final sv = mod.generateSynth();

// should add a Z if it's explicitly added
expect(sv, contains('z'));
});
});
}

0 comments on commit 06c8d87

Please sign in to comment.