digraphx 0.6__tar.gz → 0.8__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.
- {digraphx-0.6 → digraphx-0.8}/CHANGELOG.md +38 -0
- {digraphx-0.6/src/digraphx.egg-info → digraphx-0.8}/PKG-INFO +3 -3
- digraphx-0.8/benchmarks/test_benchmarks.py +131 -0
- digraphx-0.8/examples/delay_padding.py +185 -0
- digraphx-0.8/paper/Makefile +59 -0
- digraphx-0.8/paper/delay_padding.md +686 -0
- digraphx-0.8/paper/delay_padding.pdf +0 -0
- digraphx-0.8/paper/figures/circuit_ring.tikz +52 -0
- digraphx-0.8/paper/figures/example_tcg.tikz +25 -0
- digraphx-0.8/paper/figures/padding_sweep.tikz +23 -0
- digraphx-0.8/paper/figures/pra_gate.tikz +73 -0
- digraphx-0.8/paper/figures/tcgraph.tikz +15 -0
- digraphx-0.8/paper/ieee.csl +519 -0
- digraphx-0.8/paper/latex.yaml +19 -0
- digraphx-0.8/paper/metadata.yaml +42 -0
- digraphx-0.8/paper/refs.bib +252 -0
- {digraphx-0.6 → digraphx-0.8}/setup.cfg +2 -2
- {digraphx-0.6 → digraphx-0.8}/src/digraphx/__init__.py +6 -0
- digraphx-0.8/src/digraphx/_cost_time.py +55 -0
- digraphx-0.8/src/digraphx/_cycle_base.py +347 -0
- digraphx-0.8/src/digraphx/_parametric_api.py +43 -0
- digraphx-0.8/src/digraphx/_parametric_base.py +161 -0
- digraphx-0.8/src/digraphx/_types.py +39 -0
- {digraphx-0.6 → digraphx-0.8}/src/digraphx/csr_digraph.py +7 -2
- digraphx-0.8/src/digraphx/css.py +110 -0
- digraphx-0.8/src/digraphx/mcf.py +388 -0
- {digraphx-0.6 → digraphx-0.8}/src/digraphx/min_cycle_ratio.py +7 -11
- {digraphx-0.6 → digraphx-0.8}/src/digraphx/min_parametric_q.py +12 -47
- {digraphx-0.6 → digraphx-0.8}/src/digraphx/neg_cycle.py +17 -33
- {digraphx-0.6 → digraphx-0.8}/src/digraphx/neg_cycle_q.py +31 -17
- {digraphx-0.6 → digraphx-0.8}/src/digraphx/parametric.py +12 -39
- {digraphx-0.6 → digraphx-0.8}/src/digraphx/tiny_digraph.py +34 -6
- {digraphx-0.6 → digraphx-0.8/src/digraphx.egg-info}/PKG-INFO +3 -3
- {digraphx-0.6 → digraphx-0.8}/src/digraphx.egg-info/SOURCES.txt +23 -2
- {digraphx-0.6 → digraphx-0.8}/src/digraphx.egg-info/scm_file_list.json +24 -3
- digraphx-0.8/src/digraphx.egg-info/scm_version.json +8 -0
- digraphx-0.8/tests/test_cost_time_api.py +39 -0
- digraphx-0.8/tests/test_css.py +165 -0
- digraphx-0.8/tests/test_graph_contract.py +128 -0
- {digraphx-0.6 → digraphx-0.8}/tests/test_neg_cycle.py +29 -0
- digraphx-0.8/tests/test_neg_cycle_succ_verify.py +38 -0
- digraphx-0.8/tunable_parameter.md +153 -0
- digraphx-0.6/src/digraphx/_cycle_base.py +0 -180
- digraphx-0.6/src/digraphx/_parametric_base.py +0 -101
- digraphx-0.6/src/digraphx/mcf.py +0 -335
- digraphx-0.6/src/digraphx.egg-info/scm_version.json +0 -8
- digraphx-0.6/tests/test_delay_padding_example_howard.py +0 -141
- digraphx-0.6/tests/test_timing_example_howard.py +0 -153
- {digraphx-0.6 → digraphx-0.8}/.coveragerc +0 -0
- {digraphx-0.6 → digraphx-0.8}/.github/workflows/jekyll-gh-pages.yml +0 -0
- {digraphx-0.6 → digraphx-0.8}/.github/workflows/multi-platforms.yml +0 -0
- {digraphx-0.6 → digraphx-0.8}/.github/workflows/python-app.yml +0 -0
- {digraphx-0.6 → digraphx-0.8}/.github/workflows/python-publish.yml +0 -0
- {digraphx-0.6 → digraphx-0.8}/.gitignore +0 -0
- {digraphx-0.6 → digraphx-0.8}/.isort.cfg +0 -0
- {digraphx-0.6 → digraphx-0.8}/.pre-commit-config.yaml +0 -0
- {digraphx-0.6 → digraphx-0.8}/.readthedocs.yml +0 -0
- {digraphx-0.6 → digraphx-0.8}/.vscode/settings.json +0 -0
- {digraphx-0.6 → digraphx-0.8}/AGENTS.md +0 -0
- {digraphx-0.6 → digraphx-0.8}/AUTHORS.md +0 -0
- {digraphx-0.6 → digraphx-0.8}/CONTRIBUTING.md +0 -0
- {digraphx-0.6 → digraphx-0.8}/GEMINI.md +0 -0
- {digraphx-0.6 → digraphx-0.8}/LICENSE.txt +0 -0
- {digraphx-0.6 → digraphx-0.8}/README.md +0 -0
- {digraphx-0.6 → digraphx-0.8}/coverage.json +0 -0
- {digraphx-0.6 → digraphx-0.8}/docs/Makefile +0 -0
- {digraphx-0.6 → digraphx-0.8}/docs/_static/.gitignore +0 -0
- {digraphx-0.6 → digraphx-0.8}/docs/authors.md +0 -0
- {digraphx-0.6 → digraphx-0.8}/docs/changelog.md +0 -0
- {digraphx-0.6 → digraphx-0.8}/docs/conf.py +0 -0
- {digraphx-0.6 → digraphx-0.8}/docs/contributing.md +0 -0
- {digraphx-0.6 → digraphx-0.8}/docs/examples/plot_cycle_detection.py +0 -0
- {digraphx-0.6 → digraphx-0.8}/docs/examples/plot_tiny_digraph.py +0 -0
- {digraphx-0.6 → digraphx-0.8}/docs/figures_demo.md +0 -0
- {digraphx-0.6 → digraphx-0.8}/docs/index.md +0 -0
- {digraphx-0.6 → digraphx-0.8}/docs/license.md +0 -0
- {digraphx-0.6 → digraphx-0.8}/docs/readme.md +0 -0
- {digraphx-0.6 → digraphx-0.8}/docs/requirements.txt +0 -0
- {digraphx-0.6 → digraphx-0.8}/environment.yml +0 -0
- {digraphx-0.6 → digraphx-0.8}/experimental/__init__.py +0 -0
- {digraphx-0.6 → digraphx-0.8}/experimental/spare_tsv.py +0 -0
- {digraphx-0.6 → digraphx-0.8}/experimental/test_spare_tsv.py +0 -0
- {digraphx-0.6 → digraphx-0.8}/experiments/experi-descent-new.py +0 -0
- {digraphx-0.6 → digraphx-0.8}/experiments/experi-descent-old.py +0 -0
- {digraphx-0.6 → digraphx-0.8}/experiments/experi-descent.py +0 -0
- {digraphx-0.6 → digraphx-0.8}/experiments/experi.py +0 -0
- {digraphx-0.6 → digraphx-0.8}/experiments/plot_node_colormap.ipynb +0 -0
- {digraphx-0.6 → digraphx-0.8}/experiments/plot_node_colormap.py +0 -0
- {digraphx-0.6 → digraphx-0.8}/mypy.ini +0 -0
- {digraphx-0.6 → digraphx-0.8}/note.md +0 -0
- {digraphx-0.6 → digraphx-0.8}/pyproject.toml +0 -0
- {digraphx-0.6 → digraphx-0.8}/requirements/README.md +0 -0
- {digraphx-0.6 → digraphx-0.8}/requirements/default.txt +0 -0
- {digraphx-0.6 → digraphx-0.8}/requirements/doc.txt +0 -0
- {digraphx-0.6 → digraphx-0.8}/requirements/test.txt +0 -0
- {digraphx-0.6 → digraphx-0.8}/requirements.txt +0 -0
- {digraphx-0.6 → digraphx-0.8}/setup.py +0 -0
- {digraphx-0.6 → digraphx-0.8}/src/digraphx/py.typed +0 -0
- {digraphx-0.6 → digraphx-0.8}/src/digraphx.egg-info/dependency_links.txt +0 -0
- {digraphx-0.6 → digraphx-0.8}/src/digraphx.egg-info/not-zip-safe +0 -0
- {digraphx-0.6 → digraphx-0.8}/src/digraphx.egg-info/requires.txt +0 -0
- {digraphx-0.6 → digraphx-0.8}/src/digraphx.egg-info/top_level.txt +0 -0
- {digraphx-0.6 → digraphx-0.8}/tests/__init__.py +0 -0
- {digraphx-0.6 → digraphx-0.8}/tests/conftest.py +0 -0
- {digraphx-0.6 → digraphx-0.8}/tests/test_coverage_extras.py +0 -0
- {digraphx-0.6 → digraphx-0.8}/tests/test_csr_digraph.py +0 -0
- {digraphx-0.6 → digraphx-0.8}/tests/test_cycle_ratio.py +0 -0
- {digraphx-0.6 → digraphx-0.8}/tests/test_edge_cases.py +0 -0
- {digraphx-0.6 → digraphx-0.8}/tests/test_howard_cycle_cancellation.py +0 -0
- {digraphx-0.6 → digraphx-0.8}/tests/test_mcf.py +0 -0
- {digraphx-0.6 → digraphx-0.8}/tests/test_min_cycle_ratio_extra.py +0 -0
- {digraphx-0.6 → digraphx-0.8}/tests/test_min_cycle_ratio_property.py +0 -0
- {digraphx-0.6 → digraphx-0.8}/tests/test_min_parametric_q.py +0 -0
- {digraphx-0.6 → digraphx-0.8}/tests/test_min_parametric_q_extra.py +0 -0
- {digraphx-0.6 → digraphx-0.8}/tests/test_neg_cycle_q.py +0 -0
- {digraphx-0.6 → digraphx-0.8}/tests/test_neg_cycle_q_simple_timing.py +0 -0
- {digraphx-0.6 → digraphx-0.8}/tests/test_neg_cycle_simple_timing.py +0 -0
- {digraphx-0.6 → digraphx-0.8}/tests/test_parametric.py +0 -0
- {digraphx-0.6 → digraphx-0.8}/tests/test_stress.py +0 -0
- {digraphx-0.6 → digraphx-0.8}/tests/test_timing_example.py +0 -0
- {digraphx-0.6 → digraphx-0.8}/tests/test_tiny_digraph.py +0 -0
- {digraphx-0.6 → digraphx-0.8}/tests/test_tiny_digraph_property.py +0 -0
- {digraphx-0.6 → digraphx-0.8}/tox.ini +0 -0
|
@@ -1,5 +1,43 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## Version 0.8 (2026-11-20)
|
|
4
|
+
|
|
5
|
+
### Features
|
|
6
|
+
- **Clock Skew Scheduling API (`css.py`)**: Added `min_cycle_ratio`, `even`, `prop`, `cprop`, and `min_clock_period`, expressing the single-parameter CSS family (Min CP, EVEN, PROP, C-PROP) as one min-ratio-cycle engine over a shared `(cost, time)` abstraction. `min_clock_period` handles the max-ratio case via the negated-cost transformation. Exported from the package root.
|
|
7
|
+
- **Delay-padding example and figure**: Added `examples/delay_padding.py` with a `--tikz` mode that derives `paper/figures/padding_sweep.tikz` from the same demo calls, plus a `figures` Makefile target. The output is byte-identical to the hand-written figure. (#7c3f039, #05902fa)
|
|
8
|
+
|
|
9
|
+
### Bug Fixes
|
|
10
|
+
- **CSS ratio name clash**: Renamed `css.min_cycle_ratio` to `css_ratio`; the new engine shadowed the pre-existing `min_cycle_ratio` submodule, so the root re-export was not the intended object. (#67d2b75)
|
|
11
|
+
|
|
12
|
+
### Refactoring
|
|
13
|
+
- **Shared parametric/cycle cores and injected strategies**: Added `_types` as the single source for `Node`/`Arc`/`Domain`/`Ratio`/`Cycle` and a real `_parametric_api` ABC; replaced the minimize/alternate_direction flag matrix with `KeepSmaller`/`KeepLarger` and `HowardSearch`/`AlternatingSearch` strategies; moved negativity checking into the relaxation strategy; unified cost/time arithmetic in `CostTimeAPI`; gave MCF explicit `Flow`/`ResidualNetwork`/constraint objects. Public API unchanged. (#8d8205a)
|
|
14
|
+
|
|
15
|
+
### Testing & Code Quality
|
|
16
|
+
- **Canonical CSS tests**: Added `tests/test_css.py` with the preserved golden values. Removed the duplicated `find_beta`/`even`/`prop` helpers by deleting `test_timing_example_howard.py` and `test_delay_padding_example_howard.py`; their golden values now live in `test_css.py`.
|
|
17
|
+
- **Graph-contract and parity tests**: Added graph-contract, successor-verification and cost/time parity coverage alongside the refactor. (#8d8205a)
|
|
18
|
+
|
|
19
|
+
### Documentation
|
|
20
|
+
- **Multi-corner delay-padding paper**: Added the paper source. (#f96413e)
|
|
21
|
+
|
|
22
|
+
## Version 0.7 (2026-10-09)
|
|
23
|
+
|
|
24
|
+
### Features
|
|
25
|
+
- **Optional `max_iter` cap for Howard's method**: `howard` / `howard_pred` / `howard_succ` accept an optional `max_iter` (default `None` = unbounded); a set cap raises `RuntimeError` instead of looping forever on degenerate graphs. (#8669cdd)
|
|
26
|
+
|
|
27
|
+
### Performance
|
|
28
|
+
- **Fast-path `TinyDiGraph.add_edge`**: Lazy-slot resolution avoids unnecessary work on edge insertion. (#a7ed9c3)
|
|
29
|
+
- **Pre-weighted edge list reuse**: Howard relaxation reuses the pre-weighted edge list instead of recomputing it. (#da93374)
|
|
30
|
+
|
|
31
|
+
### Bug Fixes
|
|
32
|
+
- **`cheat_adjlist_outer_dict` doctest**: Aligned the doctest with the lazy-sentinel behavior. (#20e7c11)
|
|
33
|
+
|
|
34
|
+
### Testing & Code Quality
|
|
35
|
+
- **Runtime benchmarks**: Added benchmarks for the core graph algorithms. (#0c7329a)
|
|
36
|
+
- **Neg-cycle tests**: Added tests covering the `max_iter` cap. (#8669cdd)
|
|
37
|
+
|
|
38
|
+
### Documentation
|
|
39
|
+
- **Tunable parameter reference**: Added `tunable_parameter.md`. (#9e0639b)
|
|
40
|
+
|
|
3
41
|
## Version 0.6 (2026-09-04)
|
|
4
42
|
|
|
5
43
|
### Features
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: digraphx
|
|
3
|
-
Version: 0.
|
|
4
|
-
Summary:
|
|
3
|
+
Version: 0.8
|
|
4
|
+
Summary: Directed graph algorithms for network optimization
|
|
5
5
|
Home-page: https://github.com/luk036/digraphx
|
|
6
6
|
Author: Wai-Shing Luk
|
|
7
7
|
Author-email: luk036@gmail.com
|
|
8
8
|
License: MIT
|
|
9
|
-
Project-URL: Documentation, https://
|
|
9
|
+
Project-URL: Documentation, https://luk036.github.io/digraphx/
|
|
10
10
|
Platform: any
|
|
11
11
|
Classifier: Development Status :: 4 - Beta
|
|
12
12
|
Classifier: Programming Language :: Python
|
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
"""Runtime benchmarks for digraphx core algorithms.
|
|
2
|
+
|
|
3
|
+
Run explicitly (they are outside the default ``testpaths`` so ``pytest`` alone
|
|
4
|
+
skips them):
|
|
5
|
+
|
|
6
|
+
pytest benchmarks/ --benchmark-only
|
|
7
|
+
|
|
8
|
+
Uses fixed seeds so numbers are comparable across runs and across machines.
|
|
9
|
+
"""
|
|
10
|
+
|
|
11
|
+
import random
|
|
12
|
+
from fractions import Fraction
|
|
13
|
+
|
|
14
|
+
import networkx as nx
|
|
15
|
+
import pytest
|
|
16
|
+
|
|
17
|
+
from digraphx.min_cycle_ratio import MinCycleRatioSolver, set_default
|
|
18
|
+
from digraphx.neg_cycle import NegCycleFinder
|
|
19
|
+
from digraphx.tiny_digraph import DiGraphAdapter, TinyDiGraph
|
|
20
|
+
|
|
21
|
+
SEED = 1234
|
|
22
|
+
SIZES = [200, 1000]
|
|
23
|
+
MCR_SIZES = [50, 100]
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
def weighted_graph(n: int, deg: int, seed: int = SEED) -> dict:
|
|
27
|
+
rng = random.Random(seed)
|
|
28
|
+
g: dict = {i: {} for i in range(n)}
|
|
29
|
+
for i in range(n):
|
|
30
|
+
for _ in range(deg):
|
|
31
|
+
j = rng.randrange(n)
|
|
32
|
+
if j != i:
|
|
33
|
+
g[i][j] = rng.randint(1, 9)
|
|
34
|
+
for i in range(n - 1):
|
|
35
|
+
g[i][i + 1] = 1
|
|
36
|
+
g[n - 1][0] = -n
|
|
37
|
+
return g
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
def ratio_graph(n: int, deg: int, seed: int = SEED) -> DiGraphAdapter:
|
|
41
|
+
rng = random.Random(seed)
|
|
42
|
+
g = DiGraphAdapter()
|
|
43
|
+
g.add_nodes_from(range(n))
|
|
44
|
+
for i in range(n):
|
|
45
|
+
for _ in range(deg):
|
|
46
|
+
j = rng.randrange(n)
|
|
47
|
+
if j != i:
|
|
48
|
+
g.add_edge(i, j, cost=rng.randint(-5, 9), time=rng.randint(1, 5))
|
|
49
|
+
return g
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
@pytest.mark.parametrize("n", SIZES)
|
|
53
|
+
def test_bench_tiny_build(benchmark, n: int) -> None:
|
|
54
|
+
deg = 5
|
|
55
|
+
|
|
56
|
+
def build() -> TinyDiGraph:
|
|
57
|
+
g = TinyDiGraph()
|
|
58
|
+
g.init_nodes(n)
|
|
59
|
+
for i in range(n):
|
|
60
|
+
for j in range(1, deg + 1):
|
|
61
|
+
g.add_edge(i, (i + j) % n, weight=1)
|
|
62
|
+
return g
|
|
63
|
+
|
|
64
|
+
benchmark(build)
|
|
65
|
+
|
|
66
|
+
|
|
67
|
+
@pytest.mark.parametrize("n", SIZES)
|
|
68
|
+
def test_bench_adapter_build(benchmark, n: int) -> None:
|
|
69
|
+
deg = 5
|
|
70
|
+
|
|
71
|
+
def build() -> DiGraphAdapter:
|
|
72
|
+
g = DiGraphAdapter()
|
|
73
|
+
g.add_nodes_from(range(n))
|
|
74
|
+
for i in range(n):
|
|
75
|
+
for j in range(1, deg + 1):
|
|
76
|
+
g.add_edge(i, (i + j) % n, weight=1)
|
|
77
|
+
return g
|
|
78
|
+
|
|
79
|
+
benchmark(build)
|
|
80
|
+
|
|
81
|
+
|
|
82
|
+
@pytest.mark.parametrize("n", SIZES)
|
|
83
|
+
def test_bench_howard_negative_cycle(benchmark, n: int) -> None:
|
|
84
|
+
g = weighted_graph(n, 6)
|
|
85
|
+
finder = NegCycleFinder(g)
|
|
86
|
+
|
|
87
|
+
def run() -> None:
|
|
88
|
+
dist = {v: 0 for v in g}
|
|
89
|
+
list(finder.howard(dist, lambda e: e))
|
|
90
|
+
|
|
91
|
+
benchmark(run)
|
|
92
|
+
|
|
93
|
+
|
|
94
|
+
@pytest.mark.parametrize("n", SIZES)
|
|
95
|
+
def test_bench_networkx_negative_edge_cycle(benchmark, n: int) -> None:
|
|
96
|
+
g = weighted_graph(n, 6)
|
|
97
|
+
h = nx.DiGraph()
|
|
98
|
+
for u, nb in g.items():
|
|
99
|
+
h.add_node(u)
|
|
100
|
+
for v, w in nb.items():
|
|
101
|
+
h.add_edge(u, v, weight=w)
|
|
102
|
+
|
|
103
|
+
benchmark(lambda: nx.negative_edge_cycle(h, weight="weight"))
|
|
104
|
+
|
|
105
|
+
|
|
106
|
+
@pytest.mark.parametrize("n", MCR_SIZES)
|
|
107
|
+
def test_bench_mcr_fraction(benchmark, n: int) -> None:
|
|
108
|
+
g = ratio_graph(n, 5)
|
|
109
|
+
set_default(g, "cost", 0)
|
|
110
|
+
set_default(g, "time", 1)
|
|
111
|
+
solver = MinCycleRatioSolver(g)
|
|
112
|
+
|
|
113
|
+
def run():
|
|
114
|
+
dist = {v: Fraction(0) for v in g}
|
|
115
|
+
return solver.run(dist, Fraction(10))
|
|
116
|
+
|
|
117
|
+
benchmark(run)
|
|
118
|
+
|
|
119
|
+
|
|
120
|
+
@pytest.mark.parametrize("n", MCR_SIZES)
|
|
121
|
+
def test_bench_mcr_float(benchmark, n: int) -> None:
|
|
122
|
+
g = ratio_graph(n, 5)
|
|
123
|
+
set_default(g, "cost", 0)
|
|
124
|
+
set_default(g, "time", 1)
|
|
125
|
+
solver = MinCycleRatioSolver(g)
|
|
126
|
+
|
|
127
|
+
def run():
|
|
128
|
+
dist = {v: 0.0 for v in g}
|
|
129
|
+
return solver.run(dist, 10.0)
|
|
130
|
+
|
|
131
|
+
benchmark(run)
|
|
@@ -0,0 +1,185 @@
|
|
|
1
|
+
"""Delay padding demo on a four-flip-flop ring with a reconvergent path.
|
|
2
|
+
|
|
3
|
+
A local data path from ``FF_i`` to ``FF_j`` is ONE block of combinational logic
|
|
4
|
+
whose delay runs between a minimum ``d_ij`` (early/fast) and a maximum ``D_ij``
|
|
5
|
+
(late/slow). The two numbers describe the SAME data path: setup uses ``D_ij``,
|
|
6
|
+
hold uses ``d_ij``.
|
|
7
|
+
|
|
8
|
+
Delay padding inserts extra delay into that logic. The point of this demo is
|
|
9
|
+
that an insertion only helps when it raises ``d_ij`` without raising ``D_ij`` --
|
|
10
|
+
which is possible only where the minimum-delay route and the maximum-delay route
|
|
11
|
+
differ. On a shared segment both delays rise together and the clock period does
|
|
12
|
+
not move.
|
|
13
|
+
"""
|
|
14
|
+
|
|
15
|
+
from __future__ import annotations
|
|
16
|
+
|
|
17
|
+
import argparse
|
|
18
|
+
from pathlib import Path
|
|
19
|
+
from typing import Dict, List, Optional, Sequence, Tuple
|
|
20
|
+
|
|
21
|
+
from digraphx import min_clock_period
|
|
22
|
+
|
|
23
|
+
Path_ = Tuple[str, str]
|
|
24
|
+
Edge = Dict[str, object]
|
|
25
|
+
Graph = Dict[str, Dict[str, Dict[str, object]]]
|
|
26
|
+
Sweep = List[Tuple[float, float, float]]
|
|
27
|
+
|
|
28
|
+
DATA_PATHS: Dict[Path_, Tuple[float, float]] = {
|
|
29
|
+
("A", "B"): (12.0, 3.0),
|
|
30
|
+
("B", "C"): (4.0, 4.0),
|
|
31
|
+
("C", "D"): (4.0, 4.0),
|
|
32
|
+
("D", "A"): (4.0, 4.0),
|
|
33
|
+
}
|
|
34
|
+
"""Ring ``A -> B -> C -> D -> A``; each value is ``(D_ij, d_ij)``.
|
|
35
|
+
|
|
36
|
+
``A -> B`` is a reconvergent cone: a shared prefix (delay 2) that fans out into
|
|
37
|
+
a long branch (5 + 5) and a short branch (1), so ``D_AB = 12`` and ``d_AB = 3``.
|
|
38
|
+
"""
|
|
39
|
+
|
|
40
|
+
SWEEP: Sequence[float] = (0.0, 1.0, 2.0, 3.0, 4.0, 5.0)
|
|
41
|
+
"""Padding amounts swept by both the printed table and the paper figure."""
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
def build(
|
|
45
|
+
delta_D: Dict[Path_, float] | None = None,
|
|
46
|
+
delta_d: Dict[Path_, float] | None = None,
|
|
47
|
+
) -> Graph:
|
|
48
|
+
"""Build the timing constraint graph, optionally perturbing delays.
|
|
49
|
+
|
|
50
|
+
Args:
|
|
51
|
+
delta_D: extra delay added to ``D_ij`` (raises the setup path) per pair.
|
|
52
|
+
delta_d: extra delay added to ``d_ij`` (raises the hold path) per pair.
|
|
53
|
+
"""
|
|
54
|
+
delta_D = delta_D or {}
|
|
55
|
+
delta_d = delta_d or {}
|
|
56
|
+
g: Graph = {}
|
|
57
|
+
for (i, j), (D, d) in DATA_PATHS.items():
|
|
58
|
+
D += delta_D.get((i, j), 0.0)
|
|
59
|
+
d += delta_d.get((i, j), 0.0)
|
|
60
|
+
g.setdefault(j, {})[i] = {"type": "s", "delay": D}
|
|
61
|
+
g.setdefault(i, {})[j] = {"type": "h", "delay": d}
|
|
62
|
+
return g
|
|
63
|
+
|
|
64
|
+
|
|
65
|
+
def period(
|
|
66
|
+
delta_D: Dict[Path_, float] | None = None,
|
|
67
|
+
delta_d: Dict[Path_, float] | None = None,
|
|
68
|
+
) -> float:
|
|
69
|
+
"""Minimum feasible clock period after the given perturbations."""
|
|
70
|
+
g = build(delta_D, delta_d)
|
|
71
|
+
return min_clock_period(g, {node: 0.0 for node in g})[0]
|
|
72
|
+
|
|
73
|
+
|
|
74
|
+
def pad_shared(amount: float) -> float:
|
|
75
|
+
"""Pad the shared prefix of ``A -> B``: raises ``D_AB`` and ``d_AB`` together."""
|
|
76
|
+
return period(delta_D={("A", "B"): amount}, delta_d={("A", "B"): amount})
|
|
77
|
+
|
|
78
|
+
|
|
79
|
+
def pad_min_only(amount: float) -> float:
|
|
80
|
+
"""Pad the minimum-only branch of ``A -> B``: raises ``d_AB`` alone."""
|
|
81
|
+
return period(delta_d={("A", "B"): amount})
|
|
82
|
+
|
|
83
|
+
|
|
84
|
+
def setup_floor() -> float:
|
|
85
|
+
"""Setup-only bound: no amount of hold padding can beat it."""
|
|
86
|
+
return sum(D for D, _ in DATA_PATHS.values()) / len(DATA_PATHS)
|
|
87
|
+
|
|
88
|
+
|
|
89
|
+
def sweep() -> Sweep:
|
|
90
|
+
"""``(padding, min-only period, shared period)`` for every padding amount."""
|
|
91
|
+
return [(amount, pad_min_only(amount), pad_shared(amount)) for amount in SWEEP]
|
|
92
|
+
|
|
93
|
+
|
|
94
|
+
def tikz(rows: Optional[Sweep] = None) -> str:
|
|
95
|
+
"""Render the padding sweep as a pgfplots axis, ready for ``\\input``."""
|
|
96
|
+
rows = sweep() if rows is None else rows
|
|
97
|
+
min_only = "".join(f"({a:g},{p:g})" for a, p, _ in rows)
|
|
98
|
+
shared = "".join(f"({a:g},{p:g})" for a, _, p in rows)
|
|
99
|
+
x_max = max(a for a, _, _ in rows)
|
|
100
|
+
y_max = max(max(p, q) for _, p, q in rows) + 1.0
|
|
101
|
+
return f"""\\begin{{tikzpicture}}
|
|
102
|
+
\\begin{{axis}}[
|
|
103
|
+
width=0.82\\linewidth,
|
|
104
|
+
height=5.4cm,
|
|
105
|
+
xlabel={{added delay on the $A\\to B$ logic}},
|
|
106
|
+
ylabel={{minimum clock period}},
|
|
107
|
+
xmin=0, xmax={x_max:g}, ymin=0, ymax={y_max:g},
|
|
108
|
+
domain=0:{x_max:g},
|
|
109
|
+
grid=both, grid style={{gray!25}},
|
|
110
|
+
legend pos=north east, legend cell align=left,
|
|
111
|
+
every axis plot/.append style={{thick}},
|
|
112
|
+
]
|
|
113
|
+
% padding the min-only branch lowers the period ...
|
|
114
|
+
\\addplot[color=red, mark=*] coordinates {{{min_only}}};
|
|
115
|
+
\\addlegendentry{{pad min-only branch}}
|
|
116
|
+
% ... padding the shared prefix moves both delays and changes nothing.
|
|
117
|
+
\\addplot[color=blue, mark=square*] coordinates {{{shared}}};
|
|
118
|
+
\\addlegendentry{{pad shared prefix}}
|
|
119
|
+
% setup-only floor: no hold padding can beat it.
|
|
120
|
+
\\addplot[color=black, dashed, mark=none] {{{setup_floor():g}}};
|
|
121
|
+
\\addlegendentry{{setup-only floor}}
|
|
122
|
+
\\end{{axis}}
|
|
123
|
+
\\end{{tikzpicture}}
|
|
124
|
+
"""
|
|
125
|
+
|
|
126
|
+
|
|
127
|
+
def report() -> None:
|
|
128
|
+
"""Print the narrative used in the paper."""
|
|
129
|
+
print("Delay padding demo: a 4-flip-flop ring with a reconvergent path\n")
|
|
130
|
+
print("Model")
|
|
131
|
+
print(" a local data path i -> j is ONE block of logic with")
|
|
132
|
+
print(
|
|
133
|
+
" D_ij = maximum path delay (setup) and d_ij = minimum path delay (hold)"
|
|
134
|
+
)
|
|
135
|
+
print(" minimum period = max over cycles of")
|
|
136
|
+
print(" (sum of setup delays - sum of hold delays) / (# setup edges)\n")
|
|
137
|
+
|
|
138
|
+
base = period()
|
|
139
|
+
print("[1] Baseline -- clock skew scheduling only")
|
|
140
|
+
print(f" minimum feasible clock period : {base:.2f}")
|
|
141
|
+
print(" limiting cycle : pair (A, B), D_AB - d_AB = 12 - 3\n")
|
|
142
|
+
|
|
143
|
+
shared = pad_shared(3.0)
|
|
144
|
+
print("[2] Pad the SHARED prefix of A -> B (raises D_AB and d_AB together)")
|
|
145
|
+
print(
|
|
146
|
+
f" added delay 3.00 -> period {shared:.2f} (inert: D_AB - d_AB is unchanged)"
|
|
147
|
+
)
|
|
148
|
+
print(" a simple 1-2 gate path behaves the same way: D_ij = d_ij\n")
|
|
149
|
+
|
|
150
|
+
min_only = pad_min_only(3.0)
|
|
151
|
+
gain = 100.0 * (base - min_only) / base
|
|
152
|
+
print("[3] Pad the MIN-ONLY branch of A -> B (raises d_AB alone)")
|
|
153
|
+
print(f" added delay 3.00 -> period {min_only:.2f} ({gain:.1f}% faster)")
|
|
154
|
+
print(" only a route that misses every maximum-delay route can do this\n")
|
|
155
|
+
|
|
156
|
+
print("[4] Sweep of padding on A -> B")
|
|
157
|
+
print(" pad min-only shared")
|
|
158
|
+
for amount, min_only_period, shared_period in sweep():
|
|
159
|
+
print(f" {amount:4.1f} {min_only_period:8.2f} {shared_period:6.2f}")
|
|
160
|
+
print(
|
|
161
|
+
f" floor at {setup_floor():.2f} = (12 + 4 + 4 + 4) / 4 setup-only bound\n"
|
|
162
|
+
)
|
|
163
|
+
|
|
164
|
+
print("[5] The simple paths B -> C, C -> D, D -> A have D = d,")
|
|
165
|
+
print(" so no insertion can separate their setup and hold delays.")
|
|
166
|
+
|
|
167
|
+
|
|
168
|
+
def main(argv: Optional[Sequence[str]] = None) -> None:
|
|
169
|
+
parser = argparse.ArgumentParser(description="Delay padding demo")
|
|
170
|
+
parser.add_argument(
|
|
171
|
+
"--tikz",
|
|
172
|
+
type=Path,
|
|
173
|
+
metavar="PATH",
|
|
174
|
+
help="write the padding-sweep figure as TikZ and exit",
|
|
175
|
+
)
|
|
176
|
+
args = parser.parse_args(argv)
|
|
177
|
+
if args.tikz is not None:
|
|
178
|
+
with args.tikz.open("w", encoding="utf-8", newline="\n") as handle:
|
|
179
|
+
handle.write(tikz())
|
|
180
|
+
return
|
|
181
|
+
report()
|
|
182
|
+
|
|
183
|
+
|
|
184
|
+
if __name__ == "__main__":
|
|
185
|
+
main()
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
# Build pipeline for "Novel Multi-Corner Delay Padding ...".
|
|
2
|
+
# Run from paper/ (`make paper` builds delay_padding.pdf).
|
|
3
|
+
#
|
|
4
|
+
# Flag rationale (see also the md-to-latex skill); recorded here so the
|
|
5
|
+
# knowledge is not tribal:
|
|
6
|
+
# - Title/author/abstract live in metadata.yaml, so the body headings start
|
|
7
|
+
# at `#` and map directly to \section. We therefore do NOT pass
|
|
8
|
+
# --shift-heading-level-by=-1 (there is no title H1 in the body).
|
|
9
|
+
# - --citeproc --csl=ieee.csl : IEEE numeric in-text citations and a numeric
|
|
10
|
+
# reference list. ieee.csl is vendored here and is self-contained (no
|
|
11
|
+
# <link rel="independent-parent">), so the build needs no network access.
|
|
12
|
+
# - -N : number sections/subsections.
|
|
13
|
+
# - --pdf-engine=pdflatex : every equation and caption is ASCII, so pdflatex
|
|
14
|
+
# is sufficient; no xelatex / Unicode font fallback is required.
|
|
15
|
+
# - -V geometry:margin=1in : comfortable single-column page.
|
|
16
|
+
#
|
|
17
|
+
# Figures are native TikZ pulled in with \input{figures/*.tikz}. We do not
|
|
18
|
+
# convert SVGs (a fontless rsvg-convert silently drops every <text>), and the
|
|
19
|
+
# four structural configurations ship as .tikz sources next to this Makefile.
|
|
20
|
+
#
|
|
21
|
+
# We deliberately do NOT use pandoc-crossref/cleveref: plain LaTeX
|
|
22
|
+
# \label/\ref/\eqref handles every cross-reference and is robust across
|
|
23
|
+
# document classes.
|
|
24
|
+
|
|
25
|
+
PANDOC ?= pandoc
|
|
26
|
+
CSL ?= ieee.csl
|
|
27
|
+
BIB ?= refs.bib
|
|
28
|
+
MD = delay_padding.md
|
|
29
|
+
OUT = delay_padding.pdf
|
|
30
|
+
|
|
31
|
+
PDFFLAGS = -s -t latex -N --pdf-engine=pdflatex \
|
|
32
|
+
--pdf-engine-opt=-interaction=nonstopmode \
|
|
33
|
+
--citeproc --csl=$(CSL) \
|
|
34
|
+
-V geometry:margin=1in
|
|
35
|
+
|
|
36
|
+
.PHONY: paper pdf html tex figures clean
|
|
37
|
+
|
|
38
|
+
paper: pdf
|
|
39
|
+
|
|
40
|
+
pdf: $(OUT)
|
|
41
|
+
|
|
42
|
+
$(OUT): $(MD) metadata.yaml latex.yaml $(BIB) $(CSL) $(wildcard figures/*.tikz)
|
|
43
|
+
$(PANDOC) $(PDFFLAGS) metadata.yaml latex.yaml $(MD) -o $(OUT)
|
|
44
|
+
|
|
45
|
+
figures: figures/padding_sweep.tikz
|
|
46
|
+
|
|
47
|
+
figures/padding_sweep.tikz: ../examples/delay_padding.py
|
|
48
|
+
python ../examples/delay_padding.py --tikz $@
|
|
49
|
+
|
|
50
|
+
html: $(MD) metadata.yaml latex.yaml $(BIB) $(CSL)
|
|
51
|
+
$(PANDOC) -s -t html5 --citeproc --csl=$(CSL) --mathjax --embed-resources \
|
|
52
|
+
metadata.yaml latex.yaml $(MD) -o delay_padding.html
|
|
53
|
+
|
|
54
|
+
tex: $(MD) metadata.yaml latex.yaml $(BIB) $(CSL)
|
|
55
|
+
$(PANDOC) -s -t latex -N --citeproc --csl=$(CSL) \
|
|
56
|
+
metadata.yaml latex.yaml $(MD) -o delay_padding.tex
|
|
57
|
+
|
|
58
|
+
clean:
|
|
59
|
+
rm -f $(OUT) delay_padding.tex delay_padding.html
|