How hubformat/hubsim works
Project type and purpose
• From the file tree and README, this is a C++ library project (“HUB-Float Simulation Library”) that provides a custom floating-point format (HUB) implementation plus a suite of tests.
• It is not a full-stack or microservices app, but an open-source numeric library with build tooling (Makefile), documentation (Doxyfile, doc/nd-config), and multiple test modules.
File structure
• Top-level artifacts:
• Makefile, Doxyfile – build and docs
• src/hub_float.cpp & hub_float.hpp – the core library
• doc/nd-config – Doxygen configuration and templates
• test/… – multiple test harnesses split by algorithm (arithmetic, FFT, Horner, neural network, TBLAS/LAPACK)
• Patterns:
• Single-component core ("hub_float") with clearly separated test modules
• Standard C++ build (Makefile) and doc generation
• Tests organized by feature, each with main.cpp and helpers
Pull architecture clues from the README
• Core provides configurable exponent/mantissa bits, special-case handling, conversion, and diagnostic functions
• No external runtime dependencies beyond the C++ standard library
• Emphasis on bit-level manipulation and simplified rounding
a. Main components:
1. Core Library Module
– Classes/Types: hub_float, literals, conversion utilities
– Sub-modules: quantize & grid logic, bit-field extractors, arithmetic operators, special-value handlers, string serializers
2. Build & Documentation
– Makefile orchestration
– Doxygen engine + doc/nd-config templates
3. Test Harnesses (5 independent test suites)
– Arithmetic tests
– FFT tests
– Horner polynomial evaluator tests
– Neural network example tests
– TBLAS/LAPACK solver tests
4. External Interfaces
– C++ Standard Library (iostream, math)
– Doxygen toolchain
b. Relationships & interactions:
– The Makefile invokes compilation of src/hub_float into a library or object files.
– The same Makefile triggers Doxygen using Doxyfile and doc/nd-config to generate HTML docs.
– Each test suite links against the compiled hub_float module and exercises API functions.
– Test suites may also share common utilities in test/common.
c. Architectural patterns & design principles:
– Single Responsibility: core logic in src, docs in doc/, tests in test/.
– Layering: low-level bit manipulations → core arithmetic API → test programs.
– Configuration via templates & preprocessor for exponent/mantissa widths.
– Test isolation: each algorithm test lives in its own directory with its own entry point.
d. Key technologies/frameworks:
– C++17 (or later)
– Make (build orchestration)
– Doxygen (documentation)
– Lua (in doc/nd-config converter.lua for template processing)
Detail without over-splitting
• Five test suites as distinct components.
• Sub-modules of the core if space allows (e.g., quantizer vs. arithmetic vs. serializers).
• Don’t forget the doc config folder under the doc generator component.