Online VHDL compiler & simulation guide
VHDL is known for strict type safety and structured entity-architecture separation. This guide explains how IEEE 1076-2008 VHDL compiles in the browser using GHDL, how visual schematics are elaborated, and how mixed VHDL/Verilog synthesis works.
1. The VHDL compilation pipeline: GHDL + Yosys
In traditional ASIC and FPGA flows, compiling VHDL requires heavy vendor suites like Vivado, Quartus, or ModelSim. In RTL Bench, VHDL compilation is powered by GHDL (the open-source VHDL analyzer and simulator) coupled directly to Yosys:
-
Analysis & Parsing: GHDL parses your source with
--std=08 -fsynopsys, checking strict type matches acrossieee.std_logic_1164andieee.numeric_std. -
Elaboration: The top-level
entityand its boundarchitectureare resolved. Constants, generics, and generate loops are calculated. -
RTLIL Mapping: The
ghdl-yosys-pluginconverts GHDL's intermediate abstract syntax tree directly into RTLIL (RTL Intermediate Language). -
Schematic & Netlist Generation: Yosys runs logic optimization (
opt,clean) and passes the resolved gate-level netlist to both the in-browser schematic renderer and the timing engine.
process(all)),
matching relational operators (?>, ?=), conditional variable assignments,
and unconstrained port arrays are fully supported.
2. Entity vs. architecture: The separation of interface and logic
Unlike Verilog where module ports and internal logic are declared inside a single block, VHDL enforces strict isolation between interface and implementation:
| Construct | Role | Synthesis Equivalent |
|---|---|---|
entity |
Defines external I/O pins, bus widths, and generic parameters. | Chip bounding box and port interface. |
architecture |
Defines internal processes, sequential registers, and concurrent statements. | Internal logic gates, multiplexers, and flip-flops. |
configuration |
Binds specific architectures to entities (optional). | Hierarchy resolution mapping. |
Synthesizable example: Parameterized binary counter
Here is a complete, synthesizable VHDL-2008 8-bit counter with synchronous clear and load:
library ieee;
use ieee.std_logic_1164.all;
use ieee.numeric_std.all;
entity counter_8bit is
generic (
WIDTH : natural := 8
);
port (
clk : in std_logic;
rst_n : in std_logic;
load : in std_logic;
din : in std_logic_vector(WIDTH - 1 downto 0);
dout : out std_logic_vector(WIDTH - 1 downto 0)
);
end entity counter_8bit;
architecture rtl of counter_8bit is
signal count_reg : unsigned(WIDTH - 1 downto 0);
begin
process(clk, rst_n)
begin
if rst_n = '0' then
count_reg <= (others => '0');
elsif rising_edge(clk) then
if load = '1' then
count_reg <= unsigned(din);
else
count_reg <= count_reg + 1;
end if;
end if;
end process;
dout <= std_logic_vector(count_reg);
end architecture rtl;
3. Mixed-language synthesis (VHDL + Verilog)
In modern silicon engineering, teams rarely write 100% pure VHDL or 100% pure Verilog. Existing IP blocks (like AXI peripherals or memory controllers) are often written in SystemVerilog, while control pipelines may be written in VHDL.
Because RTL Bench compiles VHDL and Verilog into unified RTLIL intermediate representations:
- You can instantiate a Verilog module inside a VHDL architecture using a matching
componentdeclaration. - You can instantiate a VHDL entity inside a SystemVerilog module simply by matching port names.
- All internal signals crossing language boundaries automatically preserve their bus widths and data types.
4. Common VHDL pitfalls & fixes
-
Mixing
std_logic_vectorwith Arithmetic:
You cannot directly add+ 1to astd_logic_vector. Always importieee.numeric_stdand cast the vector tounsignedorsignedbefore applying arithmetic operators. -
Signals vs. Variables:
Signals (<=) update scheduled at the end of the simulation cycle (equivalent to non-blocking in Verilog). Variables (:=) update immediately inside aprocess. Misusing variables for register state often creates unexpected combinatorial feedback loops. -
Unintended Latch Inference:
In combinational processes, forgetting to assign a signal in every branch of anif / elseorcasestatement forces the synthesis tool to retain the previous state, inferring a transparent latch.
Frequently asked questions
RTL Bench utilizes GHDL with the --std=08 flag, giving you native support for IEEE 1076-2008, as well as backwards compatibility for IEEE 1076-1993 and 1076-2002.
Yes. GHDL elaborates your VHDL entities into netlists, allowing you to instantiate Verilog modules directly inside VHDL architectures or wrap VHDL entities inside Verilog testbenches.
VHDL compilation uses the ghdl-yosys-plugin. GHDL parses and checks types across IEEE packages, while Yosys synthesizes the design into an interactive schematic and performs technology mapping.