# Icarus Verilog

**Icarus Verilog** 是一款开源的 Verilog 仿真与综合工具，它是一个编译系统，将 Verilog 源代码翻译为内部网表（即电路元件及其连接关系的列表），再翻译为所选后端的代码，最常用的是“vvp”事件驱动仿真引擎。其版权归 Stephen Williams 所有，以 GPL-2.0 许可证授权，托管于 GitHub 的 steveicarus 组织下，仓库约有 3600 颗星和 631 次复刻。<sup>[1](https://github.com/steveicarus/iverilog)</sup>

| 关键事实 | 详情 |
|---|---|
| 许可证与著作权 | GPL-2.0；Icarus Verilog、ivl 和 ivlpp 的版权归 Stephen Williams 所有，2000–2026<sup>[1](https://github.com/steveicarus/iverilog)</sup> |
| 编译阶段 | 预处理、解析、精化、优化、代码生成<sup>[1](https://github.com/steveicarus/iverilog)</sup> |
| 主要目标 | vvp 代码生成器，最常用的目标，也是主要的仿真引擎<sup>[2](https://steveicarus.github.io/iverilog/targets/tgt-vvp.html)</sup> |
| 其他目标 | 用于综合的 xnf 和 fpga<sup>[3](https://course.ccs.neu.edu/cs3650/ssl/TEXT-CD/Content/Software/IcarusVerilog/iverilog.pdf)</sup> |
| 语言代次 | 通过 `-g2012` 选择 SystemVerilog 2012；当出现多个 `-g` 标志时，最后一个生效<sup>[4](https://docs.systemverilogstudio.com/running/icarus-verilog/)</sup> |
| 典型搭配 | 学习与小项目：Icarus Verilog 加 GTKWave 波形查看器<sup>[5](https://tapeout.reyatech.com/blog/eda-tools-comparison)</sup> |

## 编译器工作原理

Icarus Verilog 通过一条固定的流水线处理源代码。各阶段依次为预处理、解析、精化、优化和代码生成。<sup>[1](https://github.com/steveicarus/iverilog)</sup> 预处理器可以单独运行：`iverilog -E -o out.v example.v` 会将预处理后的源代码写入文件。<sup>[6](https://steveicarus.github.io/iverilog/usage/simulation.html)</sup> 在精化阶段，网表由函子处理，其中包括一些优化和可选的综合，然后被翻译为 ivl_target 内部形式。<sup>[7](https://steveicarus.github.io/iverilog/developer/guide/index.html)</sup>

该编译器还支持来自 EDA 厂商的预处理模块库，因此 Icarus Verilog 可以使用厂商格式的库进行仿真。<sup>[6](https://steveicarus.github.io/iverilog/usage/simulation.html)</sup>

## vvp 运行时

最常见的工作流程是编译为 `.vvp` 文件，然后用独立的 `vvp` 程序运行它。典型命令为 `iverilog -o top.vvp -s top hello_world.v`，这等价于添加显式目标标志 `-tvvp`；`-s` 选项指定顶层模块。<sup>[2](https://steveicarus.github.io/iverilog/targets/tgt-vvp.html)</sup> 生成的文件以调用 vvp 的 shebang 行开头，随后是版本记录、时间精度、`vpi_module` 加载指令，以及诸如 `.scope` 和 `.timescale` 之类的带标签语句。<sup>[2](https://steveicarus.github.io/iverilog/targets/tgt-vvp.html)</sup>

**VVP 汇编。** vvp 仿真器接受的输入源代码，与常规处理器的汇编语言颇为相似。由于其他工具——包括 Icarus Verilog 编译器——是要将这种代码作为机器生成的输出产生的，其语法虽可读，却并不总是适合人类使用。每条语句可以有一个标签、一个操作码和若干操作数；每条语句以分号结束，分号同时也开始一条注释。语句可以跨越多行，只要续行的第一列除标签的第一个字符外不出现任何文本。<sup>[8](https://github.com/steveicarus/iverilog/blob/master/Documentation/developer/guide/vvp/vvp.rst)</sup> 该引擎被设计为接受 Verilog 的编译形式，综合后的设计可以用 D 触发器等常见器件来表示，而 Verilog 语言本身并未将这些定义为原语。<sup>[8](https://github.com/steveicarus/iverilog/blob/master/Documentation/developer/guide/vvp/vvp.rst)</sup>

## 语言支持与扩展

语言代次通过 `-g` 标志选择。围绕 Icarus Verilog 构建的工具链默认使用 `-g2012` 编译 [SystemVerilog](https://www.edgepedia.org/zh/systemverilog) 2012，用户也可以选择其他代次，如 `-g2005-sv`；当给出多个 `-g` 选项时，最后一个生效。<sup>[4](https://docs.systemverilogstudio.com/running/icarus-verilog/)</sup>

Icarus Verilog 支持对基线 IEEE 1364 标准的某些扩展，其中一些取自该语言的扩展变体（如 SystemVerilog），另一些则将内部行为暴露为调试辅助。文档警告说，当代码需要保持跨其他 Verilog 编译器的可移植性时，不要使用这些扩展。<sup>[9](https://steveicarus.github.io/iverilog/usage/icarus_verilog_extensions.html)</sup> 扩展系统函数包括 `$is_signed`（若其表达式为有符号则返回 1）和 `$bits`（返回其参数以位计的大小）；`$sizeof` 已被弃用，建议改用 `$bits`。<sup>[9](https://steveicarus.github.io/iverilog/usage/icarus_verilog_extensions.html)</sup> 扩展数据类型由 `-gxtypes` 启用且默认开启，它将线网/变量概念与数据类型分离，并提供基本类型 `logic`（0、1、x 和 z，可选带强度）、`bool`（限于 0 和 1）以及 `real`（64 位实数值）。此语法基于 [Cadence Design Systems](https://www.edgepedia.org/zh/cadence-design-systems) 的一项提案，该提案最初作为 IEEE 1364 的更新草案起草；保留此语法是为了向后兼容。<sup>[9](https://steveicarus.github.io/iverilog/usage/icarus_verilog_extensions.html)</sup>

**怪癖。** 对于可综合代码，文档推荐使用 `-gstrict-expr-width` 选项，它消除了一处综合与仿真不匹配的潜在来源。Icarus Verilog 还将强度显示扩展为支持显示向量的强度，并且一些含义明确的系统函数可以在编译时求值，而不必通过运行时 VPI 代码。<sup>[10](https://steveicarus.github.io/iverilog/usage/icarus_verilog_quirks.html)</sup>

## 在仿真器中的位置

在语言覆盖面上，2023 年一篇比较两者的 OOPSLA 论文指出，Icarus Verilog 在解析语言特性方面提供的支持远优于 [Verilator](https://www.edgepedia.org/zh/verilator)。<sup>[12](https://qinlinchen.github.io/papers/2023_OOPSLA_LambdaV.pdf)</sup> 2026 年的一份工具比较如此划分各自的定位：Icarus 加 GTKWave 用于学习和小项目，Verilator 用于快速 CI 回归和 C++ 协同仿真，而 VCS、Xcelium 和 [Questa](https://www.edgepedia.org/zh/questa) 等商业仿真器则用于企业级 UVM 和签核级调试。<sup>[5](https://tapeout.reyatech.com/blog/eda-tools-comparison)</sup>

Icarus Verilog 还充当参考实现：Vogls 文档将其用作 Verilog 语义的参考仿真器，<sup>[11](https://www.vogls.nl/docs/comparison.html)</sup> 研究流水线则通过用 Verilator 编译、用 Icarus Verilog 仿真的方式来验证生成的 Verilog。<sup>[13](https://arxiv.org/abs/2607.22759)</sup> 它与用于综合的 [Yosys](https://www.edgepedia.org/zh/yosys) 和用于布局布线的 nextpnr 一起，构成更广泛的开源 FPGA 工具链。<sup>[14](https://arxiv.org/abs/1903.10407)</sup>

## 实际使用

编译文件（`.f` 文件）可以列出源文件以及 `+incdir+` 和 `+define+` 选项，通过 `-f` 传递给 `iverilog`。静态检查动作只编译不写出任何内容（`iverilog -g2012 -t null ...`），构建动作用 `-o` 生成 `sim.vvp`，而构建并运行动作则随后执行 `vvp -n sim.vvp`。<sup>[4](https://docs.systemverilogstudio.com/running/icarus-verilog/)</sup> 常见的失败模式包括：顶层模块拼写错误或缺失；`vvp` 可执行文件未与 `iverilog` 一同安装，或不在 PATH 中；以及在 macOS 上，选项顺序问题：`iverilog` 在文件名之后不再读取任何选项，因此选项必须位于文件名之前。<sup>[4](https://docs.systemverilogstudio.com/running/icarus-verilog/)</sup>

## References

1. [The ICARUS Verilog Compilation System, steveicarus/iverilog README](https://github.com/steveicarus/iverilog)
2. [The vvp Code Generator (-tvvp), Icarus Verilog documentation](https://steveicarus.github.io/iverilog/targets/tgt-vvp.html)
3. [iverilog SYNOPSIS man page](https://course.ccs.neu.edu/cs3650/ssl/TEXT-CD/Content/Software/IcarusVerilog/iverilog.pdf)
4. [Icarus Verilog, SystemVerilog Studio documentation](https://docs.systemverilogstudio.com/running/icarus-verilog/)
5. [EDA Simulation Tools Compared: Verilator vs Icarus vs Commercial Flows (2026), ReyaTech](https://tapeout.reyatech.com/blog/eda-tools-comparison)
6. [Simulation Using Icarus Verilog, Icarus Verilog documentation](https://steveicarus.github.io/iverilog/usage/simulation.html)
7. [Developer Guide, Icarus Verilog documentation](https://steveicarus.github.io/iverilog/developer/guide/index.html)
8. [VVP Simulation Engine, steveicarus/iverilog developer guide](https://github.com/steveicarus/iverilog/blob/master/Documentation/developer/guide/vvp/vvp.rst)
9. [Icarus Verilog Extensions, Icarus Verilog documentation](https://steveicarus.github.io/iverilog/usage/icarus_verilog_extensions.html)
10. [Icarus Verilog Quirks, Icarus Verilog documentation](https://steveicarus.github.io/iverilog/usage/icarus_verilog_quirks.html)
11. [Comparison to other tools, Vogls Documentation](https://www.vogls.nl/docs/comparison.html)
12. [The Essence of Verilog (OOPSLA 2023), Qinlin Chen](https://qinlinchen.github.io/papers/2023_OOPSLA_LambdaV.pdf)
13. [Benchmarking LLMs for Verilog Design Flows, arXiv](https://arxiv.org/abs/2607.22759)
14. [Yosys+nextpnr: an Open Source Framework from Verilog to Bitstream for Commercial FPGAs, arXiv](https://arxiv.org/abs/1903.10407)

---
*Initially written Oct 15, 2026*

Topic: 技术与人造世界 › 计算技术与数字系统 › 计算机硬件 › Embedded & soft processors › Soft processors & open hardware › FPGA processor implementation & tooling

Copyright 2026 Edgepedia

License: Edgepedia Community License 1.0, https://www.edgepedia.org/edgepedia/license

Source: https://www.edgepedia.org/zh/icarus-verilog

English original: https://www.edgepedia.org/icarus-verilog
