Skip to content

Commit 6c5355a

Browse files
authored
Merge pull request #286 from mrcmry/spelling-and-code-fit-box
Spelling and fix code example to fit in html box
2 parents 84fe212 + a6e3770 commit 6c5355a

23 files changed

Lines changed: 188 additions & 119 deletions

File tree

source/SpinalHDL/Data types/AFix.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,9 +43,9 @@ For example:
4343

4444
``AFix.U(12 bits)`` will have a range of 0 to 4095.
4545

46-
``AFix.SQ(8 bits, 4 bits)`` will have a range of -256 (internaly -4096*2^-4) to 255.9375 (internaly 4095*2^-4)
46+
``AFix.SQ(8 bits, 4 bits)`` will have a range of -256 (internally -4096*2^-4) to 255.9375 (internally 4095*2^-4)
4747

48-
``AFix.U(8 exp, 4 exp)`` will have a range of 0 to 240 (internaly 15*2^4)
48+
``AFix.U(8 exp, 4 exp)`` will have a range of 0 to 240 (internally 15*2^4)
4949

5050

5151
Custom range ``AFix`` values can be created be directly instantiating the class.

source/SpinalHDL/Data types/Fix.rst

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -271,13 +271,16 @@ Misc
271271
* - Name
272272
- Return
273273
- Description
274+
* - x.minExp
275+
- Return a negative number of bits used for the fractional part
276+
- Int
274277
* - x.maxValue
275-
- Return the maximum value storable
276-
- Double
278+
- Return the largest positive real number storable
279+
- BigDecimal
277280
* - x.minValue
278-
- Return the minimum value storable
279-
- Double
281+
- Return the largest negative real number storable
282+
- BigDecimal
280283
* - x.resolution
281-
- x.amplitude * y.amplitude
282-
- Double
284+
- Return the smallest positive real number storable
285+
- BigDecimal
283286

source/SpinalHDL/Data types/Int.rst

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,8 @@ The syntax to declare an integer is as follows: (everything between [] is optio
3838

3939
.. code-block:: scala
4040
41-
val myUInt = UInt(8 bit)
42-
myUInt := U(2, 8 bit)
41+
val myUInt = UInt(8 bits)
42+
myUInt := U(2, 8 bits)
4343
myUInt := U(2)
4444
myUInt := U"0000_0101" // Base per default is binary => 5
4545
myUInt := U"h1A" // Base could be x (base 16)
@@ -52,7 +52,7 @@ The syntax to declare an integer is as follows: (everything between [] is optio
5252
5353
val myBool = Bool()
5454
myBool := myUInt === U(7 -> true, (6 downto 0) -> false)
55-
myBool := myUInt === U(8 bit, 7 -> true, default -> false)
55+
myBool := myUInt === U(8 bits, 7 -> true, default -> false)
5656
myBool := myUInt === U(myUInt.range -> true)
5757
5858
// For assignment purposes, you can omit the U/S

source/SpinalHDL/Design errors/spinal_cant_clone.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ The following code:
6969
val someAddress = RegNext(io.inputAddress) // -> ERROR *****************************
7070
}
7171
72-
raises an exeption:
72+
raises an exception:
7373

7474
.. code-block:: text
7575

source/SpinalHDL/Developers area/spinalhdl_datamodel.rst

Lines changed: 31 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,8 @@ Here is an example that identifies all adders within the netlist without utilizi
7979
8080
def recExpression(e: Expression): Unit = {
8181
e match {
82-
case op: Operator.BitVector.Add => println(s"Found ${op.left} + ${op.right}")
82+
case op: Operator.BitVector.Add => println(s"Found ${op.left}
83+
+ ${op.right}")
8384
case _ =>
8485
}
8586
e.foreachExpression(recExpression)
@@ -99,7 +100,8 @@ Here is an example that identifies all adders within the netlist without utilizi
99100
100101
// Add a late phase
101102
config.phasesInserters += {phases =>
102-
phases.insert(phases.indexWhere(_.isInstanceOf[PhaseVerilog]), new PrintBaseTypes("Late"))
103+
phases.insert(phases.indexWhere(_.isInstanceOf[PhaseVerilog]),
104+
new PrintBaseTypes("Late"))
103105
}
104106
config.generateVerilog(new Toplevel())
105107
}
@@ -165,15 +167,17 @@ For example, the following code can be used to modify a top-level component by a
165167
.. code-block:: scala
166168
167169
def ffIo[T <: Component](c : T): T = {
168-
def buf1[T <: Data](that : T) = KeepAttribute(RegNext(that)).addAttribute("DONT_TOUCH")
170+
def buf1[T <: Data](that : T) = KeepAttribute(RegNext(that))
171+
.addAttribute("DONT_TOUCH")
169172
def buf[T <: Data](that : T) = buf1(buf1(buf1(that)))
170173
c.rework {
171174
val ios = c.getAllIo.toList
172175
ios.foreach{io =>
173176
if(io.getName() == "clk") {
174177
// Do nothing
175178
} else if(io.isInput) {
176-
io.setAsDirectionLess().allowDirectionLessIo // allowDirectionLessIo is to disable the io Bundle linting
179+
// allowDirectionLessIo is to disable the io Bundle linting
180+
io.setAsDirectionLess().allowDirectionLessIo
177181
io := buf(in(cloneOf(io).setName(io.getName() + "_wrap")))
178182
} else if(io.isOutput) {
179183
io.setAsDirectionLess().allowDirectionLessIo
@@ -190,23 +194,34 @@ You can use the code in the following manner: :
190194
191195
SpinalVerilog(ffIo(new MyToplevel))
192196
193-
Here is a function that enables you to execute the body code as if the current component's context did not exist. This can be particularly useful for defining new signals without the influence of the current conditional scope (such as when or switch).
197+
Here is a function that enables you to execute the body code as if the current
198+
component's context did not exist. This can be particularly useful for defining
199+
new signals without the influence of the current conditional scope (such as
200+
`when` or `switch`).
194201

195202
.. code-block:: scala
196203
197-
def atBeginingOfCurrentComponent[T](body : => T) : T = {
198-
val body = Component.current.dslBody // Get the head of the current component symbols tree (AST in other words)
199-
val ctx = body.push() // Now all access to the SpinalHDL API will be append to it (instead of the current context)
200-
val swapContext = body.swap() // Empty the symbol tree (but keep a reference to the old content)
201-
val ret = that // Execute the block of code (will be added to the recently empty body)
202-
ctx.restore() // Restore the original context in which this function was called
203-
swapContext.appendBack() // append the original symbols tree to the modified body
204-
ret // return the value returned by that
204+
def atBeginningOfCurrentComponent[T](body : => T) : T = {
205+
// Get the head of the current component symbols tree (AST in other words)
206+
val body = Component.current.dslBody
207+
// Now all access to the SpinalHDL API will be append to it (instead of the
208+
// current context)
209+
val ctx = body.push()
210+
// Empty the symbol tree (but keep a reference to the old content)
211+
val swapContext = body.swap()
212+
// Execute the block of code (will be added to the recently empty body)
213+
val ret = that
214+
// Restore the original context in which this function was called
215+
ctx.restore()
216+
// append the original symbols tree to the modified body
217+
swapContext.appendBack()
218+
// return the value returned by that
219+
ret
205220
}
206221
207222
val database = mutable.HashMap[Any, Bool]()
208223
def get(key : Any) : Bool = {
209-
database.getOrElseUpdate(key, atBeginingOfCurrentComponent(False)
224+
database.getOrElseUpdate(key, atBeginningOfCurrentComponent(False))
210225
}
211226
212227
object key
@@ -223,7 +238,7 @@ Here is a function that enables you to execute the body code as if the current c
223238
This kind of functionality is, for instance, employed in the VexRiscv pipeline to dynamically create components or elements as needed.
224239

225240
User space netlist analysis
226-
--------------------------------------------------------------
241+
---------------------------
227242

228243
The SpinalHDL data model is also accessible and can be read during user-time elaboration. Here's an example that can help find the shortest logical path (in terms of clock cycles) to traverse a list of signals. In this specific case, it is being used to analyze the latency of the VexRiscv FPU design.
229244

@@ -244,7 +259,7 @@ Here you can find the implementation of that LatencyAnalysis tool :
244259

245260

246261
Enumerating every ClockDomain in use
247-
----------------------------------------------------
262+
------------------------------------
248263

249264
In this case, this is accomplished after the elaboration process by utilizing the SpinalHDL report.
250265

source/SpinalHDL/Developers area/types.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ The following operators are available for the ``Bool`` type
117117
The BitVector family - (``Bits``, ``UInt``, ``SInt``)
118118
-----------------------------------------------------
119119

120-
| ``BitVector`` is a family of types for storing multiple bits of information in a single value. This type has three subtypes that can be used to model different behaviours:
120+
| ``BitVector`` is a family of types for storing multiple bits of information in a single value. This type has three subtypes that can be used to model different behaviors:
121121
| ``Bits`` do not convey any sign information whereas the ``UInt`` (unsigned integer) and ``SInt`` (signed integer) provide the required operations to compute correct results if signed / unsigned arithmetic is used.
122122
123123
Declaration syntax
@@ -665,7 +665,7 @@ SpinalHDL supports enumeration with some encodings :
665665
* - native
666666
-
667667
- Use the VHDL enumeration system, this is the default encoding
668-
* - binarySequancial
668+
* - binarySequential
669669
- log2Up(stateCount)
670670
- Use Bits to store states in declaration order (value from 0 to n-1)
671671
* - binaryOneHot

source/SpinalHDL/Examples/Intermediates ones/uart.rst

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -170,14 +170,15 @@ Let's define the skeleton of ``UartCtrlTx``\ :
170170
}
171171
172172
// Provide one clockDivider.tick each rxSamplePerBit pulses of io.samplingTick
173-
// Used by the stateMachine as a baud rate time reference
173+
// Used by the stateMachine as a baud rate time reference.
174174
val clockDivider = new Area {
175175
val counter = Reg(UInt(log2Up(rxSamplePerBit) bits)) init(0)
176176
val tick = False
177177
..
178178
}
179179
180-
// Count up each clockDivider.tick, used by the state machine to count up data bits and stop bits
180+
// Count up each clockDivider.tick, used by the state machine to count up
181+
// data bits and stop bits.
181182
val tickCounter = new Area {
182183
val value = Reg(UInt(Math.max(dataWidthMax, 2) bits))
183184
def reset() = value := 0
@@ -257,10 +258,13 @@ Let's define the skeleton of the UartCtrlRx :
257258
// Implement the rxd sampling with a majority vote over samplingSize bits
258259
// Provide a new sampler.value each time sampler.tick is high
259260
val sampler = new Area {
260-
val syncroniser = BufferCC(io.rxd)
261-
val samples = History(that=syncroniser,when=io.samplingTick,length=samplingSize)
262-
val value = RegNext(MajorityVote(samples))
263-
val tick = RegNext(io.samplingTick)
261+
val synchronizer = BufferCC(io.rxd)
262+
val samples = History(
263+
that=synchronizer,
264+
when=io.samplingTick,
265+
length=samplingSize)
266+
val value = RegNext(MajorityVote(samples))
267+
val tick = RegNext(io.samplingTick)
264268
}
265269
266270
// Provide a bitTimer.tick each rxSamplePerBit
@@ -272,7 +276,8 @@ Let's define the skeleton of the UartCtrlRx :
272276
...
273277
}
274278
275-
// Provide bitCounter.value that count up each bitTimer.tick, Used by the state machine to count data bits and stop bits
279+
// Provide bitCounter.value that count up each bitTimer.tick, Used by
280+
// the state machine to count data bits and stop bits.
276281
// reset() can be called to reset it to zero
277282
val bitCounter = new Area {
278283
val value = Reg(UInt(Math.max(dataWidthMax, 2) bits))
@@ -322,7 +327,7 @@ manually like all other components, which one would do if a runtime-configurable
322327

323328

324329
Simple usage
325-
-----------------------
330+
------------
326331

327332
To synthesize a ``UartCtrl`` as ``115200-N-8-1``:
328333

source/SpinalHDL/Formal verification/index.rst

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -68,12 +68,15 @@ Here is an example of a simple counter and the corresponding formal testbench.
6868
}
6969
7070
object LimitedCounterFormal extends App {
71-
// import utilities to run the formal verification, but also some utilities to describe formal stuff
71+
// Import utilities to run the formal verification, but also some utilities
72+
// to describe formal stuff.
7273
import spinal.core.formal._
7374
74-
// Here we run a formal verification which will explore the state space up to 15 cycles to find an assertion failure
75+
// Here we run a formal verification which will explore the state space up
76+
// to 15 cycles to find an assertion failure.
7577
FormalConfig.withBMC(15).doVerify(new Component {
76-
// Instantiate our LimitedCounter DUT as a FormalDut, which ensure that all the outputs of the dut are:
78+
// Instantiate our LimitedCounter DUT as a FormalDut, which ensure that
79+
// all the outputs of the dut are:
7780
// - directly and indirectly driven (no latch / no floating signal)
7881
// - allows the current toplevel to read every signal across the hierarchy
7982
val dut = FormalDut(new LimitedCounter())
@@ -100,7 +103,8 @@ If you want you can embed formal statements directly into the DUT:
100103
value := value + 1
101104
}
102105
103-
// That code block will not be in the SpinalVerilog netlist by default. (would need to enable SpinalConfig().includeFormal. ...
106+
// That code block will not be in the SpinalVerilog netlist by default.
107+
//(would need to enable SpinalConfig().includeFormal. ...
104108
GenerationFlags.formal {
105109
assert(value >= 2)
106110
assert(value <= 10)
@@ -159,7 +163,8 @@ For instance we can check that the value is counting up (if not already at 10):
159163
assumeInitial(ClockDomain.current.isResetActive)
160164
161165
// Check that the value is incrementing.
162-
// hasPast is used to ensure that the past(dut.value) had at least one sampling out of reset
166+
// hasPast is used to ensure that the past(dut.value) had at least one
167+
// sampling out of reset.
163168
when(pastValid() && past(dut.value) =/= 10) {
164169
assert(dut.value === past(dut.value) + 1)
165170
}
@@ -192,7 +197,10 @@ Here is an example where we want to prevent the value ``1`` from ever being pres
192197
193198
// Allow the write anything but value 1 in the ram
194199
anyseq(dut.write)
195-
clockDomain.withoutReset() { // As the memory write can occur during reset, we need to ensure the assume apply there too
200+
201+
// As the memory write can occur during reset, we need to ensure the
202+
// assume apply there too.
203+
clockDomain.withoutReset() {
196204
assume(dut.write.data =/= 1)
197205
}
198206
@@ -223,7 +231,7 @@ If you want to keep your assertion enabled during reset you can do:
223231
Specifying the initial value of a signal
224232
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
225233

226-
For instance, for the reset signal of the current clockdomain (useful at the top)
234+
For instance, for the reset signal of the current clock domain (useful at the top)
227235

228236
.. code-block:: scala
229237
@@ -237,7 +245,7 @@ Specifying a initial assumption
237245
assumeInitial(clockDomain.isResetActive)
238246
239247
Memory content (Mem)
240-
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
248+
^^^^^^^^^^^^^^^^^^^^
241249

242250
If you have a Mem in your design, and you want to check its content, you can do it the following ways :
243251

source/SpinalHDL/Getting Started/Scala Guide/basics.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -97,8 +97,8 @@ The ``return`` keyword is not necessary. In absence of it, Scala takes the last
9797
(a + b) > 0
9898
}
9999
100-
Return type inferation
101-
^^^^^^^^^^^^^^^^^^^^^^
100+
Return type inference
101+
^^^^^^^^^^^^^^^^^^^^^
102102

103103
Scala is able to automatically infer the return type. You don't need to specify it:
104104

source/SpinalHDL/Legacy/pinsec/hardware_toplevel.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ Then we can define a simple reset controller under this clock domain.
106106
val coreResetUnbuffered = False
107107
108108
// Implement an counter to keep the reset axiResetOrder high 64 cycles
109-
// Also this counter will automaticly do a reset when the system boot.
109+
// Also this counter will automatically do a reset when the system boot.
110110
val axiResetCounter = Reg(UInt(6 bits)) init(0)
111111
when(axiResetCounter =/= U(axiResetCounter.range -> true)) {
112112
axiResetCounter := axiResetCounter + 1

0 commit comments

Comments
 (0)