Examples
|
|
in Spinal, Component
is default, but type Module = Component
is also okay
config Global Settings in SpinalConfig
Design Rules
never erase the previous assignment, except they’re in different blocks, or use a.allowOverride
to allow this action
SpinalHDL will check the registers you used only depends on same/sync clock registers
fix: add the tag
|
|
or set the clocks synchronous together
|
|
bufferCC could go across clock domain
Spinal doesn’t allow combinational loop in code
beware of the loop checking, or fix by
|
|
Check the Hierarchy violation
Datatypes
Spinal never forces IO Bundle, never forces instantiation by Module keywords, never remove unused names
basic types: Bool, Bits, UInt, SInt; composite: Bundle, Vec
|
|
edges: rise, fall, edge
|
|
set & clear:
|
|
Bits: use downto to choose bits, use when to do conditional branch
|
|
Vec: a group of indexed symbols
|
|
use fold or reduce method to design FIFO
interesting methods:
|
|
Combinational
:=
is as <=
in Verilog, \=
is as =
in Verilog, <>
is for natrual link of same datatypes
Register value:
|
|
resize the value using resized
or resize(Int)
method
Conditional:
when(){}.elsewhen(){}.otherwise{}
switch(x){ is(0){} is(1){} default{} }
Mux(cond, ..., ...)
cond ? ... : ...
bitwise branch:
|
|
divide 128 bits into a 4-way Mux
|
|
Package operations as methods improve abstract ability
Internal methods can operate on all variables under Component
Of course, it can also be package as an independent function, which is passed in as a parameter by the operation object
Sequential
Reg(type:Data), RegInit(resetValue:Data), RegNext(nextValue : Data), RegNextWhen(nextValue : Data, cond : Bool)
RegNext(something) is equal to:
|
|
If you have a register containing a Bundle, you can use the init function on each element of the Bundle.
|
|
for initialization for simulation, using randBoot() method
Memory: use Mem() class
|
|
memory could be blackboxed
|
|
Fixed-Point
|
|
bits also can be rounded
|
|
fixTo: a way same as round to inf
width propagation is auto in Spinal.
bit join:
|
|
in/out < Typename > or use master/slave
jump wire:
|
|
SpinalHDL will never Pruned signals with names
The ways you can use Scala functions to generate hardware are radically different than VHDL/Verilog for many reasons:
You can instantiate registers, combinational logic and components inside them.
You don’t have to play with process/@always that limit the scope of assignment of signals
Everything is passed by reference, which allows easy manipulation. For example you can give a bus to a function as an argument, then the function can internaly read/write to it. You can also return a Component, a Bus, or anything else from scala and the scala world.
define something inside the class is accepted
Area is used to define a group of logic
Clock Domain
|
|
set your own clock domain:
|
|
setSyncWith lets you divide the clock or gate it