preloader
Setting Up Icarus Verilog on Google Colab

    Setting Up Icarus Verilog on Google Colab

    Google Colab is a cloud-based platform that allows you to run code in a Jupyter Notebook environment. While it’s primarily designed for Python, it can also be adapted to run Verilog simulations using Icarus Verilog. This guide walks you through setting up Icarus Verilog on Colab, writing and compiling Verilog code, running simulations, and generating waveform files for debugging—all in the cloud.

    You might wonder why we’d even consider simulating Verilog code on Colab when there are many industry-grade tools available that offer synthesis, timing analysis, and complete hardware design capabilities. The answer lies in accessibility. Icarus Verilog is an open-source, lightweight alternative that remains incredibly relevant—especially for students, educators, and hobbyists. It’s perfect for academic projects, quick prototyping, and learning digital design fundamentals without the overhead of licensed tools or heavy installations.

    One major advantage of using Colab is its seamless integration with the web—allowing you to import datasets or files directly from URLs or cloud storage. This becomes particularly useful for projects where Verilog testbenches need structured data, such as input vectors, weights, or test cases. With Python handling the preprocessing and formatting, you can easily generate files that your Verilog code can read, enabling a smooth and flexible software-hardware co-design workflow.

    My own journey into this setup began with a somewhat unconventional idea: training a neural network in Verilog. It was a fun and technically challenging experiment that led me to build this workflow on Colab. If you’re curious to see how that turned out, feel free to check out my project here.

    Why Use Icarus Verilog on Google Colab?

    Icarus Verilog is an open-source Verilog simulation and synthesis tool that supports a wide range of Verilog constructs. Running it on Google Colab offers several advantages:

    • No need to install software on your local machine.
    • Easy collaboration and sharing through Colab notebooks.
    • Accessible from any device with an internet connection.
    • Free computational resources provided by Google.

    Now, let’s get started with setting up Icarus Verilog on Google Colab.

    Installing Icarus Verilog

    Before you can run Verilog simulations, you need to install Icarus Verilog on your Colab environment. To do this, execute the following commands:

    !sudo apt-get update
    !sudo apt-get install -y iverilog
    

    Once installed, verify the installation by checking the version:

    !iverilog -v
    

    If the installation is successful, you will see the version information displayed in the output.

    Writing and Running a Simple Verilog Program

    To test if Icarus Verilog is working correctly, let’s write a simple Verilog program that prints a message. In Colab, you can use the %%writefile magic command to create and save Verilog files:

    %%writefile test.v
    module hello;
      initial begin
        $display("Hello, Icarus Verilog on Colab!");
        $finish;
      end
    endmodule
    
    Compiling and Running the Verilog Code

    Once the Verilog file is created, compile it using iverilog:

    !iverilog -o test.out test.v
    

    Now, run the compiled Verilog file using vvp:

    !vvp test.out
    

    If everything is working correctly, you should see the message “Hello, Icarus Verilog on Colab!” printed in the output.

    Generating and Viewing Waveform Files

    In addition to printing messages, you can also generate waveform files to analyze signal behavior. This is particularly useful for debugging digital designs.

    To generate a VCD (Value Change Dump) file, modify your Verilog code to include the necessary $dumpfile and $dumpvars commands:

    %%writefile wave.v
    module wave;
      initial begin
        $dumpfile("wave.vcd");
        $dumpvars(0, wave);
        $display("Generating wave.vcd...");
        #10;
        $finish;
      end
    endmodule
    
    Compiling and Simulating

    Compile and simulate the modified Verilog file using the following commands:

    !iverilog -o wave.out wave.v
    !vvp wave.out
    

    You should see a message confirming that wave.vcd has been generated.

    Downloading and Viewing the Waveform File

    Once the wave.vcd file is created, you can download it to your local machine for analysis using GTKWave, a popular waveform viewer. Use the following command to download the file:

    from google.colab import files
    files.download("wave.vcd")
    

    After downloading, open the file in GTKWave and inspect the signal transitions.

    Download the Notebook

    You can download the Jupyter Notebook containing all the above steps from the following link:

    Download the Jupyter Notebook

    Conclusion

    Using Google Colab for Icarus Verilog simulations provides a simple and convenient way to write, compile, and debug Verilog code without requiring any local installations. Whether you’re a beginner learning Verilog or an experienced engineer testing small designs, this setup allows you to quickly prototype and verify your digital circuits.

    By following the steps outlined in this guide, you can:

    • Install Icarus Verilog in Google Colab.
    • Write and execute Verilog programs.
    • Generate and analyze waveform files.

    What’s more—Colab isn’t just limited to Verilog. With a bit of setup, you can manage a range of open-source tools like Yosys, Graywolf, and many components from the OpenROAD flow, with GUIs disabled. This opens the door to enabling a full end-to-end digital design workflow—all within the cloud.

    This setup is especially useful for students, researchers, and hobbyists looking for a hassle-free environment to explore digital design, without worrying about system configurations or heavy installations.

    Happy coding!

    Related Posts

    Why RISC-V Can Be a Game Changer?

      Why RISC-V Can Be a Game Changer?

      In a world dominated by proprietary chip architectures, a quiet shift is underway. RISC-V, an open-source alternative, is redefining how we think about processor design—especially in the VLSI world.

      Read more
      Introduction to VLSI Design Flow: RTL to GDSII

        Introduction to VLSI Design Flow: RTL to GDSII

        Wonder why AI, modern smartphones, and countless digital devices have become so powerful yet compact? The secret lies in the ability to pack billions of transistors into tiny silicon chips — a feat accomplished through Very Large-Scale Integration (VLSI). At the core of this accomplishment is a complex, multi-step design flow that transforms abstract hardware concepts into a physical chip ready for fabrication.

        Read more
        ROS 2 vs ROS 1: What Changed and Why It Matters?

          ROS 2 vs ROS 1: What Changed and Why It Matters?

          Is ROS 1 still the right choice for your next robotics project, with its well-established tools and wide community support? Or, given the growing demand for real-time performance, scalability, and modern middleware, is it finally time to make the move to ROS 2?

          Read more