-
Notifications
You must be signed in to change notification settings - Fork 68
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix bug in internal array discovery (#494)
- Loading branch information
Showing
3 changed files
with
55 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,6 +7,7 @@ | |
// 2023 September 11 | ||
// Author: Max Korbel <[email protected]> | ||
|
||
import 'package:collection/collection.dart'; | ||
import 'package:rohd/rohd.dart'; | ||
import 'package:test/test.dart'; | ||
|
||
|
@@ -61,6 +62,33 @@ class MultipleLocation extends Module { | |
} | ||
} | ||
|
||
class ArrayConcatMod extends Module { | ||
ArrayConcatMod() { | ||
final a = addInput('a', Logic()); | ||
final en = addInput('en', Logic()); | ||
final b = addOutput('b'); | ||
|
||
final aBar = Logic(name: 'a_bar'); | ||
final orOut = Logic(name: 'or_out'); | ||
|
||
final t0 = Logic(name: 't0'); | ||
final t2 = Logic(name: 't2'); | ||
final t3 = Logic(name: 't3'); | ||
final aConcat = LogicArray([4], 1, name: 'a_concat'); | ||
|
||
aConcat.elements[3] <= t3; | ||
aConcat.elements[2] <= t2; | ||
aConcat.elements[1] <= a; | ||
aConcat.elements[0] <= t0; | ||
|
||
aBar <= ~aConcat.elements[1]; | ||
|
||
orOut <= aBar | en; | ||
|
||
b <= aConcat.elements[1] & orOut; | ||
} | ||
} | ||
|
||
void main() { | ||
test('tryInput, exists', () { | ||
final mod = ModuleWithMaybePorts(addIn: true); | ||
|
@@ -101,4 +129,15 @@ void main() { | |
final mod = MultipleLocation(); | ||
expect(mod.build, throwsA(isA<PortRulesViolationException>())); | ||
}); | ||
|
||
test('array concat per element builds and finds sigs', () async { | ||
final mod = ArrayConcatMod(); | ||
await mod.build(); | ||
|
||
expect( | ||
mod.internalSignals.firstWhereOrNull((e) => e.name == 't0'), isNotNull); | ||
|
||
final sv = mod.generateSynth(); | ||
expect(sv, contains('assign a_concat[0] = t0;')); | ||
}); | ||
} |