Skip to content

Latest commit

 

History

History
610 lines (499 loc) · 16.2 KB

File metadata and controls

610 lines (499 loc) · 16.2 KB
id chapter4-misc
title Misc
description Misc page in Chapter4 of CircuitVerse documentation.

Misc

  1. ALU
  2. Adder
  3. Buffer
  4. TriState Buffer
  5. Tunnel
  6. Splitter
  7. Equal Split
  8. Unequal Split
  9. Flag
  10. Two's Complement
  11. Serial Port

ALU

An Arithmetic Logic Unit (ALU) circuit element is a combinational digital electronic circuit that performs arithmetic and bitwise operations on integer binary numbers. Figure 4.15 highlights the different ports in the ALU circuit element available within CircutVerse and Table 4.19 provides a brief description of the different ports.

Properties that can be customized in the PROPERTIES panel include: Direction, BitWidth

Table 4.19: Brief description of the ALU circuit element ports

Name Description
A Receives an input operand
B Receives an input operand.
CTR (BitWidth 3) Receives an input operand with bit width of 3 bits.
Ans Generates the output after the operation on the received input operands has been completed.
Carry Generates the carry output after the operation on the received input operands has been completed.

drawing

Figure 4.17: Relevant attributes for the ALU circuit element

As required, the users may change the orientation of the ALU circuit element by editing the Direction attribute available for the ALU circuit element in the PROPERTIES panel (refer Figure 4.17). Alternatively, users can use the arrow keys on their keyboard to change the orientation.

In the embedded circuit below, A and B are two operands.Table 4.20 displays the opcodes for different ALU functionalities.

Note: SLT (Set Less Than): If A is less than B, output is 1 else output is 0.

Table 4.20: CTR port input opcodes for different functionalities of ALU

Opcode Opcode Value Operation
0 0 0 0 A & B
0 0 1 1 A | B
0 1 0 2 A + B
1 0 0 4 A & ~B
1 0 1 5 A | ~B
1 1 0 6 A - B
1 1 1 7 SLT
<iframe width="600px" height="400px" src="https://circuitverse.org/simulator/embed/12141" id="projectPreview" scrolling="no" webkitAllowFullScreen mozAllowFullScreen allowFullScreen > {" "} </iframe>

Adder

The Adder circuit element is a logical circuit of a full adder that performs an addition operation on binary numbers and produces a sum of the three inputs and a carry value (Cout). Figure 4.18 displays the different pins available for the **Adder **circuit element within CircuitVerse and Table 4.21 shares a brief description of the same.

Properties that can be customized in the PROPERTIES panel include: Direction

drawing

Figure 4.18: Pin description of the Adder circuit element within the CircuitVerse platform

Table 4.21: Brief description of the Adder circuit element

Name Description
A Receives an input operand
B Receives an input operand.
Cin Receives an input carry value operand
Sum Generates the output after the operation on the received input operands. ((A XOR B) XOR Cin)
Cout Generates the carry left over after the output operation has been completed. ((A AND B) OR (Cin AND (A XOR B) )

Using Table 4.22, you can verify the behavior of the Adder circuit element in the live circuit embedded below:

Table 4.22: Truth Table for an adder

A B Cin SUM Cout
0 0 0 0 0
0 0 1 1 0
0 1 0 1 0
0 1 1 0 1
1 0 0 1 0
1 0 1 0 1
1 1 0 0 1
1 1 1 1 1
<iframe width="600px" height="400px" src="https://circuitverse.org/simulator/embed/12140" id="projectPreview" scrolling="no" webkitAllowFullScreen mozAllowFullScreen allowFullScreen > {" "} </iframe>

Buffer

The Buffer circuit element has only a single input and a single output. Its behavior is the opposite of a NOT gate––passes its input unchanged to its output. Table 4.23 displays the truth table of a buffer.

Properties that can be customized in the PROPERTIES panel include: Direction

Table 4.23: Truth table for a buffer

Input Output
0 0
1 1

You can verify the behavior of the Buffer circuit element in the live circuit embedded below:

<iframe width="600px" height="400px" src="https://circuitverse.org/simulator/embed/13250" id="projectPreview" scrolling="no" webkitAllowFullScreen mozAllowFullScreen allowFullScreen > {" "} </iframe>

TriState Buffer

The TriState buffer circuit element behaves similar to a buffer. As Figure 4.17 illustrates, this circuit element includes an additional Enable input that controls whether the primary input is passed to its output or not.

  • If the Enable input signal is HIGH, the tri-state buffer behaves like a normal buffer.
  • If the Enable input signal is LOW, the tri-state buffer passes a high impedance signal which effectively disconnects its output from the circuit.

If required, a user can change the orientation of the circuit element using the arrow keys on the keyboard or editing the value of the Direction attribute available in the PROPERTIES panel for the TriState buffer circuit element.

Properties that can be customized in the PROPERTIES panel include: Direction, BitWidth

drawing

Figure 4.19: Relevant attributes for the TriState circuit element

Table 4.24: Truth table for a TriState buffer

Enable Input Output
0 0 Z
0 1 Z
1 0 0
1 1 1

You can verify the behavior of the TriState buffer circuit element in the live circuit embedded below:

<iframe width="600px" height="400px" src="https://circuitverse.org/simulator/embed/13252" id="projectPreview" scrolling="no" webkitAllowFullScreen mozAllowFullScreen allowFullScreen > {" "} </iframe>

Tunnel

The Tunnel circuit element encapsulates desired connection points in a tunnel for transmitting signals without using a wire (refer Figure 4.18). It is recommended to use this circuit element for design areas that may require excessive wiring to connect otherwise.

drawing

Figure 4.20: Relevant property attributes for the Tunnel circuit element

When the Tunnel circuit element is implemented in a circuit design, tunnels with the same Debug Flag identifier attribute (available in the PROPERTIES panel for the Tunnel circuit element(refer Figure 4.18)) are connected together.

Properties that can be customized in the PROPERTIES panel include: BitWidth, Direction, Debug Flag identifier

You can verify the behavior of the Tunnel circuit element in the live circuit embedded below:

<iframe width="600px" height="400px" src="https://circuitverse.org/simulator/embed/12642" id="projectPreview" scrolling="no" webkitAllowFullScreen mozAllowFullScreen allowFullScreen > {" "} </iframe>

Splitter

Splitters split high bitwidth wires (buses) into lower bitwidth wires(buses) and vice versa. It is the only two-way circuit element in CircuitVerse.

The bitwidth may be split into equal parts or unequal parts. Consider that you have a 4 bitwith bus. You may split it into equal or unequal parts as shown below:

  • Equal parts: 4 -> 1 1 1 1
  • Unequal parts: 4 -> 1 2 1

Figure 4.21 shows the relevant properties for a 4 bitwidth splitter split into equal parts.

Properties that can be customized in the PROPERTIES panel include: Direction

drawing

Figure 4.21: Relevant properties for the Splitter circuit element

When the Splitter circuit element is dragged on the Canvas, the bitwidth window pops up (refer Figure 4.22) where the user must first identify the total bits the bus.

drawing

Figure 4.22: Splitter bitwidth window

In the follow up window, the user can then identify if the bitwidth must be split into equal or unequal parts.

drawing

Figure 4.23: Splitter bitwidth split window

Equal Split

You can verify the behavior of the Splitter circuit element when the bitwidth is split in equal parts in the live circuit embedded below:

<iframe width="650px" height="400px" src="https://circuitverse.org/simulator/embed/1959" id="projectPreview" scrolling="no" webkitAllowFullScreen mozAllowFullScreen allowFullScreen > {" "} </iframe>

Unequal Split

You can verify the behavior of the Splitter circuit element when the bitwidth is split in unequal parts in the live circuit embedded below:

<iframe width="650px" height="400px" src="https://circuitverse.org/simulator/embed/1960" id="projectPreview" scrolling="no" webkitAllowFullScreen mozAllowFullScreen allowFullScreen > {" "} </iframe>

Flag

The Flag circuit element is used in a circuit design to flag outputs at different points in your circuit. Figure X highlights the different attributes that are available for this circuit element.

Properties that can be customized in the PROPERTIES panel include**: **BitWidth, Orientation, Debug Flag identifier**

drawing

Figure 4.24: Relevant attributes for the Flag circuit element

Two's Complement

The Two’s Complement circuit element calculates the two’s complement of any binary number. A two's complement operation is simply a one's complement operation followed by the addition of 1 to the result.

Given number        1  1  1  1  0
1's complement      0  0  0  0  1
add 1               +           1
                   ---------------
2's complement      0  0  0  1  0

You can verify the behavior of the Two’s Complement circuit element in the live circuit embedded below:

<iframe width="600px" height="400px" src="https://circuitverse.org/simulator/embed/110615" id="projectPreview" scrolling="no" webkitAllowFullScreen mozAllowFullScreen allowFullScreen ></iframe>

Serial Port

The Serial Port component enables real-time communication between CircuitVerse and physical hardware using the Web Serial API. This allows the simulation to send (TX) and receive (RX) 8-bit data to/from devices such as Arduino, ESP32, or any microcontroller with UART support.

Properties that can be customized in the PROPERTIES panel include: Baud Rate, Direction (using arrow keys or dropdown)

Table 4.25: Brief description of the SerialPort circuit element ports

Name Direction Width Description
TX Input 8-bit Sends 8-bit values from CircuitVerse to the external device
RX Output 8-bit Receives 8-bit values from the external device into CircuitVerse

Baud Rate

Users can select a baud rate (speed of communication in bits per second) from 1 to 115200. Common values include 9600, 19200, 38400, 57600, and 115200. This must match the baud rate on the external microcontroller.

How It Works

  • The TX pin sends a new 8-bit value when it changes. The component avoids re-sending the same value to reduce traffic.
  • The RX pin gets updated with the latest byte received from the serial stream.
  • Internally, a reader reads the stream asynchronously and pushes the value to RX.

Example

⚠️ Note: This demonstration uses a safe, low-voltage LED circuit.
Do not attempt to replicate this with high-voltage devices unless properly trained in electrical safety.

This example demonstrates how to use the Serial Port component to control an LED connected to an Arduino board based on light intensity from an LDR (Light Dependent Resistor). The Arduino sends sensor data to CircuitVerse using RX, and CircuitVerse responds with control signals using TX.

Circuit

drawing Figure 4.25: The simulated CircuitVerse setup using the Serial Port component. It receives analog values from the LDR via RX and sends control signals via TX.

Hardware Circuit

drawing Figure 4.26: A schematic representation of the hardware setup, including Arduino Uno, LDR, and LED.

Arduino Sketch

int ldrPin = A0;  // Connect LDR to analog pin A0
int ldrValue = 0;
int ledPin = 7;  // Choose any digital pin
int receivedByte = 0;
void setup() {
  pinMode(ledPin, OUTPUT);
  Serial.begin(9600);
}
void loop() {

  ldrValue = analogRead(ldrPin);  // Read LDR value (0–1023)
  Serial.write(ldrValue >> 2);    // Send 8-bit value (0–255) via Serial.write()

  if (Serial.available() > 0) {
    receivedByte = Serial.read();  // Read 1 byte (0–255)
    if (receivedByte == 1) {
      digitalWrite(ledPin, HIGH);
    } else {
      digitalWrite(ledPin, LOW);
    }
  }
  delay(500);  // Small delay to reduce noise
}

Compatibility and Browser Requirements

  • Secure Context Requirement:
    The Web Serial API is available only in secure contexts (i.e., when accessed via HTTPS). Users will be prompted to grant permission to access connected serial devices at runtime. This permission must be granted manually for each session.

  • Baud Rate Change Notice:
    Any changes made to the Baud Rate property will take effect only after the serial connection is re-established.

  • Browser Support:

    • Supported: Chromium-based browsers such as Google Chrome, Microsoft Edge, and Opera.
    • Not Supported: Mozilla Firefox, Apple Safari, and other non-Chromium browsers.

Related Resources