Welcome to Digital Logic Design! In this course, we use Visual Studio Code (VS Code) paired with Apio to write, verify, and simulate Verilog code.
This setup runs natively on Windows, macOS (including M1/M2/M3 Apple Silicon), and Linux. It matches our course autograder exactly, meaning if your code compiles and simulates correctly on your laptop, it will behave the same way when graded.
If you do not already have it, download and install VS Code for your operating system:
Apio relies on Python to manage its backend tools.
We will install Apio and its required compilers (iverilog and GTKWave) directly inside VS Code.
Ctrl+Shift+X on Windows, Cmd+Shift+X on Mac).Ctrl+Shift+P or Cmd+Shift+P).apio install --all
Note: This download may take a few minutes. A success message will appear in your terminal when finished.
🛑 Common Error: If you get the following error - especially if you are on a MAC:
Error: “apio command not found”
Try the following:
python3 -m pip install -U apio
apio packages install
To make sure everything is installed correctly, let’s create a simple AND gate logic module and test it.
Create a brand new, empty folder on your computer named Project0. Open this folder in VS Code (File -> Open Folder).
Project0.v)Create a new file named Project0.v and paste the following code:
// File Name: Project0.v
module Project0
(
input [2:0] SW, // a, b, c
output [0:0] LEDG // m
);
Majority M(.m(LEDG[0]), .b(SW[2]), .a(SW[1]), .c(SW[0]));
endmodule
Majority.v)Create a new file named Majority.v and paste the following code:
// File Name: Majority.v
module Majority (
input a, b, c,
output m
);
wire ab, ac, bc;
and a1(ab, a, b);
and a2(ac, a, c);
and a3(bc, b, c);
or o1(m, ab, ac, bc);
endmodule
Project0_tb.v)Create a second file named Project0_tb.v. This file tells the simulator what inputs to inject so you can watch the output change. Paste this code:
// File Name: Project0_tb.v
`timescale 1 ns/1 ns
module TestBench0();
reg [2:0] SW;
wire [0:0] LEDG;
Majority M(.a(SW[2]), .b(SW[1]), .c(SW[0]), .m(LEDG[0]));
initial begin
$dumpvars(0, TestBench0);
SW = 3'b000; #5;
SW = 3'b001; #5;
SW = 3'b010; #5;
SW = 3'b011; #5;
SW = 3'b100; #5;
SW = 3'b101; #5;
SW = 3'b110; #5;
SW = 3'b111; #5;
end
endmodule
Open the VS Code built-in terminal (Terminal -> New Terminal) and run these two commands:
apio create --board icestick --top-module Project0
apio lint
apio sim
If successful, GTKWave will automatically pop open on your screen!
When GTKWave opens, it will look blank at first. Follow these quick steps to see your signals:
In the top-left SST panel, click on TestBench0->M.

In the panel below it, you will see your signals/wires: a, b, c, m, etc.

Select the signals a, b, c, and m(hold Ctrl or Cmd to click multiple), then click the Append button at the bottom left.

Click the Zoom Fit icon (magnifying glass with an “all” box) in the top toolbar to see your complete timing diagram!
_tb.v file contains the exact $dumpfile and $dumpvars lines shown in the example above. Without them, no waveform data is saved for GTKWave to display.