Skip to content
Systems programming for what’s next.
— Vex

VexHDL Transpiler, Synthesis, and Integration Guide ​

This guide details VexHDL's interoperability with Verilog and VHDL, external module imports, simulator bypass rules, synthesis pipeline, and timing verification.


1. Foreign Language Interface (extern) ​

VexHDL allows you to import existing Verilog or VHDL modules directly into your project. This is useful for reusing legacy IP (like memory controllers or clock managers).

1.1 Importing Verilog Modules ​

Use extern "verilog" block pointing to the source file:

vexhdl
extern "verilog" from "ip_cores/fifo_mem.v" {
    // Declarations match Verilog module ports and parameters
    module fifo_mem #(
        DATA_WIDTH: U32 = 8,
        ADDR_WIDTH: U32 = 4,
    )(
        clk: Input,
        wr_en: Input,
        rd_en: Input,
        data_in: Input[DATA_WIDTH],
        data_out: Output[DATA_WIDTH],
        full: Output,
        empty: Output,
    );
}

1.2 Importing VHDL Entities ​

Use extern "vhdl" block:

vexhdl
extern "vhdl" from "ip_cores/sp_ram.vhd" {
    module sp_ram #(
        width: U32 = 16,
        depth: U32 = 256,
    )(
        clk: Input,
        we: Input,
        addr: Input[8],
        di: Input[width],
        do: Output[width],
    );
}

2. Compilation and Simulation Bypass Rules ​

The inspected compiler and driver impose these integration boundaries; they do not establish compatibility with every synthesis tool or foreign IP block:

  1. Single-Language Target Constraint: You cannot mix extern "verilog" and extern "vhdl" in the same project. If both are present, the compiler throws E030: SirUnsynthesizable error.
  2. Simulation Bypass:
    • If a project contains only VexHDL, the built-in simulator may be available, subject to the current simulator implementation and target setup.
    • Foreign module bodies require a compatible external simulator. The driver contains detection and external-runner paths, but the selected simulator must be installed and configured for the emitted language. Keep its command, version, log and waveform in the validation record; do not infer a successful invisible fallback from source acceptance.

3. Synthesis and Place & Route Pipeline ​

The compiler has Verilog, VHDL and BLIF emitters, with representation limits. Foreign Verilog suppresses VHDL output; foreign VHDL suppresses Verilog output. BLIF output is unavailable when foreign modules or unresolved blackboxes would otherwise be lost. The hardware driver's foreign-source snapshot path currently accepts Verilog, not VHDL.

A typical FPGA flow has separate artifacts:

text
VexHDL source + foreign RTL
  → compatible generated RTL
  → synthesis netlist
  → target-specific place and route + timing reports
  → device bitstream packaging
  → programmer + selected board

For an iCE40-style flow, Yosys and nextpnr are examples of the middle tools. The placement output is not automatically a programmable bitstream; packaging is a separate target-specific step. Tool availability, device database, pin/clock constraints and programmer configuration are part of the project. Do not substitute this schematic for Studio release instructions or assume that another FPGA family uses the same formats and commands.

4. SDF Timing Verification post-synthesis ​

The sibling VexHDL implementation contains an SDF parser, delay annotation and setup/hold checks in vex-hdl-sim. The driver accepts an explicit SDF input. These are implemented components, not proof that every cell model, timing arc, conditional check or annotation in a vendor-generated SDF is supported.

Before relying on a timing simulation:

  1. Use the netlist, SDF and cell models from the same build.
  2. Check hierarchy/instance matching and the simulator's time units.
  3. Confirm expected annotations were applied and unsupported records reported.
  4. Exercise a deliberately violating fixture to verify the relevant checker.
  5. Retain the selected tool's static timing reports as well as simulation logs.

A simulation with no reported violations covers only its driven stimulus and implemented timing checks; it does not establish timing closure for all paths.

Source Ownership ​

These details were inspected in the separate VexHDL source tree:

  • crates/vex-hdl-compiler/src/lib.rs: foreign-language selection and emitter gating.
  • crates/vex-hdl-driver/src/lib.rs: foreign source snapshots and external simulation.
  • crates/vex-hdl-sim/src/sdf.rs and src/lib.rs: SDF parsing/annotation and timing checks.

The Vex language 0.4.0 documentation target does not change the independently versioned Studio compatibility matrix on the HDL overview.

Released under the MIT License.