Skip to content

Commit 8782f43

Browse files
authored
Doc fixes and a couple more tests (#525)
1 parent 4131bcd commit 8782f43

File tree

5 files changed

+54
-2
lines changed

5 files changed

+54
-2
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ tmp_test/
1717
*.vcd
1818
*_fsm.md
1919
.vscode/*
20+
devtools_options.yaml
2021

2122
# Exceptions
2223
!.vscode/extensions.json

.pubignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ tmp_test/
1717
*.vcd
1818
*_fsm.md
1919
.vscode/*
20+
devtools_options.yaml
2021

2122
# Exceptions
2223
!.vscode/extensions.json

doc/user_guide/_docs/A11-interfaces.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ class SimpleInterface extends PairInterface {
8888
SimpleInterface()
8989
: super(
9090
portsFromConsumer: [Port('rsp')],
91-
portsFromProducer: [Port('req')],
91+
portsFromProvider: [Port('req')],
9292
sharedInputPorts: [Port('clk')],
9393
);
9494

lib/src/interfaces/pair_interface.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ class PairInterface extends Interface<PairDirection> {
9696
})
9797
.toList(growable: false);
9898

99-
/// Creates a new instance of a [PairInterface] with the same ports other
99+
/// Creates a new instance of a [PairInterface] with the same ports and other
100100
/// characteristics.
101101
PairInterface.clone(PairInterface otherInterface)
102102
: this(

test/array_collapsing_test.dart

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ import 'package:rohd/rohd.dart';
1111
import 'package:rohd/src/utilities/simcompare.dart';
1212
import 'package:test/test.dart';
1313

14+
import 'logic_array_test.dart';
15+
1416
class ArrayModule extends Module {
1517
ArrayModule(LogicArray a) {
1618
final inpA = addInputArray('a', a, dimensions: a.dimensions);
@@ -22,6 +24,36 @@ class ArrayModule extends Module {
2224
}
2325
}
2426

27+
class ArrayTopMod extends Module {
28+
ArrayTopMod(Logic clk) {
29+
clk = addInput('clk', clk);
30+
31+
final intermediate =
32+
LogicArray([4], 1, name: 'asdf', naming: Naming.mergeable);
33+
final arrOut = ArraySubModOut(clk).arrOut;
34+
for (var i = 0; i < intermediate.width; i++) {
35+
final idx = (i + 1) % intermediate.width;
36+
intermediate.elements[idx] <= arrOut.elements[idx];
37+
}
38+
ArraySubModIn(clk, intermediate);
39+
}
40+
}
41+
42+
class ArraySubModIn extends Module {
43+
ArraySubModIn(Logic clk, LogicArray inp) {
44+
clk = addInput('clk', clk);
45+
addInputArray('inp', inp, dimensions: [4]);
46+
}
47+
}
48+
49+
class ArraySubModOut extends Module {
50+
LogicArray get arrOut => output('arrOut') as LogicArray;
51+
ArraySubModOut(Logic clk) {
52+
clk = addInput('clk', clk);
53+
addOutputArray('arrOut', dimensions: [4]);
54+
}
55+
}
56+
2557
class ArrayWithShuffledAssignment extends Module {
2658
ArrayWithShuffledAssignment(LogicArray a) {
2759
final inpA = addInputArray('a', a, dimensions: a.dimensions);
@@ -61,6 +93,24 @@ void main() {
6193
tearDown(() async {
6294
await Simulator.reset();
6395
});
96+
97+
test('simple 1d collapse', () async {
98+
final mod = SimpleLAPassthrough(LogicArray([4], 1));
99+
await mod.build();
100+
final sv = mod.generateSynth();
101+
102+
expect(sv, contains('assign laOut = laIn;'));
103+
});
104+
105+
test('array collapse for cross-module connection', () async {
106+
final mod = ArrayTopMod(Logic());
107+
await mod.build();
108+
final sv = mod.generateSynth();
109+
110+
expect(sv, contains(RegExp(r'ArraySubModIn.*\.inp\(inp\)')));
111+
expect(sv, contains(RegExp(r'ArraySubModOut.*\.arrOut\(inp\)')));
112+
});
113+
64114
test('array nets with intermediate collapse', () async {
65115
final mod = ArrayModuleWithNetIntermediates(
66116
LogicArray([3, 3], 1), LogicArray([3, 3], 1));

0 commit comments

Comments
 (0)