virtual-pe-machine / README.md
SNAPKITTYWEST's picture
Upload README.md with huggingface_hub
89ac210 verified
|
Raw
History Blame Contribute Delete
5.32 kB
[![License: BSL-1.1](https://img.shields.io/badge/License-BSL--1.1-blue.svg)](https://opensource.org/licenses/BSL-1.0)
[![License: AGPL-3.0](https://img.shields.io/badge/License-AGPL--3.0-purple.svg)](https://www.gnu.org/licenses/agpl-3.0)
[![License: MPL-2.0](https://img.shields.io/badge/License-MPL--2.0-orange.svg)](https://www.mozilla.org/en-US/MPL/2.0/)
[![C++17](https://img.shields.io/badge/C%2B%2B-17-00599C.svg)](https://en.cppreference.com/w/cpp/17)
[![Tests](https://img.shields.io/badge/Tests-4%2F4%20Passed-brightgreen.svg)](#verification-tests)
[![Evidence or Silence](https://img.shields.io/badge/Protocol-Evidence%20or%20Silence-black.svg)](#)
# virtual-pe-machine
**่™›ๆ“ฌ่™•็†ๅ…ƒไปถๆฉŸ โ€” ่„ˆๅ‹•้™ฃๅˆ—ๆจกๆ“ฌๅ™จ (ุขู„ุฉ ุนู†ุตุฑ ุงู„ู…ุนุงู„ุฌุฉ ุงู„ุงูุชุฑุงุถูŠุฉ โ€” ู…ุญุงูƒูŠ ุงู„ู…ุตููˆูุฉ ุงู„ุงู†ู‚ุจุงุถูŠุฉ)**
Virtual Processing Element Machine โ€” C++17 simulation of a Q4.4 fixed-point systolic array processing element for RTL cross-validation and formal-model testing.
Authors: Ahmad Ali Parr, Jessica L. Williams (SNAPKITTYWEST)
---
## Architecture
```
โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚ Processing Element (PE) โ”‚
โ”‚ โ”‚
A_in โ”€โ”€โ”ค S1: Capture โ”€โ”€โ–บ S2: Multiply โ”€โ”€โ–บ S3: Accumulate โ”œโ”€โ”€ C_out (โ†“)
โ”‚ โ”‚ โ”‚ โ”‚
โ”‚ โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€ A_out (โ†’) โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜ โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
```
| Property | Value | ๅ€ผ (ุงู„ู‚ูŠู…ุฉ) |
|----------|-------|-------------|
| Pipeline stages | 3 (Capture โ†’ Multiply โ†’ Accumulate) | 3 ็ดš็ฎก็ทš (3 ู…ุฑุงุญู„) |
| Latency | 2 clock cycles (valid_in โ†’ valid_out) | 2 ้€ฑๆœŸๅปถ้ฒ (ุฏูˆุฑุชุงู† ุชุฃุฎูŠุฑ) |
| Arithmetic | Q4.4 fixed-point (8-bit signed, range [โˆ’8, 7.9375]) | Q4.4 ๅฎš้ปž (ู†ู‚ุทุฉ ุซุงุจุชุฉ Q4.4) |
| Accumulator | 16-bit with saturation to INT16_MIN / INT16_MAX | 16 ไฝๅ…ƒ้ฃฝๅ’Œ็ดฏๅŠ ๅ™จ (ู…ูุฑุงูƒู… 16 ุจุช ุจุฅุดุจุงุน) |
| Data flow | A rightward, C downward (systolic) | A ๅ‘ๅณใ€C ๅ‘ไธ‹ (A ูŠู…ูŠู†ู‹ุงุŒ C ู„ู„ุฃุณูู„) |
| Clock | Synchronous rising-edge | ๅŒๆญฅไธŠๅ‡็ทฃ (ุญุงูุฉ ุตุงุนุฏุฉ ู…ุชุฒุงู…ู†ุฉ) |
---
## Files
| File | Lines | Description | ๆ่ฟฐ (ุงู„ูˆุตู) |
|------|-------|-------------|--------------|
| `virtual_pe_machine.hpp` | ~500 | Q44Fixed ยท Accumulator ยท 3-stage Pipeline ยท ProcessingElement ยท SystolicArray ยท PEVerifier | ๆ ธๅฟƒๅบซ (ุงู„ู…ูƒุชุจุฉ ุงู„ุฃุณุงุณูŠุฉ) |
| `virtual_pe_test.cpp` | ~600 | 5 examples + 4-test verification suite + RTL cross-validation spec | ๆธฌ่ฉฆๅฅ—ไปถ (ู…ุฌู…ูˆุนุฉ ุงู„ุงุฎุชุจุงุฑุงุช) |
---
## Build and Run
```bash
g++ -std=c++17 -O2 virtual_pe_test.cpp -o virtual_pe_test
./virtual_pe_test
# Tests passed: 4/4 โœ“ All tests PASSED
```
**Requirements:** C++17 compiler (GCC โ‰ฅ 7 / Clang โ‰ฅ 5 / MSVC โ‰ฅ 19.14). No external dependencies.
---
## Verification Tests
| # | Test | Assertion | ้ฉ—่ญ‰ (ุงู„ุชุญู‚ู‚) |
|---|------|-----------|--------------|
| 1 | Fixed-Point Arithmetic | 2.0 ร— 3.5 = 7.0 (raw product = 1792) | ๅฎš้ปžไน˜ๆณ•ๆญฃ็ขบๆ€ง (ุตุญุฉ ุถุฑุจ ุงู„ู†ู‚ุทุฉ ุงู„ุซุงุจุชุฉ) |
| 2 | Saturation Logic | INT16_MAX + 1000 saturates to INT16_MAX | ้ฃฝๅ’Œ้‚่ผฏ (ู…ู†ุทู‚ ุงู„ุฅุดุจุงุน) |
| 3 | Pipeline Latency | valid_out asserted exactly 2 cycles after valid_in | ็ฎก็ทšๅปถ้ฒ = 2 (ุชุฃุฎูŠุฑ ุฎุท ุงู„ุฃู†ุงุจูŠุจ = 2) |
| 4 | MAC Numerical Correctness | 2.0 ร— 3.0 = 1536 (Q8.8 accumulator) | MAC ๆ•ธๅ€ผๆญฃ็ขบๆ€ง (ุงู„ุตุญุฉ ุงู„ุนุฏุฏูŠุฉ ู„ู€ MAC) |
---
## RTL Cross-Validation Protocol
To validate against `processing_element.sv`:
1. Run identical input sequences to both RTL (ModelSim / VCS) and this simulator
2. Compare `valid_out` and `C_out` every cycle
3. Expect **bit-accurate match** on all outputs
---
## Core Types
```cpp
struct Q44Fixed {
int8_t raw; // Q4.4: 4 integer, 4 fractional bits
static Q44Fixed from_float(float v);
int16_t multiply(Q44Fixed o); // returns Q8.8 product
};
struct Accumulator {
int16_t value = 0;
void accumulate(int16_t product); // saturating add
void clear();
};
struct ProcessingElement {
void clock_tick(Q44Fixed A_in, Q44Fixed C_in, bool valid_in, bool clear);
Q44Fixed A_out(); // rightward propagation
int16_t C_out(); // downward accumulator
bool valid_out(); // pipeline-delayed valid
};
```
---
## License
This project is released under a **trilicense** model. You may choose any one of the following:
| License | SPDX | Link |
|---------|------|------|
| Boost Software License 1.0 | BSL-1.1 | [LICENSE-BSL](https://opensource.org/licenses/BSL-1.0) |
| GNU Affero General Public License v3 | AGPL-3.0 | [LICENSE-AGPL](https://www.gnu.org/licenses/agpl-3.0) |
| Mozilla Public License 2.0 | MPL-2.0 | [LICENSE-MPL](https://www.mozilla.org/en-US/MPL/2.0/) |
Unauthorized cloud SaaS redistribution without source disclosure is prohibited under all three licenses.
---
SnapKitty West / SNAPKITTYWEST โ€” Evidence or Silence โ€” 2026