Skip to content

Commit

Permalink
Use LogicValue instead of Logic in software .map
Browse files Browse the repository at this point in the history
  • Loading branch information
quekyj committed Oct 9, 2023
1 parent c3b3af2 commit 9296696
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions lib/src/binary_gray.dart
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,8 @@ class BinaryToGrayConverter extends Module {
for (var i = 0; i < (1 << inputWidth); i++)
CaseItem(Const(i, width: inputWidth), [
grayVal <
Const(binaryToGrayMap(Const(i, width: inputWidth)).swizzle(),
Const(
binaryToGrayMap(LogicValue.ofInt(i, inputWidth)).swizzle(),
width: inputWidth)
])
])
Expand All @@ -60,8 +61,8 @@ class BinaryToGrayConverter extends Module {
/// If [binary] has no bits, an empty list is returned.
///
/// Returns a list of [LogicValue] representing the Gray code.
List<LogicValue> binaryToGrayMap(Logic binary) {
final reverseBit = binary.value.toList().swizzle();
List<LogicValue> binaryToGrayMap(LogicValue binary) {
final reverseBit = binary.toList().swizzle();
final binList = reverseBit.toList().asMap().entries.map((entry) {
final currentBit = entry.value;
final idx = entry.key;
Expand Down Expand Up @@ -107,9 +108,10 @@ class GrayToBinaryConverter extends Module {
[
for (var i = 0; i < (1 << inputWidth); i++)
CaseItem(Const(i, width: inputWidth), [
// Conditional assignment here
binaryVal <
Const(grayToBinaryMap(Const(i, width: inputWidth)).swizzle(),
Const(
grayToBinaryMap(LogicValue.ofInt(i, inputWidth))
.swizzle(),
width: inputWidth),
]),
],
Expand All @@ -130,8 +132,8 @@ class GrayToBinaryConverter extends Module {
/// If [gray] has no bits, an empty list is returned.
///
/// Returns a list of [LogicValue] representing the binary representation.
List<LogicValue> grayToBinaryMap(Logic gray) {
final reverseGray = gray.value.toList().swizzle();
List<LogicValue> grayToBinaryMap(LogicValue gray) {
final reverseGray = gray.toList().swizzle();
final grayList = reverseGray.toList();
var previousBit = LogicValue.zero;

Expand Down

0 comments on commit 9296696

Please sign in to comment.