Arduino Custom Verilog Chip: Wiring, Code and Simulator
To build this Arduino Custom Verilog Chip project you need an Arduino Uno and a Verilog chip and an LED bar graph. A 4-bit counter written in Verilog sits on the board like any other chip. The Uno clocks it and reads its outputs back. Make the 14 connections in the wiring table, upload the Arduino C++ code, and select the chip and edit its Verilog: make it count down (q <= q - 1), or add an enable input. Run again to see your hardware change.
Open this circuit in the free Arduino Uno simulator
Parts list
| Qty | Part | What it does |
|---|---|---|
| 1 | Arduino Uno | the microcontroller board |
| 1 | Verilog Chip | Design your own chip in Verilog: its ports become pins (inputs left, outputs right). It is synthesized with Yosys when you press Run. |
| 1 | LED Bar Graph | Ten LEDs in a row: A1–A10 anodes, C1–C10 cathodes. |
Wiring
| # | From | To |
|---|---|---|
| 1 | Arduino Uno pin 2 | Verilog Chip clk |
| 2 | Arduino Uno pin 3 | Verilog Chip rst |
| 3 | Verilog Chip q[0] | LED Bar Graph A1 |
| 4 | Verilog Chip q[1] | LED Bar Graph A2 |
| 5 | Verilog Chip q[2] | LED Bar Graph A3 |
| 6 | Verilog Chip q[3] | LED Bar Graph A4 |
| 7 | Arduino Uno A0 | Verilog Chip q[0] |
| 8 | Arduino Uno A1 | Verilog Chip q[1] |
| 9 | Arduino Uno A2 | Verilog Chip q[2] |
| 10 | Arduino Uno A3 | Verilog Chip q[3] |
| 11 | Arduino Uno GND | LED Bar Graph C1 |
| 12 | Arduino Uno GND | LED Bar Graph C2 |
| 13 | Arduino Uno GND | LED Bar Graph C3 |
| 14 | Arduino Uno GND | LED Bar Graph C4 |
Step by step
- Open the simulator. Open the BitForBytes Embedded Lab in your browser and start from the Arduino Uno. No install or account is needed.
- Add the parts. Add a Verilog chip and an LED bar graph from the parts palette.
- Wire 1. Connect Arduino Uno pin 2 to Verilog Chip clk.
- Wire 2. Connect Arduino Uno pin 3 to Verilog Chip rst.
- Wire 3. Connect Verilog Chip q[0] to LED Bar Graph A1.
- Wire 4. Connect Verilog Chip q[1] to LED Bar Graph A2.
- Wire 5. Connect Verilog Chip q[2] to LED Bar Graph A3.
- Wire 6. Connect Verilog Chip q[3] to LED Bar Graph A4.
- Wire 7. Connect Arduino Uno A0 to Verilog Chip q[0].
- Wire 8. Connect Arduino Uno A1 to Verilog Chip q[1].
- Wire 9. Connect Arduino Uno A2 to Verilog Chip q[2].
- Wire 10. Connect Arduino Uno A3 to Verilog Chip q[3].
- Wire 11. Connect Arduino Uno GND to LED Bar Graph C1.
- Wire 12. Connect Arduino Uno GND to LED Bar Graph C2.
- Wire 13. Connect Arduino Uno GND to LED Bar Graph C3.
- Wire 14. Connect Arduino Uno GND to LED Bar Graph C4.
- Paste the Arduino C++ code. Paste the Arduino C++ code below into the code editor.
- Run it. Press Run. Select the chip and edit its Verilog: make it count down (q <= q - 1), or add an enable input. Run again to see your hardware change.
Arduino C++ code
// A chip you designed in Verilog, wired to the Uno.
// The chip is a 4-bit counter: pin 2 clocks it, pin 3 resets it,
// and its outputs q[0]..q[3] light the bar graph and come back on A0..A3.
const int CLK = 2;
const int RST = 3;
void pulse(int pin) {
digitalWrite(pin, HIGH);
digitalWrite(pin, LOW);
}
void setup() {
Serial.begin(9600);
pinMode(CLK, OUTPUT);
pinMode(RST, OUTPUT);
for (int i = 0; i < 4; i++) pinMode(A0 + i, INPUT);
// Hold reset through one clock edge: q goes to 0.
digitalWrite(RST, HIGH);
pulse(CLK);
digitalWrite(RST, LOW);
}
void loop() {
pulse(CLK); // one rising edge: q = q + 1
int q = 0;
for (int i = 0; i < 4; i++) q |= digitalRead(A0 + i) << i;
Serial.print("count = ");
Serial.println(q);
delay(400);
}
What to try
Select the chip and edit its Verilog: make it count down (q <= q - 1), or add an enable input. Run again to see your hardware change.
Frequently asked questions
How do I wire the Custom Verilog Chip project on an Arduino Uno?
Make 14 connections: Arduino Uno pin 2 to Verilog Chip clk; Arduino Uno pin 3 to Verilog Chip rst; Verilog Chip q[0] to LED Bar Graph A1; Verilog Chip q[1] to LED Bar Graph A2; Verilog Chip q[2] to LED Bar Graph A3; Verilog Chip q[3] to LED Bar Graph A4; Arduino Uno A0 to Verilog Chip q[0]; Arduino Uno A1 to Verilog Chip q[1]; Arduino Uno A2 to Verilog Chip q[2]; Arduino Uno A3 to Verilog Chip q[3]; Arduino Uno GND to LED Bar Graph C1; Arduino Uno GND to LED Bar Graph C2; Arduino Uno GND to LED Bar Graph C3; Arduino Uno GND to LED Bar Graph C4.
What parts do I need for this Arduino project?
An Arduino Uno and a Verilog chip and an LED bar graph.
Can I simulate this Arduino project online for free?
Yes. The BitForBytes Embedded Lab runs this exact circuit and Arduino C++ code in your browser for free, with no install and no hardware. The sketch is compiled with the real Arduino toolchain and runs on an emulated ATmega328P.
What does the code do?
A 4-bit counter written in Verilog sits on the board like any other chip. The Uno clocks it and reads its outputs back.
More Arduino Uno projects
- Arduino LED Blink: Wiring, Code and Simulator
- Arduino LDR Light Sensor: Wiring, Code and Simulator
- Arduino NTC Thermistor Thermometer: Wiring, Code and Simulator
- Arduino PWM to Analog RC Filter: Wiring, Code and Simulator
- Arduino Capacitance Meter: Wiring, Code and Simulator
- Arduino DC Motor PWM Speed Control with MOSFET: Wiring, Code and Simulator