yosys-master
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
ShowWorker Struct Reference
+ Collaboration diagram for ShowWorker:

Data Structures

struct  net_conn
 

Public Member Functions

std::string nextColor ()
 
std::string nextColor (std::string presetColor)
 
std::string nextColor (RTLIL::SigSpec sig, std::string defaultColor)
 
std::string nextColor (const RTLIL::SigSig &conn, std::string defaultColor)
 
std::string nextColor (const RTLIL::SigSpec &sig)
 
std::string nextColor (const RTLIL::SigSig &conn)
 
std::string widthLabel (int bits)
 
const char * findColor (std::string member_name)
 
const char * findLabel (std::string member_name)
 
const char * escape (std::string id, bool is_name=false)
 
int id2num (RTLIL::IdString id)
 
std::string gen_signode_simple (RTLIL::SigSpec sig, bool range_check=true)
 
std::string gen_portbox (std::string port, RTLIL::SigSpec sig, bool driver, std::string *node=NULL)
 
void collect_proc_signals (std::vector< RTLIL::SigSpec > &obj, std::set< RTLIL::SigSpec > &signals)
 
void collect_proc_signals (std::vector< RTLIL::SigSig > &obj, std::set< RTLIL::SigSpec > &input_signals, std::set< RTLIL::SigSpec > &output_signals)
 
void collect_proc_signals (RTLIL::CaseRule *obj, std::set< RTLIL::SigSpec > &input_signals, std::set< RTLIL::SigSpec > &output_signals)
 
void collect_proc_signals (RTLIL::SwitchRule *obj, std::set< RTLIL::SigSpec > &input_signals, std::set< RTLIL::SigSpec > &output_signals)
 
void collect_proc_signals (RTLIL::SyncRule *obj, std::set< RTLIL::SigSpec > &input_signals, std::set< RTLIL::SigSpec > &output_signals)
 
void collect_proc_signals (RTLIL::Process *obj, std::set< RTLIL::SigSpec > &input_signals, std::set< RTLIL::SigSpec > &output_signals)
 
void handle_module ()
 
 ShowWorker (FILE *f, RTLIL::Design *design, std::vector< RTLIL::Design * > &libs, uint32_t colorSeed, bool genWidthLabels, bool genSignedLabels, bool stretchIO, bool enumerateIds, bool abbreviateIds, bool notitle, const std::vector< std::pair< std::string, RTLIL::Selection >> &color_selections, const std::vector< std::pair< std::string, RTLIL::Selection >> &label_selections)
 

Static Public Member Functions

static uint32_t xorshift32 (uint32_t x)
 

Data Fields

CellTypes ct
 
std::vector< std::string > dot_escape_store
 
std::map< RTLIL::IdString, int > dot_id2num_store
 
std::map< RTLIL::IdString, int > autonames
 
int single_idx_count
 
std::map< std::string, net_connnet_conn_map
 
FILE * f
 
RTLIL::Designdesign
 
RTLIL::Modulemodule
 
uint32_t currentColor
 
bool genWidthLabels
 
bool genSignedLabels
 
bool stretchIO
 
bool enumerateIds
 
bool abbreviateIds
 
bool notitle
 
int page_counter
 
const std::vector< std::pair
< std::string,
RTLIL::Selection > > & 
color_selections
 
const std::vector< std::pair
< std::string,
RTLIL::Selection > > & 
label_selections
 

Detailed Description

Definition at line 40 of file show.cc.

Constructor & Destructor Documentation

ShowWorker::ShowWorker ( FILE *  f,
RTLIL::Design design,
std::vector< RTLIL::Design * > &  libs,
uint32_t  colorSeed,
bool  genWidthLabels,
bool  genSignedLabels,
bool  stretchIO,
bool  enumerateIds,
bool  abbreviateIds,
bool  notitle,
const std::vector< std::pair< std::string, RTLIL::Selection >> &  color_selections,
const std::vector< std::pair< std::string, RTLIL::Selection >> &  label_selections 
)
inline

Definition at line 507 of file show.cc.

510  :
511  f(f), design(design), currentColor(colorSeed), genWidthLabels(genWidthLabels),
514  {
517  ct.setup_stdcells();
519  ct.setup_design(design);
520 
521  for (auto lib : libs)
522  ct.setup_design(lib);
523 
524  design->optimize();
525  page_counter = 0;
526  for (auto &mod_it : design->modules_)
527  {
528  module = mod_it.second;
529  if (!design->selected_module(module->name))
530  continue;
531  if (design->selected_whole_module(module->name)) {
532  if (module->get_bool_attribute("\\blackbox")) {
533  log("Skipping blackbox module %s.\n", id2cstr(module->name));
534  continue;
535  } else
536  if (module->cells_.empty() && module->connections().empty() && module->processes.empty()) {
537  log("Skipping empty module %s.\n", id2cstr(module->name));
538  continue;
539  } else
540  log("Dumping module %s to page %d.\n", id2cstr(module->name), ++page_counter);
541  } else
542  log("Dumping selected parts of module %s to page %d.\n", id2cstr(module->name), ++page_counter);
543  handle_module();
544  }
545  }
RTLIL::Module * module
Definition: show.cc:54
bool stretchIO
Definition: show.cc:58
void setup_stdcells()
Definition: celltypes.h:132
bool selected_module(RTLIL::IdString mod_name) const
Definition: rtlil.cc:379
RTLIL::Design * design
Definition: show.cc:53
void setup_internals_mem()
Definition: celltypes.h:115
const std::vector< RTLIL::SigSig > & connections() const
Definition: rtlil.cc:1307
const std::vector< std::pair< std::string, RTLIL::Selection > > & label_selections
Definition: show.cc:65
bool abbreviateIds
Definition: show.cc:60
int page_counter
Definition: show.cc:62
const std::vector< std::pair< std::string, RTLIL::Selection > > & color_selections
Definition: show.cc:64
bool notitle
Definition: show.cc:61
void optimize()
Definition: rtlil.cc:369
bool genWidthLabels
Definition: show.cc:56
RTLIL::IdString name
Definition: rtlil.h:599
bool selected_whole_module(RTLIL::IdString mod_name) const
Definition: rtlil.cc:388
static const char * id2cstr(const RTLIL::IdString &str)
Definition: rtlil.h:267
std::map< RTLIL::IdString, RTLIL::Process * > processes
Definition: rtlil.h:602
std::map< RTLIL::IdString, RTLIL::Module * > modules_
Definition: rtlil.h:507
std::map< RTLIL::IdString, RTLIL::Cell * > cells_
Definition: rtlil.h:596
bool enumerateIds
Definition: show.cc:59
FILE * f
Definition: show.cc:52
void log(const char *format,...)
Definition: log.cc:180
void setup_internals()
Definition: celltypes.h:83
void setup_design(RTLIL::Design *design)
Definition: celltypes.h:77
void setup_stdcells_mem()
Definition: celltypes.h:149
bool genSignedLabels
Definition: show.cc:57
void handle_module()
Definition: show.cc:304
CellTypes ct
Definition: show.cc:42
uint32_t currentColor
Definition: show.cc:55

+ Here is the call graph for this function:

Member Function Documentation

void ShowWorker::collect_proc_signals ( std::vector< RTLIL::SigSpec > &  obj,
std::set< RTLIL::SigSpec > &  signals 
)
inline

Definition at line 260 of file show.cc.

261  {
262  for (auto &it : obj)
263  if (!it.is_fully_const())
264  signals.insert(it);
265  }

+ Here is the caller graph for this function:

void ShowWorker::collect_proc_signals ( std::vector< RTLIL::SigSig > &  obj,
std::set< RTLIL::SigSpec > &  input_signals,
std::set< RTLIL::SigSpec > &  output_signals 
)
inline

Definition at line 267 of file show.cc.

268  {
269  for (auto &it : obj) {
270  output_signals.insert(it.first);
271  if (!it.second.is_fully_const())
272  input_signals.insert(it.second);
273  }
274  }
void ShowWorker::collect_proc_signals ( RTLIL::CaseRule obj,
std::set< RTLIL::SigSpec > &  input_signals,
std::set< RTLIL::SigSpec > &  output_signals 
)
inline

Definition at line 276 of file show.cc.

277  {
278  collect_proc_signals(obj->compare, input_signals);
279  collect_proc_signals(obj->actions, input_signals, output_signals);
280  for (auto it : obj->switches)
281  collect_proc_signals(it, input_signals, output_signals);
282  }
std::vector< RTLIL::SigSpec > compare
Definition: rtlil.h:1119
void collect_proc_signals(std::vector< RTLIL::SigSpec > &obj, std::set< RTLIL::SigSpec > &signals)
Definition: show.cc:260
std::vector< RTLIL::SigSig > actions
Definition: rtlil.h:1120
std::vector< RTLIL::SwitchRule * > switches
Definition: rtlil.h:1121

+ Here is the call graph for this function:

void ShowWorker::collect_proc_signals ( RTLIL::SwitchRule obj,
std::set< RTLIL::SigSpec > &  input_signals,
std::set< RTLIL::SigSpec > &  output_signals 
)
inline

Definition at line 284 of file show.cc.

285  {
286  input_signals.insert(obj->signal);
287  for (auto it : obj->cases)
288  collect_proc_signals(it, input_signals, output_signals);
289  }
RTLIL_ATTRIBUTE_MEMBERS std::vector< RTLIL::CaseRule * > cases
Definition: rtlil.h:1134
RTLIL::SigSpec signal
Definition: rtlil.h:1132
void collect_proc_signals(std::vector< RTLIL::SigSpec > &obj, std::set< RTLIL::SigSpec > &signals)
Definition: show.cc:260

+ Here is the call graph for this function:

void ShowWorker::collect_proc_signals ( RTLIL::SyncRule obj,
std::set< RTLIL::SigSpec > &  input_signals,
std::set< RTLIL::SigSpec > &  output_signals 
)
inline

Definition at line 291 of file show.cc.

292  {
293  input_signals.insert(obj->signal);
294  collect_proc_signals(obj->actions, input_signals, output_signals);
295  }
RTLIL::SigSpec signal
Definition: rtlil.h:1145
std::vector< RTLIL::SigSig > actions
Definition: rtlil.h:1146
void collect_proc_signals(std::vector< RTLIL::SigSpec > &obj, std::set< RTLIL::SigSpec > &signals)
Definition: show.cc:260

+ Here is the call graph for this function:

void ShowWorker::collect_proc_signals ( RTLIL::Process obj,
std::set< RTLIL::SigSpec > &  input_signals,
std::set< RTLIL::SigSpec > &  output_signals 
)
inline

Definition at line 297 of file show.cc.

298  {
299  collect_proc_signals(&obj->root_case, input_signals, output_signals);
300  for (auto it : obj->syncs)
301  collect_proc_signals(it, input_signals, output_signals);
302  }
std::vector< RTLIL::SyncRule * > syncs
Definition: rtlil.h:1157
void collect_proc_signals(std::vector< RTLIL::SigSpec > &obj, std::set< RTLIL::SigSpec > &signals)
Definition: show.cc:260
RTLIL_ATTRIBUTE_MEMBERS RTLIL::CaseRule root_case
Definition: rtlil.h:1156

+ Here is the call graph for this function:

const char* ShowWorker::escape ( std::string  id,
bool  is_name = false 
)
inline

Definition at line 142 of file show.cc.

143  {
144  if (id.size() == 0)
145  return "";
146 
147  if (id[0] == '$' && is_name) {
148  if (enumerateIds) {
149  if (autonames.count(id) == 0) {
150  autonames[id] = autonames.size() + 1;
151  log("Generated short name for internal identifier: _%d_ -> %s\n", autonames[id], id.c_str());
152  }
153  id = stringf("_%d_", autonames[id]);
154  } else if (abbreviateIds) {
155  const char *p = id.c_str();
156  const char *q = strrchr(p, '$');
157  id = std::string(q);
158  }
159  }
160 
161  if (id[0] == '\\')
162  id = id.substr(1);
163 
164  std::string str;
165  for (char ch : id) {
166  if (ch == '\\' || ch == '"')
167  str += "\\";
168  str += ch;
169  }
170 
171  dot_escape_store.push_back(str);
172  return dot_escape_store.back().c_str();
173  }
std::string stringf(const char *fmt,...)
Definition: yosys.cc:58
std::map< RTLIL::IdString, int > autonames
Definition: show.cc:46
bool abbreviateIds
Definition: show.cc:60
std::vector< std::string > dot_escape_store
Definition: show.cc:44
bool enumerateIds
Definition: show.cc:59
void log(const char *format,...)
Definition: log.cc:180
std::string id(RTLIL::IdString internal_id, bool may_rename=true)

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

const char* ShowWorker::findColor ( std::string  member_name)
inline

Definition at line 124 of file show.cc.

125  {
126  for (auto &s : color_selections)
127  if (s.second.selected_member(module->name, member_name)) {
128  dot_escape_store.push_back(stringf(", color=\"%s\"", s.first.c_str()));
129  return dot_escape_store.back().c_str();
130  }
131  return "";
132  }
RTLIL::Module * module
Definition: show.cc:54
std::string stringf(const char *fmt,...)
Definition: yosys.cc:58
const std::vector< std::pair< std::string, RTLIL::Selection > > & color_selections
Definition: show.cc:64
RTLIL::IdString name
Definition: rtlil.h:599
std::vector< std::string > dot_escape_store
Definition: show.cc:44

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

const char* ShowWorker::findLabel ( std::string  member_name)
inline

Definition at line 134 of file show.cc.

135  {
136  for (auto &s : label_selections)
137  if (s.second.selected_member(module->name, member_name))
138  return escape(s.first);
139  return escape(member_name, true);
140  }
RTLIL::Module * module
Definition: show.cc:54
const std::vector< std::pair< std::string, RTLIL::Selection > > & label_selections
Definition: show.cc:65
RTLIL::IdString name
Definition: rtlil.h:599
const char * escape(std::string id, bool is_name=false)
Definition: show.cc:142

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

std::string ShowWorker::gen_portbox ( std::string  port,
RTLIL::SigSpec  sig,
bool  driver,
std::string *  node = NULL 
)
inline

Definition at line 203 of file show.cc.

204  {
205  std::string code;
206  std::string net = gen_signode_simple(sig);
207  if (net.empty())
208  {
209  std::string label_string;
210  int pos = sig.size()-1;
211  int idx = single_idx_count++;
212  for (int rep, i = int(sig.chunks().size())-1; i >= 0; i -= rep) {
213  const RTLIL::SigChunk &c = sig.chunks().at(i);
214  net = gen_signode_simple(c, false);
215  log_assert(!net.empty());
216  for (rep = 1; i-rep >= 0 && c == sig.chunks().at(i-rep); rep++) {}
217  std::string repinfo = rep > 1 ? stringf("%dx ", rep) : "";
218  if (driver) {
219  label_string += stringf("<s%d> %d:%d - %s%d:%d |", i, pos, pos-c.width+1, repinfo.c_str(), c.offset+c.width-1, c.offset);
220  net_conn_map[net].in.insert(stringf("x%d:s%d", idx, i));
221  net_conn_map[net].bits = rep*c.width;
222  net_conn_map[net].color = nextColor(c, net_conn_map[net].color);
223  } else {
224  label_string += stringf("<s%d> %s%d:%d - %d:%d |", i, repinfo.c_str(), c.offset+c.width-1, c.offset, pos, pos-rep*c.width+1);
225  net_conn_map[net].out.insert(stringf("x%d:s%d", idx, i));
226  net_conn_map[net].bits = rep*c.width;
227  net_conn_map[net].color = nextColor(c, net_conn_map[net].color);
228  }
229  pos -= rep * c.width;
230  }
231  if (label_string[label_string.size()-1] == '|')
232  label_string = label_string.substr(0, label_string.size()-1);
233  code += stringf("x%d [ shape=record, style=rounded, label=\"%s\" ];\n", idx, label_string.c_str());
234  if (!port.empty()) {
236  if (driver)
237  code += stringf("%s:e -> x%d:w [arrowhead=odiamond, arrowtail=odiamond, dir=both, %s, %s];\n", port.c_str(), idx, nextColor(sig).c_str(), widthLabel(sig.size()).c_str());
238  else
239  code += stringf("x%d:e -> %s:w [arrowhead=odiamond, arrowtail=odiamond, dir=both, %s, %s];\n", idx, port.c_str(), nextColor(sig).c_str(), widthLabel(sig.size()).c_str());
240  }
241  if (node != NULL)
242  *node = stringf("x%d", idx);
243  }
244  else
245  {
246  if (!port.empty()) {
247  if (driver)
248  net_conn_map[net].in.insert(port);
249  else
250  net_conn_map[net].out.insert(port);
251  net_conn_map[net].bits = sig.size();
252  net_conn_map[net].color = nextColor(sig, net_conn_map[net].color);
253  }
254  if (node != NULL)
255  *node = net;
256  }
257  return code;
258  }
std::string stringf(const char *fmt,...)
Definition: yosys.cc:58
std::string gen_signode_simple(RTLIL::SigSpec sig, bool range_check=true)
Definition: show.cc:182
static std::string idx(std::string str)
Definition: test_autotb.cc:57
std::map< std::string, net_conn > net_conn_map
Definition: show.cc:50
int size() const
Definition: rtlil.h:1019
#define log_assert(_assert_expr_)
Definition: log.h:85
static uint32_t xorshift32(uint32_t x)
Definition: show.cc:67
#define NULL
std::string widthLabel(int bits)
Definition: show.cc:115
int single_idx_count
Definition: show.cc:47
uint32_t currentColor
Definition: show.cc:55
const std::vector< RTLIL::SigChunk > & chunks() const
Definition: rtlil.h:1016
std::string nextColor()
Definition: show.cc:74

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

std::string ShowWorker::gen_signode_simple ( RTLIL::SigSpec  sig,
bool  range_check = true 
)
inline

Definition at line 182 of file show.cc.

183  {
184  if (GetSize(sig) == 0) {
185  fprintf(f, "v%d [ label=\"\" ];\n", single_idx_count);
186  return stringf("v%d", single_idx_count++);
187  }
188 
189  if (sig.is_chunk()) {
190  const RTLIL::SigChunk &c = sig.as_chunk();
191  if (c.wire != NULL && design->selected_member(module->name, c.wire->name)) {
192  if (!range_check || c.wire->width == c.width)
193  return stringf("n%d", id2num(c.wire->name));
194  } else {
195  fprintf(f, "v%d [ label=\"%s\" ];\n", single_idx_count, findLabel(log_signal(c)));
196  return stringf("v%d", single_idx_count++);
197  }
198  }
199 
200  return std::string();
201  }
RTLIL::Module * module
Definition: show.cc:54
std::string stringf(const char *fmt,...)
Definition: yosys.cc:58
RTLIL::Design * design
Definition: show.cc:53
const char * log_signal(const RTLIL::SigSpec &sig, bool autoint)
Definition: log.cc:269
int width
Definition: rtlil.h:826
const char * findLabel(std::string member_name)
Definition: show.cc:134
bool selected_member(RTLIL::IdString mod_name, RTLIL::IdString memb_name) const
Definition: rtlil.cc:397
RTLIL::Wire * wire
Definition: rtlil.h:885
bool is_chunk() const
Definition: rtlil.cc:2755
int GetSize(RTLIL::Wire *wire)
Definition: yosys.cc:334
RTLIL::IdString name
Definition: rtlil.h:599
RTLIL::SigChunk as_chunk() const
Definition: rtlil.cc:2877
RTLIL::IdString name
Definition: rtlil.h:825
#define NULL
FILE * f
Definition: show.cc:52
int single_idx_count
Definition: show.cc:47
int id2num(RTLIL::IdString id)
Definition: show.cc:175

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void ShowWorker::handle_module ( )
inline

Definition at line 304 of file show.cc.

305  {
306  single_idx_count = 0;
307  dot_escape_store.clear();
308  dot_id2num_store.clear();
309  net_conn_map.clear();
310 
311  fprintf(f, "digraph \"%s\" {\n", escape(module->name.str()));
312  if (!notitle)
313  fprintf(f, "label=\"%s\";\n", escape(module->name.str()));
314  fprintf(f, "rankdir=\"LR\";\n");
315  fprintf(f, "remincross=true;\n");
316 
317  std::set<std::string> all_sources, all_sinks;
318 
319  std::map<std::string, std::string> wires_on_demand;
320  for (auto &it : module->wires_) {
321  if (!design->selected_member(module->name, it.first))
322  continue;
323  const char *shape = "diamond";
324  if (it.second->port_input || it.second->port_output)
325  shape = "octagon";
326  if (it.first[0] == '\\') {
327  fprintf(f, "n%d [ shape=%s, label=\"%s\", %s, fontcolor=\"black\" ];\n",
328  id2num(it.first), shape, findLabel(it.first.str()),
329  nextColor(RTLIL::SigSpec(it.second), "color=\"black\"").c_str());
330  if (it.second->port_input)
331  all_sources.insert(stringf("n%d", id2num(it.first)));
332  else if (it.second->port_output)
333  all_sinks.insert(stringf("n%d", id2num(it.first)));
334  } else {
335  wires_on_demand[stringf("n%d", id2num(it.first))] = it.first.str();
336  }
337  }
338 
339  if (stretchIO)
340  {
341  fprintf(f, "{ rank=\"source\";");
342  for (auto n : all_sources)
343  fprintf(f, " %s;", n.c_str());
344  fprintf(f, "}\n");
345 
346  fprintf(f, "{ rank=\"sink\";");
347  for (auto n : all_sinks)
348  fprintf(f, " %s;", n.c_str());
349  fprintf(f, "}\n");
350  }
351 
352  for (auto &it : module->cells_)
353  {
354  if (!design->selected_member(module->name, it.first))
355  continue;
356 
357  std::vector<RTLIL::IdString> in_ports, out_ports;
358 
359  for (auto &conn : it.second->connections()) {
360  if (!ct.cell_output(it.second->type, conn.first))
361  in_ports.push_back(conn.first);
362  else
363  out_ports.push_back(conn.first);
364  }
365 
366  std::sort(in_ports.begin(), in_ports.end(), RTLIL::sort_by_id_str());
367  std::sort(out_ports.begin(), out_ports.end(), RTLIL::sort_by_id_str());
368 
369  std::string label_string = "{{";
370 
371  for (auto &p : in_ports)
372  label_string += stringf("<p%d> %s%s|", id2num(p), escape(p.str()),
373  genSignedLabels && it.second->hasParam(p.str() + "_SIGNED") &&
374  it.second->getParam(p.str() + "_SIGNED").as_bool() ? "*" : "");
375  if (label_string[label_string.size()-1] == '|')
376  label_string = label_string.substr(0, label_string.size()-1);
377 
378  label_string += stringf("}|%s\\n%s|{", findLabel(it.first.str()), escape(it.second->type.str()));
379 
380  for (auto &p : out_ports)
381  label_string += stringf("<p%d> %s|", id2num(p), escape(p.str()));
382  if (label_string[label_string.size()-1] == '|')
383  label_string = label_string.substr(0, label_string.size()-1);
384 
385  label_string += "}}";
386 
387  std::string code;
388  for (auto &conn : it.second->connections()) {
389  code += gen_portbox(stringf("c%d:p%d", id2num(it.first), id2num(conn.first)),
390  conn.second, ct.cell_output(it.second->type, conn.first));
391  }
392 
393 #ifdef CLUSTER_CELLS_AND_PORTBOXES
394  if (!code.empty())
395  fprintf(f, "subgraph cluster_c%d {\nc%d [ shape=record, label=\"%s\"%s ];\n%s}\n",
396  id2num(it.first), id2num(it.first), label_string.c_str(), findColor(it.first), code.c_str());
397  else
398 #endif
399  fprintf(f, "c%d [ shape=record, label=\"%s\"%s ];\n%s",
400  id2num(it.first), label_string.c_str(), findColor(it.first.str()), code.c_str());
401  }
402 
403  for (auto &it : module->processes)
404  {
405  RTLIL::Process *proc = it.second;
406 
407  if (!design->selected_member(module->name, proc->name))
408  continue;
409 
410  std::set<RTLIL::SigSpec> input_signals, output_signals;
411  collect_proc_signals(proc, input_signals, output_signals);
412 
413  int pidx = single_idx_count++;
414  input_signals.erase(RTLIL::SigSpec());
415  output_signals.erase(RTLIL::SigSpec());
416 
417  for (auto &sig : input_signals) {
418  std::string code, node;
419  code += gen_portbox("", sig, false, &node);
420  fprintf(f, "%s", code.c_str());
421  net_conn_map[node].out.insert(stringf("p%d", pidx));
422  net_conn_map[node].bits = sig.size();
423  net_conn_map[node].color = nextColor(sig, net_conn_map[node].color);
424  }
425 
426  for (auto &sig : output_signals) {
427  std::string code, node;
428  code += gen_portbox("", sig, true, &node);
429  fprintf(f, "%s", code.c_str());
430  net_conn_map[node].in.insert(stringf("p%d", pidx));
431  net_conn_map[node].bits = sig.size();
432  net_conn_map[node].color = nextColor(sig, net_conn_map[node].color);
433  }
434 
435  std::string proc_src = RTLIL::unescape_id(proc->name);
436  if (proc->attributes.count("\\src") > 0)
437  proc_src = proc->attributes.at("\\src").decode_string();
438  fprintf(f, "p%d [shape=box, style=rounded, label=\"PROC %s\\n%s\"];\n", pidx, findLabel(proc->name.str()), proc_src.c_str());
439  }
440 
441  for (auto &conn : module->connections())
442  {
443  bool found_lhs_wire = false;
444  for (auto &c : conn.first.chunks()) {
445  if (c.wire == NULL || design->selected_member(module->name, c.wire->name))
446  found_lhs_wire = true;
447  }
448  bool found_rhs_wire = false;
449  for (auto &c : conn.second.chunks()) {
450  if (c.wire == NULL || design->selected_member(module->name, c.wire->name))
451  found_rhs_wire = true;
452  }
453  if (!found_lhs_wire || !found_rhs_wire)
454  continue;
455 
456  std::string code, left_node, right_node;
457  code += gen_portbox("", conn.second, false, &left_node);
458  code += gen_portbox("", conn.first, true, &right_node);
459  fprintf(f, "%s", code.c_str());
460 
461  if (left_node[0] == 'x' && right_node[0] == 'x') {
463  fprintf(f, "%s:e -> %s:w [arrowhead=odiamond, arrowtail=odiamond, dir=both, %s, %s];\n", left_node.c_str(), right_node.c_str(), nextColor(conn).c_str(), widthLabel(conn.first.size()).c_str());
464  } else {
465  net_conn_map[right_node].bits = conn.first.size();
466  net_conn_map[right_node].color = nextColor(conn, net_conn_map[right_node].color);
467  net_conn_map[left_node].bits = conn.first.size();
468  net_conn_map[left_node].color = nextColor(conn, net_conn_map[left_node].color);
469  if (left_node[0] == 'x') {
470  net_conn_map[right_node].in.insert(left_node);
471  } else if (right_node[0] == 'x') {
472  net_conn_map[left_node].out.insert(right_node);
473  } else {
474  net_conn_map[right_node].in.insert(stringf("x%d:e", single_idx_count));
475  net_conn_map[left_node].out.insert(stringf("x%d:w", single_idx_count));
476  fprintf(f, "x%d [shape=box, style=rounded, label=\"BUF\"];\n", single_idx_count++);
477  }
478  }
479  }
480 
481  for (auto &it : net_conn_map)
482  {
484  if (wires_on_demand.count(it.first) > 0) {
485  if (it.second.in.size() == 1 && it.second.out.size() > 1 && it.second.in.begin()->substr(0, 1) == "p")
486  it.second.out.erase(*it.second.in.begin());
487  if (it.second.in.size() == 1 && it.second.out.size() == 1) {
488  std::string from = *it.second.in.begin(), to = *it.second.out.begin();
489  if (from != to || from.substr(0, 1) != "p")
490  fprintf(f, "%s:e -> %s:w [%s, %s];\n", from.c_str(), to.c_str(), nextColor(it.second.color).c_str(), widthLabel(it.second.bits).c_str());
491  continue;
492  }
493  if (it.second.in.size() == 0 || it.second.out.size() == 0)
494  fprintf(f, "%s [ shape=diamond, label=\"%s\" ];\n", it.first.c_str(), findLabel(wires_on_demand[it.first]));
495  else
496  fprintf(f, "%s [ shape=point ];\n", it.first.c_str());
497  }
498  for (auto &it2 : it.second.in)
499  fprintf(f, "%s:e -> %s:w [%s, %s];\n", it2.c_str(), it.first.c_str(), nextColor(it.second.color).c_str(), widthLabel(it.second.bits).c_str());
500  for (auto &it2 : it.second.out)
501  fprintf(f, "%s:e -> %s:w [%s, %s];\n", it.first.c_str(), it2.c_str(), nextColor(it.second.color).c_str(), widthLabel(it.second.bits).c_str());
502  }
503 
504  fprintf(f, "}\n");
505  }
RTLIL::Module * module
Definition: show.cc:54
std::string str() const
Definition: rtlil.h:182
bool stretchIO
Definition: show.cc:58
std::string stringf(const char *fmt,...)
Definition: yosys.cc:58
void sort(T *array, int size, LessThan lt)
Definition: Sort.h:57
RTLIL::Design * design
Definition: show.cc:53
const std::vector< RTLIL::SigSig > & connections() const
Definition: rtlil.cc:1307
std::map< RTLIL::IdString, int > dot_id2num_store
Definition: show.cc:45
std::map< RTLIL::IdString, RTLIL::Wire * > wires_
Definition: rtlil.h:595
static std::string unescape_id(std::string str)
Definition: rtlil.h:257
const char * findColor(std::string member_name)
Definition: show.cc:124
std::map< std::string, net_conn > net_conn_map
Definition: show.cc:50
const char * findLabel(std::string member_name)
Definition: show.cc:134
bool selected_member(RTLIL::IdString mod_name, RTLIL::IdString memb_name) const
Definition: rtlil.cc:397
tuple n
Definition: fsm/generate.py:59
bool notitle
Definition: show.cc:61
bool cell_output(RTLIL::IdString type, RTLIL::IdString port)
Definition: celltypes.h:193
RTLIL::IdString name
Definition: rtlil.h:599
const char * escape(std::string id, bool is_name=false)
Definition: show.cc:142
std::vector< std::string > dot_escape_store
Definition: show.cc:44
static uint32_t xorshift32(uint32_t x)
Definition: show.cc:67
RTLIL::IdString name
Definition: rtlil.h:1154
std::map< RTLIL::IdString, RTLIL::Process * > processes
Definition: rtlil.h:602
#define NULL
std::map< RTLIL::IdString, RTLIL::Cell * > cells_
Definition: rtlil.h:596
FILE * f
Definition: show.cc:52
void collect_proc_signals(std::vector< RTLIL::SigSpec > &obj, std::set< RTLIL::SigSpec > &signals)
Definition: show.cc:260
std::string widthLabel(int bits)
Definition: show.cc:115
std::string gen_portbox(std::string port, RTLIL::SigSpec sig, bool driver, std::string *node=NULL)
Definition: show.cc:203
int single_idx_count
Definition: show.cc:47
int id2num(RTLIL::IdString id)
Definition: show.cc:175
bool genSignedLabels
Definition: show.cc:57
CellTypes ct
Definition: show.cc:42
uint32_t currentColor
Definition: show.cc:55
std::string nextColor()
Definition: show.cc:74

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

int ShowWorker::id2num ( RTLIL::IdString  id)
inline

Definition at line 175 of file show.cc.

176  {
177  if (dot_id2num_store.count(id) > 0)
178  return dot_id2num_store[id];
179  return dot_id2num_store[id] = dot_id2num_store.size() + 1;
180  }
std::map< RTLIL::IdString, int > dot_id2num_store
Definition: show.cc:45
std::string id(RTLIL::IdString internal_id, bool may_rename=true)

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

std::string ShowWorker::nextColor ( )
inline

Definition at line 74 of file show.cc.

75  {
76  if (currentColor == 0)
77  return "color=\"black\"";
78  return stringf("colorscheme=\"dark28\", color=\"%d\", fontcolor=\"%d\"", currentColor%8+1, currentColor%8+1);
79  }
std::string stringf(const char *fmt,...)
Definition: yosys.cc:58
uint32_t currentColor
Definition: show.cc:55

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

std::string ShowWorker::nextColor ( std::string  presetColor)
inline

Definition at line 81 of file show.cc.

82  {
83  if (presetColor.empty())
84  return nextColor();
85  return presetColor;
86  }
std::string nextColor()
Definition: show.cc:74

+ Here is the call graph for this function:

std::string ShowWorker::nextColor ( RTLIL::SigSpec  sig,
std::string  defaultColor 
)
inline

Definition at line 88 of file show.cc.

89  {
90  sig.sort_and_unify();
91  for (auto &c : sig.chunks()) {
92  if (c.wire != NULL)
93  for (auto &s : color_selections)
94  if (s.second.selected_members.count(module->name) > 0 && s.second.selected_members.at(module->name).count(c.wire->name) > 0)
95  return stringf("color=\"%s\"", s.first.c_str());
96  }
97  return defaultColor;
98  }
RTLIL::Module * module
Definition: show.cc:54
std::string stringf(const char *fmt,...)
Definition: yosys.cc:58
const std::vector< std::pair< std::string, RTLIL::Selection > > & color_selections
Definition: show.cc:64
RTLIL::IdString name
Definition: rtlil.h:599
void sort_and_unify()
Definition: rtlil.cc:2291
#define NULL
const std::vector< RTLIL::SigChunk > & chunks() const
Definition: rtlil.h:1016

+ Here is the call graph for this function:

std::string ShowWorker::nextColor ( const RTLIL::SigSig conn,
std::string  defaultColor 
)
inline

Definition at line 100 of file show.cc.

101  {
102  return nextColor(conn.first, nextColor(conn.second, defaultColor));
103  }
std::string nextColor()
Definition: show.cc:74

+ Here is the call graph for this function:

std::string ShowWorker::nextColor ( const RTLIL::SigSpec sig)
inline

Definition at line 105 of file show.cc.

106  {
107  return nextColor(sig, nextColor());
108  }
std::string nextColor()
Definition: show.cc:74

+ Here is the call graph for this function:

std::string ShowWorker::nextColor ( const RTLIL::SigSig conn)
inline

Definition at line 110 of file show.cc.

111  {
112  return nextColor(conn, nextColor());
113  }
std::string nextColor()
Definition: show.cc:74

+ Here is the call graph for this function:

std::string ShowWorker::widthLabel ( int  bits)
inline

Definition at line 115 of file show.cc.

116  {
117  if (bits <= 1)
118  return "label=\"\"";
119  if (!genWidthLabels)
120  return "style=\"setlinewidth(3)\", label=\"\"";
121  return stringf("style=\"setlinewidth(3)\", label=\"<%d>\"", bits);
122  }
std::string stringf(const char *fmt,...)
Definition: yosys.cc:58
bool genWidthLabels
Definition: show.cc:56

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static uint32_t ShowWorker::xorshift32 ( uint32_t  x)
inlinestatic

Definition at line 67 of file show.cc.

67  {
68  x ^= x << 13;
69  x ^= x >> 17;
70  x ^= x << 5;
71  return x;
72  }

+ Here is the caller graph for this function:

Field Documentation

bool ShowWorker::abbreviateIds

Definition at line 60 of file show.cc.

std::map<RTLIL::IdString, int> ShowWorker::autonames

Definition at line 46 of file show.cc.

const std::vector<std::pair<std::string, RTLIL::Selection> >& ShowWorker::color_selections

Definition at line 64 of file show.cc.

CellTypes ShowWorker::ct

Definition at line 42 of file show.cc.

uint32_t ShowWorker::currentColor

Definition at line 55 of file show.cc.

RTLIL::Design* ShowWorker::design

Definition at line 53 of file show.cc.

std::vector<std::string> ShowWorker::dot_escape_store

Definition at line 44 of file show.cc.

std::map<RTLIL::IdString, int> ShowWorker::dot_id2num_store

Definition at line 45 of file show.cc.

bool ShowWorker::enumerateIds

Definition at line 59 of file show.cc.

FILE* ShowWorker::f

Definition at line 52 of file show.cc.

bool ShowWorker::genSignedLabels

Definition at line 57 of file show.cc.

bool ShowWorker::genWidthLabels

Definition at line 56 of file show.cc.

const std::vector<std::pair<std::string, RTLIL::Selection> >& ShowWorker::label_selections

Definition at line 65 of file show.cc.

RTLIL::Module* ShowWorker::module

Definition at line 54 of file show.cc.

std::map<std::string, net_conn> ShowWorker::net_conn_map

Definition at line 50 of file show.cc.

bool ShowWorker::notitle

Definition at line 61 of file show.cc.

int ShowWorker::page_counter

Definition at line 62 of file show.cc.

int ShowWorker::single_idx_count

Definition at line 47 of file show.cc.

bool ShowWorker::stretchIO

Definition at line 58 of file show.cc.


The documentation for this struct was generated from the following file: