Skip to content

Commit c96b0d7

Browse files
author
Oron Port
committed
change Grey to Gray, as proper name for the enumeration encoding. also better documentation.
1 parent c5b076d commit c96b0d7

File tree

6 files changed

+9
-9
lines changed

6 files changed

+9
-9
lines changed

compiler/ir/src/main/scala/dfhdl/compiler/printing/Printer.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -421,7 +421,7 @@ class DFPrinter(using val getSet: MemberGetSet, val printerOptions: PrinterOptio
421421
val dfhdlOps: Set[String] = Set("<>", ":=", ":==")
422422
val dfhdlTypes: Set[String] = Set(
423423
"Bit", "Boolean", "Int", "UInt", "SInt", "Bits", "X", "Encoded", "Struct", "Opaque",
424-
"StartAt", "OneHot", "Grey", "Unit", "Time", "Freq", "String", "fs", "ns", "ps", "us", "ms",
424+
"StartAt", "OneHot", "Gray", "Unit", "Time", "Freq", "String", "fs", "ns", "ps", "us", "ms",
425425
"sec", "min", "hr", "Hz", "KHz", "MHz", "GHz"
426426
)
427427
def colorCode(cs: String): String =

core/src/main/scala/dfhdl/core/DFEnum.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ object DFEncoding:
1818
val width: W
1919
abstract class Default extends StartAt(0)
2020

21-
abstract class Grey extends Auto:
21+
abstract class Gray extends Auto:
2222
final def calcWidth(entryCount: Int): Int =
2323
(entryCount - 1).bitsWidth(false)
2424
final def encode(idx: Int): BigInt = BigInt(idx ^ (idx >>> 1))

core/src/main/scala/dfhdl/core/Width.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,7 @@ object Width extends WidthLP:
183183
case _ => None
184184
case '[DFEncoding.OneHot] =>
185185
Some(entryCount)
186-
case '[DFEncoding.Grey] =>
186+
case '[DFEncoding.Gray] =>
187187
Some((entryCount - 1).bitsWidth(false))
188188
case '[DFEncoding.Manual[w]] =>
189189
TypeRepr.of[w] match

core/src/test/scala/CoreSpec/DFEnumSpec.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ class DFEnumSpec extends DFSpec:
1010
case Foo, Bar, Baz
1111
enum MyEnum3 extends Encoded.OneHot:
1212
case Foo, Bar, Baz
13-
enum MyEnum4 extends Encoded.Grey:
13+
enum MyEnum4 extends Encoded.Gray:
1414
case Foo, Bar, Baz
1515
enum MyEnum5(val value: UInt[8] <> CONST) extends Encoded.Manual(8):
1616
case Foo extends MyEnum5(200)

core/src/test/scala/CoreSpec/DFTypeSpec.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ class DFTypeSpec extends DFSpec:
2121
case Foo, Bar, Baz
2222
enum MyEnum3 extends Encoded.OneHot:
2323
case Foo, Bar, Baz
24-
enum MyEnum4 extends Encoded.Grey:
24+
enum MyEnum4 extends Encoded.Gray:
2525
case Foo, Bar, Baz
2626
enum MyEnum5(val value: UInt[8] <> CONST) extends Encoded.Manual(8):
2727
case Foo extends MyEnum5(200)

docs/user-guide/type-system/index.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1210,7 +1210,7 @@ DFHDL supports several encoding schemes for enums:
12101210
1. **Binary Encoded** (default)
12111211
```scala
12121212
enum MyEnum extends Encoded:
1213-
case A, B, C, D // Encoded as 0,1,2,3
1213+
case A, B, C, D // Encoded as 00,01,10,11
12141214
```
12151215

12161216
2. **One-Hot Encoded**
@@ -1221,14 +1221,14 @@ enum MyEnum extends Encoded.OneHot:
12211221

12221222
3. **Gray Encoded**
12231223
```scala
1224-
enum MyEnum extends Encoded.Grey:
1224+
enum MyEnum extends Encoded.Gray:
12251225
case A, B, C // Encoded as 00,01,11
12261226
```
12271227

12281228
4. **Custom Start Value**
12291229
```scala
1230-
enum MyEnum extends Encoded.StartAt(10):
1231-
case A, B, C // Encoded as 10,11,12
1230+
enum MyEnum extends Encoded.StartAt(4):
1231+
case A, B, C // Encoded as 100,101,110
12321232
```
12331233

12341234
5. **Manual Encoding**

0 commit comments

Comments
 (0)