Skip to content

Commit

Permalink
Using Logic.named() for key components
Browse files Browse the repository at this point in the history
  • Loading branch information
desmonddak committed Jan 18, 2025
1 parent c2ec6fa commit 23f6f2d
Show file tree
Hide file tree
Showing 16 changed files with 362 additions and 392 deletions.
6 changes: 4 additions & 2 deletions lib/src/arithmetic/addend_compressor.dart
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,8 @@ class ColumnCompressor {
}
final t = CompressTerm(
CompressTermType.sum,
nameLogic('cmp_sum_iter${iteration}_c$col', compressor.sum),
compressor.sum.named('cmp_sum_iter${iteration}_c$col',
naming: Naming.mergeable),
inputs,
0,
col);
Expand All @@ -256,7 +257,8 @@ class ColumnCompressor {
if (col < columns.length - 1) {
final t = CompressTerm(
CompressTermType.carry,
nameLogic('cmp_carry_iter${iteration}_c$col', compressor.carry),
compressor.carry.named('cmp_carry_iter${iteration}_c$col',
naming: Naming.mergeable),
inputs,
0,
col);
Expand Down
13 changes: 8 additions & 5 deletions lib/src/arithmetic/adder.dart
Original file line number Diff line number Diff line change
Expand Up @@ -76,13 +76,16 @@ class NativeAdder extends Adder {
if (a.width != b.width) {
throw RohdHclException('inputs of a and b should have same width.');
}
final ax = a.zeroExtend(a.width + 1).named('ax', naming: Naming.mergeable);
final bx = b.zeroExtend(a.width + 1).named('bx', naming: Naming.mergeable);
final apb = (ax + bx).named('ax_plus_bx', naming: Naming.mergeable);
if (carryIn == null) {
sum <= a.zeroExtend(a.width + 1) + b.zeroExtend(b.width + 1);
sum <= apb;
} else {
sum <=
a.zeroExtend(a.width + 1) +
b.zeroExtend(b.width + 1) +
carryIn!.zeroExtend(a.width + 1);
final cinx = carryIn!
.zeroExtend(a.width + 1)
.named('carryInx', naming: Naming.mergeable);
sum <= (apb + cinx).named('ax_plus_bx_plus_cx', naming: Naming.mergeable);
}
}
}
15 changes: 7 additions & 8 deletions lib/src/arithmetic/floating_point/floating_point_adder.dart
Original file line number Diff line number Diff line change
Expand Up @@ -76,11 +76,11 @@ abstract class FloatingPointAdder extends Module {
@protected
(FloatingPoint, FloatingPoint) swap(
Logic swap, (FloatingPoint, FloatingPoint) toSwap) {
final in1 = nameLogic('swap_in_${toSwap.$1.name}', toSwap.$1);
final in2 = nameLogic('swap_in_${toSwap.$2.name}', toSwap.$2);
final in1 = toSwap.$1.named('swap_in_${toSwap.$1.name}');
final in2 = toSwap.$2.named('swap_in_${toSwap.$2.name}');

final out1 = nameLogic('swap_out_larger', mux(swap, in2, in1));
final out2 = nameLogic('swap_out_smaller', mux(swap, in1, in2));
final out1 = mux(swap, in2, in1).named('swap_out_larger');
final out2 = mux(swap, in1, in2).named('swap_out_smaller');
final first = a.clone(name: 'larger')..gets(out1);
final second = a.clone(name: 'smaller')..gets(out2);
return (first, second);
Expand All @@ -94,11 +94,10 @@ abstract class FloatingPointAdder extends Module {
final be = toSort.$2.exponent;
final am = toSort.$1.mantissa;
final bm = toSort.$2.mantissa;
final doSwap = nameLogic(
'doSwap',
ae.lt(be) |
final doSwap = (ae.lt(be) |
(ae.eq(be) & am.lt(bm)) |
((ae.eq(be) & am.eq(bm)) & toSort.$1.sign));
((ae.eq(be) & am.eq(bm)) & toSort.$1.sign))
.named('doSwap');

final swapped = swap(doSwap, toSort);

Expand Down
Loading

0 comments on commit 23f6f2d

Please sign in to comment.