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 |
---|---|---|
|
4-input OR gate |
Behavioral |
|
3-input XOR gate |
Dataflow |
|
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 |
---|---|---|
|
2-to-4 line decoder |
4 outputs |
|
3-to-8 decoder (structural) |
8 outputs |
Multiplexers (``multiplexers/``):
Component |
Description |
Select Lines |
---|---|---|
|
2-to-1 MUX (dataflow) |
1 bit |
|
4-to-1 MUX (structural) |
2 bits |
|
8-to-1 MUX (structural) |
3 bits |
Sequential Logic (src/sequential/
)ο
Flip-Flops (``flip_flops/``):
Component |
Description |
Features |
---|---|---|
|
D flip-flop |
Edge-triggered |
|
T flip-flop |
Toggle functionality |
Registers (``registers/``):
Component |
Description |
Width |
---|---|---|
|
8-bit register |
8 bits |
|
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 inor_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 |
---|---|---|
|
Run all tests |
|
|
Test basic gates only |
|
|
Test specific component |
|
|
Syntax check all files |
|
|
Show project statistics |
|
|
Remove build artifacts |
|
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 |
---|---|---|
|
Run VHDL tests |
Push/PR |
|
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 designsExtended testing: Parallel test structure in
test/
Documentation expansion: Modular Sphinx documentation
Best Practicesο
Separation of Concerns: Clear boundaries between source, tests, and docs
Consistent Naming: Follow established conventions
Modular Design: Each component is self-contained
Comprehensive Testing: Every component should have tests
Living Documentation: Keep docs synchronized with code