# almuhs/binary_to_bcd_display architecture

> Architecture diagram of the GitHub repository almuhs/binary_to_bcd_display, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-04-03). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/almuhs/binary_to_bcd_display
- Repository: https://github.com/almuhs/binary_to_bcd_display

## Overview

##### Project Type and Purpose
- The project is a FPGA-based design written in VHDL.
- Its purpose is to take a binary input (from physical switches), convert it into a BCD representation, decode each BCD digit into a seven-segment format, and then drive a multiplexed display (compatible with the ZXDOS module on a QMTech Artix-7 SDRAM Board).

##### File Structure
- Top-Level Files: The LICENSE, README, and constraints file (ch03_zxdos.xdc) which contains board-specific pin assignments.
- VHDL Files:
- counter_clk.vhd – Responsible for generating or dividing the system clock signal.
- decoder_bcd_7s.vhd – Implements the logic for decoding a single BCD digit to a 7-segment display pattern.
- display_mux.vhd – Manages the multiplexing control to allow sharing of the seven-segment hardware across multiple digits.
- show_num_display.vhd – Likely the top-level module which integrates the binary-to-BCD conversion logic with the display control.

##### README for Additional Insights
- The README clarifies that the design handles binary-to-BCD conversion and two levels of display control (decoding and multiplexing).
- It mentions that the ZXDOS module is used, which influences the way enabling inputs are logically inverted.

a. Main Components:
- Input/Clock Generation:
- Clock Generator (counter_clk.vhd): Provides timing signals for synchronization.
- Binary Input Source: The switches on the FPGA board.
- Processing/Conversion:
- Binary-to-BCD Converter: Although not a directly named module, this functionality is likely implemented within show_num_display.vhd.
- Processing:
- BCD-to-7-Segment Decoder (decoder_bcd_7s.vhd): Converts each BCD digit to seven-segment codes.
- Multiplexer (display_mux.vhd): Cycles through the 4 digits to drive the multiplexed display.
- FPGA Board Integration:
- Physical connection via the ZXDOS module (pins defined in ch03_zxdos.xdc) for driving the actual 7-segment display.

b. Relationships & Interactions:
- The binary input (from switches) is interpreted by the top-level module (show_num_display.vhd), which passes the data through a binary-to-BCD conversion stage.
- The converted BCD digits are sent to individual BCD decoders that generate seven-segment codes.
- A clock signal from counter_clk.vhd drives the multiplexing control in display_mux.vhd to selectively enable one digit at a time.
- The output from the multiplexed decoder is finally delivered, correctly interfaced with the ZXDOS module constraints, to light up the 7-segment display.

c. Architectural Patterns and Design Principles:
- Modularity: Each VHDL file represents a modular component handling a specific task (clock, decode, multiplex, conversion).
- Hierarchical Design: The top-level module (show_num_display.vhd) acts as the integration point, coordinating communication and control among submodules.
- Signal Synchronization: The clock divider (counter_clk.vhd) is a key element for managing how fast the multiplexing occurs relative to the display refresh rate.
- Hardware Abstraction: Board-specific details (e.g., inverted signals due to the low-level design of the ZXDOS module) are abstracted in the constraints file and module interconnections.

d. Relevant Technologies/Frameworks:
- VHDL is the primary language.
- Targeted for the Artix-7 FPGA (from Xilinx).
- ZXDOS module for 7-segment display interfacing.
- Standard digital logic design paradigms (multiplexing, decoding, clock division).

##### Instructing the Principal Software Engineer
□ Clock Generator (counter_clk)
□ Binary Input (external switches)
□ Binary-to-BCD Converter (embedded within the top-level module)
□ BCD-to-7-Segment Decoder (decoder_bcd_7s)
□ Display Multiplexer (display_mux)
□ FPGA Board/ZXDOS Module (output interface, constraints from ch03_zxdos.xdc)
– Data flow from Binary Input to Conversion Module.
– Propagation of BCD digits to individual decoders.
– Control signals from the Clock Generator driving the Multiplexer.
– Final output going to the ZXDOS interfaced 7-segment hardware.
– Input/Clock elements (e.g., rounded rectangles)
– Conversion/Logic blocks (e.g., standard rectangles)
– Output/Interface modules (e.g., parallelograms)
- Signal inversions noted (e.g., for ZXDOS enabling) so that they are accurately represented.

## Diagram (Mermaid)

```mermaid
flowchart TD
    subgraph "Input/Clock Domain"
        A("Binary Input (Switches)"):::input
        B("Clock Generator"):::clock
    end

    subgraph "Processing Domain"
        C("Binary-to-BCD Converter"):::processing
        D("BCD-to-7-Segment Decoder"):::processing
        E("Display Multiplexer"):::processing
    end

    subgraph "Output Domain"
        F("FPGA Board/ZXDOS Module Interface"):::output
    end

    A -->|"providesData"| C
    C -->|"convertsToBCD"| D
    D -->|"digitSignals"| E
    B -->|"clockDrives"| E
    E -->|"outputSignals"| F

    click B "https://github.com/almuhs/binary_to_bcd_display/blob/main/counter_clk.vhd"
    click C "https://github.com/almuhs/binary_to_bcd_display/blob/main/show_num_display.vhd"
    click D "https://github.com/almuhs/binary_to_bcd_display/blob/main/decoder_bcd_7s.vhd"
    click E "https://github.com/almuhs/binary_to_bcd_display/blob/main/display_mux.vhd"
    click F "https://github.com/almuhs/binary_to_bcd_display/blob/main/ch03_zxdos.xdc"

    classDef input fill:#FAD7A0,stroke:#C0392B,stroke-width:2px;
    classDef clock fill:#AED6F1,stroke:#1B4F72,stroke-width:2px;
    classDef processing fill:#A9DFBF,stroke:#196F3D,stroke-width:2px;
    classDef output fill:#F9E79F,stroke:#B9770E,stroke-width:2px;
```
