Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Emphasise that read_verilog doesn't lint #4705

Merged
merged 4 commits into from
Nov 18, 2024
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions README.md
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

does not perform any syntax checking

Is an exaggeration. Maybe: "does not perform robust syntax checking"?

Copy link
Member

@nakengelhardt nakengelhardt Nov 11, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see it more as a statement of intent. read_verilog doesn't try to check if the input is correct or not, it just proceeds assuming it is correct. If that turns out to be a wrong assumption it will sometimes error out, but often not in a way that is particularly useful for the user for finding the problem. Sometimes it will also just continue, and end up with who knows what netlist. Given the history of this code and the alternatives, we think it would be a waste of effort to change that.

Original file line number Diff line number Diff line change
Expand Up @@ -260,6 +260,16 @@ The command ``prep`` provides a good default word-level synthesis script, as
used in SMT-based formal verification.


Additional information
======================

The ``read_verilog`` command, used by default when calling ``read`` with Verilog
source input, does not perform any syntax checking. You should instead lint
your source with another tool such as
[Verilator](https://www.veripool.org/verilator/) first, e.g. by calling
``verilator --lint-only``.


Unsupported Verilog-2005 Features
=================================

Expand Down
6 changes: 3 additions & 3 deletions docs/source/code_examples/fifo/fifo.v
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What's the relation to the docs change? Is this to make verilator linting happy?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah verilator gave lint warnings so I figured it was easy enough to fix them (and this wasn't a guided tutorial of how to fix it yourself)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Although it does make the first image slightly more complex
image
(left is preview, right is latest)

Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,15 @@ module addr_gen
) ( input en, clk, rst,
output reg [AWIDTH-1:0] addr
);
initial addr <= 0;
initial addr = 0;

// async reset
// increment address when enabled
always @(posedge clk or posedge rst)
if (rst)
addr <= 0;
else if (en) begin
if (addr == MAX_DATA-1)
if ({'0, addr} == MAX_DATA-1)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would not include this change, it's fine to get some linting messages from verilator IMO (gives people some idea of what to expect from verilator too).

addr <= 0;
else
addr <= addr + 1;
Expand Down Expand Up @@ -57,7 +57,7 @@ module fifo
);

// status signals
initial count <= 0;
initial count = 0;

always @(posedge clk or posedge rst) begin
if (rst)
Expand Down
8 changes: 8 additions & 0 deletions docs/source/getting_started/example_synth.rst
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,14 @@ First, let's quickly look at the design we'll be synthesizing:

.. todo:: fifo.v description

While the open source `read_verilog` frontend generally does a pretty good job
at processing valid Verilog input, it does not provide very good error handling
or reporting. Using an external tool such as `verilator`_ before running Yosys
is highly recommended. We can quickly check the Verilog syntax of our design by
calling ``verilator --lint-only fifo.v``.

.. _verilator: https://www.veripool.org/verilator/

Loading the design
~~~~~~~~~~~~~~~~~~

Expand Down
5 changes: 5 additions & 0 deletions docs/source/introduction.rst
Original file line number Diff line number Diff line change
Expand Up @@ -69,9 +69,14 @@ Things you can't do

- Check out `nextpnr`_ for that

- Rely on built-in syntax checking

- Use an external tool like `verilator`_ instead

.. todo:: nextpnr for FPGAs, consider mentioning openlane, vpr, coriolis

.. _nextpnr: https://github.com/YosysHQ/nextpnr
.. _verilator: https://www.veripool.org/verilator/

The Yosys family
----------------
Expand Down
Loading