yosys-master
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
verific.cc
Go to the documentation of this file.
1 /*
2  * yosys -- Yosys Open SYnthesis Suite
3  *
4  * Copyright (C) 2012 Clifford Wolf <clifford@clifford.at>
5  *
6  * Permission to use, copy, modify, and/or distribute this software for any
7  * purpose with or without fee is hereby granted, provided that the above
8  * copyright notice and this permission notice appear in all copies.
9  *
10  * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
11  * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
12  * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
13  * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
14  * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
15  * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
16  * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
17  *
18  */
19 
20 #include "kernel/yosys.h"
21 #include "kernel/sigtools.h"
22 #include "kernel/log.h"
23 #include <stdlib.h>
24 #include <stdio.h>
25 #include <string.h>
26 
27 #ifndef _WIN32
28 # include <unistd.h>
29 # include <dirent.h>
30 #endif
31 
33 
34 #ifdef YOSYS_ENABLE_VERIFIC
35 
36 #pragma clang diagnostic push
37 #pragma clang diagnostic ignored "-Woverloaded-virtual"
38 
39 #include "veri_file.h"
40 #include "vhdl_file.h"
41 #include "VeriModule.h"
42 #include "VhdlUnits.h"
43 #include "DataBase.h"
44 #include "Message.h"
45 
46 #pragma clang diagnostic pop
47 
48 #ifdef VERIFIC_NAMESPACE
49 using namespace Verific ;
50 #endif
51 
52 static void msg_func(msg_type_t msg_type, const char *message_id, linefile_type linefile, const char *msg, va_list args)
53 {
54  log("VERIFIC-%s [%s] ",
55  msg_type == VERIFIC_NONE ? "NONE" :
56  msg_type == VERIFIC_ERROR ? "ERROR" :
57  msg_type == VERIFIC_WARNING ? "WARNING" :
58  msg_type == VERIFIC_IGNORE ? "IGNORE" :
59  msg_type == VERIFIC_INFO ? "INFO" :
60  msg_type == VERIFIC_COMMENT ? "COMMENT" :
61  msg_type == VERIFIC_PROGRAM_ERROR ? "PROGRAM_ERROR" : "UNKNOWN", message_id);
62  if (linefile)
63  log("%s:%d: ", LineFile::GetFileName(linefile), LineFile::GetLineNo(linefile));
64  logv(msg, args);
65  log("\n");
66 }
67 
68 static void import_attributes(std::map<RTLIL::IdString, RTLIL::Const> &attributes, DesignObj *obj)
69 {
70  MapIter mi;
71  Att *attr;
72 
73  if (obj->Linefile())
74  attributes["\\src"] = stringf("%s:%d", LineFile::GetFileName(obj->Linefile()), LineFile::GetLineNo(obj->Linefile()));
75 
76  // FIXME: Parse numeric attributes
77  FOREACH_ATTRIBUTE(obj, mi, attr)
78  attributes[RTLIL::escape_id(attr->Key())] = RTLIL::Const(std::string(attr->Value()));
79 }
80 
81 static RTLIL::SigSpec operatorInput(Instance *inst, std::map<Net*, RTLIL::SigBit> &net_map)
82 {
83  RTLIL::SigSpec sig;
84  for (int i = int(inst->InputSize())-1; i >= 0; i--)
85  if (inst->GetInputBit(i))
86  sig.append(net_map.at(inst->GetInputBit(i)));
87  else
89  return sig;
90 }
91 
92 static RTLIL::SigSpec operatorInput1(Instance *inst, std::map<Net*, RTLIL::SigBit> &net_map)
93 {
94  RTLIL::SigSpec sig;
95  for (int i = int(inst->Input1Size())-1; i >= 0; i--)
96  if (inst->GetInput1Bit(i))
97  sig.append(net_map.at(inst->GetInput1Bit(i)));
98  else
100  return sig;
101 }
102 
103 static RTLIL::SigSpec operatorInput2(Instance *inst, std::map<Net*, RTLIL::SigBit> &net_map)
104 {
105  RTLIL::SigSpec sig;
106  for (int i = int(inst->Input2Size())-1; i >= 0; i--)
107  if (inst->GetInput2Bit(i))
108  sig.append(net_map.at(inst->GetInput2Bit(i)));
109  else
111  return sig;
112 }
113 
114 static RTLIL::SigSpec operatorInport(Instance *inst, const char *portname, std::map<Net*, RTLIL::SigBit> &net_map)
115 {
116  PortBus *portbus = inst->View()->GetPortBus(portname);
117  if (portbus) {
118  RTLIL::SigSpec sig;
119  for (unsigned i = 0; i < portbus->Size(); i++) {
120  Net *net = inst->GetNet(portbus->ElementAtIndex(i));
121  if (net) {
122  if (net->IsGnd())
124  else if (net->IsPwr())
126  else
127  sig.append(net_map.at(net));
128  } else
130  }
131  return sig;
132  } else {
133  Port *port = inst->View()->GetPort(portname);
134  log_assert(port != NULL);
135  Net *net = inst->GetNet(port);
136  return net_map.at(net);
137  }
138 }
139 
140 static RTLIL::SigSpec operatorOutput(Instance *inst, std::map<Net*, RTLIL::SigBit> &net_map, RTLIL::Module *module)
141 {
142  RTLIL::SigSpec sig;
143  RTLIL::Wire *dummy_wire = NULL;
144  for (int i = int(inst->OutputSize())-1; i >= 0; i--)
145  if (inst->GetOutputBit(i)) {
146  sig.append(net_map.at(inst->GetOutputBit(i)));
147  dummy_wire = NULL;
148  } else {
149  if (dummy_wire == NULL)
150  dummy_wire = module->addWire(NEW_ID);
151  else
152  dummy_wire->width++;
153  sig.append(RTLIL::SigSpec(dummy_wire, dummy_wire->width - 1));
154  }
155  return sig;
156 }
157 
158 static bool import_netlist_instance_gates(RTLIL::Module *module, std::map<Net*, RTLIL::SigBit> &net_map, Instance *inst)
159 {
160  if (inst->Type() == PRIM_AND) {
161  module->addAndGate(RTLIL::escape_id(inst->Name()), net_map.at(inst->GetInput1()), net_map.at(inst->GetInput2()), net_map.at(inst->GetOutput()));
162  return true;
163  }
164 
165  if (inst->Type() == PRIM_NAND) {
166  RTLIL::SigSpec tmp = module->addWire(NEW_ID);
167  module->addAndGate(NEW_ID, net_map.at(inst->GetInput1()), net_map.at(inst->GetInput2()), tmp);
168  module->addNotGate(RTLIL::escape_id(inst->Name()), tmp, net_map.at(inst->GetOutput()));
169  return true;
170  }
171 
172  if (inst->Type() == PRIM_OR) {
173  module->addOrGate(RTLIL::escape_id(inst->Name()), net_map.at(inst->GetInput1()), net_map.at(inst->GetInput2()), net_map.at(inst->GetOutput()));
174  return true;
175  }
176 
177  if (inst->Type() == PRIM_NOR) {
178  RTLIL::SigSpec tmp = module->addWire(NEW_ID);
179  module->addOrGate(NEW_ID, net_map.at(inst->GetInput1()), net_map.at(inst->GetInput2()), tmp);
180  module->addNotGate(RTLIL::escape_id(inst->Name()), tmp, net_map.at(inst->GetOutput()));
181  return true;
182  }
183 
184  if (inst->Type() == PRIM_XOR) {
185  module->addXorGate(RTLIL::escape_id(inst->Name()), net_map.at(inst->GetInput1()), net_map.at(inst->GetInput2()), net_map.at(inst->GetOutput()));
186  return true;
187  }
188 
189  if (inst->Type() == PRIM_INV) {
190  module->addNotGate(RTLIL::escape_id(inst->Name()), net_map.at(inst->GetInput()), net_map.at(inst->GetOutput()));
191  return true;
192  }
193 
194  if (inst->Type() == PRIM_MUX) {
195  module->addMuxGate(RTLIL::escape_id(inst->Name()), net_map.at(inst->GetInput1()), net_map.at(inst->GetInput2()), net_map.at(inst->GetControl()), net_map.at(inst->GetOutput()));
196  return true;
197  }
198 
199  if (inst->Type() == PRIM_TRI) {
200  module->addMuxGate(RTLIL::escape_id(inst->Name()), RTLIL::State::Sz, net_map.at(inst->GetInput()), net_map.at(inst->GetControl()), net_map.at(inst->GetOutput()));
201  return true;
202  }
203 
204  if (inst->Type() == PRIM_FADD)
205  {
206  RTLIL::SigSpec a = net_map.at(inst->GetInput1()), b = net_map.at(inst->GetInput2()), c = net_map.at(inst->GetCin());
207  RTLIL::SigSpec x = inst->GetCout() ? net_map.at(inst->GetCout()) : module->addWire(NEW_ID);
208  RTLIL::SigSpec y = inst->GetOutput() ? net_map.at(inst->GetOutput()) : module->addWire(NEW_ID);
209  RTLIL::SigSpec tmp1 = module->addWire(NEW_ID);
210  RTLIL::SigSpec tmp2 = module->addWire(NEW_ID);
211  RTLIL::SigSpec tmp3 = module->addWire(NEW_ID);
212  module->addXorGate(NEW_ID, a, b, tmp1);
213  module->addXorGate(RTLIL::escape_id(inst->Name()), tmp1, c, y);
214  module->addAndGate(NEW_ID, tmp1, c, tmp2);
215  module->addAndGate(NEW_ID, a, b, tmp3);
216  module->addOrGate(NEW_ID, tmp2, tmp3, x);
217  return true;
218  }
219 
220  if (inst->Type() == PRIM_DFFRS)
221  {
222  if (inst->GetSet()->IsGnd() && inst->GetReset()->IsGnd())
223  module->addDffGate(RTLIL::escape_id(inst->Name()), net_map.at(inst->GetClock()), net_map.at(inst->GetInput()), net_map.at(inst->GetOutput()));
224  else if (inst->GetSet()->IsGnd())
225  module->addAdffGate(RTLIL::escape_id(inst->Name()), net_map.at(inst->GetClock()), net_map.at(inst->GetReset()),
226  net_map.at(inst->GetInput()), net_map.at(inst->GetOutput()), false);
227  else if (inst->GetReset()->IsGnd())
228  module->addAdffGate(RTLIL::escape_id(inst->Name()), net_map.at(inst->GetClock()), net_map.at(inst->GetSet()),
229  net_map.at(inst->GetInput()), net_map.at(inst->GetOutput()), true);
230  else
231  module->addDffsrGate(RTLIL::escape_id(inst->Name()), net_map.at(inst->GetClock()), net_map.at(inst->GetSet()), net_map.at(inst->GetReset()),
232  net_map.at(inst->GetInput()), net_map.at(inst->GetOutput()));
233  return true;
234  }
235 
236  return false;
237 }
238 
239 static bool import_netlist_instance_cells(RTLIL::Module *module, std::map<Net*, RTLIL::SigBit> &net_map, Instance *inst)
240 {
241  if (inst->Type() == PRIM_AND) {
242  module->addAnd(RTLIL::escape_id(inst->Name()), net_map.at(inst->GetInput1()), net_map.at(inst->GetInput2()), net_map.at(inst->GetOutput()));
243  return true;
244  }
245 
246  if (inst->Type() == PRIM_NAND) {
247  RTLIL::SigSpec tmp = module->addWire(NEW_ID);
248  module->addAnd(NEW_ID, net_map.at(inst->GetInput1()), net_map.at(inst->GetInput2()), tmp);
249  module->addNot(RTLIL::escape_id(inst->Name()), tmp, net_map.at(inst->GetOutput()));
250  return true;
251  }
252 
253  if (inst->Type() == PRIM_OR) {
254  module->addOr(RTLIL::escape_id(inst->Name()), net_map.at(inst->GetInput1()), net_map.at(inst->GetInput2()), net_map.at(inst->GetOutput()));
255  return true;
256  }
257 
258  if (inst->Type() == PRIM_NOR) {
259  RTLIL::SigSpec tmp = module->addWire(NEW_ID);
260  module->addOr(NEW_ID, net_map.at(inst->GetInput1()), net_map.at(inst->GetInput2()), tmp);
261  module->addNot(RTLIL::escape_id(inst->Name()), tmp, net_map.at(inst->GetOutput()));
262  return true;
263  }
264 
265  if (inst->Type() == PRIM_XOR) {
266  module->addXor(RTLIL::escape_id(inst->Name()), net_map.at(inst->GetInput1()), net_map.at(inst->GetInput2()), net_map.at(inst->GetOutput()));
267  return true;
268  }
269 
270  if (inst->Type() == PRIM_XNOR) {
271  module->addXnor(RTLIL::escape_id(inst->Name()), net_map.at(inst->GetInput1()), net_map.at(inst->GetInput2()), net_map.at(inst->GetOutput()));
272  return true;
273  }
274 
275  if (inst->Type() == PRIM_INV) {
276  module->addNot(RTLIL::escape_id(inst->Name()), net_map.at(inst->GetInput()), net_map.at(inst->GetOutput()));
277  return true;
278  }
279 
280  if (inst->Type() == PRIM_MUX) {
281  module->addMux(RTLIL::escape_id(inst->Name()), net_map.at(inst->GetInput1()), net_map.at(inst->GetInput2()), net_map.at(inst->GetControl()), net_map.at(inst->GetOutput()));
282  return true;
283  }
284 
285  if (inst->Type() == PRIM_TRI) {
286  module->addMux(RTLIL::escape_id(inst->Name()), RTLIL::State::Sz, net_map.at(inst->GetInput()), net_map.at(inst->GetControl()), net_map.at(inst->GetOutput()));
287  return true;
288  }
289 
290  if (inst->Type() == PRIM_FADD)
291  {
292  RTLIL::SigSpec a_plus_b = module->addWire(NEW_ID, 2);
293  RTLIL::SigSpec y = inst->GetOutput() ? net_map.at(inst->GetOutput()) : module->addWire(NEW_ID);
294  if (inst->GetCout())
295  y.append(net_map.at(inst->GetCout()));
296  module->addAdd(NEW_ID, net_map.at(inst->GetInput1()), net_map.at(inst->GetInput2()), a_plus_b);
297  module->addAdd(RTLIL::escape_id(inst->Name()), a_plus_b, net_map.at(inst->GetCin()), y);
298  return true;
299  }
300 
301  if (inst->Type() == PRIM_DFFRS)
302  {
303  if (inst->GetSet()->IsGnd() && inst->GetReset()->IsGnd())
304  module->addDff(RTLIL::escape_id(inst->Name()), net_map.at(inst->GetClock()), net_map.at(inst->GetInput()), net_map.at(inst->GetOutput()));
305  else if (inst->GetSet()->IsGnd())
306  module->addAdff(RTLIL::escape_id(inst->Name()), net_map.at(inst->GetClock()), net_map.at(inst->GetReset()),
307  net_map.at(inst->GetInput()), net_map.at(inst->GetOutput()), RTLIL::State::S0);
308  else if (inst->GetReset()->IsGnd())
309  module->addAdff(RTLIL::escape_id(inst->Name()), net_map.at(inst->GetClock()), net_map.at(inst->GetSet()),
310  net_map.at(inst->GetInput()), net_map.at(inst->GetOutput()), RTLIL::State::S1);
311  else
312  module->addDffsr(RTLIL::escape_id(inst->Name()), net_map.at(inst->GetClock()), net_map.at(inst->GetSet()), net_map.at(inst->GetReset()),
313  net_map.at(inst->GetInput()), net_map.at(inst->GetOutput()));
314  return true;
315  }
316 
317  #define IN operatorInput(inst, net_map)
318  #define IN1 operatorInput1(inst, net_map)
319  #define IN2 operatorInput2(inst, net_map)
320  #define OUT operatorOutput(inst, net_map, module)
321  #define SIGNED inst->View()->IsSigned()
322 
323  if (inst->Type() == OPER_ADDER) {
324  RTLIL::SigSpec out = OUT;
325  if (inst->GetCout() != NULL)
326  out.append(net_map.at(inst->GetCout()));
327  if (inst->GetCin()->IsGnd()) {
328  module->addAdd(RTLIL::escape_id(inst->Name()), IN1, IN2, out, SIGNED);
329  } else {
330  RTLIL::SigSpec tmp = module->addWire(NEW_ID, GetSize(out));
331  module->addAdd(NEW_ID, IN1, IN2, tmp, SIGNED);
332  module->addAdd(RTLIL::escape_id(inst->Name()), tmp, net_map.at(inst->GetCin()), out, false);
333  }
334  return true;
335  }
336 
337  if (inst->Type() == OPER_MULTIPLIER) {
338  module->addMul(RTLIL::escape_id(inst->Name()), IN1, IN2, OUT, SIGNED);
339  return true;
340  }
341 
342  if (inst->Type() == OPER_DIVIDER) {
343  module->addDiv(RTLIL::escape_id(inst->Name()), IN1, IN2, OUT, SIGNED);
344  return true;
345  }
346 
347  if (inst->Type() == OPER_MODULO) {
348  module->addMod(RTLIL::escape_id(inst->Name()), IN1, IN2, OUT, SIGNED);
349  return true;
350  }
351 
352  if (inst->Type() == OPER_REMAINDER) {
353  module->addMod(RTLIL::escape_id(inst->Name()), IN1, IN2, OUT, SIGNED);
354  return true;
355  }
356 
357  if (inst->Type() == OPER_SHIFT_LEFT) {
358  module->addShl(RTLIL::escape_id(inst->Name()), IN1, IN2, OUT, false);
359  return true;
360  }
361 
362  if (inst->Type() == OPER_SHIFT_RIGHT) {
363  Net *net_cin = inst->GetCin();
364  Net *net_a_msb = inst->GetInput1Bit(0);
365  if (net_cin->IsGnd())
366  module->addShr(RTLIL::escape_id(inst->Name()), IN1, IN2, OUT, false);
367  else if (net_cin == net_a_msb)
368  module->addSshr(RTLIL::escape_id(inst->Name()), IN1, IN2, OUT, true);
369  else
370  log_error("Can't import Verific OPER_SHIFT_RIGHT instance %s: carry_in is neither 0 nor msb of left input\n", inst->Name());
371  return true;
372  }
373 
374  if (inst->Type() == OPER_REDUCE_AND) {
375  module->addReduceAnd(RTLIL::escape_id(inst->Name()), IN, net_map.at(inst->GetOutput()), SIGNED);
376  return true;
377  }
378 
379  if (inst->Type() == OPER_REDUCE_OR) {
380  module->addReduceOr(RTLIL::escape_id(inst->Name()), IN, net_map.at(inst->GetOutput()), SIGNED);
381  return true;
382  }
383 
384  if (inst->Type() == OPER_REDUCE_XOR) {
385  module->addReduceXor(RTLIL::escape_id(inst->Name()), IN, net_map.at(inst->GetOutput()), SIGNED);
386  return true;
387  }
388 
389  if (inst->Type() == OPER_REDUCE_XNOR) {
390  module->addReduceXnor(RTLIL::escape_id(inst->Name()), IN, net_map.at(inst->GetOutput()), SIGNED);
391  return true;
392  }
393 
394  if (inst->Type() == OPER_LESSTHAN) {
395  Net *net_cin = inst->GetCin();
396  if (net_cin->IsGnd())
397  module->addLt(RTLIL::escape_id(inst->Name()), IN1, IN2, net_map.at(inst->GetOutput()), SIGNED);
398  else if (net_cin->IsPwr())
399  module->addLe(RTLIL::escape_id(inst->Name()), IN1, IN2, net_map.at(inst->GetOutput()), SIGNED);
400  else
401  log_error("Can't import Verific OPER_LESSTHAN instance %s: carry_in is neither 0 nor 1\n", inst->Name());
402  return true;
403  }
404 
405  if (inst->Type() == OPER_WIDE_AND) {
406  module->addAnd(RTLIL::escape_id(inst->Name()), IN1, IN2, OUT, SIGNED);
407  return true;
408  }
409 
410  if (inst->Type() == OPER_WIDE_OR) {
411  module->addOr(RTLIL::escape_id(inst->Name()), IN1, IN2, OUT, SIGNED);
412  return true;
413  }
414 
415  if (inst->Type() == OPER_WIDE_XOR) {
416  module->addXor(RTLIL::escape_id(inst->Name()), IN1, IN2, OUT, SIGNED);
417  return true;
418  }
419 
420  if (inst->Type() == OPER_WIDE_XNOR) {
421  module->addXnor(RTLIL::escape_id(inst->Name()), IN1, IN2, OUT, SIGNED);
422  return true;
423  }
424 
425  if (inst->Type() == OPER_WIDE_BUF) {
426  module->addPos(RTLIL::escape_id(inst->Name()), IN, OUT, SIGNED);
427  return true;
428  }
429 
430  if (inst->Type() == OPER_WIDE_INV) {
431  module->addNot(RTLIL::escape_id(inst->Name()), IN, OUT, SIGNED);
432  return true;
433  }
434 
435  if (inst->Type() == OPER_MINUS) {
436  module->addSub(RTLIL::escape_id(inst->Name()), IN1, IN2, OUT, SIGNED);
437  return true;
438  }
439 
440  if (inst->Type() == OPER_UMINUS) {
441  module->addNeg(RTLIL::escape_id(inst->Name()), IN, OUT, SIGNED);
442  return true;
443  }
444 
445  if (inst->Type() == OPER_EQUAL) {
446  module->addEq(RTLIL::escape_id(inst->Name()), IN1, IN2, net_map.at(inst->GetOutput()), SIGNED);
447  return true;
448  }
449 
450  if (inst->Type() == OPER_NEQUAL) {
451  module->addNe(RTLIL::escape_id(inst->Name()), IN1, IN2, net_map.at(inst->GetOutput()), SIGNED);
452  return true;
453  }
454 
455  if (inst->Type() == OPER_WIDE_MUX) {
456  module->addMux(RTLIL::escape_id(inst->Name()), IN1, IN2, net_map.at(inst->GetControl()), OUT);
457  return true;
458  }
459 
460  if (inst->Type() == OPER_WIDE_TRI) {
461  module->addMux(RTLIL::escape_id(inst->Name()), RTLIL::SigSpec(RTLIL::State::Sz, inst->OutputSize()), IN, net_map.at(inst->GetControl()), OUT);
462  return true;
463  }
464 
465  if (inst->Type() == OPER_WIDE_DFFRS) {
466  RTLIL::SigSpec sig_set = operatorInport(inst, "set", net_map);
467  RTLIL::SigSpec sig_reset = operatorInport(inst, "reset", net_map);
468  if (sig_set.is_fully_const() && !sig_set.as_bool() && sig_reset.is_fully_const() && !sig_reset.as_bool())
469  module->addDff(RTLIL::escape_id(inst->Name()), net_map.at(inst->GetClock()), IN, OUT);
470  else
471  module->addDffsr(RTLIL::escape_id(inst->Name()), net_map.at(inst->GetClock()), sig_set, sig_reset, IN, OUT);
472  return true;
473  }
474 
475  #undef IN
476  #undef IN1
477  #undef IN2
478  #undef OUT
479  #undef SIGNED
480 
481  return false;
482 }
483 
484 static void import_netlist(RTLIL::Design *design, Netlist *nl, std::set<Netlist*> &nl_todo, bool mode_gates)
485 {
486  std::string module_name = nl->IsOperator() ? std::string("$verific$") + nl->Owner()->Name() : RTLIL::escape_id(nl->Owner()->Name());
487 
488  if (design->has(module_name)) {
489  if (!nl->IsOperator())
490  log_cmd_error("Re-definition of module `%s'.\n", nl->Owner()->Name());
491  return;
492  }
493 
494  RTLIL::Module *module = new RTLIL::Module;
495  module->name = module_name;
496  design->add(module);
497 
498  log("Importing module %s.\n", RTLIL::id2cstr(module->name));
499 
500  std::map<Net*, RTLIL::SigBit> net_map;
501 
502  SetIter si;
503  MapIter mi, mi2;
504  Port *port;
505  PortBus *portbus;
506  Net *net;
507  NetBus *netbus;
508  Instance *inst;
509  PortRef *pr;
510 
511  FOREACH_PORT_OF_NETLIST(nl, mi, port)
512  {
513  if (port->Bus())
514  continue;
515 
516  // log(" importing port %s.\n", port->Name());
517 
518  RTLIL::Wire *wire = module->addWire(RTLIL::escape_id(port->Name()));
519  import_attributes(wire->attributes, port);
520 
521  wire->port_id = nl->IndexOf(port) + 1;
522 
523  if (port->GetDir() == DIR_INOUT || port->GetDir() == DIR_IN)
524  wire->port_input = true;
525  if (port->GetDir() == DIR_INOUT || port->GetDir() == DIR_OUT)
526  wire->port_output = true;
527 
528  if (port->GetNet()) {
529  net = port->GetNet();
530  if (net_map.count(net) == 0)
531  net_map[net] = wire;
532  else if (wire->port_input)
533  module->connect(net_map.at(net), wire);
534  else
535  module->connect(wire, net_map.at(net));
536  }
537  }
538 
539  FOREACH_PORTBUS_OF_NETLIST(nl, mi, portbus)
540  {
541  // log(" importing portbus %s.\n", portbus->Name());
542 
543  RTLIL::Wire *wire = module->addWire(RTLIL::escape_id(portbus->Name()), portbus->Size());
544  wire->start_offset = std::min(portbus->LeftIndex(), portbus->RightIndex());
545  import_attributes(wire->attributes, portbus);
546 
547  if (portbus->GetDir() == DIR_INOUT || portbus->GetDir() == DIR_IN)
548  wire->port_input = true;
549  if (portbus->GetDir() == DIR_INOUT || portbus->GetDir() == DIR_OUT)
550  wire->port_output = true;
551 
552  for (int i = portbus->LeftIndex();; i += portbus->IsUp() ? +1 : -1) {
553  if (portbus->ElementAtIndex(i) && portbus->ElementAtIndex(i)->GetNet()) {
554  net = portbus->ElementAtIndex(i)->GetNet();
555  RTLIL::SigBit bit(wire, i - wire->start_offset);
556  if (net_map.count(net) == 0)
557  net_map[net] = bit;
558  else if (wire->port_input)
559  module->connect(net_map.at(net), bit);
560  else
561  module->connect(bit, net_map.at(net));
562  }
563  if (i == portbus->RightIndex())
564  break;
565  }
566  }
567 
568  module->fixup_ports();
569 
570  FOREACH_NET_OF_NETLIST(nl, mi, net)
571  {
572  if (net->IsRamNet())
573  {
574  RTLIL::Memory *memory = new RTLIL::Memory;
575  memory->name = RTLIL::escape_id(net->Name());
576  log_assert(module->count_id(memory->name) == 0);
577  module->memories[memory->name] = memory;
578 
579  int number_of_bits = net->Size();
580  int bits_in_word = number_of_bits;
581  FOREACH_PORTREF_OF_NET(net, si, pr) {
582  if (pr->GetInst()->Type() == OPER_READ_PORT) {
583  bits_in_word = std::min<int>(bits_in_word, pr->GetInst()->OutputSize());
584  continue;
585  }
586  if (pr->GetInst()->Type() == OPER_WRITE_PORT || pr->GetInst()->Type() == OPER_CLOCKED_WRITE_PORT) {
587  bits_in_word = std::min<int>(bits_in_word, pr->GetInst()->Input2Size());
588  continue;
589  }
590  log_error("Verific RamNet %s is connected to unsupported instance type %s (%s).\n",
591  net->Name(), pr->GetInst()->View()->Owner()->Name(), pr->GetInst()->Name());
592  }
593 
594  memory->width = bits_in_word;
595  memory->size = number_of_bits / bits_in_word;
596  continue;
597  }
598 
599  if (net_map.count(net)) {
600  // log(" skipping net %s.\n", net->Name());
601  continue;
602  }
603 
604  if (net->Bus())
605  continue;
606 
607  // log(" importing net %s.\n", net->Name());
608 
609  RTLIL::IdString wire_name = module->uniquify(RTLIL::escape_id(net->Name()));
610  RTLIL::Wire *wire = module->addWire(wire_name);
611  import_attributes(wire->attributes, net);
612 
613  net_map[net] = wire;
614  }
615 
616  FOREACH_NETBUS_OF_NETLIST(nl, mi, netbus)
617  {
618  bool found_new_net = false;
619  for (int i = netbus->LeftIndex();; i += netbus->IsUp() ? +1 : -1) {
620  net = netbus->ElementAtIndex(i);
621  if (net_map.count(net) == 0)
622  found_new_net = true;
623  if (i == netbus->RightIndex())
624  break;
625  }
626 
627  if (found_new_net)
628  {
629  // log(" importing netbus %s.\n", netbus->Name());
630 
631  RTLIL::IdString wire_name = module->uniquify(RTLIL::escape_id(netbus->Name()));
632  RTLIL::Wire *wire = module->addWire(wire_name, netbus->Size());
633  wire->start_offset = std::min(netbus->LeftIndex(), netbus->RightIndex());
634  import_attributes(wire->attributes, netbus);
635 
636  for (int i = netbus->LeftIndex();; i += netbus->IsUp() ? +1 : -1) {
637  if (netbus->ElementAtIndex(i)) {
638  net = netbus->ElementAtIndex(i);
639  RTLIL::SigBit bit(wire, i - wire->start_offset);
640  if (net_map.count(net) == 0)
641  net_map[net] = bit;
642  else
643  module->connect(bit, net_map.at(net));
644  }
645  if (i == netbus->RightIndex())
646  break;
647  }
648  }
649  else
650  {
651  // log(" skipping netbus %s.\n", netbus->Name());
652  }
653  }
654 
655  FOREACH_INSTANCE_OF_NETLIST(nl, mi, inst)
656  {
657  // log(" importing cell %s (%s).\n", inst->Name(), inst->View()->Owner()->Name());
658 
659  if (inst->Type() == PRIM_PWR) {
660  module->connect(net_map.at(inst->GetOutput()), RTLIL::State::S1);
661  continue;
662  }
663 
664  if (inst->Type() == PRIM_GND) {
665  module->connect(net_map.at(inst->GetOutput()), RTLIL::State::S0);
666  continue;
667  }
668 
669  if (inst->Type() == PRIM_X) {
670  module->connect(net_map.at(inst->GetOutput()), RTLIL::State::Sx);
671  continue;
672  }
673 
674  if (inst->Type() == PRIM_Z) {
675  module->connect(net_map.at(inst->GetOutput()), RTLIL::State::Sz);
676  continue;
677  }
678 
679  if (inst->Type() == OPER_READ_PORT)
680  {
681  RTLIL::Memory *memory = module->memories.at(RTLIL::escape_id(inst->GetInput()->Name()));
682  if (memory->width != int(inst->OutputSize()))
683  log_error("Import of asymetric memories from Verific is not supported yet: %s %s\n", inst->Name(), inst->GetInput()->Name());
684 
685  RTLIL::SigSpec addr = operatorInput1(inst, net_map);
686  RTLIL::SigSpec data = operatorOutput(inst, net_map, module);
687 
688  RTLIL::Cell *cell = module->addCell(RTLIL::escape_id(inst->Name()), "$memrd");
689  cell->parameters["\\MEMID"] = memory->name.str();
690  cell->parameters["\\CLK_ENABLE"] = false;
691  cell->parameters["\\CLK_POLARITY"] = true;
692  cell->parameters["\\TRANSPARENT"] = false;
693  cell->parameters["\\ABITS"] = GetSize(addr);
694  cell->parameters["\\WIDTH"] = GetSize(data);
695  cell->setPort("\\CLK", RTLIL::State::S0);
696  cell->setPort("\\ADDR", addr);
697  cell->setPort("\\DATA", data);
698  continue;
699  }
700 
701  if (inst->Type() == OPER_WRITE_PORT || inst->Type() == OPER_CLOCKED_WRITE_PORT)
702  {
703  RTLIL::Memory *memory = module->memories.at(RTLIL::escape_id(inst->GetOutput()->Name()));
704  if (memory->width != int(inst->Input2Size()))
705  log_error("Import of asymetric memories from Verific is not supported yet: %s %s\n", inst->Name(), inst->GetInput()->Name());
706 
707  RTLIL::SigSpec addr = operatorInput1(inst, net_map);
708  RTLIL::SigSpec data = operatorInput2(inst, net_map);
709 
710  RTLIL::Cell *cell = module->addCell(RTLIL::escape_id(inst->Name()), "$memwr");
711  cell->parameters["\\MEMID"] = memory->name.str();
712  cell->parameters["\\CLK_ENABLE"] = false;
713  cell->parameters["\\CLK_POLARITY"] = true;
714  cell->parameters["\\PRIORITY"] = 0;
715  cell->parameters["\\ABITS"] = GetSize(addr);
716  cell->parameters["\\WIDTH"] = GetSize(data);
717  cell->setPort("\\EN", RTLIL::SigSpec(net_map.at(inst->GetControl())).repeat(GetSize(data)));
718  cell->setPort("\\CLK", RTLIL::State::S0);
719  cell->setPort("\\ADDR", addr);
720  cell->setPort("\\DATA", data);
721 
722  if (inst->Type() == OPER_CLOCKED_WRITE_PORT) {
723  cell->parameters["\\CLK_ENABLE"] = true;
724  cell->setPort("\\CLK", net_map.at(inst->GetClock()));
725  }
726  continue;
727  }
728 
729  if (!mode_gates) {
730  if (import_netlist_instance_cells(module, net_map, inst))
731  continue;
732  if (inst->IsOperator())
733  log_warning("Unsupported Verific operator: %s (fallback to gate level implementation provided by verific)\n", inst->View()->Owner()->Name());
734  } else {
735  if (import_netlist_instance_gates(module, net_map, inst))
736  continue;
737  }
738 
739  if (inst->IsPrimitive())
740  log_error("Unsupported Verific primitive: %s\n", inst->View()->Owner()->Name());
741 
742  nl_todo.insert(inst->View());
743 
744  RTLIL::Cell *cell = module->addCell(RTLIL::escape_id(inst->Name()), inst->IsOperator() ?
745  std::string("$verific$") + inst->View()->Owner()->Name() : RTLIL::escape_id(inst->View()->Owner()->Name()));
746 
747  FOREACH_PORTREF_OF_INST(inst, mi2, pr) {
748  // log(" .%s(%s)\n", pr->GetPort()->Name(), pr->GetNet()->Name());
749  const char *port_name = pr->GetPort()->Name();
750  int port_offset = 0;
751  if (pr->GetPort()->Bus()) {
752  port_name = pr->GetPort()->Bus()->Name();
753  port_offset = pr->GetPort()->Bus()->IndexOf(pr->GetPort()) -
754  std::min(pr->GetPort()->Bus()->LeftIndex(), pr->GetPort()->Bus()->RightIndex());
755  }
756  RTLIL::SigSpec conn;
757  if (cell->hasPort(RTLIL::escape_id(port_name)))
758  conn = cell->getPort(RTLIL::escape_id(port_name));
759  while (GetSize(conn) <= port_offset) {
760  if (pr->GetPort()->GetDir() != DIR_IN)
761  conn.append(module->addWire(NEW_ID, port_offset - GetSize(conn)));
762  conn.append(RTLIL::State::Sz);
763  }
764  conn.replace(port_offset, net_map.at(pr->GetNet()));
765  cell->setPort(RTLIL::escape_id(port_name), conn);
766  }
767  }
768 }
769 
770 #endif /* YOSYS_ENABLE_VERIFIC */
771 
773 
774 struct VerificPass : public Pass {
775  VerificPass() : Pass("verific", "load Verilog and VHDL designs using Verific") { }
776  virtual void help()
777  {
778  // |---v---|---v---|---v---|---v---|---v---|---v---|---v---|---v---|---v---|---v---|
779  log("\n");
780  log(" verific {-vlog95|-vlog2k|-sv2005|-sv2009|-sv} <verilog-file>..\n");
781  log("\n");
782  log("Load the specified Verilog/SystemVerilog files into Verific.\n");
783  log("\n");
784  log("\n");
785  log(" verific {-vhdl87|-vhdl93|-vhdl2k|-vhdl2008} <vhdl-file>..\n");
786  log("\n");
787  log("Load the specified VHDL files into Verific.\n");
788  log("\n");
789  log("\n");
790  log(" verific -import [-gates] {-all | <top-module>..}\n");
791  log("\n");
792  log("Elaborate the design for the sepcified top modules, import to Yosys and\n");
793  log("reset the internal state of Verific. A gate-level netlist is created\n");
794  log("when called with -gates.\n");
795  log("\n");
796  log("Visit http://verific.com/ for more information on Verific.\n");
797  log("\n");
798  }
799 #ifdef YOSYS_ENABLE_VERIFIC
800  virtual void execute(std::vector<std::string> args, RTLIL::Design *design)
801  {
802  log_header("Executing VERIFIC (loading Verilog and VHDL designs using Verific).\n");
803 
804  Message::SetConsoleOutput(0);
805  Message::RegisterCallBackMsg(msg_func);
806 
807  if (args.size() > 1 && args[1] == "-vlog95") {
808  for (size_t argidx = 2; argidx < args.size(); argidx++)
809  if (!veri_file::Analyze(args[argidx].c_str(), veri_file::VERILOG_95))
810  log_cmd_error("Reading `%s' in VERILOG_95 mode failed.\n", args[argidx].c_str());
811  return;
812  }
813 
814  if (args.size() > 1 && args[1] == "-vlog2k") {
815  for (size_t argidx = 2; argidx < args.size(); argidx++)
816  if (!veri_file::Analyze(args[argidx].c_str(), veri_file::VERILOG_2K))
817  log_cmd_error("Reading `%s' in VERILOG_2K mode failed.\n", args[argidx].c_str());
818  return;
819  }
820 
821  if (args.size() > 1 && args[1] == "-sv2005") {
822  for (size_t argidx = 2; argidx < args.size(); argidx++)
823  if (!veri_file::Analyze(args[argidx].c_str(), veri_file::SYSTEM_VERILOG_2005))
824  log_cmd_error("Reading `%s' in SYSTEM_VERILOG_2005 mode failed.\n", args[argidx].c_str());
825  return;
826  }
827 
828  if (args.size() > 1 && args[1] == "-sv2009") {
829  for (size_t argidx = 2; argidx < args.size(); argidx++)
830  if (!veri_file::Analyze(args[argidx].c_str(), veri_file::SYSTEM_VERILOG_2009))
831  log_cmd_error("Reading `%s' in SYSTEM_VERILOG_2009 mode failed.\n", args[argidx].c_str());
832  return;
833  }
834 
835  if (args.size() > 1 && args[1] == "-sv") {
836  for (size_t argidx = 2; argidx < args.size(); argidx++)
837  if (!veri_file::Analyze(args[argidx].c_str(), veri_file::SYSTEM_VERILOG))
838  log_cmd_error("Reading `%s' in SYSTEM_VERILOG mode failed.\n", args[argidx].c_str());
839  return;
840  }
841 
842  if (args.size() > 1 && args[1] == "-vhdl87") {
843  vhdl_file::SetDefaultLibraryPath((proc_share_dirname() + "verific/vhdl_vdbs_1993").c_str());
844  for (size_t argidx = 2; argidx < args.size(); argidx++)
845  if (!vhdl_file::Analyze(args[argidx].c_str(), "work", vhdl_file::VHDL_87))
846  log_cmd_error("Reading `%s' in VHDL_87 mode failed.\n", args[argidx].c_str());
847  return;
848  }
849 
850  if (args.size() > 1 && args[1] == "-vhdl93") {
851  vhdl_file::SetDefaultLibraryPath((proc_share_dirname() + "verific/vhdl_vdbs_1993").c_str());
852  for (size_t argidx = 2; argidx < args.size(); argidx++)
853  if (!vhdl_file::Analyze(args[argidx].c_str(), "work", vhdl_file::VHDL_93))
854  log_cmd_error("Reading `%s' in VHDL_93 mode failed.\n", args[argidx].c_str());
855  return;
856  }
857 
858  if (args.size() > 1 && args[1] == "-vhdl2k") {
859  vhdl_file::SetDefaultLibraryPath((proc_share_dirname() + "verific/vhdl_vdbs_1993").c_str());
860  for (size_t argidx = 2; argidx < args.size(); argidx++)
861  if (!vhdl_file::Analyze(args[argidx].c_str(), "work", vhdl_file::VHDL_2K))
862  log_cmd_error("Reading `%s' in VHDL_2K mode failed.\n", args[argidx].c_str());
863  return;
864  }
865 
866  if (args.size() > 1 && args[1] == "-vhdl2008") {
867  vhdl_file::SetDefaultLibraryPath((proc_share_dirname() + "verific/vhdl_vdbs_2008").c_str());
868  for (size_t argidx = 2; argidx < args.size(); argidx++)
869  if (!vhdl_file::Analyze(args[argidx].c_str(), "work", vhdl_file::VHDL_2008))
870  log_cmd_error("Reading `%s' in VHDL_2008 mode failed.\n", args[argidx].c_str());
871  return;
872  }
873 
874  if (args.size() > 1 && args[1] == "-import")
875  {
876  std::set<Netlist*> nl_todo, nl_done;
877  bool mode_all = false, mode_gates = false;
878 
879  size_t argidx = 2;
880  for (; argidx < args.size(); argidx++) {
881  if (args[argidx] == "-all") {
882  mode_all = true;
883  continue;
884  }
885  if (args[argidx] == "-gates") {
886  mode_gates = true;
887  continue;
888  }
889  break;
890  }
891 
892  if (argidx > args.size() && args[argidx].substr(0, 1) == "-")
893  cmd_error(args, argidx, "unknown option");
894 
895  if (mode_all)
896  {
897  if (argidx != args.size())
898  log_cmd_error("Got -all and an explicit list of top modules.\n");
899 
900  MapIter m1, m2, m3;
901  VeriModule *mod;
902  FOREACH_VERILOG_MODULE(m1, mod)
903  args.push_back(mod->Name());
904 
905  VhdlLibrary *lib;
906  VhdlPrimaryUnit *primunit;
907  FOREACH_VHDL_LIBRARY(m1, lib)
908  FOREACH_VHDL_PRIMARY_UNIT(lib, m2, primunit) {
909  if (primunit->IsPackageDecl())
910  continue;
911  args.push_back(primunit->Name());
912  }
913  }
914  else
915  if (argidx == args.size())
916  log_cmd_error("No top module specified.\n");
917 
918  for (; argidx < args.size(); argidx++) {
919  if (veri_file::GetModule(args[argidx].c_str())) {
920  if (!veri_file::Elaborate(args[argidx].c_str()))
921  log_cmd_error("Elaboration of top module `%s' failed.\n", args[argidx].c_str());
922  nl_todo.insert(Netlist::PresentDesign());
923  } else {
924  if (!vhdl_file::Elaborate(args[argidx].c_str()))
925  log_cmd_error("Elaboration of top module `%s' failed.\n", args[argidx].c_str());
926  nl_todo.insert(Netlist::PresentDesign());
927  }
928  }
929 
930  while (!nl_todo.empty()) {
931  Netlist *nl = *nl_todo.begin();
932  if (nl_done.count(nl) == 0)
933  import_netlist(design, nl, nl_todo, mode_gates);
934  nl_todo.erase(nl);
935  nl_done.insert(nl);
936  }
937 
938  Libset::Reset();
939  return;
940  }
941 
942  log_cmd_error("Missing or unsupported mode parameter.\n");
943  }
944 #else /* YOSYS_ENABLE_VERIFIC */
945  virtual void execute(std::vector<std::string>, RTLIL::Design *) {
946  log_cmd_error("This version of Yosys is built without Verific support.\n");
947  }
948 #endif
949 } VerificPass;
950 
952 
RTLIL::Cell * addReduceXor(RTLIL::IdString name, RTLIL::SigSpec sig_a, RTLIL::SigSpec sig_y, bool is_signed=false)
std::string str() const
Definition: rtlil.h:182
virtual void execute(std::vector< std::string >, RTLIL::Design *)
Definition: verific.cc:945
RTLIL::Cell * addXorGate(RTLIL::IdString name, RTLIL::SigBit sig_a, RTLIL::SigBit sig_b, RTLIL::SigBit sig_y)
RTLIL::Cell * addDiv(RTLIL::IdString name, RTLIL::SigSpec sig_a, RTLIL::SigSpec sig_b, RTLIL::SigSpec sig_y, bool is_signed=false)
std::string stringf(const char *fmt,...)
Definition: yosys.cc:58
void log_warning(const char *format,...)
Definition: log.cc:196
RTLIL::Cell * addCell(RTLIL::IdString name, RTLIL::IdString type)
Definition: rtlil.cc:1353
void add(RTLIL::Module *module)
Definition: rtlil.cc:259
void log_header(const char *format,...)
Definition: log.cc:188
RTLIL::Cell * addDffGate(RTLIL::IdString name, RTLIL::SigSpec sig_clk, RTLIL::SigSpec sig_d, RTLIL::SigSpec sig_q, bool clk_polarity=true)
Definition: rtlil.cc:1681
#define YOSYS_NAMESPACE_END
Definition: yosys.h:100
RTLIL::Cell * addNot(RTLIL::IdString name, RTLIL::SigSpec sig_a, RTLIL::SigSpec sig_y, bool is_signed=false)
bool as_bool() const
Definition: rtlil.cc:2818
RTLIL::Cell * addSshr(RTLIL::IdString name, RTLIL::SigSpec sig_a, RTLIL::SigSpec sig_b, RTLIL::SigSpec sig_y, bool is_signed=false)
void setPort(RTLIL::IdString portname, RTLIL::SigSpec signal)
Definition: rtlil.cc:1789
bool port_input
Definition: rtlil.h:827
virtual void help()
Definition: verific.cc:776
int width
Definition: rtlil.h:826
std::map< RTLIL::IdString, RTLIL::Memory * > memories
Definition: rtlil.h:601
RTLIL::Cell * addEq(RTLIL::IdString name, RTLIL::SigSpec sig_a, RTLIL::SigSpec sig_b, RTLIL::SigSpec sig_y, bool is_signed=false)
void log_error(const char *format,...)
Definition: log.cc:204
RTLIL::Module * module
Definition: abc.cc:94
int port_id
Definition: rtlil.h:826
std::map< RTLIL::IdString, RTLIL::Const > parameters
Definition: rtlil.h:856
int size
Definition: rtlil.h:836
RTLIL::Cell * addAdd(RTLIL::IdString name, RTLIL::SigSpec sig_a, RTLIL::SigSpec sig_b, RTLIL::SigSpec sig_y, bool is_signed=false)
RTLIL::Cell * addReduceOr(RTLIL::IdString name, RTLIL::SigSpec sig_a, RTLIL::SigSpec sig_y, bool is_signed=false)
RTLIL::Cell * addNotGate(RTLIL::IdString name, RTLIL::SigBit sig_a, RTLIL::SigBit sig_y)
if(!(yy_init))
Definition: ilang_lexer.cc:846
static std::string escape_id(std::string str)
Definition: rtlil.h:251
bool port_output
Definition: rtlil.h:827
RTLIL::Cell * addNeg(RTLIL::IdString name, RTLIL::SigSpec sig_a, RTLIL::SigSpec sig_y, bool is_signed=false)
RTLIL::Cell * addAnd(RTLIL::IdString name, RTLIL::SigSpec sig_a, RTLIL::SigSpec sig_b, RTLIL::SigSpec sig_y, bool is_signed=false)
RTLIL::Cell * addShr(RTLIL::IdString name, RTLIL::SigSpec sig_a, RTLIL::SigSpec sig_b, RTLIL::SigSpec sig_y, bool is_signed=false)
RTLIL::Cell * addXnor(RTLIL::IdString name, RTLIL::SigSpec sig_a, RTLIL::SigSpec sig_b, RTLIL::SigSpec sig_y, bool is_signed=false)
RTLIL::Cell * addMod(RTLIL::IdString name, RTLIL::SigSpec sig_a, RTLIL::SigSpec sig_b, RTLIL::SigSpec sig_y, bool is_signed=false)
RTLIL::Cell * addReduceAnd(RTLIL::IdString name, RTLIL::SigSpec sig_a, RTLIL::SigSpec sig_y, bool is_signed=false)
RTLIL::Cell * addDff(RTLIL::IdString name, RTLIL::SigSpec sig_clk, RTLIL::SigSpec sig_d, RTLIL::SigSpec sig_q, bool clk_polarity=true)
Definition: rtlil.cc:1599
void connect(const RTLIL::SigSig &conn)
Definition: rtlil.cc:1278
RTLIL::Cell * addAndGate(RTLIL::IdString name, RTLIL::SigBit sig_a, RTLIL::SigBit sig_b, RTLIL::SigBit sig_y)
RTLIL::Cell * addOrGate(RTLIL::IdString name, RTLIL::SigBit sig_a, RTLIL::SigBit sig_b, RTLIL::SigBit sig_y)
RTLIL_ATTRIBUTE_MEMBERS bool hasPort(RTLIL::IdString portname) const
Definition: rtlil.cc:1766
const RTLIL::SigSpec & getPort(RTLIL::IdString portname) const
Definition: rtlil.cc:1809
RTLIL::Cell * addShl(RTLIL::IdString name, RTLIL::SigSpec sig_a, RTLIL::SigSpec sig_b, RTLIL::SigSpec sig_y, bool is_signed=false)
int GetSize(RTLIL::Wire *wire)
Definition: yosys.cc:334
RTLIL::Cell * addLt(RTLIL::IdString name, RTLIL::SigSpec sig_a, RTLIL::SigSpec sig_b, RTLIL::SigSpec sig_y, bool is_signed=false)
RTLIL::IdString name
Definition: rtlil.h:835
void fixup_ports()
Definition: rtlil.cc:1312
#define log_assert(_assert_expr_)
Definition: log.h:85
bool is_fully_const() const
Definition: rtlil.cc:2763
RTLIL::Wire * addWire(RTLIL::IdString name, int width=1)
Definition: rtlil.cc:1331
RTLIL::IdString name
Definition: rtlil.h:599
#define NEW_ID
Definition: yosys.h:166
RTLIL::Cell * addMul(RTLIL::IdString name, RTLIL::SigSpec sig_a, RTLIL::SigSpec sig_b, RTLIL::SigSpec sig_y, bool is_signed=false)
RTLIL::Cell * addAdff(RTLIL::IdString name, RTLIL::SigSpec sig_clk, RTLIL::SigSpec sig_arst, RTLIL::SigSpec sig_d, RTLIL::SigSpec sig_q, RTLIL::Const arst_value, bool clk_polarity=true, bool arst_polarity=true)
Definition: rtlil.cc:1639
RTLIL::Cell * addSub(RTLIL::IdString name, RTLIL::SigSpec sig_a, RTLIL::SigSpec sig_b, RTLIL::SigSpec sig_y, bool is_signed=false)
Definition: register.h:27
static const char * id2cstr(const RTLIL::IdString &str)
Definition: rtlil.h:267
void log_cmd_error(const char *format,...)
Definition: log.cc:211
RTLIL::Cell * addDffsr(RTLIL::IdString name, RTLIL::SigSpec sig_clk, RTLIL::SigSpec sig_set, RTLIL::SigSpec sig_clr, RTLIL::SigSpec sig_d, RTLIL::SigSpec sig_q, bool clk_polarity=true, bool set_polarity=true, bool clr_polarity=true)
Definition: rtlil.cc:1623
bool has(RTLIL::IdString id) const
Definition: rtlil.h:519
#define USING_YOSYS_NAMESPACE
Definition: yosys.h:102
RTLIL::Cell * addXor(RTLIL::IdString name, RTLIL::SigSpec sig_a, RTLIL::SigSpec sig_b, RTLIL::SigSpec sig_y, bool is_signed=false)
virtual size_t count_id(RTLIL::IdString id)
Definition: rtlil.cc:472
void replace(const RTLIL::SigSpec &pattern, const RTLIL::SigSpec &with)
Definition: rtlil.cc:2297
#define NULL
#define YOSYS_NAMESPACE_BEGIN
Definition: yosys.h:99
RTLIL::IdString uniquify(RTLIL::IdString name)
Definition: rtlil.cc:1244
RTLIL::Cell * addDffsrGate(RTLIL::IdString name, RTLIL::SigSpec sig_clk, RTLIL::SigSpec sig_set, RTLIL::SigSpec sig_clr, RTLIL::SigSpec sig_d, RTLIL::SigSpec sig_q, bool clk_polarity=true, bool set_polarity=true, bool clr_polarity=true)
Definition: rtlil.cc:1700
RTLIL::Cell * addMux(RTLIL::IdString name, RTLIL::SigSpec sig_a, RTLIL::SigSpec sig_b, RTLIL::SigSpec sig_s, RTLIL::SigSpec sig_y)
void log(const char *format,...)
Definition: log.cc:180
RTLIL::Cell * addMuxGate(RTLIL::IdString name, RTLIL::SigBit sig_a, RTLIL::SigBit sig_b, RTLIL::SigBit sig_s, RTLIL::SigBit sig_y)
RTLIL::SigSpec repeat(int num) const
Definition: rtlil.cc:2631
RTLIL::Cell * addReduceXnor(RTLIL::IdString name, RTLIL::SigSpec sig_a, RTLIL::SigSpec sig_y, bool is_signed=false)
std::string proc_share_dirname()
Definition: yosys.cc:543
void append(const RTLIL::SigSpec &signal)
Definition: rtlil.cc:2523
RTLIL::Cell * addNe(RTLIL::IdString name, RTLIL::SigSpec sig_a, RTLIL::SigSpec sig_b, RTLIL::SigSpec sig_y, bool is_signed=false)
RTLIL::Cell * addOr(RTLIL::IdString name, RTLIL::SigSpec sig_a, RTLIL::SigSpec sig_b, RTLIL::SigSpec sig_y, bool is_signed=false)
int start_offset
Definition: rtlil.h:826
VerificPass VerificPass
int width
Definition: rtlil.h:836
RTLIL::Cell * addPos(RTLIL::IdString name, RTLIL::SigSpec sig_a, RTLIL::SigSpec sig_y, bool is_signed=false)
RTLIL::Cell * addLe(RTLIL::IdString name, RTLIL::SigSpec sig_a, RTLIL::SigSpec sig_b, RTLIL::SigSpec sig_y, bool is_signed=false)
void logv(const char *format, va_list ap)
Definition: log.cc:76
RTLIL::Cell * addAdffGate(RTLIL::IdString name, RTLIL::SigSpec sig_clk, RTLIL::SigSpec sig_arst, RTLIL::SigSpec sig_d, RTLIL::SigSpec sig_q, bool arst_value=false, bool clk_polarity=true, bool arst_polarity=true)
Definition: rtlil.cc:1712