# mostafakhfagy/5-bit-adder architecture

> Architecture diagram of the GitHub repository mostafakhfagy/5-bit-adder, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-05-15). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/mostafakhfagy/5-bit-adder
- Repository: https://github.com/mostafakhfagy/5-bit-adder

## Overview

##### Project type and purpose
- This is a digital‐logic circuit design project, implemented in Logisim (.circ file).
- Purpose: build a 5-bit binary adder, display inputs/results on 7-segment LEDs, and use a control bit to switch between decimal and hexadecimal display modes.

##### File structure
- index.circ: the top‐level Logisim circuit.
- docs/: design specification and deliverables in Word/PDF.
- screens/: annotated screenshots of subcircuits and final layouts.
- README.md: outlines the architecture, subcircuits, and implementation steps.

##### Gather architectural insights from the README
- Hierarchical, modular design:
- Half Adder subcircuit → Full Adder subcircuit → 5-bit Adder
- 6×64 Decoder built from smaller decoders
- Seven separate “segment driver” circuits (A–G)
- Control Unit for decimal/hex toggling
- Final 7-segment display assemblies
- Inputs: two 5-bit numbers + control bit; Outputs: up to six 7-segment displays (operands and sum).

##### Main components and interactions
a. Components:
1. Input switches (two 5-bit buses + mode bit)
2. Half Adder (for LSB) + four Full Adders → 5-bit Adder (6-bit result)
3. 6×64 Decoder (built from smaller decoders + OR gates)
4. Seven Segment Drivers (one per segment A–G)
5. Control Unit (enables decimal vs. hex mapping)
6. Seven 7-segment Displays: two for operand A, two for operand B, two for result (plus carry if needed)
b. Data flow:
- Input switches → Adder → 6-bit sum bus → Decoder
- Decoder outputs → Segment Drivers + Control Unit → 7-segment displays
- Control bit → Control Unit → multiplexes decoder outputs between decimal/hex tables
c. Architectural patterns:
- Hierarchical composition of small combinational modules (HA, FA, decoder, OR networks)
- Data-path vs. control-path separation: the adder/decoder form the data path; the control unit gates display mapping
d. Key technologies:
- Logisim for circuit simulation
- Binary arithmetic (half/full adders)
- Decoder design and OR gate networks for segment mapping
- Multiplexing logic for decimal/hex switching

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% I/O Layer
    subgraph "I/O Layer"
        direction TB
        Switches["Input Switches (2×5-bit + Mode bit)"]:::io
        Displays["7-Segment Displays (2 for A, 2 for B, 2 for Sum)"]:::io
    end

    %% Arithmetic Block
    subgraph "Arithmetic Block" 
        direction TB
        HA["Half Adder (1-bit)"]:::datapath
        FA["Full Adder ×4 (1-bit each)"]:::datapath
        Adder5["5-bit Adder (5-bit in → 6-bit out)"]:::datapath
    end

    %% Decoder Block
    subgraph "Decoder Block"
        direction TB
        Decoder6x64["6×64 Decoder"]:::datapath
    end

    %% Segment Drivers
    subgraph "Segment Drivers (A–G)"
        direction TB
        SegDrv["Seven Segment Drivers"]:::datapath
    end

    %% Control Block
    subgraph "Control Block"
        direction TB
        CtrlUnit["Control Unit (DEC_EN, HEX_EN)"]:::control
    end

    %% Connections
    Switches -->|"5-bit operands"| HA
    HA --> FA
    FA --> Adder5
    Adder5 -->|"6-bit sum"| Decoder6x64
    Decoder6x64 -->|"64 lines"| SegDrv
    SegDrv --> Displays
    Switches -->|mode bit| CtrlUnit
    CtrlUnit -.->|DEC_EN / HEX_EN| SegDrv

    %% Click Events
    click Switches "https://github.com/mostafakhfagy/5-bit-adder/blob/main/index.circ"
    click HA "https://github.com/mostafakhfagy/5-bit-adder/blob/main/README.md"
    click FA "https://github.com/mostafakhfagy/5-bit-adder/blob/main/README.md"
    click Adder5 "https://github.com/mostafakhfagy/5-bit-adder/blob/main/README.md"
    click Decoder6x64 "https://github.com/mostafakhfagy/5-bit-adder/blob/main/README.md"
    click SegDrv "https://github.com/mostafakhfagy/5-bit-adder/blob/main/README.md"
    click CtrlUnit "https://github.com/mostafakhfagy/5-bit-adder/blob/main/README.md"
    click Displays "https://github.com/mostafakhfagy/5-bit-adder/blob/main/index.circ"
    click Switches "https://github.com/mostafakhfagy/5-bit-adder/blob/main/index.circ"
    click TopLevel "https://github.com/mostafakhfagy/5-bit-adder/blob/main/index.circ"
    click DocsDocx "https://github.com/mostafakhfagy/5-bit-adder/blob/main/docs/CS302 Project_ 5-Bit Binary Adder with Decimal and Hexadecimal Display Switching.docx"
    click DocsPdf "https://github.com/mostafakhfagy/5-bit-adder/blob/main/docs/CS302 Project_ 5-Bit Binary Adder with Decimal and Hexadecimal Display Switching.pdf"
    click Readme "https://github.com/mostafakhfagy/5-bit-adder/blob/main/README.md"
    click Screens "https://github.com/mostafakhfagy/5-bit-adder/tree/main/screens/"

    %% Styles
    classDef datapath fill:#D6EAF8,stroke:#2980B9
    classDef control fill:#D5F5E3,stroke:#27AE60
    classDef io fill:#FDEBD0,stroke:#E67E22
```
