scoreboarding 0.1.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- scoreboarding-0.1.0/.github/ISSUE_TEMPLATE/bug_report.md +22 -0
- scoreboarding-0.1.0/.github/ISSUE_TEMPLATE/feature_request.md +17 -0
- scoreboarding-0.1.0/.github/workflows/ci.yml +39 -0
- scoreboarding-0.1.0/.gitignore +40 -0
- scoreboarding-0.1.0/CHANGELOG.md +27 -0
- scoreboarding-0.1.0/CLAUDE.md +53 -0
- scoreboarding-0.1.0/CODE_OF_CONDUCT.md +32 -0
- scoreboarding-0.1.0/CONTRIBUTING.md +37 -0
- scoreboarding-0.1.0/LICENSE +21 -0
- scoreboarding-0.1.0/PKG-INFO +211 -0
- scoreboarding-0.1.0/README.md +159 -0
- scoreboarding-0.1.0/SECURITY.md +16 -0
- scoreboarding-0.1.0/assets/logo.png +0 -0
- scoreboarding-0.1.0/docs/architecture.md +145 -0
- scoreboarding-0.1.0/docs/charter.md +34 -0
- scoreboarding-0.1.0/docs/logo-prompt.md +7 -0
- scoreboarding-0.1.0/examples/classic.txt +16 -0
- scoreboarding-0.1.0/examples/run_classic.sh +4 -0
- scoreboarding-0.1.0/pyproject.toml +58 -0
- scoreboarding-0.1.0/src/scoreboarding/__init__.py +51 -0
- scoreboarding-0.1.0/src/scoreboarding/cli.py +189 -0
- scoreboarding-0.1.0/src/scoreboarding/engine.py +347 -0
- scoreboarding-0.1.0/src/scoreboarding/model.py +144 -0
- scoreboarding-0.1.0/src/scoreboarding/py.typed +0 -0
- scoreboarding-0.1.0/src/scoreboarding/render.py +83 -0
- scoreboarding-0.1.0/tests/__init__.py +0 -0
- scoreboarding-0.1.0/tests/test_cli.py +106 -0
- scoreboarding-0.1.0/tests/test_engine.py +562 -0
- scoreboarding-0.1.0/tests/test_render.py +56 -0
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: Bug report
|
|
3
|
+
about: Report a bug in the simulator
|
|
4
|
+
labels: bug
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
**Describe the bug**
|
|
8
|
+
A clear and concise description of what the bug is.
|
|
9
|
+
|
|
10
|
+
**Program / input**
|
|
11
|
+
Paste the program text (FU declarations + instructions) that triggers the bug.
|
|
12
|
+
|
|
13
|
+
**Expected behavior**
|
|
14
|
+
What cycle numbers did you expect (show your hand derivation if possible)?
|
|
15
|
+
|
|
16
|
+
**Actual behavior**
|
|
17
|
+
What cycle numbers did the simulator produce?
|
|
18
|
+
|
|
19
|
+
**Environment**
|
|
20
|
+
- scoreboarding version:
|
|
21
|
+
- Python version:
|
|
22
|
+
- OS:
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: Feature request
|
|
3
|
+
about: Suggest a new feature or improvement
|
|
4
|
+
labels: enhancement
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
**Is your feature request related to a problem?**
|
|
8
|
+
A clear and concise description of the problem.
|
|
9
|
+
|
|
10
|
+
**Proposed solution**
|
|
11
|
+
Describe the feature or change you would like.
|
|
12
|
+
|
|
13
|
+
**Alternatives considered**
|
|
14
|
+
Any alternative approaches you considered.
|
|
15
|
+
|
|
16
|
+
**Additional context**
|
|
17
|
+
Any other context, references, or examples.
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
name: CI
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
branches: ["main"]
|
|
6
|
+
pull_request:
|
|
7
|
+
branches: ["main"]
|
|
8
|
+
|
|
9
|
+
jobs:
|
|
10
|
+
test:
|
|
11
|
+
name: "Python ${{ matrix.python-version }}"
|
|
12
|
+
runs-on: ubuntu-latest
|
|
13
|
+
strategy:
|
|
14
|
+
fail-fast: false
|
|
15
|
+
matrix:
|
|
16
|
+
python-version: ["3.10", "3.11", "3.12", "3.13"]
|
|
17
|
+
|
|
18
|
+
steps:
|
|
19
|
+
- uses: actions/checkout@v4
|
|
20
|
+
|
|
21
|
+
- name: Set up Python ${{ matrix.python-version }}
|
|
22
|
+
uses: actions/setup-python@v5
|
|
23
|
+
with:
|
|
24
|
+
python-version: ${{ matrix.python-version }}
|
|
25
|
+
|
|
26
|
+
- name: Install uv
|
|
27
|
+
run: pip install uv
|
|
28
|
+
|
|
29
|
+
- name: Install dependencies
|
|
30
|
+
run: uv pip install -e ".[dev]" --system
|
|
31
|
+
|
|
32
|
+
- name: Run pytest
|
|
33
|
+
run: pytest -q
|
|
34
|
+
|
|
35
|
+
- name: Run ruff
|
|
36
|
+
run: ruff check .
|
|
37
|
+
|
|
38
|
+
- name: Run mypy
|
|
39
|
+
run: mypy src
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
# Python
|
|
2
|
+
__pycache__/
|
|
3
|
+
*.py[cod]
|
|
4
|
+
*$py.class
|
|
5
|
+
*.so
|
|
6
|
+
*.egg
|
|
7
|
+
*.egg-info/
|
|
8
|
+
dist/
|
|
9
|
+
build/
|
|
10
|
+
.eggs/
|
|
11
|
+
|
|
12
|
+
# Virtual environments
|
|
13
|
+
.venv/
|
|
14
|
+
venv/
|
|
15
|
+
env/
|
|
16
|
+
|
|
17
|
+
# uv
|
|
18
|
+
uv.lock
|
|
19
|
+
|
|
20
|
+
# mypy
|
|
21
|
+
.mypy_cache/
|
|
22
|
+
*.pyi
|
|
23
|
+
|
|
24
|
+
# pytest
|
|
25
|
+
.pytest_cache/
|
|
26
|
+
.coverage
|
|
27
|
+
htmlcov/
|
|
28
|
+
|
|
29
|
+
# ruff
|
|
30
|
+
.ruff_cache/
|
|
31
|
+
|
|
32
|
+
# IDE
|
|
33
|
+
.vscode/
|
|
34
|
+
.idea/
|
|
35
|
+
*.swp
|
|
36
|
+
*.swo
|
|
37
|
+
|
|
38
|
+
# OS
|
|
39
|
+
.DS_Store
|
|
40
|
+
Thumbs.db
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
All notable changes to this project will be documented in this file.
|
|
4
|
+
|
|
5
|
+
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
|
|
6
|
+
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
7
|
+
|
|
8
|
+
## [Unreleased]
|
|
9
|
+
|
|
10
|
+
## [0.1.0] - 2026-06-17
|
|
11
|
+
|
|
12
|
+
### Added
|
|
13
|
+
- `FunctionalUnit`, `Instruction`, `Trace`, `InstructionResult`, `CycleSnapshot` data
|
|
14
|
+
model in `src/scoreboarding/model.py`.
|
|
15
|
+
- Cycle-exact Scoreboarding engine in `src/scoreboarding/engine.py` implementing all
|
|
16
|
+
four stages (Issue, Read Operands, Execute, Write Result) with structural, RAW, WAR,
|
|
17
|
+
and WAW hazard detection.
|
|
18
|
+
- `render_trace()` timing-table renderer.
|
|
19
|
+
- `scoreboarding` CLI with `--snapshots` flag for per-cycle state dumps.
|
|
20
|
+
- 50 tests covering golden trace, in-order issue invariant, all four hazard types,
|
|
21
|
+
simulation termination, and error handling.
|
|
22
|
+
- `examples/classic.txt` -- the classic CDC 6600 floating-point scheduling example.
|
|
23
|
+
- CI on Python 3.10, 3.11, 3.12, 3.13 via GitHub Actions.
|
|
24
|
+
- PyPI release pending (package-upload quota exhausted at release time; will follow).
|
|
25
|
+
|
|
26
|
+
[Unreleased]: https://github.com/amaar-mc/scoreboarding/compare/v0.1.0...HEAD
|
|
27
|
+
[0.1.0]: https://github.com/amaar-mc/scoreboarding/releases/tag/v0.1.0
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
# CLAUDE.md -- scoreboarding
|
|
2
|
+
|
|
3
|
+
## Project
|
|
4
|
+
|
|
5
|
+
Pure-Python cycle-exact Thornton Scoreboarding (CDC 6600) simulator.
|
|
6
|
+
Companion to `tomasulo` (out-of-order with register renaming).
|
|
7
|
+
|
|
8
|
+
## Layout
|
|
9
|
+
|
|
10
|
+
```
|
|
11
|
+
src/scoreboarding/
|
|
12
|
+
model.py -- dataclasses: FunctionalUnit, Instruction, FunctionalUnitStatus,
|
|
13
|
+
InstructionStatus, InstructionResult, CycleSnapshot, Trace
|
|
14
|
+
engine.py -- the simulation engine (four stages, three tables)
|
|
15
|
+
render.py -- render_trace() timing-table formatter
|
|
16
|
+
cli.py -- scoreboarding CLI: run(argv) + main()
|
|
17
|
+
__init__.py -- public API re-exports
|
|
18
|
+
py.typed -- PEP 561 marker
|
|
19
|
+
tests/
|
|
20
|
+
test_engine.py -- golden trace + all hazard invariants (30 tests)
|
|
21
|
+
test_cli.py -- CLI parse + run tests (14 tests)
|
|
22
|
+
test_render.py -- render output tests (6 tests)
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
## Dev gates (must all pass)
|
|
26
|
+
|
|
27
|
+
```bash
|
|
28
|
+
uv run pytest -q
|
|
29
|
+
uv run ruff check .
|
|
30
|
+
uv run mypy src
|
|
31
|
+
uv build
|
|
32
|
+
uv run --with twine twine check dist/*
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
## Key constraints
|
|
36
|
+
|
|
37
|
+
- mypy strict: no `Any`, no missing annotations.
|
|
38
|
+
- No default parameter values in public API; use keyword-only args.
|
|
39
|
+
- No em dashes in source or docs (use -- or plain dashes).
|
|
40
|
+
- No TODO/FIXME in code.
|
|
41
|
+
- ruff: line-length=100, selectors E,F,I,UP,B,SIM,RUF.
|
|
42
|
+
- Zero runtime deps.
|
|
43
|
+
|
|
44
|
+
## Algorithm
|
|
45
|
+
|
|
46
|
+
Four stages: Issue (structural + WAW check), Read Operands (RAW wait),
|
|
47
|
+
Execute (latency countdown), Write Result (WAR check then broadcast).
|
|
48
|
+
See docs/architecture.md for the full description.
|
|
49
|
+
|
|
50
|
+
## PyPI
|
|
51
|
+
|
|
52
|
+
Not yet published (quota exhausted at initial release). `uv build && twine check dist/*`
|
|
53
|
+
to validate the distribution. Publish when quota resets.
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
# Code of Conduct
|
|
2
|
+
|
|
3
|
+
## Our Pledge
|
|
4
|
+
|
|
5
|
+
We are committed to making participation in this project a harassment-free experience
|
|
6
|
+
for everyone, regardless of age, body size, disability, ethnicity, gender identity and
|
|
7
|
+
expression, level of experience, nationality, personal appearance, race, religion, or
|
|
8
|
+
sexual identity and orientation.
|
|
9
|
+
|
|
10
|
+
## Our Standards
|
|
11
|
+
|
|
12
|
+
Examples of behavior that contributes to a positive environment:
|
|
13
|
+
- Using welcoming and inclusive language
|
|
14
|
+
- Being respectful of differing viewpoints and experiences
|
|
15
|
+
- Gracefully accepting constructive criticism
|
|
16
|
+
- Focusing on what is best for the community
|
|
17
|
+
|
|
18
|
+
Examples of unacceptable behavior:
|
|
19
|
+
- Harassment, trolling, or personal attacks
|
|
20
|
+
- Publishing others' private information without consent
|
|
21
|
+
- Other conduct which could reasonably be considered inappropriate
|
|
22
|
+
|
|
23
|
+
## Enforcement
|
|
24
|
+
|
|
25
|
+
Instances of abusive or unacceptable behavior may be reported by opening a GitHub
|
|
26
|
+
issue or contacting the maintainer directly. All complaints will be reviewed and
|
|
27
|
+
investigated and will result in a response that is deemed necessary and appropriate.
|
|
28
|
+
|
|
29
|
+
## Attribution
|
|
30
|
+
|
|
31
|
+
This Code of Conduct is adapted from the
|
|
32
|
+
[Contributor Covenant](https://www.contributor-covenant.org), version 2.1.
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
# Contributing
|
|
2
|
+
|
|
3
|
+
Contributions are welcome. Please open an issue before submitting large changes.
|
|
4
|
+
|
|
5
|
+
## Development setup
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
git clone https://github.com/amaar-mc/scoreboarding
|
|
9
|
+
cd scoreboarding
|
|
10
|
+
uv venv .venv
|
|
11
|
+
uv pip install -e ".[dev]"
|
|
12
|
+
```
|
|
13
|
+
|
|
14
|
+
## Quality gates (all must pass)
|
|
15
|
+
|
|
16
|
+
```bash
|
|
17
|
+
uv run pytest -q
|
|
18
|
+
uv run ruff check .
|
|
19
|
+
uv run mypy src
|
|
20
|
+
uv build
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
## Code style
|
|
24
|
+
|
|
25
|
+
- Python 3.10+, strict mypy, ruff lint.
|
|
26
|
+
- No default parameter values in public API functions -- use keyword-only arguments.
|
|
27
|
+
- No `TODO` or `FIXME` in committed code -- implement or note the omission in an issue.
|
|
28
|
+
- Commit format: `type(scope): description`.
|
|
29
|
+
|
|
30
|
+
## Testing
|
|
31
|
+
|
|
32
|
+
New behaviour must be accompanied by tests. Bug fixes must include a failing test
|
|
33
|
+
that demonstrates the bug before the fix is applied.
|
|
34
|
+
|
|
35
|
+
## License
|
|
36
|
+
|
|
37
|
+
By contributing you agree that your changes are licensed under the MIT License.
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Amaar Chughtai
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,211 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: scoreboarding
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Pure-Python cycle-exact simulator of Thornton's Scoreboarding (CDC 6600) in-order dynamic scheduling, with structural, WAR, and WAW hazard detection and per-instruction traces for computer architecture education.
|
|
5
|
+
Project-URL: Homepage, https://github.com/amaar-mc/scoreboarding
|
|
6
|
+
Project-URL: Repository, https://github.com/amaar-mc/scoreboarding
|
|
7
|
+
Project-URL: Issues, https://github.com/amaar-mc/scoreboarding/issues
|
|
8
|
+
Project-URL: Changelog, https://github.com/amaar-mc/scoreboarding/blob/main/CHANGELOG.md
|
|
9
|
+
Author: Amaar Chughtai
|
|
10
|
+
License: MIT License
|
|
11
|
+
|
|
12
|
+
Copyright (c) 2026 Amaar Chughtai
|
|
13
|
+
|
|
14
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
15
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
16
|
+
in the Software without restriction, including without limitation the rights
|
|
17
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
18
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
19
|
+
furnished to do so, subject to the following conditions:
|
|
20
|
+
|
|
21
|
+
The above copyright notice and this permission notice shall be included in all
|
|
22
|
+
copies or substantial portions of the Software.
|
|
23
|
+
|
|
24
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
25
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
26
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
27
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
28
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
29
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
30
|
+
SOFTWARE.
|
|
31
|
+
License-File: LICENSE
|
|
32
|
+
Keywords: cdc-6600,computer-architecture,cpu-simulator,education,hazards,in-order,instruction-scheduling,pipeline,scoreboarding,simulation
|
|
33
|
+
Classifier: Development Status :: 3 - Alpha
|
|
34
|
+
Classifier: Intended Audience :: Education
|
|
35
|
+
Classifier: Intended Audience :: Science/Research
|
|
36
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
37
|
+
Classifier: Programming Language :: Python :: 3
|
|
38
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
39
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
40
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
41
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
42
|
+
Classifier: Topic :: Education
|
|
43
|
+
Classifier: Topic :: Scientific/Engineering
|
|
44
|
+
Classifier: Typing :: Typed
|
|
45
|
+
Requires-Python: >=3.10
|
|
46
|
+
Provides-Extra: dev
|
|
47
|
+
Requires-Dist: hatchling>=1.25; extra == 'dev'
|
|
48
|
+
Requires-Dist: mypy>=1.11; extra == 'dev'
|
|
49
|
+
Requires-Dist: pytest>=8; extra == 'dev'
|
|
50
|
+
Requires-Dist: ruff>=0.6; extra == 'dev'
|
|
51
|
+
Description-Content-Type: text/markdown
|
|
52
|
+
|
|
53
|
+
# scoreboarding
|
|
54
|
+
|
|
55
|
+
<p align="center">
|
|
56
|
+
<img src="assets/logo.png" alt="scoreboarding logo" width="160">
|
|
57
|
+
</p>
|
|
58
|
+
|
|
59
|
+
Pure-Python cycle-exact simulator of Thornton's **Scoreboarding** algorithm,
|
|
60
|
+
as implemented in the CDC 6600 (1964). Designed for computer architecture
|
|
61
|
+
education: readable source, zero runtime dependencies, and per-instruction
|
|
62
|
+
cycle-number traces.
|
|
63
|
+
|
|
64
|
+
> PyPI publish pending (package-upload quota). `pip install scoreboarding`
|
|
65
|
+
> will work once the first release is live. Install from source in the meantime.
|
|
66
|
+
|
|
67
|
+
---
|
|
68
|
+
|
|
69
|
+
## What is Scoreboarding?
|
|
70
|
+
|
|
71
|
+
Scoreboarding is an **in-order issue, out-of-order execution** dynamic
|
|
72
|
+
scheduling technique. The processor issues instructions one at a time
|
|
73
|
+
(program order), but lets them read operands and execute independently once
|
|
74
|
+
their hazards clear. A central scoreboard -- three tables -- tracks every
|
|
75
|
+
in-flight instruction and enforces the classic CDC 6600 hazard rules without
|
|
76
|
+
any register renaming.
|
|
77
|
+
|
|
78
|
+
### The Four Stages
|
|
79
|
+
|
|
80
|
+
| Stage | What happens | Hazard checked |
|
|
81
|
+
|---|---|---|
|
|
82
|
+
| **Issue** | Assign instruction to a free FU | Structural (FU busy) + WAW (another active insn writes same dest) |
|
|
83
|
+
| **Read Operands** | Read both source registers | RAW (stall until producing FU has written result) |
|
|
84
|
+
| **Execute** | Occupy the FU for its full latency | -- |
|
|
85
|
+
| **Write Result** | Commit result to register file, free FU | WAR (stall until every earlier reader has read its operand) |
|
|
86
|
+
|
|
87
|
+
### Three Tracking Tables
|
|
88
|
+
|
|
89
|
+
1. **Instruction Status** -- per-instruction cycle stamps (Issue / ReadOperands / ExecuteComplete / WriteResult).
|
|
90
|
+
2. **Functional Unit Status** -- per-FU: busy flag, op, destination (Fi), sources (Fj, Fk), producing FUs (Qj, Qk), ready flags (Rj, Rk).
|
|
91
|
+
3. **Register Result Status** -- which FU will next write each register (None once written).
|
|
92
|
+
|
|
93
|
+
### How it differs from Tomasulo
|
|
94
|
+
|
|
95
|
+
| | Scoreboarding | Tomasulo |
|
|
96
|
+
|---|---|---|
|
|
97
|
+
| Issue order | In order | In order |
|
|
98
|
+
| Execution order | Out of order | Out of order |
|
|
99
|
+
| WAW handling | Stall Issue | Register renaming (RS tags) |
|
|
100
|
+
| WAR handling | Stall Write Result | Eliminated by renaming |
|
|
101
|
+
| RAW handling | Stall Read Operands | Stall in RS until CDB broadcast |
|
|
102
|
+
| Register renaming | No | Yes (via reservation stations) |
|
|
103
|
+
| Broadcast mechanism | Central scoreboard | Common Data Bus |
|
|
104
|
+
|
|
105
|
+
See the sibling package [tomasulo](https://github.com/amaar-mc/tomasulo) for the
|
|
106
|
+
Tomasulo out-of-order scheduler with register renaming.
|
|
107
|
+
|
|
108
|
+
---
|
|
109
|
+
|
|
110
|
+
## Install
|
|
111
|
+
|
|
112
|
+
```bash
|
|
113
|
+
# From source (until PyPI release):
|
|
114
|
+
git clone https://github.com/amaar-mc/scoreboarding
|
|
115
|
+
cd scoreboarding
|
|
116
|
+
uv pip install -e ".[dev]"
|
|
117
|
+
```
|
|
118
|
+
|
|
119
|
+
---
|
|
120
|
+
|
|
121
|
+
## Usage
|
|
122
|
+
|
|
123
|
+
### Python API
|
|
124
|
+
|
|
125
|
+
```python
|
|
126
|
+
from scoreboarding import FunctionalUnit, Instruction, run, render_trace
|
|
127
|
+
|
|
128
|
+
fus = [
|
|
129
|
+
FunctionalUnit(name="Load1", kind="load", latency=2),
|
|
130
|
+
FunctionalUnit(name="Mult1", kind="mult", latency=10),
|
|
131
|
+
FunctionalUnit(name="Add1", kind="add", latency=2),
|
|
132
|
+
FunctionalUnit(name="Div1", kind="div", latency=40),
|
|
133
|
+
]
|
|
134
|
+
|
|
135
|
+
program = [
|
|
136
|
+
Instruction(op="LD", dest="F6", src1="R2", src2=""),
|
|
137
|
+
Instruction(op="LD", dest="F2", src1="R3", src2=""),
|
|
138
|
+
Instruction(op="MULT", dest="F0", src1="F2", src2="F4"),
|
|
139
|
+
Instruction(op="SUB", dest="F8", src1="F6", src2="F2"),
|
|
140
|
+
Instruction(op="DIV", dest="F10", src1="F0", src2="F6"),
|
|
141
|
+
Instruction(op="ADD", dest="F6", src1="F8", src2="F2"),
|
|
142
|
+
]
|
|
143
|
+
|
|
144
|
+
trace = run(program, functional_units=fus)
|
|
145
|
+
print(render_trace(trace))
|
|
146
|
+
```
|
|
147
|
+
|
|
148
|
+
### Example timing table
|
|
149
|
+
|
|
150
|
+
```
|
|
151
|
+
+---------------------+-------+---------+----------+-------------+
|
|
152
|
+
| Instruction | Issue | ReadOps | ExecComp | WriteResult |
|
|
153
|
+
+---------------------+-------+---------+----------+-------------+
|
|
154
|
+
| LD F6, R2 | 1 | 1 | 2 | 3 |
|
|
155
|
+
| LD F2, R3 | 3 | 3 | 4 | 5 |
|
|
156
|
+
| MULT F0, F2, F4 | 4 | 5 | 14 | 15 |
|
|
157
|
+
| SUB F8, F6, F2 | 4 | 5 | 6 | 7 |
|
|
158
|
+
| DIV F10, F0, F6 | 5 | 15 | 54 | 55 |
|
|
159
|
+
| ADD F6, F8, F2 | 8 | 8 | 9 | 16 |
|
|
160
|
+
+---------------------+-------+---------+----------+-------------+
|
|
161
|
+
Total cycles: 16
|
|
162
|
+
```
|
|
163
|
+
|
|
164
|
+
### CLI
|
|
165
|
+
|
|
166
|
+
```bash
|
|
167
|
+
# Use the bundled example:
|
|
168
|
+
scoreboarding examples/classic.txt
|
|
169
|
+
|
|
170
|
+
# Enable per-cycle snapshots:
|
|
171
|
+
scoreboarding --snapshots examples/classic.txt
|
|
172
|
+
|
|
173
|
+
# Read from stdin:
|
|
174
|
+
cat examples/classic.txt | scoreboarding -
|
|
175
|
+
```
|
|
176
|
+
|
|
177
|
+
Program file format:
|
|
178
|
+
|
|
179
|
+
```
|
|
180
|
+
# Comments start with #
|
|
181
|
+
FU Load1 load 2
|
|
182
|
+
FU Mult1 mult 10
|
|
183
|
+
FU Add1 add 2
|
|
184
|
+
FU Div1 div 40
|
|
185
|
+
|
|
186
|
+
LD F6, R2
|
|
187
|
+
LD F2, R3
|
|
188
|
+
MULT F0, F2, F4
|
|
189
|
+
SUB F8, F6, F2
|
|
190
|
+
DIV F10, F0, F6
|
|
191
|
+
ADD F6, F8, F2
|
|
192
|
+
```
|
|
193
|
+
|
|
194
|
+
---
|
|
195
|
+
|
|
196
|
+
## Development
|
|
197
|
+
|
|
198
|
+
```bash
|
|
199
|
+
uv run pytest -q
|
|
200
|
+
uv run ruff check .
|
|
201
|
+
uv run mypy src
|
|
202
|
+
uv build
|
|
203
|
+
```
|
|
204
|
+
|
|
205
|
+
CI runs on Python 3.10, 3.11, 3.12, 3.13 via GitHub Actions.
|
|
206
|
+
|
|
207
|
+
---
|
|
208
|
+
|
|
209
|
+
## License
|
|
210
|
+
|
|
211
|
+
MIT -- see [LICENSE](LICENSE).
|
|
@@ -0,0 +1,159 @@
|
|
|
1
|
+
# scoreboarding
|
|
2
|
+
|
|
3
|
+
<p align="center">
|
|
4
|
+
<img src="assets/logo.png" alt="scoreboarding logo" width="160">
|
|
5
|
+
</p>
|
|
6
|
+
|
|
7
|
+
Pure-Python cycle-exact simulator of Thornton's **Scoreboarding** algorithm,
|
|
8
|
+
as implemented in the CDC 6600 (1964). Designed for computer architecture
|
|
9
|
+
education: readable source, zero runtime dependencies, and per-instruction
|
|
10
|
+
cycle-number traces.
|
|
11
|
+
|
|
12
|
+
> PyPI publish pending (package-upload quota). `pip install scoreboarding`
|
|
13
|
+
> will work once the first release is live. Install from source in the meantime.
|
|
14
|
+
|
|
15
|
+
---
|
|
16
|
+
|
|
17
|
+
## What is Scoreboarding?
|
|
18
|
+
|
|
19
|
+
Scoreboarding is an **in-order issue, out-of-order execution** dynamic
|
|
20
|
+
scheduling technique. The processor issues instructions one at a time
|
|
21
|
+
(program order), but lets them read operands and execute independently once
|
|
22
|
+
their hazards clear. A central scoreboard -- three tables -- tracks every
|
|
23
|
+
in-flight instruction and enforces the classic CDC 6600 hazard rules without
|
|
24
|
+
any register renaming.
|
|
25
|
+
|
|
26
|
+
### The Four Stages
|
|
27
|
+
|
|
28
|
+
| Stage | What happens | Hazard checked |
|
|
29
|
+
|---|---|---|
|
|
30
|
+
| **Issue** | Assign instruction to a free FU | Structural (FU busy) + WAW (another active insn writes same dest) |
|
|
31
|
+
| **Read Operands** | Read both source registers | RAW (stall until producing FU has written result) |
|
|
32
|
+
| **Execute** | Occupy the FU for its full latency | -- |
|
|
33
|
+
| **Write Result** | Commit result to register file, free FU | WAR (stall until every earlier reader has read its operand) |
|
|
34
|
+
|
|
35
|
+
### Three Tracking Tables
|
|
36
|
+
|
|
37
|
+
1. **Instruction Status** -- per-instruction cycle stamps (Issue / ReadOperands / ExecuteComplete / WriteResult).
|
|
38
|
+
2. **Functional Unit Status** -- per-FU: busy flag, op, destination (Fi), sources (Fj, Fk), producing FUs (Qj, Qk), ready flags (Rj, Rk).
|
|
39
|
+
3. **Register Result Status** -- which FU will next write each register (None once written).
|
|
40
|
+
|
|
41
|
+
### How it differs from Tomasulo
|
|
42
|
+
|
|
43
|
+
| | Scoreboarding | Tomasulo |
|
|
44
|
+
|---|---|---|
|
|
45
|
+
| Issue order | In order | In order |
|
|
46
|
+
| Execution order | Out of order | Out of order |
|
|
47
|
+
| WAW handling | Stall Issue | Register renaming (RS tags) |
|
|
48
|
+
| WAR handling | Stall Write Result | Eliminated by renaming |
|
|
49
|
+
| RAW handling | Stall Read Operands | Stall in RS until CDB broadcast |
|
|
50
|
+
| Register renaming | No | Yes (via reservation stations) |
|
|
51
|
+
| Broadcast mechanism | Central scoreboard | Common Data Bus |
|
|
52
|
+
|
|
53
|
+
See the sibling package [tomasulo](https://github.com/amaar-mc/tomasulo) for the
|
|
54
|
+
Tomasulo out-of-order scheduler with register renaming.
|
|
55
|
+
|
|
56
|
+
---
|
|
57
|
+
|
|
58
|
+
## Install
|
|
59
|
+
|
|
60
|
+
```bash
|
|
61
|
+
# From source (until PyPI release):
|
|
62
|
+
git clone https://github.com/amaar-mc/scoreboarding
|
|
63
|
+
cd scoreboarding
|
|
64
|
+
uv pip install -e ".[dev]"
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
---
|
|
68
|
+
|
|
69
|
+
## Usage
|
|
70
|
+
|
|
71
|
+
### Python API
|
|
72
|
+
|
|
73
|
+
```python
|
|
74
|
+
from scoreboarding import FunctionalUnit, Instruction, run, render_trace
|
|
75
|
+
|
|
76
|
+
fus = [
|
|
77
|
+
FunctionalUnit(name="Load1", kind="load", latency=2),
|
|
78
|
+
FunctionalUnit(name="Mult1", kind="mult", latency=10),
|
|
79
|
+
FunctionalUnit(name="Add1", kind="add", latency=2),
|
|
80
|
+
FunctionalUnit(name="Div1", kind="div", latency=40),
|
|
81
|
+
]
|
|
82
|
+
|
|
83
|
+
program = [
|
|
84
|
+
Instruction(op="LD", dest="F6", src1="R2", src2=""),
|
|
85
|
+
Instruction(op="LD", dest="F2", src1="R3", src2=""),
|
|
86
|
+
Instruction(op="MULT", dest="F0", src1="F2", src2="F4"),
|
|
87
|
+
Instruction(op="SUB", dest="F8", src1="F6", src2="F2"),
|
|
88
|
+
Instruction(op="DIV", dest="F10", src1="F0", src2="F6"),
|
|
89
|
+
Instruction(op="ADD", dest="F6", src1="F8", src2="F2"),
|
|
90
|
+
]
|
|
91
|
+
|
|
92
|
+
trace = run(program, functional_units=fus)
|
|
93
|
+
print(render_trace(trace))
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
### Example timing table
|
|
97
|
+
|
|
98
|
+
```
|
|
99
|
+
+---------------------+-------+---------+----------+-------------+
|
|
100
|
+
| Instruction | Issue | ReadOps | ExecComp | WriteResult |
|
|
101
|
+
+---------------------+-------+---------+----------+-------------+
|
|
102
|
+
| LD F6, R2 | 1 | 1 | 2 | 3 |
|
|
103
|
+
| LD F2, R3 | 3 | 3 | 4 | 5 |
|
|
104
|
+
| MULT F0, F2, F4 | 4 | 5 | 14 | 15 |
|
|
105
|
+
| SUB F8, F6, F2 | 4 | 5 | 6 | 7 |
|
|
106
|
+
| DIV F10, F0, F6 | 5 | 15 | 54 | 55 |
|
|
107
|
+
| ADD F6, F8, F2 | 8 | 8 | 9 | 16 |
|
|
108
|
+
+---------------------+-------+---------+----------+-------------+
|
|
109
|
+
Total cycles: 16
|
|
110
|
+
```
|
|
111
|
+
|
|
112
|
+
### CLI
|
|
113
|
+
|
|
114
|
+
```bash
|
|
115
|
+
# Use the bundled example:
|
|
116
|
+
scoreboarding examples/classic.txt
|
|
117
|
+
|
|
118
|
+
# Enable per-cycle snapshots:
|
|
119
|
+
scoreboarding --snapshots examples/classic.txt
|
|
120
|
+
|
|
121
|
+
# Read from stdin:
|
|
122
|
+
cat examples/classic.txt | scoreboarding -
|
|
123
|
+
```
|
|
124
|
+
|
|
125
|
+
Program file format:
|
|
126
|
+
|
|
127
|
+
```
|
|
128
|
+
# Comments start with #
|
|
129
|
+
FU Load1 load 2
|
|
130
|
+
FU Mult1 mult 10
|
|
131
|
+
FU Add1 add 2
|
|
132
|
+
FU Div1 div 40
|
|
133
|
+
|
|
134
|
+
LD F6, R2
|
|
135
|
+
LD F2, R3
|
|
136
|
+
MULT F0, F2, F4
|
|
137
|
+
SUB F8, F6, F2
|
|
138
|
+
DIV F10, F0, F6
|
|
139
|
+
ADD F6, F8, F2
|
|
140
|
+
```
|
|
141
|
+
|
|
142
|
+
---
|
|
143
|
+
|
|
144
|
+
## Development
|
|
145
|
+
|
|
146
|
+
```bash
|
|
147
|
+
uv run pytest -q
|
|
148
|
+
uv run ruff check .
|
|
149
|
+
uv run mypy src
|
|
150
|
+
uv build
|
|
151
|
+
```
|
|
152
|
+
|
|
153
|
+
CI runs on Python 3.10, 3.11, 3.12, 3.13 via GitHub Actions.
|
|
154
|
+
|
|
155
|
+
---
|
|
156
|
+
|
|
157
|
+
## License
|
|
158
|
+
|
|
159
|
+
MIT -- see [LICENSE](LICENSE).
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
# Security Policy
|
|
2
|
+
|
|
3
|
+
## Supported Versions
|
|
4
|
+
|
|
5
|
+
| Version | Supported |
|
|
6
|
+
| ------- | --------- |
|
|
7
|
+
| 0.1.x | Yes |
|
|
8
|
+
|
|
9
|
+
## Reporting a Vulnerability
|
|
10
|
+
|
|
11
|
+
This is a pure-Python CPU simulator with zero runtime dependencies and no network
|
|
12
|
+
access. The attack surface is limited to malformed program files processed by the CLI.
|
|
13
|
+
|
|
14
|
+
If you discover a security vulnerability, please open a GitHub issue with the label
|
|
15
|
+
`security`. Do not include exploit code in the public issue; describe the class of
|
|
16
|
+
vulnerability and a minimal reproduction. We will respond within 7 days.
|
|
Binary file
|