Skip to content

Commit 3f0038f

Browse files
3.6: minor fixes for typos and exercises (freechipsproject#160)
Co-authored-by: edwardcwang <edwardcwang@users.noreply.github.com>
1 parent 29f12c1 commit 3f0038f

File tree

1 file changed

+10
-11
lines changed

1 file changed

+10
-11
lines changed

3.6_types.ipynb

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@
165165
"\n",
166166
"If you make a mistake and mix up `UInt` and `Int` or `Bool` and `Boolean`, the Scala compiler will generally catch it for you.\n",
167167
"This is because of Scala's static typing.\n",
168-
"At compile time, the compiler is able to distinguish between Chisel and Scala types and understand that `if ()` expects a `Boolean` and `when ()` expects a `Bool`.\n"
168+
"At compile time, the compiler is able to distinguish between Chisel and Scala types and also able to understand that `if ()` expects a `Boolean` and `when ()` expects a `Bool`.\n"
169169
]
170170
},
171171
{
@@ -288,7 +288,7 @@
288288
"metadata": {},
289289
"source": [
290290
"It is good to remember that Chisel types generally should not be value matched.\n",
291-
"Scala's match executes during circuit elaboration, but what you probably want is an post-elaboration comparison.\n",
291+
"Scala's match executes during circuit elaboration, but what you probably want is a post-elaboration comparison.\n",
292292
"The following gives a syntax error:"
293293
]
294294
},
@@ -367,8 +367,8 @@
367367
"cell_type": "markdown",
368368
"metadata": {},
369369
"source": [
370-
"If you look at the `delay` function, you should note that addition to matching on the type of each character, we are also:\n",
371-
"- Directly reference internal values of the parameters\n",
370+
"If you look at the `delay` function, you should note that in addition to matching on the type of each character, we are also:\n",
371+
"- Directly referencing internal values of the parameters\n",
372372
"- Sometimes, are matching directly on the internal values of the parameters\n",
373373
"\n",
374374
"These are possible due to the compiler implementing an `unapply` method. Note that unapplying the case is just syntactic sugar; e.g. the following two cases examples are equivalent:\n",
@@ -429,7 +429,7 @@
429429
"\n",
430430
"Partial functions can be chained together with `orElse`.\n",
431431
"\n",
432-
"Note that calling a `PartialFunction` with a undefined input will result in a runtime error. This can happen, for example, if the input to the `PartialFunction` is user-defined. To be more type-safe, we recommend writing functions that return an `Option` instead."
432+
"Note that calling a `PartialFunction` with an undefined input will result in a runtime error. This can happen, for example, if the input to the `PartialFunction` is user-defined. To be more type-safe, we recommend writing functions that return an `Option` instead."
433433
]
434434
},
435435
{
@@ -542,7 +542,7 @@
542542
"\n",
543543
"This section will just get your toes wet; to understand more, check out [this tutorial](https://twitter.github.io/scala_school/type-basics.html).\n",
544544
"\n",
545-
"Classes can be polymorphic in their types. One good example are sequences, which require knowing what the type of the elements it contains."
545+
"Classes can be polymorphic in their types. One good example is sequences, which require knowing their contained type."
546546
]
547547
},
548548
{
@@ -621,7 +621,7 @@
621621
"\n",
622622
"`chisel3.Data` is the base class for Chisel hardware types.\n",
623623
"`UInt`, `SInt`, `Vec`, `Bundle`, etc. are all instances of `Data`.\n",
624-
"`Data` can be used in IOs and support `:=`, wires, regs, etc.\n",
624+
"`Data` can be used in IOs and supports `:=`, wires, regs, etc.\n",
625625
"\n",
626626
"Registers are a good example of polymorphic code in Chisel.\n",
627627
"Look at the implementation of `RegEnable` (a register with a `Bool` enable signal) [here](https://github.com/freechipsproject/chisel3/blob/v3.0.0/src/main/scala/chisel3/util/Reg.scala#L10).\n",
@@ -644,7 +644,7 @@
644644
"These operations cannot be done on arbitrary objects; for example wire := 3 is illegal because 3 is a Scala Int, not a Chisel UInt.\n",
645645
"If we use a type constraint to say that type T is a subclass of Data, then we can use := on any objects of type T because := is defined for all Data.\n",
646646
"\n",
647-
"Here is an implementations of a shift register that take types as a parameter.\n",
647+
"Here is an implementation of a shift register that take types as a parameter.\n",
648648
"*gen* is an argument of type T that tells what width to use, for example new ShiftRegister(UInt(4.W)) is a shift register for 4-bit UInts.\n",
649649
"*gen* also allows the Scala compiler to infer the type T- you can write new ShiftRegister[UInt](UInt(4.W)) if you want to to be more specific, but the Scala compiler is smart enough to figure it out if you leave out the [UInt]."
650650
]
@@ -760,6 +760,7 @@
760760
"source": [
761761
"object Mac {\n",
762762
" def apply[T <: Data : Ring](a: T, b: T, c: T): T = {\n",
763+
" ??? // your code\n",
763764
" }\n",
764765
"}\n",
765766
"\n",
@@ -819,9 +820,7 @@
819820
" val out = Output(genReg)\n",
820821
" })\n",
821822
" \n",
822-
" val reg = RegInit(genReg, Ring[T].zero) // init to zero\n",
823-
" reg := reg + io.in\n",
824-
" io.out := reg\n",
823+
" ??? // your code\n",
825824
"}\n",
826825
"\n",
827826
"test(new Integrator(SInt(4.W), SInt(8.W))) { c =>\n",

0 commit comments

Comments
 (0)