Skip to content

Volt 0.1.1

Choose a tag to compare

@github-actions github-actions released this 08 Nov 21:53
· 57 commits to main since this release
c33b53d

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 a fn body no longer takes the value of a loop variable
    with the same name around the call. With const I = 1 and
    fn pick(x: [u8; 4]) -> u8 { x[I] }, the call
    for I in 0..4 { ys[I] = pick(xs) } gave ys[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 a match pattern in the body, and for
    a constant's value (const J = I + 1) read inside a loop over I. A
    block let or 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 with E2005 because the caller has a name W or i.
    What to do: a design that reuses a name of a function body or of a
    constant for a loop variable, a block let or a port may get different
    SystemVerilog; warning W1002 points at these places.

  • An inner declaration hides a generic parameter or a module-level
    for variable
    (#130).
    A block let, a for inside comb or a nested for, or a let in a
    loop body with the name of a generic parameter or a loop variable is no
    longer replaced with the parameter's value. In G<3>,
    comb { let N = s y = N } gave y = 3; it now gives y = s. In
    for i in 0..1 { let i = s y = i }, 0.1.0 wrote y = 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 generic N
    (it was E2006), and the shorthand connection P { i } (it was
    E1001).

  • New W1002 warnings for a name that hides another
    (#130): a module-level
    for variable that hides a top-level item, a port, a module signal or a
    generic parameter; a let in a loop body that hides the loop variable,
    a top-level item or a let of the enclosing body; a generic parameter
    of an instantiated generic module that hides a top-level item; a block
    let or a comb loop 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 let with the name of a generic parameter:
      E1003;
    • a module-level loop variable in a pattern, and a block let that
      hides a generic parameter used in a pattern: E1015;
    • a block let that hides a generic parameter used in a type width
      (uint<N>): E2005;
    • a let of 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-level for bound: E2021.

    What to do: give the inner name a name of its own; the error points
    at it.

  • A block let or a loop variable hides a bundle port, an inout
    port, the @mmio handle regs and a pipeline stage value

    (#136,
    #137,
    #138). A use of the name
    now reads the local. After let tx : Flags = ..., tx.fired read the
    port's tx_valid && tx_ready; it now reads the field of the local. The
    same holds for dq.released after let dq : St = ... (it read
    !dq_oe) and regs.control.enable after let regs : Regs = ... (it
    read the register map). In a pipeline stage,
    for a in 0..2 { r[a] <= x } wrote r[a_a_r] twice; it now writes
    r[0] and r[1].

    • The index and the length of a bundle array are evaluated where they
      are used: a port, a module let, a block let or a loop variable
      that hides a top-level constant there is now E2008 (0.1.0 read the
      constant and selected rx[0]).
    • Inferred contracts: a counter or a state machine whose limit or
      written value is a block let no longer gets an inferred contract.
      0.1.0 took the let for the constant it hides and generated an
      invariant that does not hold (a failure in volt test, a
      counterexample in volt verify) or a cover point for a transition
      that does not exist. A match on 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 let with the name of a stage value in the module-level
      comb of a pipeline compiles; it was E5012.
    • New diagnostics: a local that hides a bundle port or regs gets
      W1002; a field access on a u8 local that hides a bundle port is
      E2003; dq.drive(v) on a local that hides an inout port is
      E0001; a write to a field of a local regs is E4001 (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 new W1002
    warnings and E2008 errors point at these places.

Visibility across files

  • A constant or a struct of another file needs pub and use in every
    position
    (#139). A
    constant that is not pub or not imported with use, read in a
    module-level for bound or in the length or index of a bundle array,
    and such a struct used as a bundle type or a Handshake payload, are
    now E1001. 0.1.0 read them without a word: with a private K = 1 in
    another file, y = rx[K].data selected rx_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 with use a::X as J now resolves in these positions (it was
    E2008, E2021 or E4001). A loop variable with the name of a hidden
    item of another file no longer gets W1002.
    What to do: a new E1001 says that the file that uses the name does
    not see it. Make the item pub in the file that declares it, and add
    use package::Name; to the file that uses it.

Widths

  • The untyped let of an inlined function keeps its flexible width in
    a comb block
    (#132),
    as it already did at module level and now also in a for inside 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-level y = g(a, b, c) gave 510; both now give 510. Some designs
    of the same kind stopped volt test with a Verilator width warning
    ((s | c) as u16); they now simulate.
    What to do: the SystemVerilog of a fn called from comb whose
    untyped let is 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
    for inside comb. 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 / 3 was written 2'h3 / 2'd3 (1) and is now 2'd2;
    x == 7 / 3 and x < 5 % 3 compared with a wrong value. New errors:

    • E2010 when the result does not fit its target:
      y : u2 = 5 + 2, const X : u8 = 200 + 100, x < 3 - 1 with
      x : u1. 0.1.0 wrapped the value without a word. The same for a
      comb loop variable that does not fit (ys[i] = i where i goes
      past the range of the target); every combination of nested loops is
      checked.
    • E2023 for a division or a remainder by zero: 7 / 0,
      5 % (2 - 2).

    What to do: if the build now reports E2010 or E2023, 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 match on an enum constant defined through a chain of more than 63
    constants
    (const A0 : E = A1, ...) is now E0003
    (#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 warning W1006 in 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 (with const N : u32 = 7,
    module Fir<const N: u32> { out y : u8 y = N } gave
    assign y = 32'd7; in Fir.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 with use gets no warning.
    What to do: a script that expects the module's file in build/rtl/
    no longer finds it. Instantiate the module where it is used:
    Fir<8> { ... } generates Fir_8.sv. A build that treats warnings as
    errors may now fail.

Division

  • New warning W2015 for 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 run and volt test --waves run 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 --watch runs 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 for substitution 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, inout methods, @mmio handles and pipeline values
    ignored a block-scope name that hides them
    (#137).
  • An inferred counter contract took a block let for 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 / 2 in a u1 gave 0
    (#144).
  • The range check of comb loop 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 for bound, a bundle array length or index, and a
    bundle type or Handshake payload could read a private constant or
    struct of another file
    (#139).

Widths

  • The untyped let of a function inlined in a comb block lost its
    flexible width (#132).

Verilator

  • Verilator 5.052 miscompiled correct SystemVerilog with its DFG
    optimizer on, so volt test could 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 of volt test uses, 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. In o : u9 = a * b / c + d with four u8 inputs, 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 in a * b / c with u8 operands. Warning W2015 marks
    every such place; write the width on both operands
    ((a * b) as u16 / (c as u16)).

  • A struct let whose flattened field name equals another name
    (#154): with
    let p : S (field x) in a block and a port p_x, a read of p_x
    reads the field of the local in the generated SystemVerilog. Do not
    name a port or signal <let>_<field>; rename the let.

  • A module-level let with the name of a bundle port or of regs
    (#155) is accepted
    without error E1003, and the name then means two different things.
    Give the let a name of its own.

  • Constant evaluation in the parser stops at depth 64
    (#159): a module-level
    for bound 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 with E2021; a cycle there gets E2021 instead of E2020;
    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
    without as.

  • A test block can read a private constant of another file
    (#162) without error
    E1001. Make the constant pub and import it with use in 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 with use. 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 clockless extern module) and reaches another domain, volt check
    reports no E3001 and 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 a let and pass that let to sync().

  • valid depending on ready through a submodule
    (#193): E4007 does not
    follow a combinational path from a Handshake port's ready to its
    valid through a submodule instance or a built-in primitive
    (EdgeDetect, arbiters), and the automatic protocol contracts do not
    catch it either. Make the valid decision in a register of the
    producer, as E4007'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 | iex

Linux and macOS:

curl -fsSL https://volt-hdl.github.io/volt/install.sh | sh

Running 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.