Visualizing Verilog Simulation

You don’t usually think of simulating Verilog code — usually for an FPGA — as a visual process. You write a test script colloquially known as a test bench and run your simulation. You might get some printed information or you might get a graphical result by dumping a waveform, but you don’t usually see the circuit. A new site combines Yosys and a Javascript-based logic simulator to let you visualize and simulate Verilog in your browser. It is a work in progress on GitHub, so you might find a few hiccups like we did, but it is still an impressive piece of work.

If you aren’t up on Verilog, you can use the “Load Example Code” button to pick a few samples. You might try this if you want something really simple:


module test(
input a,
output b
);

assign b=~a;

endmodule

That creates a circuit like this:

The A button is live, so clicking it will change the little faux LED to red along with the associated wires. It may not be obvious, but you can drag components around to suit you. You can also delete wires and create new connections. If there is a way to add and delete components, we couldn’t figure it out.

This isn’t a bad way to learn Verilog since you can quickly see what the code is doing. It isn’t flexible enough to be a workhorse simulator, though. For example, naming something clk puts a clock input on the schematic, but using any other name as a clock leaves it as a button like “a” in the example above. There’s no way to set the clock either.

This is fun, though. Yosys has a lot of features we usually don’t use, including the ability to generate graphviz files with schematics of the design, although they aren’t as clear as this. We’d love to see this married with Falstad as the simulation engine so you could basically use Verilog modules as part of your simulation. That simulator can do digital circuits, it just doesn’t accept Verilog.  If you want real simulation in your browser, try EDA Playground, which we use a lot.

13 thoughts on “Visualizing Verilog Simulation

      1. I’ve always stuck with the old Xilinx 95xx series CPLDs, cause first, I have drawers full of ’em, and second, I only design using the schematic tool… It’s way easier for me to define logic visually by schematic than trying to work out lines of code. My brain just prefers visual logic, I guess. This is pretty cool!

  1. The author here. Thanks for posting this on Hackaday and for all the useful feedback!
    I designed the tool to be used for a university course, for teaching digital design simultaneously with Verilog coding for computer science students. The focus is on synthesis and schematic readability, because I want my students to understand that they are building circuits, and not writing software.
    The project is open source and contributions are most welcome. I will encourage my students to enhance the simulator with features it needs. And I’d like to have a lot: adding/removing components by hand, saving and loading, export to SVG, export to Verilog, clock control, memory state editing, waveform inspection, and so on.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.