Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
54 changes: 54 additions & 0 deletions docs/chapter4/8misc.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ description: "Misc page in Chapter4 of CircuitVerse documentation."
8. [Unequal Split](#unequal-split)
9. [Flag](#flag)
10. [Two's Complement](#twos-complement)
11. [Bit Extender](#bit-extender)

## ALU

Expand Down Expand Up @@ -519,3 +520,56 @@ You can verify the behavior of the **Two’s Complement** circuit element in the
mozAllowFullScreen
allowFullScreen
></iframe>

## Bit Extender

The **Bit Extender** is a combinational digital circuit component that extends an input binary value to a specified larger bit width. It supports multiple extension strategies such as **zero-extension**, **sign-extension**, **one-extension**, and **custom input extension**.

This is useful in arithmetic operations and situations where bit width alignment is required between components.

> Properties that can be customized in the **PROPERTIES** panel include: `Bit Width In`, `Bit Width Out`, `Extension Type`, `Direction`

---

### Bit Extender Ports

| **Name** | **Description** |
|-------------------|-----------------|
| `Bit Width In` | Input value to be extended |
| `Bit Width Out` | Output after extension |
| `input` (optional) | Used only when `Extension Type = Input`; specifies the extension bit |

Comment on lines +530 to +541
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

Ports vs. properties are conflated – revise column names
Bit Width In and Bit Width Out are configurable properties, not electrical ports. Presenting them in a “Ports” table is misleading. Typically the Bit Extender exposes one input port (e.g. In) and one output port (e.g. Out), plus an optional input port when Extension Type = Input.

Suggested minimal fix: rename the table to “Configurable Properties & Optional Port” and separate the true port(s):

-| **Name**          | **Description** |
-|-------------------|-----------------|
-| `Bit Width In`    | Input value to be extended |
-| `Bit Width Out`   | Output after extension |
-| `input` (optional) | Used only when `Extension Type = Input`; specifies the extension bit |
+| **Name** | **Type** | **Description** |
+|----------|---------|-----------------|
+| `In`     | Port    | Input value to be extended |
+| `Out`    | Port    | Extended output |
+| `input` *(optional)* | Port | Filler bit when `Extension Type = Input` |
+| `Bit Width In`  | Property | Width of `In` |
+| `Bit Width Out` | Property | Width of `Out` |
+| `Extension Type`| Property | Zero / One / Sign / Input |
+| `Direction`     | Property | Orientation on canvas |
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
> Properties that can be customized in the **PROPERTIES** panel include: `Bit Width In`, `Bit Width Out`, `Extension Type`, `Direction`
---
### Bit Extender Ports
| **Name** | **Description** |
|-------------------|-----------------|
| `Bit Width In` | Input value to be extended |
| `Bit Width Out` | Output after extension |
| `input` (optional) | Used only when `Extension Type = Input`; specifies the extension bit |
| **Name** | **Type** | **Description** |
|------------------------|--------------|-----------------------------------------------|
| `In` | Port | Input value to be extended |
| `Out` | Port | Extended output |
| `input` *(optional)* | Port | Filler bit when `Extension Type = Input` |
| `Bit Width In` | Property | Width of `In` |
| `Bit Width Out` | Property | Width of `Out` |
| `Extension Type` | Property | Zero / One / Sign / Input |
| `Direction` | Property | Orientation on canvas |
🤖 Prompt for AI Agents
In docs/chapter4/8misc.md around lines 530 to 541, the table incorrectly mixes
configurable properties with electrical ports, causing confusion. Rename the
table header to "Configurable Properties & Optional Port" to clarify this
distinction, and separate the actual ports like `In` and `Out` into a different
section or table to clearly differentiate them from properties such as `Bit
Width In` and `Bit Width Out`.

---

![Bit Extender Circuit](/img/img_chapter4/4.25.png)
*Figure 4.25: Relevant attributes for the Bit Extender circuit element*

---

### Behavior

If the **input width** (`Bit Width In`) is less than the **output width** (`Bit Width Out`), the remaining bits are filled based on the selected extension strategy:

| **Extension Type** | **Filler Bits** |
|--------------------|---------------------------------------------------------------|
| `Zero` | All extra bits are set to `0` |
| `One` | All extra bits are set to `1` |
| `Sign` | Fills with the **most significant bit** of the input (sign bit)|
| `Input` | Fills with the value of an external **input node** |

If the input bit width is **greater than** the output, the input is **truncated from the MSB side**.

---

### Example

- `Bit Width In = 4`, `Bit Width Out = 8`
- Input: `1011`
- Extension Type: `Sign`

The MSB is `1`, so the output becomes: `11111011`

### Embedded Circuit

<!-- **[Pull Resistor Simulation](https://circuitverse.org/simulator/embed/TODO)** -->
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

Remove or replace the placeholder embed link
The embedded circuit section still contains a commented TODO link. Either supply the correct CircuitVerse embed URL or delete the placeholder to avoid dead-content in the published docs.

-<!-- **[Pull Resistor Simulation](https://circuitverse.org/simulator/embed/TODO)** -->
+<iframe
+  width="600px"
+  height="400px"
+  src="https://circuitverse.org/simulator/embed/<project_id>"
+  id="projectPreview"
+  scrolling="no"
+  webkitAllowFullScreen
+  mozAllowFullScreen
+  allowFullScreen
+></iframe>

Committable suggestion skipped: line range outside the PR's diff.

🤖 Prompt for AI Agents
In docs/chapter4/8misc.md at line 574, there is a commented placeholder embed
link with a TODO that should not remain in the published documentation. Either
replace this placeholder with the correct CircuitVerse embed URL for the Pull
Resistor Simulation or remove the entire commented line to prevent dead or
incomplete content in the docs.


Binary file added static/img/img_chapter4/4.25.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.