-
In ROHD, the Will there be support that allows import 'package:rohd/rohd.dart';
void slicing(Logic a, Logic b, Logic c, Logic d, Logic e, Logic f) {
d <= b[7];
e <= [d, c, a].swizzle();
f <= [d, c, a].rswizzle();
}
void main() async {
// Declare Logic
final a = Logic(name: 'a', width: 4);
final b = Logic(name: 'b', width: 8);
final c = Const(7, width: 5);
final d = Logic(name: 'd');
final e = Logic(name: 'e', width: d.width + c.width + a.width);
// PURPOSELY ADD +1 here.
final f = Logic(name: 'f', width: d.width + c.width + a.width + 1);
final rangeSwizzling = RangeSwizzling(a, b, c, d, e, f, slicing);
await rangeSwizzling.build();
print(rangeSwizzling.generateSynth());
print('\n');
a.put(bin('1110'));
b.put(bin('11000100'));
print('e: ${rangeSwizzling.e.value.toString(includeWidth: false)}');
print('f: ${rangeSwizzling.f.value.toString(includeWidth: false)}');
}
class RangeSwizzling extends Module {
Logic get d => output('d');
Logic get e => output('e');
Logic get f => output('f');
RangeSwizzling(Logic a, Logic b, Logic c, Logic d, Logic e, Logic f,
void Function(Logic a, Logic b, Logic c, Logic d, Logic e, Logic f) slice)
: super(name: 'range_swizzling') {
a = addInput(a.name, a, width: a.width);
b = addInput(b.name, b, width: b.width);
c = addInput(c.name, c, width: c.width);
d = addOutput(d.name, width: d.width);
e = addOutput(e.name, width: e.width);
f = addOutput(f.name, width: f.width);
slice(a, b, c, d, e, f);
}
} |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 6 replies
-
There is a method zeroExtend. Or have I misunderstood something? f <= [d, c, a].rswizzle().zeroExtend(f.width); |
Beta Was this translation helpful? Give feedback.
-
This code actually should fail at connection time rather than
But the root-cause is the same, and the other answer from @chykon still applies. |
Beta Was this translation helpful? Give feedback.
There is a method zeroExtend. Or have I misunderstood something?