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

Allow constant Z driving to show up in SV without error #441

Merged
merged 1 commit into from
Dec 1, 2023
Merged
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
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'));
});
});
}