Arduino Custom IC with Verilog Behaviour: Wiring, Code and Simulator

To build this Arduino Custom IC with Verilog Behaviour project you need an Arduino Uno and a generic IC (DIP), a yellow LED and a 220 Ω resistor. A Generic IC named MY-XOR, with pins you named yourself and one line of Verilog as its behaviour. The Uno steps its inputs and prints the truth table it measures. Make the 7 connections in the wiring table, upload the Arduino C++ code, and select the chip and change its behaviour to assign Y = A & B; (or ~(A | B)), then Run again: the printed truth table changes with your hardware.

Open this circuit in the free Arduino Uno simulator

Parts list

QtyPartWhat it does
1Arduino Unothe microcontroller board
1Generic IC (DIP)Make your own part: set its name, number of pins and pin names (comma-separated) in the inspector. Give it behaviour in Verilog using those pin names (assign OUT = A & B;) and it simulates; a pin named only by its number is P1, P2… in the code. Without behaviour it is drawn and wired only.
1yellow LEDLights when A (anode, the bent leg) is high and C (cathode) is low. Use a resistor.
1220 Ω resistorLimits current. 220 Ω in series with an LED; 10 kΩ as a pull-up or pull-down.

Wiring

#FromTo
1Arduino Uno pin 2Generic IC (DIP) A
2Arduino Uno pin 3Generic IC (DIP) B
3Arduino Uno pin 4Generic IC (DIP) Y
4Arduino Uno GNDGeneric IC (DIP) GND
5Generic IC (DIP) Yyellow LED anode (A, long leg)
6yellow LED cathode (C, short leg)220 Ω resistor leg 1
7Arduino Uno GND220 Ω resistor leg 2

Step by step

  1. Open the simulator. Open the BitForBytes Embedded Lab in your browser and start from the Arduino Uno. No install or account is needed.
  2. Add the parts. Add a generic IC (DIP), a yellow LED and a 220 Ω resistor from the parts palette.
  3. Wire 1. Connect Arduino Uno pin 2 to Generic IC (DIP) A.
  4. Wire 2. Connect Arduino Uno pin 3 to Generic IC (DIP) B.
  5. Wire 3. Connect Arduino Uno pin 4 to Generic IC (DIP) Y.
  6. Wire 4. Connect Arduino Uno GND to Generic IC (DIP) GND.
  7. Wire 5. Connect Generic IC (DIP) Y to yellow LED anode (A, long leg).
  8. Wire 6. Connect yellow LED cathode (C, short leg) to 220 Ω resistor leg 1.
  9. Wire 7. Connect Arduino Uno GND to 220 Ω resistor leg 2.
  10. Paste the Arduino C++ code. Paste the Arduino C++ code below into the code editor.
  11. Run it. Press Run. Select the chip and change its behaviour to assign Y = A & B; (or ~(A | B)), then Run again: the printed truth table changes with your hardware.

Arduino C++ code

// Your own chip: a Generic IC whose behaviour is a line of Verilog.
// The Uno steps A and B (pins 2, 3) through 00, 01, 10, 11 and reads the
// chip's Y output back on pin 4, printing the truth table it measures.
const int A = 2, B = 3, Y = 4;

void setup() {
  Serial.begin(9600);
  pinMode(A, OUTPUT);
  pinMode(B, OUTPUT);
  pinMode(Y, INPUT);
  Serial.println("A B | Y");
}

void loop() {
  for (int n = 0; n < 4; n++) {
    int a = (n >> 1) & 1, b = n & 1;
    digitalWrite(A, a);
    digitalWrite(B, b);
    delay(5);
    Serial.print(a); Serial.print(' '); Serial.print(b);
    Serial.print(" | "); Serial.println(digitalRead(Y));
    delay(700);
  }
  Serial.println("-----");
}

What to try

Select the chip and change its behaviour to assign Y = A & B; (or ~(A | B)), then Run again: the printed truth table changes with your hardware.

Frequently asked questions

How do I wire the Custom IC with Verilog Behaviour project on an Arduino Uno?

Make 7 connections: Arduino Uno pin 2 to Generic IC (DIP) A; Arduino Uno pin 3 to Generic IC (DIP) B; Arduino Uno pin 4 to Generic IC (DIP) Y; Arduino Uno GND to Generic IC (DIP) GND; Generic IC (DIP) Y to yellow LED anode (A, long leg); yellow LED cathode (C, short leg) to 220 Ω resistor leg 1; Arduino Uno GND to 220 Ω resistor leg 2.

What parts do I need for this Arduino project?

An Arduino Uno and a generic IC (DIP), a yellow LED and a 220 Ω resistor.

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 Generic IC named MY-XOR, with pins you named yourself and one line of Verilog as its behaviour. The Uno steps its inputs and prints the truth table it measures.

More Arduino Uno projects