8#include <unordered_set>
17 renderImpl(
netlist, buffer,
nullptr);
24 std::unordered_set<NetlistNode const *>
const &nodes) {
25 renderImpl(
netlist, buffer, &nodes);
32 auto const &portNode = node.
as<
Port>();
33 buffer.
format(
" N{} [label=\"{} port {}\"]\n", node.
ID,
34 toString(portNode.direction), portNode.name);
39 buffer.
format(
" N{} [label=\"Variable {}\"]\n", node.
ID, varNode.name);
43 buffer.
format(
" N{} [label=\"Assignment\"]\n", node.
ID);
47 buffer.
format(
" N{} [label=\"Case\"]\n", node.
ID);
51 buffer.
format(
" N{} [label=\"Conditional\"]\n", node.
ID);
55 buffer.
format(
" N{} [label=\"Merge\"]\n", node.
ID);
59 auto const &state = node.
as<
State>();
60 buffer.
format(
" N{} [label=\"{} {}\"]\n", node.
ID, state.name,
61 toString(state.bounds));
66 buffer.
format(
" N{} [label=\"Const {}\"]\n", node.
ID,
67 constNode.value.toString());
76 renderImpl(NetlistGraph
const &netlist, FormatBuffer &buffer,
77 std::unordered_set<NetlistNode const *>
const *filter) {
78 auto included = [&](NetlistNode
const &node) {
79 return filter ==
nullptr || filter->count(&node) != 0;
82 buffer.append(
"digraph {\n");
83 buffer.append(
" node [shape=record];\n");
84 for (
auto const &node : netlist) {
85 if (!included(*node)) {
88 writeNode(buffer, *node);
90 for (
auto const &node : netlist) {
91 if (!included(*node)) {
98 if (!included(edge->getTargetNode())) {
101 if (edge->symbol !=
nullptr && !edge->symbol->empty()) {
102 buffer.format(
" N{} -> N{} [label=\"{}{}\"]\n", node->
ID,
103 edge->getTargetNode().ID, edge->symbol->name,
104 toString(edge->bounds));
106 buffer.format(
" N{} -> N{}\n", node->
ID, edge->getTargetNode().ID);
110 buffer.append(
"}\n");
Represent the netlist connectivity of an elaborated design.
Definition NetlistGraph.hpp:44
Definition NetlistNode.hpp:33
NodeKind kind
Definition NetlistNode.hpp:38
size_t ID
Definition NetlistNode.hpp:37
auto as() -> T &
Definition NetlistNode.hpp:45
auto getOutEdges() const -> const OutEdgeListType &
Definition DirectedGraph.hpp:256
Definition NetlistNode.hpp:71
Definition FormatBuffer.hpp:9
@ Case
Definition NetlistNode.hpp:25
@ State
Definition NetlistNode.hpp:27
@ Variable
Definition NetlistNode.hpp:22
@ Port
Definition NetlistNode.hpp:21
@ Merge
Definition NetlistNode.hpp:26
@ Conditional
Definition NetlistNode.hpp:24
@ Constant
Definition NetlistNode.hpp:28
@ Assignment
Definition NetlistNode.hpp:23
A utility class for rendering a netlist graph in DOT format.
Definition NetlistDot.hpp:13
static auto render(NetlistGraph const &netlist, FormatBuffer &buffer)
Render the whole netlist graph.
Definition NetlistDot.hpp:16
static auto render(NetlistGraph const &netlist, FormatBuffer &buffer, std::unordered_set< NetlistNode const * > const &nodes)
Definition NetlistDot.hpp:23