A simple synchronous counter taken through the complete VLSI flow: simulation โ coverage โ Yosys synthesis โ OpenROAD floorplan, placement & routing.
A 4-bit synchronous up-counter with reset
module Mycounter (
input clk,
input rst,
output reg [3:0] out
);
always @(posedge clk) begin
if (rst)
out <= 4'b0000;
else
out <= out + 1;
end
endmodule
Compile & run with Icarus Verilog, view waveforms with GTKWave
module Testbench;
reg clk, rst;
wire [3:0] out;
Mycounter uut (.clk(clk), .rst(rst), .out(out));
initial begin clk = 0; forever #5 clk = ~clk; end
initial begin
$dumpfile("count.vcd");
$dumpvars(0, Testbench);
rst = 1; #20; rst = 0; #200;
$finish;
end
initial $monitor("Time=%t | rst=%b | out=%d", $time, rst, out);
endmodule
# Compile RTL + testbench
$ iverilog -o Mycounter Mycounter.v Testbench.v
# Run simulation
$ vvp Mycounter
# View waveforms
$ gtkwave count.vcd
Map behavioral Verilog to Nangate45 standard cells
# 1. Read source
read_verilog Mycounter.v
# 2. Synthesis
synth -top Mycounter
# 3. Map to Nangate45 library
dfflibmap -liberty Nangate45_typ.lib
abc -liberty Nangate45_typ.lib
# 4. Clean and Write
clean
write_verilog Mycounter_synth.v
# 5. Reports
stat -liberty Nangate45_typ.lib
$ yosys -s yosys_run.tcl
| Cell | Count | Role |
|---|---|---|
DFF_X1 |
4 | D Flip-Flops (4-bit counter register) |
INV_X1 |
1 | Inverter |
NOR2_X1 |
4 | 2-input NOR gates |
XNOR2_X1 |
1 | 2-input XNOR gate |
NAND3_X1 |
1 | 3-input NAND gate |
AND2_X1 |
1 | 2-input AND gate |
AOI21_X1 |
1 | AND-OR-Invert complex gate |
| File | Origin | Purpose |
|---|---|---|
Mycounter_synth.v |
๐ค Yosys | Gate-level netlist โ input to OpenROAD |
Mycounter_synth.png |
๐ค Yosys | Circuit schematic visualization |
Floorplan โ Place โ CTS โ Route โ Layout
# 10ns clock = 100 MHz
create_clock -name clk -period 10.0 [get_ports clk]
$ openroad openroad_run.tcl
| File | Origin | Stage | Purpose |
|---|---|---|---|
Mycounter.v |
โ๏ธ Written | Design | Synthesizable RTL |
Testbench.v |
โ๏ธ Written | Simulate | Testbench |
yosys_run.tcl |
โ๏ธ Written | Synthesize | Yosys script |
Mycounter.sdc |
โ๏ธ Written | PDA | Timing constraints |
openroad_run.tcl |
โ๏ธ Written | PDA | OpenROAD script |
Mycounter_synth.v |
๐ค Yosys | Synthesize | Gate-level netlist |
Mycounter_synth.png |
๐ค Yosys | Synthesize | Circuit schematic |
Mycounter.def |
๐ค OpenROAD | PDA | Final layout (DEF) |
count.vcd |
๐ค iverilog | Simulate | Waveform dump |
# 1. Simulate
$ iverilog -o Mycounter Mycounter.v Testbench.v && vvp Mycounter
# 2. Synthesize
$ yosys -s yosys_run.tcl
# 3. Physical Design
$ openroad openroad_run.tcl