SILICON
Loading...
Searching...
No Matches
circuitAutoplacer.hpp
Go to the documentation of this file.
1/*
2 Copyright (c) 2026. Giulio Cocconi
3
4 This program is free software: you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation, either version 3 of the License, or
7 (at your option) any later version.
8
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
13
14 You should have received a copy of the GNU General Public License
15 along with this program. If not, see <http://www.gnu.org/licenses/>.
16 */
17
18#pragma once
19
20#include <functional>
21#include <span>
22#include <stdexcept>
23#include <unordered_map>
24#include <vector>
25
29
30namespace SILICON::core {
31class Circuit;
32}
33
34namespace SILICON::ui {
36class GraphicalIO;
37
38using IoOrientationMap = std::unordered_map<GraphicalIO*, PortSide>;
39
49
53
57
60 std::function<bool()> isCancelled;
61
63 std::function<void(int completed, int total)> progress;
64};
65
73class AutoplacementRoutingFailure : public std::runtime_error {
74public:
75 using std::runtime_error::runtime_error;
76};
77
91
102public:
109 [[nodiscard]] static IoOrientationMap
111 std::span<GraphicalLogicComponent* const> components);
112
130 [[nodiscard]] static CircuitAutoplacement
131 compute(const core::Circuit& circuit,
132 std::span<GraphicalLogicComponent* const> components,
133 const CircuitAutoplacerOptions& options = {});
134};
135
136} // namespace SILICON::ui
Represents a digital circuit as a directed graph of components.
Definition circuit.hpp:125
Complete pure autoplacement result.
Combines OGDF component layout with libavoid orthogonal wire routing.
static IoOrientationMap boundaryIoOrientations(const core::Circuit &circuit, std::span< GraphicalLogicComponent *const > components)
Determines boundary I/O sides directly from connected component ports.
static CircuitAutoplacement compute(const core::Circuit &circuit, std::span< GraphicalLogicComponent *const > components, const CircuitAutoplacerOptions &options={})
Computes component placements and routed wire paths for a circuit.
std::unordered_map< GraphicalLogicComponent *, QPointF > PlacementMap
Map from graphical component to the computed scene position for that item.
Abstract base class for all graphical Input and Output components.
Base class for logic-gate graphical components.
std::unordered_map< GraphicalIO *, PortSide > IoOrientationMap
IoOrientationMap ioPortOrientations
Cardinal port sides selected for boundary I/O components.
GraphLayout::PlacementMap components
Computed scene positions for participating components.
bool cancelled
Cancellation before a complete candidate; the scene must stay unchanged.
std::vector< RoutedWire > wires
Routed scene-space wire paths.
Configuration for full circuit autoplacement and wire routing.
int obstaclePadding
Extra scene-unit padding added around component obstacles for routing clearance.
std::function< bool()> isCancelled
Optional cooperative cancellation check, also polled during routing. A candidate finishes routing bef...
std::function< void(int completed, int total)> progress
Optional notification after each completed candidate.
GraphLayoutOptions graphLayout
Options passed directly to GraphLayout for component placement.
int candidateCount
Maximum number of deterministic candidates. Large designs use fewer candidates and refinements to bou...
Configuration for OGDF-based component placement.