Repository navigation
Volt 0.1.1
Volt 0.1.1 fixes bugs of 0.1.0 that produced wrong SystemVerilog without
a diagnostic: the design compiled, and the generated hardware did
something other than what the source says. Upgrading is recommended.
This is a bug-fix release. No rule that decides whether a design is
accepted, or what it computes, changed; the specification gained one
warning (a generic parameter that hides a top-level item now gets
W1002). Some input that 0.1.0 accepted is now rejected, and some input
now gives different SystemVerilog. In all but one of these cases the
0.1.0 result went against the language specification; the exception is a
new limit on long enum constant chains (see Constants).
They are listed under Behavior changes; read that
section before upgrading.
Behavior changes
Upgrading from 0.1.0: for each item below, the same input gives a
different result in 0.1.1. Where 0.1.0 compiled a design and 0.1.1
reports an error or writes different SystemVerilog, the 0.1.0 output went
against the specification: in most cases it computed a wrong value; in
the visibility cases (#139)
it read a name that the file is not allowed to see. The one exception is
under Constants.
Names in inlined functions, generic modules and loops
-
A name in an inlined function body is resolved where the function is
declared (#128). A
constant in afnbody no longer takes the value of a loop variable
with the same name around the call. Withconst I = 1and
fn pick(x: [u8; 4]) -> u8 { x[I] }, the call
for I in 0..4 { ys[I] = pick(xs) }gaveys[k] = xs[k]; it now gives
ys[k] = xs[1]. The same holds for a constant in a part-select start,
a range bound, a nested call and amatchpattern in the body, and for
a constant's value (const J = I + 1) read inside a loop overI. A
blockletor a loop variable now also hides an outer name with the
same spelling in a computed index and in a value. A type width
(uint<W>) or a constant array (T[i]) in the body is no longer
rejected withE2005because the caller has a nameWori.
What to do: a design that reuses a name of a function body or of a
constant for a loop variable, a blockletor a port may get different
SystemVerilog; warningW1002points at these places. -
An inner declaration hides a generic parameter or a module-level
forvariable (#130).
A blocklet, aforinsidecombor a nestedfor, or aletin a
loop body with the name of a generic parameter or a loop variable is no
longer replaced with the parameter's value. InG<3>,
comb { let N = s y = N }gavey = 3; it now givesy = s. In
for i in 0..1 { let i = s y = i }, 0.1.0 wrotey = 0; 0.1.1 writes
y = s. Two inputs that were rejected now compile:
comb { for N in 0..2 { ys[N] = N } }in a module with a genericN
(it wasE2006), and the shorthand connectionP { i }(it was
E1001). -
New
W1002warnings for a name that hides another
(#130): a module-level
forvariable that hides a top-level item, a port, a module signal or a
generic parameter; aletin a loop body that hides the loop variable,
a top-level item or aletof the enclosing body; a generic parameter
of an instantiated generic module that hides a top-level item; a block
letor acombloop variable that hides a generic parameter.
What to do: rename the inner name. A build that treats warnings as
errors may now fail. -
Some inputs that 0.1.0 accepted are now errors
(#130); in each of them
the 0.1.0 output used the hidden value (the literal of the generic
parameter or of the loop, or the top-level constant):- a port or a module
letwith the name of a generic parameter:
E1003; - a module-level loop variable in a pattern, and a block
letthat
hides a generic parameter used in a pattern:E1015; - a block
letthat hides a generic parameter used in a type width
(uint<N>):E2005; - a
letof a loop body used as a generic argument (W<i>):E2008;
used in a type width:E2021; - a port or a module signal that hides a top-level constant, used in a
module-levelforbound:E2021.
What to do: give the inner name a name of its own; the error points
at it. - a port or a module
-
A block
letor a loop variable hides a bundle port, aninout
port, the@mmiohandleregsand a pipeline stage value
(#136,
#137,
#138). A use of the name
now reads the local. Afterlet tx : Flags = ...,tx.firedread the
port'stx_valid && tx_ready; it now reads the field of the local. The
same holds fordq.releasedafterlet dq : St = ...(it read
!dq_oe) andregs.control.enableafterlet regs : Regs = ...(it
read the register map). In a pipeline stage,
for a in 0..2 { r[a] <= x }wroter[a_a_r]twice; it now writes
r[0]andr[1].- The index and the length of a bundle array are evaluated where they
are used: a port, a modulelet, a blockletor a loop variable
that hides a top-level constant there is nowE2008(0.1.0 read the
constant and selectedrx[0]). - Inferred contracts: a counter or a state machine whose limit or
written value is a blockletno longer gets an inferred contract.
0.1.0 took theletfor the constant it hides and generated an
invariantthat does not hold (a failure involt test, a
counterexample involt verify) or a cover point for a transition
that does not exist. Amatchon an enum local that hides the state
register (comb { let st : Color = c; match st { ... } }) no longer
removes the cover points of the state machine. - A local
letwith the name of a stage value in the module-level
combof a pipeline compiles; it wasE5012. - New diagnostics: a local that hides a bundle port or
regsgets
W1002; a field access on au8local that hides a bundle port is
E2003;dq.drive(v)on a local that hides aninoutport is
E0001; a write to a field of a localregsisE4001(it was
E4006).
What to do: a design that reuses the name of a port, of
regs, of a
stage value or of a top-level constant in a block may get different
SystemVerilog and different inferred contracts; the newW1002
warnings andE2008errors point at these places. - The index and the length of a bundle array are evaluated where they
Visibility across files
- A constant or a struct of another file needs
pubandusein every
position (#139). A
constant that is notpubor not imported withuse, read in a
module-levelforbound or in the length or index of a bundle array,
and such a struct used as a bundle type or aHandshakepayload, are
nowE1001. 0.1.0 read them without a word: with a privateK = 1in
another file,y = rx[K].dataselectedrx_1_data. A glob import
(use a::*) does not bring private items. The body of a generic module
is resolved in the file that declares it. A constant or bundle type
imported withuse a::X as Jnow resolves in these positions (it was
E2008,E2021orE4001). A loop variable with the name of a hidden
item of another file no longer getsW1002.
What to do: a newE1001says that the file that uses the name does
not see it. Make the itempubin the file that declares it, and add
use package::Name;to the file that uses it.
Widths
- The untyped
letof an inlined function keeps its flexible width in
acombblock (#132),
as it already did at module level and now also in aforinside a
block, a contract and a register's reset value. With
fn g(a: u8, b: u8, c: u8) -> u9 { let s = a + b; (s | c) + c }and
a = b = c = 255,comb { x = g(a, b, c) }gave 254 and the
module-levely = g(a, b, c)gave 510; both now give 510. Some designs
of the same kind stoppedvolt testwith a Verilator width warning
((s | c) as u16); they now simulate.
What to do: the SystemVerilog of afncalled fromcombwhose
untypedletis used in a narrower operation changes. No source change
is needed.
Literal arithmetic
-
Arithmetic on literals alone is computed at compile time with its
exact value (#144,
#152,
#153): arithmetic whose
operands are all literals, generic parameters or loop variables of a
forinsidecomb. The result is written as one literal. 0.1.0 cut every literal
to the width of its context and left the operation to SystemVerilog:
y : u2 = 7 / 3was written2'h3 / 2'd3(1) and is now2'd2;
x == 7 / 3andx < 5 % 3compared with a wrong value. New errors:E2010when the result does not fit its target:
y : u2 = 5 + 2,const X : u8 = 200 + 100,x < 3 - 1with
x : u1. 0.1.0 wrapped the value without a word. The same for a
combloop variable that does not fit (ys[i] = iwhereigoes
past the range of the target); every combination of nested loops is
checked.E2023for a division or a remainder by zero:7 / 0,
5 % (2 - 2).
What to do: if the build now reports
E2010orE2023, the 0.1.0
SystemVerilog of that line already computed a wrong value. Widen the
target, or fix the constant; the help line of the error says how.
Constants
- A
matchon an enum constant defined through a chain of more than 63
constants (const A0 : E = A1, ...) is nowE0003
(#128). In 0.1.0 a chain
that loops back on itself overflowed the stack of the generator; the
depth limit that now stops it also rejects a long chain without a
cycle, which 0.1.0 folded correctly. This is a new limitation, not the
fix of a wrong result; the limit itself is tracked in
#133.
What to do: keep the chain at 63 constants or fewer.
Generic modules
- A generic module that is never instantiated generates no
SystemVerilog, and gets the new warningW1006in the main file
(#143). 0.1.0 wrote it as
a SystemVerilog module, with its parameter resolved to a top-level
constant with the same name (withconst N : u32 = 7,
module Fir<const N: u32> { out y : u8 y = N }gave
assign y = 32'd7;inFir.sv) or left as an undeclared name
(assign y = N;). Instantiated generic modules (Fir_4.sv) and
modules that are not generic do not change; a generic module in a file
loaded withusegets no warning.
What to do: a script that expects the module's file inbuild/rtl/
no longer finds it. Instantiate the module where it is used:
Fir<8> { ... }generatesFir_8.sv. A build that treats warnings as
errors may now fail.
Division
- New warning
W2015for an operand of/or%that is cut before
the division (#173). It
rejects nothing and the generated SystemVerilog does not change; see
New warnings.
What to do: write the width on both operands. A build that treats
warnings as errors may now fail.
Verilator options
volt test,volt runandvolt test --wavesrun Verilator with
-fno-dfg(#148),
locally and in Docker. The generated SystemVerilog does not change; see
Simulation.
What to do: nothing in Volt. If you run Verilator on the generated
SystemVerilog yourself, add-fno-dfg.
Commands
volt test --watchruns again for a file saved during a run
(#176). 0.1.0 missed that
save: the screen kept the result of the old contents (it could say
"tests passed") until the next save.
What to do: nothing.
Fixed
Each of these produced a wrong result without a diagnostic in 0.1.0. The
input, the old output and the new one are under
Behavior changes.
Name resolution
- An inlined function took the value of a same-named loop variable for a
constant of its body
(#128). - Generic and module-level
forsubstitution replaced an inner
declaration that hides the parameter or the loop variable
(#130). - The index and the length of a bundle array were resolved through
top-level constants and nothing else
(#136). - Bundle fields,
inoutmethods,@mmiohandles and pipeline values
ignored a block-scope name that hides them
(#137). - An inferred counter contract took a block
letfor a constant
(#138). - A generic module that is never instantiated was written to
SystemVerilog with its parameter resolved to a same-named top-level
constant (#143).
Literal arithmetic
- Arithmetic on literals alone was written with each literal cut to the
width of its context:2 / 2in au1gave 0
(#144). - The range check of
combloop variables in literal arithmetic stopped
above 65,536 combinations
(#152). - A literal arithmetic tree deeper than 64 levels was written with
context-width literals
(#153).
Visibility
- A module-level
forbound, a bundle array length or index, and a
bundle type orHandshakepayload could read a private constant or
struct of another file
(#139).
Widths
- The untyped
letof a function inlined in acombblock lost its
flexible width (#132).
Verilator
- Verilator 5.052 miscompiled correct SystemVerilog with its DFG
optimizer on, sovolt testcould print wrong values
(#148); see
Simulation. - The Verilator of Volt's own continuous integration is pinned to the
5.052 release that the Docker image ofvolt testuses, instead of a
development build that miscompiled correct SystemVerilog
(#145).
volt test --watch
- A file saved while a run was going on started no new run
(#176).
Simulation
volt test, volt run and volt test --waves now pass -fno-dfg to
every Verilator build, with a local Verilator and with the Docker image.
With its DFG optimizer on, Verilator 5.052 compiles some correct
SystemVerilog into a model that prints wrong values: for
assign o = 4'(p) - 4'(p);, which is 0 for every p, it printed 4'hf
(#148; reported upstream as
verilator/verilator#9060).
The option stays until Verilator fixes it.
The measured cost is none: on the nine test files of examples/ and the
tests of the book, the total time of volt test changed by -0.5%, less
than the difference between two runs.
If you run Verilator on the generated SystemVerilog yourself, add
-fno-dfg too.
New warnings
W1006: a generic module in the main file is never instantiated,
so no SystemVerilog is generated for it: "module 'Fir' is generic and is
never instantiated; no SystemVerilog is generated for it (parameterized
output is planned: #171)". Writing such
a module as a parameterized SystemVerilog module is a proposal for
0.2.0 (#171).W2015: an operand of/or%is an arithmetic value wider than
the width at which the division is made, so it is cut before the
division. Ino : u9 = a * b / c + dwith fouru8inputs,a * b
(16 bits) is cut to 8 bits: "this operand of '/' is cut to 8 bits before
the division (its natural width is 16); the rule changes in v0.2.0
(#150)". The generated SystemVerilog does not always do the same as the
type checker here (#150),
and the rule for the width of such a division changes in 0.2.0, so the
value of these divisions may change then. The warning marks every place
that can change. Writing the width on both operands, as in
(a * b) as u16 / (c as u16), removes the warning, and the value then
does not depend on the rule; the quotient is then 16 bits wide, so
widen or narrow it to its target as for any other value. A literal, a constant, an operand as wide
as the division, and a division widened to its target
(o : u9 = (a + b) / c) get no warning.
Known issues
These bugs are open. Each one is planned for a later release; until then,
the workaround avoids it.
-
Division with a wider arithmetic operand
(#150): the generated
SystemVerilog can compute/or%at a different width than the type
checker, as ina * b / cwithu8operands. WarningW2015marks
every such place; write the width on both operands
((a * b) as u16 / (c as u16)). -
A struct
letwhose flattened field name equals another name
(#154): with
let p : S(fieldx) in a block and a portp_x, a read ofp_x
reads the field of the local in the generated SystemVerilog. Do not
name a port or signal<let>_<field>; rename thelet. -
A module-level
letwith the name of a bundle port or ofregs
(#155) is accepted
without errorE1003, and the name then means two different things.
Give theleta name of its own. -
Constant evaluation in the parser stops at depth 64
(#159): a module-level
forbound or a bundle array length that is a constant expression
deeper than 64 levels, or the end of a chain of 64 constants, is
rejected withE2021; a cycle there getsE2021instead ofE2020;
and a counter whose limit is such a chain gets no inferred contract.
Keep constant chains and expressions shallower than 64 levels. -
An import alias (
use a::X as J)
(#161): an aliased
constant used as a value is written into the SystemVerilog under its
alias (assign y = J;, an undeclared name), without a diagnostic; an
aliased type, function, domain or module is rejected. Import such items
withoutas. -
A test block can read a private constant of another file
(#162) without error
E1001. Make the constantpuband import it withusein the test
file, as the visibility rules require. -
A generic module that is never instantiated and uses its parameter in
a type (in x : uint<N>)
(#172) is rejected with
E2021("this is a generic parameter (runtime value)"), also in a file
loaded withuse. Instantiate the module once, for example
Fir<8> { ... }. -
A clock-domain crossing through a module without a clock
(#189): when a signal of
one clock domain passes through a submodule that has no clock port (or
a clocklessextern module) and reaches another domain,volt check
reports noE3001and the generated SystemVerilog has no
synchronizer. Synchronize the signal into the destination domain with
sync()before it enters the clockless module, or read the module's
output into aletand pass thatlettosync(). -
validdepending onreadythrough a submodule
(#193):E4007does not
follow a combinational path from aHandshakeport'sreadyto its
validthrough a submodule instance or a built-in primitive
(EdgeDetect, arbiters), and the automatic protocol contracts do not
catch it either. Make thevaliddecision in a register of the
producer, asE4007's help shows (reg valid_r ...; on clk { ... }; tx.valid = valid_r).
The full list of limitations, with workarounds:
Known limitations.
Install
Windows (PowerShell):
irm https://volt-hdl.github.io/volt/install.ps1 | iexLinux and macOS:
curl -fsSL https://volt-hdl.github.io/volt/install.sh | shRunning the script again updates an installed Volt to this release.
VOLT_VERSION=0.1.1 installs this release instead of the newest one. In
a new terminal, volt --version prints volt 0.1.1 followed by the
commit in parentheses. The VS Code extension is attached to this release
as volt-hdl-0.1.1.vsix. Verifying a download, installing by hand and
the platform notes are unchanged from 0.1.0: see
Install Volt.
Support
The latest release is the supported one. Fixes go into main and ship
with the next release. Before 1.0, a new last digit (0.1.1) brings fixes
and a new middle digit (0.2.0) may break existing code; a fix for a
silent wrong result may reject input that was accepted before even in a
last-digit release, as in this one. Report bugs in the
issues.
The full change log, in Turkish:
CHANGELOG.md.
Planned work: Roadmap.