Project Structure

Understanding the organization and architecture of the VHDL Digital Design Samples project.

Overview

The project follows a hierarchical structure designed for educational purposes, separating source code, tests, documentation, and build scripts into logical directories.

Directory Layout

vhdl-samples/
β”œβ”€β”€ πŸ“ src/                    # Source code (VHDL designs)
β”‚   β”œβ”€β”€ πŸ“ gates/              # Basic logic gates
β”‚   β”œβ”€β”€ πŸ“ combinational/      # Combinational circuits
β”‚   β”‚   β”œβ”€β”€ πŸ“ adders/         # Addition circuits
β”‚   β”‚   β”œβ”€β”€ πŸ“ decoders/       # Decoder circuits
β”‚   β”‚   β”œβ”€β”€ πŸ“ multiplexers/   # MUX/DEMUX circuits
β”‚   β”‚   β”œβ”€β”€ πŸ“ comparators/    # Comparison circuits
β”‚   β”‚   └── πŸ“ shifters/       # Bit shifting circuits
β”‚   β”œβ”€β”€ πŸ“ sequential/         # Sequential circuits
β”‚   β”‚   β”œβ”€β”€ πŸ“ flip_flops/     # Flip-flop implementations
β”‚   β”‚   β”œβ”€β”€ πŸ“ latches/        # Latch implementations
β”‚   β”‚   β”œβ”€β”€ πŸ“ registers/      # Register implementations
β”‚   β”‚   β”œβ”€β”€ πŸ“ counters/       # Counter implementations
β”‚   β”‚   └── πŸ“ state_machines/ # FSM implementations
β”‚   └── πŸ“ modules/            # Complex/mixed modules
β”œβ”€β”€ πŸ“ test/                   # Test files (mirroring src/)
β”‚   β”œβ”€β”€ πŸ“ gates/
β”‚   β”œβ”€β”€ πŸ“ combinational/
β”‚   └── πŸ“ sequential/
β”œβ”€β”€ πŸ“ docs/                   # Documentation (Sphinx)
β”‚   β”œβ”€β”€ πŸ“ _static/            # Static assets (CSS, images)
β”‚   β”œβ”€β”€ πŸ“ components/         # Component documentation
β”‚   β”œβ”€β”€ πŸ“ testing/            # Testing documentation
β”‚   └── πŸ“ development/        # Development guides
β”œβ”€β”€ πŸ“ scripts/                # Build and utility scripts
β”œβ”€β”€ πŸ“ .github/workflows/      # CI/CD workflows
β”œβ”€β”€ πŸ“„ Makefile                # Build system
β”œβ”€β”€ πŸ“„ README.md               # Project overview
└── πŸ“„ LICENSE                 # MIT License

Source Code Organization

The src/ directory is organized by complexity and circuit type:

Basic Gates (src/gates/)

File

Description

Modeling Style

or_gate.vhd

4-input OR gate

Behavioral

xor_3.vhd

3-input XOR gate

Dataflow

my_xor.vhd

2-input XOR (structural)

Structural

Combinational Logic (src/combinational/)

Adders (``adders/``):

Component

Description

Key Features

Half Adders

1-bit addition (no carry-in)

Basic building block

Full Adders

1-bit addition (with carry)

Multiple implementations

4-bit Adders

Multi-bit arithmetic

Ripple carry design

Decoders (``decoders/``):

Component

Description

Outputs

decoder_2x4.vhd

2-to-4 line decoder

4 outputs

decoder_3x8_str.vhd

3-to-8 decoder (structural)

8 outputs

Multiplexers (``multiplexers/``):

Component

Description

Select Lines

mux_2x1_df.vhd

2-to-1 MUX (dataflow)

1 bit

mux_4x1_str.vhd

4-to-1 MUX (structural)

2 bits

mux_8x1_str.vhd

8-to-1 MUX (structural)

3 bits

Sequential Logic (src/sequential/)

Flip-Flops (``flip_flops/``):

Component

Description

Features

d_flip_flop.vhd

D flip-flop

Edge-triggered

t_flip_flop.vhd

T flip-flop

Toggle functionality

Registers (``registers/``):

Component

Description

Width

register_8_bit.vhd

8-bit register

8 bits

pipo_4bit_behave.vhd

4-bit PIPO register

4 bits

Test Structure

The test/ directory mirrors the src/ structure:

test/
β”œβ”€β”€ πŸ“ gates/
β”‚   β”œβ”€β”€ or_gate_tb.vhd         # Tests all 16 input combinations
β”‚   └── xor_testbench.vhd      # Tests XOR functionality
β”œβ”€β”€ πŸ“ combinational/
β”‚   β”œβ”€β”€ πŸ“ adders/
β”‚   β”‚   β”œβ”€β”€ fa_testbench.vhd   # Full adder tests
β”‚   β”‚   β”œβ”€β”€ ha_behave_tb.vhd   # Half adder tests
β”‚   β”‚   └── rc_adder_testbench.vhd  # 4-bit adder tests
β”‚   β”œβ”€β”€ πŸ“ decoders/
β”‚   β”‚   └── decoder_2x4_testbench.vhd
β”‚   └── πŸ“ multiplexers/
β”‚       └── mux_2x1_tb.vhd
└── πŸ“ sequential/
    └── πŸ“ flip_flops/
        └── d_flip_flop_tb.vhd

Naming Conventions

File Naming

  • Source files: <component_name>.vhd

  • Testbenches: <component_name>_tb.vhd or <component_name>_testbench.vhd

  • Entity names: Match filename (e.g., or_gate entity in or_gate.vhd)

VHDL Naming

  • Entities: lowercase with underscores (d_flip_flop)

  • Architectures: PascalCase (Behavioral, Dataflow, Structural)

  • Signals: lowercase with underscores (clk_signal)

  • Ports: uppercase (CLK, DATA_IN, OUTPUT)

Build System Architecture

The project uses a multi-layered build system:

graph TD A[Developer] --> B[Makefile] B --> C[Test Scripts] B --> D[Build Scripts] B --> E[Documentation] C --> F[GHDL Compiler] D --> F E --> G[Sphinx] F --> H[Simulation Results] G --> I[HTML Documentation] J[GitHub Actions] --> B J --> K[Deploy to Pages]

Makefile Targets

Target

Description

Usage

test

Run all tests

make test

test-gates

Test basic gates only

make test-gates

test-<component>

Test specific component

make test-or-gate

build

Syntax check all files

make build

stats

Show project statistics

make stats

clean

Remove build artifacts

make clean

Documentation Architecture

Sphinx-based documentation system:

docs/
β”œβ”€β”€ πŸ“„ conf.py                 # Sphinx configuration
β”œβ”€β”€ πŸ“„ index.rst               # Main documentation page
β”œβ”€β”€ πŸ“„ installation.rst        # Installation guide
β”œβ”€β”€ πŸ“„ quickstart.rst          # Quick start guide
β”œβ”€β”€ πŸ“ components/             # Component documentation
β”‚   β”œβ”€β”€ gates.rst
β”‚   β”œβ”€β”€ combinational.rst
β”‚   └── sequential.rst
β”œβ”€β”€ πŸ“ testing/                # Testing documentation
└── πŸ“ development/            # Development guides

Dependencies and Tools

Core Dependencies

Tool

Purpose

Version

Required

GHDL

VHDL compiler/simulator

5.0.1+

Yes

Make

Build automation

3.81+

Yes

Git

Version control

2.0+

Yes

Documentation Dependencies

Package

Purpose

Version

Required

Sphinx

Documentation generator

7.0.0+

Yes

Read the Docs Theme

Documentation theme

2.0.0+

Yes

MyST Parser

Markdown support

2.0.0+

Optional

CI/CD Pipeline

The project uses GitHub Actions for continuous integration:

graph LR A[Git Push] --> B[GitHub Actions] B --> C[Install GHDL] B --> D[Install Python] C --> E[Run Tests] D --> F[Build Docs] E --> G[Test Results] F --> H[Deploy to Pages]

Workflow Files

File

Purpose

Triggers

.github/workflows/test.yml

Run VHDL tests

Push/PR

.github/workflows/docs.yml

Build/deploy docs

Push to main

Scalability Considerations

Design for Growth

The structure is designed to accommodate:

  • New component categories: Add directories under src/

  • More complex designs: Use src/modules/ for mixed designs

  • Extended testing: Parallel test structure in test/

  • Documentation expansion: Modular Sphinx documentation

Best Practices

  1. Separation of Concerns: Clear boundaries between source, tests, and docs

  2. Consistent Naming: Follow established conventions

  3. Modular Design: Each component is self-contained

  4. Comprehensive Testing: Every component should have tests

  5. Living Documentation: Keep docs synchronized with code