2 * yosys -- Yosys Open SYnthesis Suite
4 * Copyright (C) 2012 Clifford Wolf <clifford@clifford.at>
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.
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.
20 #include "kernel/yosys.h"
21 #include "kernel/sigtools.h"
22 #include "kernel/log.h"
32 #include "frontends/verific/verific.h"
36 #ifdef YOSYS_ENABLE_VERIFIC
39 #pragma clang diagnostic push
40 #pragma clang diagnostic ignored "-Woverloaded-virtual"
43 #include "veri_file.h"
44 #include "vhdl_file.h"
45 #include "hier_tree.h"
46 #include "VeriModule.h"
47 #include "VeriWrite.h"
48 #include "VhdlUnits.h"
49 #include "VeriLibrary.h"
51 #ifndef SYMBIOTIC_VERIFIC_API_VERSION
52 # error "Only Symbiotic EDA flavored Verific is supported. Please contact office@symbioticeda.com for commercial support for Yosys+Verific."
55 #if SYMBIOTIC_VERIFIC_API_VERSION < 1
56 # error "Please update your version of Symbiotic EDA flavored Verific."
60 #pragma clang diagnostic pop
63 #ifdef VERIFIC_NAMESPACE
64 using namespace Verific
;
69 #ifdef YOSYS_ENABLE_VERIFIC
73 bool verific_import_pending
;
74 string verific_error_msg
;
75 int verific_sva_fsm_limit
;
77 vector
<string
> verific_incdirs
, verific_libdirs
;
79 void msg_func(msg_type_t msg_type
, const char *message_id
, linefile_type linefile
, const char *msg
, va_list args
)
81 string message_prefix
= stringf("VERIFIC-%s [%s] ",
82 msg_type
== VERIFIC_NONE
? "NONE" :
83 msg_type
== VERIFIC_ERROR
? "ERROR" :
84 msg_type
== VERIFIC_WARNING
? "WARNING" :
85 msg_type
== VERIFIC_IGNORE
? "IGNORE" :
86 msg_type
== VERIFIC_INFO
? "INFO" :
87 msg_type
== VERIFIC_COMMENT
? "COMMENT" :
88 msg_type
== VERIFIC_PROGRAM_ERROR
? "PROGRAM_ERROR" : "UNKNOWN", message_id
);
90 string message
= linefile
? stringf("%s:%d: ", LineFile::GetFileName(linefile
), LineFile::GetLineNo(linefile
)) : "";
91 message
+= vstringf(msg
, args
);
93 if (msg_type
== VERIFIC_ERROR
|| msg_type
== VERIFIC_WARNING
|| msg_type
== VERIFIC_PROGRAM_ERROR
)
94 log_warning_noprefix("%s%s\n", message_prefix
.c_str(), message
.c_str());
96 log("%s%s\n", message_prefix
.c_str(), message
.c_str());
98 if (verific_error_msg
.empty() && (msg_type
== VERIFIC_ERROR
|| msg_type
== VERIFIC_PROGRAM_ERROR
))
99 verific_error_msg
= message
;
102 string
get_full_netlist_name(Netlist
*nl
)
104 if (nl
->NumOfRefs() == 1) {
105 Instance
*inst
= (Instance
*)nl
->GetReferences()->GetLast();
106 return get_full_netlist_name(inst
->Owner()) + "." + inst
->Name();
109 return nl
->CellBaseName();
112 // ==================================================================
114 VerificImporter::VerificImporter(bool mode_gates
, bool mode_keep
, bool mode_nosva
, bool mode_names
, bool mode_verific
, bool mode_autocover
) :
115 mode_gates(mode_gates
), mode_keep(mode_keep
), mode_nosva(mode_nosva
),
116 mode_names(mode_names
), mode_verific(mode_verific
), mode_autocover(mode_autocover
)
120 RTLIL::SigBit
VerificImporter::net_map_at(Net
*net
)
122 if (net
->IsExternalTo(netlist
))
123 log_error("Found external reference to '%s.%s' in netlist '%s', please use -flatten or -extnets.\n",
124 get_full_netlist_name(net
->Owner()).c_str(), net
->Name(), get_full_netlist_name(netlist
).c_str());
126 return net_map
.at(net
);
129 bool is_blackbox(Netlist
*nl
)
131 if (nl
->IsBlackBox())
134 const char *attr
= nl
->GetAttValue("blackbox");
135 if (attr
!= nullptr && strcmp(attr
, "0"))
141 RTLIL::IdString
VerificImporter::new_verific_id(Verific::DesignObj
*obj
)
143 std::string s
= stringf("$verific$%s", obj
->Name());
145 s
+= stringf("$%s:%d", Verific::LineFile::GetFileName(obj
->Linefile()), Verific::LineFile::GetLineNo(obj
->Linefile()));
146 s
+= stringf("$%d", autoidx
++);
150 void VerificImporter::import_attributes(dict
<RTLIL::IdString
, RTLIL::Const
> &attributes
, DesignObj
*obj
)
156 attributes
["\\src"] = stringf("%s:%d", LineFile::GetFileName(obj
->Linefile()), LineFile::GetLineNo(obj
->Linefile()));
158 // FIXME: Parse numeric attributes
159 FOREACH_ATTRIBUTE(obj
, mi
, attr
) {
160 if (attr
->Key()[0] == ' ' || attr
->Value() == nullptr)
162 attributes
[RTLIL::escape_id(attr
->Key())] = RTLIL::Const(std::string(attr
->Value()));
166 RTLIL::SigSpec
VerificImporter::operatorInput(Instance
*inst
)
169 for (int i
= int(inst
->InputSize())-1; i
>= 0; i
--)
170 if (inst
->GetInputBit(i
))
171 sig
.append(net_map_at(inst
->GetInputBit(i
)));
173 sig
.append(RTLIL::State::Sz
);
177 RTLIL::SigSpec
VerificImporter::operatorInput1(Instance
*inst
)
180 for (int i
= int(inst
->Input1Size())-1; i
>= 0; i
--)
181 if (inst
->GetInput1Bit(i
))
182 sig
.append(net_map_at(inst
->GetInput1Bit(i
)));
184 sig
.append(RTLIL::State::Sz
);
188 RTLIL::SigSpec
VerificImporter::operatorInput2(Instance
*inst
)
191 for (int i
= int(inst
->Input2Size())-1; i
>= 0; i
--)
192 if (inst
->GetInput2Bit(i
))
193 sig
.append(net_map_at(inst
->GetInput2Bit(i
)));
195 sig
.append(RTLIL::State::Sz
);
199 RTLIL::SigSpec
VerificImporter::operatorInport(Instance
*inst
, const char *portname
)
201 PortBus
*portbus
= inst
->View()->GetPortBus(portname
);
204 for (unsigned i
= 0; i
< portbus
->Size(); i
++) {
205 Net
*net
= inst
->GetNet(portbus
->ElementAtIndex(i
));
208 sig
.append(RTLIL::State::S0
);
209 else if (net
->IsPwr())
210 sig
.append(RTLIL::State::S1
);
212 sig
.append(net_map_at(net
));
214 sig
.append(RTLIL::State::Sz
);
218 Port
*port
= inst
->View()->GetPort(portname
);
219 log_assert(port
!= NULL
);
220 Net
*net
= inst
->GetNet(port
);
221 return net_map_at(net
);
225 RTLIL::SigSpec
VerificImporter::operatorOutput(Instance
*inst
, const pool
<Net
*, hash_ptr_ops
> *any_all_nets
)
228 RTLIL::Wire
*dummy_wire
= NULL
;
229 for (int i
= int(inst
->OutputSize())-1; i
>= 0; i
--)
230 if (inst
->GetOutputBit(i
) && (!any_all_nets
|| !any_all_nets
->count(inst
->GetOutputBit(i
)))) {
231 sig
.append(net_map_at(inst
->GetOutputBit(i
)));
234 if (dummy_wire
== NULL
)
235 dummy_wire
= module
->addWire(new_verific_id(inst
));
238 sig
.append(RTLIL::SigSpec(dummy_wire
, dummy_wire
->width
- 1));
243 bool VerificImporter::import_netlist_instance_gates(Instance
*inst
, RTLIL::IdString inst_name
)
245 if (inst
->Type() == PRIM_AND
) {
246 module
->addAndGate(inst_name
, net_map_at(inst
->GetInput1()), net_map_at(inst
->GetInput2()), net_map_at(inst
->GetOutput()));
250 if (inst
->Type() == PRIM_NAND
) {
251 RTLIL::SigSpec tmp
= module
->addWire(new_verific_id(inst
));
252 module
->addAndGate(new_verific_id(inst
), net_map_at(inst
->GetInput1()), net_map_at(inst
->GetInput2()), tmp
);
253 module
->addNotGate(inst_name
, tmp
, net_map_at(inst
->GetOutput()));
257 if (inst
->Type() == PRIM_OR
) {
258 module
->addOrGate(inst_name
, net_map_at(inst
->GetInput1()), net_map_at(inst
->GetInput2()), net_map_at(inst
->GetOutput()));
262 if (inst
->Type() == PRIM_NOR
) {
263 RTLIL::SigSpec tmp
= module
->addWire(new_verific_id(inst
));
264 module
->addOrGate(new_verific_id(inst
), net_map_at(inst
->GetInput1()), net_map_at(inst
->GetInput2()), tmp
);
265 module
->addNotGate(inst_name
, tmp
, net_map_at(inst
->GetOutput()));
269 if (inst
->Type() == PRIM_XOR
) {
270 module
->addXorGate(inst_name
, net_map_at(inst
->GetInput1()), net_map_at(inst
->GetInput2()), net_map_at(inst
->GetOutput()));
274 if (inst
->Type() == PRIM_XNOR
) {
275 module
->addXnorGate(inst_name
, net_map_at(inst
->GetInput1()), net_map_at(inst
->GetInput2()), net_map_at(inst
->GetOutput()));
279 if (inst
->Type() == PRIM_BUF
) {
280 auto outnet
= inst
->GetOutput();
281 if (!any_all_nets
.count(outnet
))
282 module
->addBufGate(inst_name
, net_map_at(inst
->GetInput()), net_map_at(outnet
));
286 if (inst
->Type() == PRIM_INV
) {
287 module
->addNotGate(inst_name
, net_map_at(inst
->GetInput()), net_map_at(inst
->GetOutput()));
291 if (inst
->Type() == PRIM_MUX
) {
292 module
->addMuxGate(inst_name
, net_map_at(inst
->GetInput1()), net_map_at(inst
->GetInput2()), net_map_at(inst
->GetControl()), net_map_at(inst
->GetOutput()));
296 if (inst
->Type() == PRIM_TRI
) {
297 module
->addMuxGate(inst_name
, RTLIL::State::Sz
, net_map_at(inst
->GetInput()), net_map_at(inst
->GetControl()), net_map_at(inst
->GetOutput()));
301 if (inst
->Type() == PRIM_FADD
)
303 RTLIL::SigSpec a
= net_map_at(inst
->GetInput1()), b
= net_map_at(inst
->GetInput2()), c
= net_map_at(inst
->GetCin());
304 RTLIL::SigSpec x
= inst
->GetCout() ? net_map_at(inst
->GetCout()) : module
->addWire(new_verific_id(inst
));
305 RTLIL::SigSpec y
= inst
->GetOutput() ? net_map_at(inst
->GetOutput()) : module
->addWire(new_verific_id(inst
));
306 RTLIL::SigSpec tmp1
= module
->addWire(new_verific_id(inst
));
307 RTLIL::SigSpec tmp2
= module
->addWire(new_verific_id(inst
));
308 RTLIL::SigSpec tmp3
= module
->addWire(new_verific_id(inst
));
309 module
->addXorGate(new_verific_id(inst
), a
, b
, tmp1
);
310 module
->addXorGate(inst_name
, tmp1
, c
, y
);
311 module
->addAndGate(new_verific_id(inst
), tmp1
, c
, tmp2
);
312 module
->addAndGate(new_verific_id(inst
), a
, b
, tmp3
);
313 module
->addOrGate(new_verific_id(inst
), tmp2
, tmp3
, x
);
317 if (inst
->Type() == PRIM_DFFRS
)
319 VerificClocking
clocking(this, inst
->GetClock());
320 log_assert(clocking
.disable_sig
== State::S0
);
321 log_assert(clocking
.body_net
== nullptr);
323 if (inst
->GetSet()->IsGnd() && inst
->GetReset()->IsGnd())
324 clocking
.addDff(inst_name
, net_map_at(inst
->GetInput()), net_map_at(inst
->GetOutput()));
325 else if (inst
->GetSet()->IsGnd())
326 clocking
.addAdff(inst_name
, net_map_at(inst
->GetReset()), net_map_at(inst
->GetInput()), net_map_at(inst
->GetOutput()), State::S0
);
327 else if (inst
->GetReset()->IsGnd())
328 clocking
.addAdff(inst_name
, net_map_at(inst
->GetSet()), net_map_at(inst
->GetInput()), net_map_at(inst
->GetOutput()), State::S1
);
330 clocking
.addDffsr(inst_name
, net_map_at(inst
->GetSet()), net_map_at(inst
->GetReset()),
331 net_map_at(inst
->GetInput()), net_map_at(inst
->GetOutput()));
338 bool VerificImporter::import_netlist_instance_cells(Instance
*inst
, RTLIL::IdString inst_name
)
340 RTLIL::Cell
*cell
= nullptr;
342 if (inst
->Type() == PRIM_AND
) {
343 cell
= module
->addAnd(inst_name
, net_map_at(inst
->GetInput1()), net_map_at(inst
->GetInput2()), net_map_at(inst
->GetOutput()));
344 import_attributes(cell
->attributes
, inst
);
348 if (inst
->Type() == PRIM_NAND
) {
349 RTLIL::SigSpec tmp
= module
->addWire(new_verific_id(inst
));
350 cell
= module
->addAnd(new_verific_id(inst
), net_map_at(inst
->GetInput1()), net_map_at(inst
->GetInput2()), tmp
);
351 import_attributes(cell
->attributes
, inst
);
352 cell
= module
->addNot(inst_name
, tmp
, net_map_at(inst
->GetOutput()));
353 import_attributes(cell
->attributes
, inst
);
357 if (inst
->Type() == PRIM_OR
) {
358 cell
= module
->addOr(inst_name
, net_map_at(inst
->GetInput1()), net_map_at(inst
->GetInput2()), net_map_at(inst
->GetOutput()));
359 import_attributes(cell
->attributes
, inst
);
363 if (inst
->Type() == PRIM_NOR
) {
364 RTLIL::SigSpec tmp
= module
->addWire(new_verific_id(inst
));
365 cell
= module
->addOr(new_verific_id(inst
), net_map_at(inst
->GetInput1()), net_map_at(inst
->GetInput2()), tmp
);
366 import_attributes(cell
->attributes
, inst
);
367 cell
= module
->addNot(inst_name
, tmp
, net_map_at(inst
->GetOutput()));
368 import_attributes(cell
->attributes
, inst
);
372 if (inst
->Type() == PRIM_XOR
) {
373 cell
= module
->addXor(inst_name
, net_map_at(inst
->GetInput1()), net_map_at(inst
->GetInput2()), net_map_at(inst
->GetOutput()));
374 import_attributes(cell
->attributes
, inst
);
378 if (inst
->Type() == PRIM_XNOR
) {
379 cell
= module
->addXnor(inst_name
, net_map_at(inst
->GetInput1()), net_map_at(inst
->GetInput2()), net_map_at(inst
->GetOutput()));
380 import_attributes(cell
->attributes
, inst
);
384 if (inst
->Type() == PRIM_INV
) {
385 cell
= module
->addNot(inst_name
, net_map_at(inst
->GetInput()), net_map_at(inst
->GetOutput()));
386 import_attributes(cell
->attributes
, inst
);
390 if (inst
->Type() == PRIM_MUX
) {
391 cell
= module
->addMux(inst_name
, net_map_at(inst
->GetInput1()), net_map_at(inst
->GetInput2()), net_map_at(inst
->GetControl()), net_map_at(inst
->GetOutput()));
392 import_attributes(cell
->attributes
, inst
);
396 if (inst
->Type() == PRIM_TRI
) {
397 cell
= module
->addMux(inst_name
, RTLIL::State::Sz
, net_map_at(inst
->GetInput()), net_map_at(inst
->GetControl()), net_map_at(inst
->GetOutput()));
398 import_attributes(cell
->attributes
, inst
);
402 if (inst
->Type() == PRIM_FADD
)
404 RTLIL::SigSpec a_plus_b
= module
->addWire(new_verific_id(inst
), 2);
405 RTLIL::SigSpec y
= inst
->GetOutput() ? net_map_at(inst
->GetOutput()) : module
->addWire(new_verific_id(inst
));
407 y
.append(net_map_at(inst
->GetCout()));
408 cell
= module
->addAdd(new_verific_id(inst
), net_map_at(inst
->GetInput1()), net_map_at(inst
->GetInput2()), a_plus_b
);
409 import_attributes(cell
->attributes
, inst
);
410 cell
= module
->addAdd(inst_name
, a_plus_b
, net_map_at(inst
->GetCin()), y
);
411 import_attributes(cell
->attributes
, inst
);
415 if (inst
->Type() == PRIM_DFFRS
)
417 VerificClocking
clocking(this, inst
->GetClock());
418 log_assert(clocking
.disable_sig
== State::S0
);
419 log_assert(clocking
.body_net
== nullptr);
421 if (inst
->GetSet()->IsGnd() && inst
->GetReset()->IsGnd())
422 cell
= clocking
.addDff(inst_name
, net_map_at(inst
->GetInput()), net_map_at(inst
->GetOutput()));
423 else if (inst
->GetSet()->IsGnd())
424 cell
= clocking
.addAdff(inst_name
, net_map_at(inst
->GetReset()), net_map_at(inst
->GetInput()), net_map_at(inst
->GetOutput()), RTLIL::State::S0
);
425 else if (inst
->GetReset()->IsGnd())
426 cell
= clocking
.addAdff(inst_name
, net_map_at(inst
->GetSet()), net_map_at(inst
->GetInput()), net_map_at(inst
->GetOutput()), RTLIL::State::S1
);
428 cell
= clocking
.addDffsr(inst_name
, net_map_at(inst
->GetSet()), net_map_at(inst
->GetReset()),
429 net_map_at(inst
->GetInput()), net_map_at(inst
->GetOutput()));
430 import_attributes(cell
->attributes
, inst
);
434 if (inst
->Type() == PRIM_DLATCHRS
)
436 if (inst
->GetSet()->IsGnd() && inst
->GetReset()->IsGnd())
437 cell
= module
->addDlatch(inst_name
, net_map_at(inst
->GetControl()), net_map_at(inst
->GetInput()), net_map_at(inst
->GetOutput()));
439 cell
= module
->addDlatchsr(inst_name
, net_map_at(inst
->GetControl()), net_map_at(inst
->GetSet()), net_map_at(inst
->GetReset()),
440 net_map_at(inst
->GetInput()), net_map_at(inst
->GetOutput()));
441 import_attributes(cell
->attributes
, inst
);
445 #define IN operatorInput(inst)
446 #define IN1 operatorInput1(inst)
447 #define IN2 operatorInput2(inst)
448 #define OUT operatorOutput(inst)
449 #define FILTERED_OUT operatorOutput(inst, &any_all_nets)
450 #define SIGNED inst->View()->IsSigned()
452 if (inst
->Type() == OPER_ADDER
) {
453 RTLIL::SigSpec out
= OUT
;
454 if (inst
->GetCout() != NULL
)
455 out
.append(net_map_at(inst
->GetCout()));
456 if (inst
->GetCin()->IsGnd()) {
457 cell
= module
->addAdd(inst_name
, IN1
, IN2
, out
, SIGNED
);
458 import_attributes(cell
->attributes
, inst
);
460 RTLIL::SigSpec tmp
= module
->addWire(new_verific_id(inst
), GetSize(out
));
461 cell
= module
->addAdd(new_verific_id(inst
), IN1
, IN2
, tmp
, SIGNED
);
462 import_attributes(cell
->attributes
, inst
);
463 cell
= module
->addAdd(inst_name
, tmp
, net_map_at(inst
->GetCin()), out
, false);
464 import_attributes(cell
->attributes
, inst
);
469 if (inst
->Type() == OPER_MULTIPLIER
) {
470 cell
= module
->addMul(inst_name
, IN1
, IN2
, OUT
, SIGNED
);
471 import_attributes(cell
->attributes
, inst
);
475 if (inst
->Type() == OPER_DIVIDER
) {
476 cell
= module
->addDiv(inst_name
, IN1
, IN2
, OUT
, SIGNED
);
477 import_attributes(cell
->attributes
, inst
);
481 if (inst
->Type() == OPER_MODULO
) {
482 cell
= module
->addMod(inst_name
, IN1
, IN2
, OUT
, SIGNED
);
483 import_attributes(cell
->attributes
, inst
);
487 if (inst
->Type() == OPER_REMAINDER
) {
488 cell
= module
->addMod(inst_name
, IN1
, IN2
, OUT
, SIGNED
);
489 import_attributes(cell
->attributes
, inst
);
493 if (inst
->Type() == OPER_SHIFT_LEFT
) {
494 cell
= module
->addShl(inst_name
, IN1
, IN2
, OUT
, false);
495 import_attributes(cell
->attributes
, inst
);
499 if (inst
->Type() == OPER_ENABLED_DECODER
) {
501 vec
.append(net_map_at(inst
->GetControl()));
502 for (unsigned i
= 1; i
< inst
->OutputSize(); i
++) {
503 vec
.append(RTLIL::State::S0
);
505 cell
= module
->addShl(inst_name
, vec
, IN
, OUT
, false);
506 import_attributes(cell
->attributes
, inst
);
510 if (inst
->Type() == OPER_DECODER
) {
512 vec
.append(RTLIL::State::S1
);
513 for (unsigned i
= 1; i
< inst
->OutputSize(); i
++) {
514 vec
.append(RTLIL::State::S0
);
516 cell
= module
->addShl(inst_name
, vec
, IN
, OUT
, false);
517 import_attributes(cell
->attributes
, inst
);
521 if (inst
->Type() == OPER_SHIFT_RIGHT
) {
522 Net
*net_cin
= inst
->GetCin();
523 Net
*net_a_msb
= inst
->GetInput1Bit(0);
524 if (net_cin
->IsGnd())
525 cell
= module
->addShr(inst_name
, IN1
, IN2
, OUT
, false);
526 else if (net_cin
== net_a_msb
)
527 cell
= module
->addSshr(inst_name
, IN1
, IN2
, OUT
, true);
529 log_error("Can't import Verific OPER_SHIFT_RIGHT instance %s: carry_in is neither 0 nor msb of left input\n", inst
->Name());
530 import_attributes(cell
->attributes
, inst
);
534 if (inst
->Type() == OPER_REDUCE_AND
) {
535 cell
= module
->addReduceAnd(inst_name
, IN
, net_map_at(inst
->GetOutput()), SIGNED
);
536 import_attributes(cell
->attributes
, inst
);
540 if (inst
->Type() == OPER_REDUCE_OR
) {
541 cell
= module
->addReduceOr(inst_name
, IN
, net_map_at(inst
->GetOutput()), SIGNED
);
542 import_attributes(cell
->attributes
, inst
);
546 if (inst
->Type() == OPER_REDUCE_XOR
) {
547 cell
= module
->addReduceXor(inst_name
, IN
, net_map_at(inst
->GetOutput()), SIGNED
);
548 import_attributes(cell
->attributes
, inst
);
552 if (inst
->Type() == OPER_REDUCE_XNOR
) {
553 cell
= module
->addReduceXnor(inst_name
, IN
, net_map_at(inst
->GetOutput()), SIGNED
);
554 import_attributes(cell
->attributes
, inst
);
558 if (inst
->Type() == OPER_REDUCE_NOR
) {
559 SigSpec t
= module
->ReduceOr(new_verific_id(inst
), IN
, SIGNED
);
560 cell
= module
->addNot(inst_name
, t
, net_map_at(inst
->GetOutput()));
561 import_attributes(cell
->attributes
, inst
);
565 if (inst
->Type() == OPER_LESSTHAN
) {
566 Net
*net_cin
= inst
->GetCin();
567 if (net_cin
->IsGnd())
568 cell
= module
->addLt(inst_name
, IN1
, IN2
, net_map_at(inst
->GetOutput()), SIGNED
);
569 else if (net_cin
->IsPwr())
570 cell
= module
->addLe(inst_name
, IN1
, IN2
, net_map_at(inst
->GetOutput()), SIGNED
);
572 log_error("Can't import Verific OPER_LESSTHAN instance %s: carry_in is neither 0 nor 1\n", inst
->Name());
573 import_attributes(cell
->attributes
, inst
);
577 if (inst
->Type() == OPER_WIDE_AND
) {
578 cell
= module
->addAnd(inst_name
, IN1
, IN2
, OUT
, SIGNED
);
579 import_attributes(cell
->attributes
, inst
);
583 if (inst
->Type() == OPER_WIDE_OR
) {
584 cell
= module
->addOr(inst_name
, IN1
, IN2
, OUT
, SIGNED
);
585 import_attributes(cell
->attributes
, inst
);
589 if (inst
->Type() == OPER_WIDE_XOR
) {
590 cell
= module
->addXor(inst_name
, IN1
, IN2
, OUT
, SIGNED
);
591 import_attributes(cell
->attributes
, inst
);
595 if (inst
->Type() == OPER_WIDE_XNOR
) {
596 cell
= module
->addXnor(inst_name
, IN1
, IN2
, OUT
, SIGNED
);
597 import_attributes(cell
->attributes
, inst
);
601 if (inst
->Type() == OPER_WIDE_BUF
) {
602 cell
= module
->addPos(inst_name
, IN
, FILTERED_OUT
, SIGNED
);
603 import_attributes(cell
->attributes
, inst
);
607 if (inst
->Type() == OPER_WIDE_INV
) {
608 cell
= module
->addNot(inst_name
, IN
, OUT
, SIGNED
);
609 import_attributes(cell
->attributes
, inst
);
613 if (inst
->Type() == OPER_MINUS
) {
614 cell
= module
->addSub(inst_name
, IN1
, IN2
, OUT
, SIGNED
);
615 import_attributes(cell
->attributes
, inst
);
619 if (inst
->Type() == OPER_UMINUS
) {
620 cell
= module
->addNeg(inst_name
, IN
, OUT
, SIGNED
);
621 import_attributes(cell
->attributes
, inst
);
625 if (inst
->Type() == OPER_EQUAL
) {
626 cell
= module
->addEq(inst_name
, IN1
, IN2
, net_map_at(inst
->GetOutput()), SIGNED
);
627 import_attributes(cell
->attributes
, inst
);
631 if (inst
->Type() == OPER_NEQUAL
) {
632 cell
= module
->addNe(inst_name
, IN1
, IN2
, net_map_at(inst
->GetOutput()), SIGNED
);
633 import_attributes(cell
->attributes
, inst
);
637 if (inst
->Type() == OPER_WIDE_MUX
) {
638 cell
= module
->addMux(inst_name
, IN1
, IN2
, net_map_at(inst
->GetControl()), OUT
);
639 import_attributes(cell
->attributes
, inst
);
643 if (inst
->Type() == OPER_NTO1MUX
) {
644 cell
= module
->addShr(inst_name
, IN2
, IN1
, net_map_at(inst
->GetOutput()));
645 import_attributes(cell
->attributes
, inst
);
649 if (inst
->Type() == OPER_WIDE_NTO1MUX
)
651 SigSpec data
= IN2
, out
= OUT
;
653 int wordsize_bits
= ceil_log2(GetSize(out
));
654 int wordsize
= 1 << wordsize_bits
;
656 SigSpec sel
= {IN1
, SigSpec(State::S0
, wordsize_bits
)};
659 for (int i
= 0; i
< GetSize(data
); i
+= GetSize(out
)) {
660 SigSpec d
= data
.extract(i
, GetSize(out
));
661 d
.extend_u0(wordsize
);
662 padded_data
.append(d
);
665 cell
= module
->addShr(inst_name
, padded_data
, sel
, out
);
666 import_attributes(cell
->attributes
, inst
);
670 if (inst
->Type() == OPER_SELECTOR
)
672 cell
= module
->addPmux(inst_name
, State::S0
, IN2
, IN1
, net_map_at(inst
->GetOutput()));
673 import_attributes(cell
->attributes
, inst
);
677 if (inst
->Type() == OPER_WIDE_SELECTOR
)
680 cell
= module
->addPmux(inst_name
, SigSpec(State::S0
, GetSize(out
)), IN2
, IN1
, out
);
681 import_attributes(cell
->attributes
, inst
);
685 if (inst
->Type() == OPER_WIDE_TRI
) {
686 cell
= module
->addMux(inst_name
, RTLIL::SigSpec(RTLIL::State::Sz
, inst
->OutputSize()), IN
, net_map_at(inst
->GetControl()), OUT
);
687 import_attributes(cell
->attributes
, inst
);
691 if (inst
->Type() == OPER_WIDE_DFFRS
)
693 VerificClocking
clocking(this, inst
->GetClock());
694 log_assert(clocking
.disable_sig
== State::S0
);
695 log_assert(clocking
.body_net
== nullptr);
697 RTLIL::SigSpec sig_set
= operatorInport(inst
, "set");
698 RTLIL::SigSpec sig_reset
= operatorInport(inst
, "reset");
700 if (sig_set
.is_fully_const() && !sig_set
.as_bool() && sig_reset
.is_fully_const() && !sig_reset
.as_bool())
701 cell
= clocking
.addDff(inst_name
, IN
, OUT
);
703 cell
= clocking
.addDffsr(inst_name
, sig_set
, sig_reset
, IN
, OUT
);
704 import_attributes(cell
->attributes
, inst
);
718 void VerificImporter::merge_past_ffs_clock(pool
<RTLIL::Cell
*> &candidates
, SigBit clock
, bool clock_pol
)
720 bool keep_running
= true;
725 keep_running
= false;
727 dict
<SigBit
, pool
<RTLIL::Cell
*>> dbits_db
;
730 for (auto cell
: candidates
) {
731 SigBit bit
= sigmap(cell
->getPort("\\D"));
732 dbits_db
[bit
].insert(cell
);
736 dbits
.sort_and_unify();
738 for (auto chunk
: dbits
.chunks())
740 SigSpec sig_d
= chunk
;
742 if (chunk
.wire
== nullptr || GetSize(sig_d
) == 1)
745 SigSpec sig_q
= module
->addWire(NEW_ID
, GetSize(sig_d
));
746 RTLIL::Cell
*new_ff
= module
->addDff(NEW_ID
, clock
, sig_d
, sig_q
, clock_pol
);
749 log(" merging single-bit past_ffs into new %d-bit ff %s.\n", GetSize(sig_d
), log_id(new_ff
));
751 for (int i
= 0; i
< GetSize(sig_d
); i
++)
752 for (auto old_ff
: dbits_db
[sig_d
[i
]])
755 log(" replacing old ff %s on bit %d.\n", log_id(old_ff
), i
);
757 SigBit old_q
= old_ff
->getPort("\\Q");
758 SigBit new_q
= sig_q
[i
];
760 sigmap
.add(old_q
, new_q
);
761 module
->connect(old_q
, new_q
);
762 candidates
.erase(old_ff
);
763 module
->remove(old_ff
);
770 void VerificImporter::merge_past_ffs(pool
<RTLIL::Cell
*> &candidates
)
772 dict
<pair
<SigBit
, int>, pool
<RTLIL::Cell
*>> database
;
774 for (auto cell
: candidates
)
776 SigBit clock
= cell
->getPort("\\CLK");
777 bool clock_pol
= cell
->getParam("\\CLK_POLARITY").as_bool();
778 database
[make_pair(clock
, int(clock_pol
))].insert(cell
);
781 for (auto it
: database
)
782 merge_past_ffs_clock(it
.second
, it
.first
.first
, it
.first
.second
);
785 void VerificImporter::import_netlist(RTLIL::Design
*design
, Netlist
*nl
, std::set
<Netlist
*> &nl_todo
)
787 std::string netlist_name
= nl
->GetAtt(" \\top") ? nl
->CellBaseName() : nl
->Owner()->Name();
788 std::string module_name
= nl
->IsOperator() ? "$verific$" + netlist_name
: RTLIL::escape_id(netlist_name
);
792 if (design
->has(module_name
)) {
793 if (!nl
->IsOperator() && !is_blackbox(nl
))
794 log_cmd_error("Re-definition of module `%s'.\n", netlist_name
.c_str());
798 module
= new RTLIL::Module
;
799 module
->name
= module_name
;
802 if (is_blackbox(nl
)) {
803 log("Importing blackbox module %s.\n", RTLIL::id2cstr(module
->name
));
804 module
->set_bool_attribute("\\blackbox");
806 log("Importing module %s.\n", RTLIL::id2cstr(module
->name
));
818 FOREACH_PORT_OF_NETLIST(nl
, mi
, port
)
824 log(" importing port %s.\n", port
->Name());
826 RTLIL::Wire
*wire
= module
->addWire(RTLIL::escape_id(port
->Name()));
827 import_attributes(wire
->attributes
, port
);
829 wire
->port_id
= nl
->IndexOf(port
) + 1;
831 if (port
->GetDir() == DIR_INOUT
|| port
->GetDir() == DIR_IN
)
832 wire
->port_input
= true;
833 if (port
->GetDir() == DIR_INOUT
|| port
->GetDir() == DIR_OUT
)
834 wire
->port_output
= true;
836 if (port
->GetNet()) {
837 net
= port
->GetNet();
838 if (net_map
.count(net
) == 0)
840 else if (wire
->port_input
)
841 module
->connect(net_map_at(net
), wire
);
843 module
->connect(wire
, net_map_at(net
));
847 FOREACH_PORTBUS_OF_NETLIST(nl
, mi
, portbus
)
850 log(" importing portbus %s.\n", portbus
->Name());
852 RTLIL::Wire
*wire
= module
->addWire(RTLIL::escape_id(portbus
->Name()), portbus
->Size());
853 wire
->start_offset
= min(portbus
->LeftIndex(), portbus
->RightIndex());
854 import_attributes(wire
->attributes
, portbus
);
856 if (portbus
->GetDir() == DIR_INOUT
|| portbus
->GetDir() == DIR_IN
)
857 wire
->port_input
= true;
858 if (portbus
->GetDir() == DIR_INOUT
|| portbus
->GetDir() == DIR_OUT
)
859 wire
->port_output
= true;
861 for (int i
= portbus
->LeftIndex();; i
+= portbus
->IsUp() ? +1 : -1) {
862 if (portbus
->ElementAtIndex(i
) && portbus
->ElementAtIndex(i
)->GetNet()) {
863 net
= portbus
->ElementAtIndex(i
)->GetNet();
864 RTLIL::SigBit
bit(wire
, i
- wire
->start_offset
);
865 if (net_map
.count(net
) == 0)
867 else if (wire
->port_input
)
868 module
->connect(net_map_at(net
), bit
);
870 module
->connect(bit
, net_map_at(net
));
872 if (i
== portbus
->RightIndex())
877 module
->fixup_ports();
879 dict
<Net
*, char, hash_ptr_ops
> init_nets
;
880 pool
<Net
*, hash_ptr_ops
> anyconst_nets
, anyseq_nets
;
881 pool
<Net
*, hash_ptr_ops
> allconst_nets
, allseq_nets
;
882 any_all_nets
.clear();
884 FOREACH_NET_OF_NETLIST(nl
, mi
, net
)
888 RTLIL::Memory
*memory
= new RTLIL::Memory
;
889 memory
->name
= RTLIL::escape_id(net
->Name());
890 log_assert(module
->count_id(memory
->name
) == 0);
891 module
->memories
[memory
->name
] = memory
;
893 int number_of_bits
= net
->Size();
894 int bits_in_word
= number_of_bits
;
895 FOREACH_PORTREF_OF_NET(net
, si
, pr
) {
896 if (pr
->GetInst()->Type() == OPER_READ_PORT
) {
897 bits_in_word
= min
<int>(bits_in_word
, pr
->GetInst()->OutputSize());
900 if (pr
->GetInst()->Type() == OPER_WRITE_PORT
|| pr
->GetInst()->Type() == OPER_CLOCKED_WRITE_PORT
) {
901 bits_in_word
= min
<int>(bits_in_word
, pr
->GetInst()->Input2Size());
904 log_error("Verific RamNet %s is connected to unsupported instance type %s (%s).\n",
905 net
->Name(), pr
->GetInst()->View()->Owner()->Name(), pr
->GetInst()->Name());
908 memory
->width
= bits_in_word
;
909 memory
->size
= number_of_bits
/ bits_in_word
;
911 const char *ascii_initdata
= net
->GetWideInitialValue();
912 if (ascii_initdata
) {
913 while (*ascii_initdata
!= 0 && *ascii_initdata
!= '\'')
915 if (*ascii_initdata
== '\'')
917 if (*ascii_initdata
!= 0) {
918 log_assert(*ascii_initdata
== 'b');
921 for (int word_idx
= 0; word_idx
< memory
->size
; word_idx
++) {
922 Const initval
= Const(State::Sx
, memory
->width
);
923 bool initval_valid
= false;
924 for (int bit_idx
= memory
->width
-1; bit_idx
>= 0; bit_idx
--) {
925 if (*ascii_initdata
== 0)
927 if (*ascii_initdata
== '0' || *ascii_initdata
== '1') {
928 initval
[bit_idx
] = (*ascii_initdata
== '0') ? State::S0
: State::S1
;
929 initval_valid
= true;
934 RTLIL::Cell
*cell
= module
->addCell(new_verific_id(net
), "$meminit");
935 cell
->parameters
["\\WORDS"] = 1;
936 if (net
->GetOrigTypeRange()->LeftRangeBound() < net
->GetOrigTypeRange()->RightRangeBound())
937 cell
->setPort("\\ADDR", word_idx
);
939 cell
->setPort("\\ADDR", memory
->size
- word_idx
- 1);
940 cell
->setPort("\\DATA", initval
);
941 cell
->parameters
["\\MEMID"] = RTLIL::Const(memory
->name
.str());
942 cell
->parameters
["\\ABITS"] = 32;
943 cell
->parameters
["\\WIDTH"] = memory
->width
;
944 cell
->parameters
["\\PRIORITY"] = RTLIL::Const(autoidx
-1);
951 if (net
->GetInitialValue())
952 init_nets
[net
] = net
->GetInitialValue();
954 const char *rand_const_attr
= net
->GetAttValue(" rand_const");
955 const char *rand_attr
= net
->GetAttValue(" rand");
957 const char *anyconst_attr
= net
->GetAttValue("anyconst");
958 const char *anyseq_attr
= net
->GetAttValue("anyseq");
960 const char *allconst_attr
= net
->GetAttValue("allconst");
961 const char *allseq_attr
= net
->GetAttValue("allseq");
963 if (rand_const_attr
!= nullptr && (!strcmp(rand_const_attr
, "1") || !strcmp(rand_const_attr
, "'1'"))) {
964 anyconst_nets
.insert(net
);
965 any_all_nets
.insert(net
);
967 else if (rand_attr
!= nullptr && (!strcmp(rand_attr
, "1") || !strcmp(rand_attr
, "'1'"))) {
968 anyseq_nets
.insert(net
);
969 any_all_nets
.insert(net
);
971 else if (anyconst_attr
!= nullptr && (!strcmp(anyconst_attr
, "1") || !strcmp(anyconst_attr
, "'1'"))) {
972 anyconst_nets
.insert(net
);
973 any_all_nets
.insert(net
);
975 else if (anyseq_attr
!= nullptr && (!strcmp(anyseq_attr
, "1") || !strcmp(anyseq_attr
, "'1'"))) {
976 anyseq_nets
.insert(net
);
977 any_all_nets
.insert(net
);
979 else if (allconst_attr
!= nullptr && (!strcmp(allconst_attr
, "1") || !strcmp(allconst_attr
, "'1'"))) {
980 allconst_nets
.insert(net
);
981 any_all_nets
.insert(net
);
983 else if (allseq_attr
!= nullptr && (!strcmp(allseq_attr
, "1") || !strcmp(allseq_attr
, "'1'"))) {
984 allseq_nets
.insert(net
);
985 any_all_nets
.insert(net
);
988 if (net_map
.count(net
)) {
990 log(" skipping net %s.\n", net
->Name());
997 RTLIL::IdString wire_name
= module
->uniquify(mode_names
|| net
->IsUserDeclared() ? RTLIL::escape_id(net
->Name()) : new_verific_id(net
));
1000 log(" importing net %s as %s.\n", net
->Name(), log_id(wire_name
));
1002 RTLIL::Wire
*wire
= module
->addWire(wire_name
);
1003 import_attributes(wire
->attributes
, net
);
1005 net_map
[net
] = wire
;
1008 FOREACH_NETBUS_OF_NETLIST(nl
, mi
, netbus
)
1010 bool found_new_net
= false;
1011 for (int i
= netbus
->LeftIndex();; i
+= netbus
->IsUp() ? +1 : -1) {
1012 net
= netbus
->ElementAtIndex(i
);
1013 if (net_map
.count(net
) == 0)
1014 found_new_net
= true;
1015 if (i
== netbus
->RightIndex())
1021 RTLIL::IdString wire_name
= module
->uniquify(mode_names
|| netbus
->IsUserDeclared() ? RTLIL::escape_id(netbus
->Name()) : new_verific_id(netbus
));
1023 if (verific_verbose
)
1024 log(" importing netbus %s as %s.\n", netbus
->Name(), log_id(wire_name
));
1026 RTLIL::Wire
*wire
= module
->addWire(wire_name
, netbus
->Size());
1027 wire
->start_offset
= min(netbus
->LeftIndex(), netbus
->RightIndex());
1028 import_attributes(wire
->attributes
, netbus
);
1030 RTLIL::Const initval
= Const(State::Sx
, GetSize(wire
));
1031 bool initval_valid
= false;
1033 for (int i
= netbus
->LeftIndex();; i
+= netbus
->IsUp() ? +1 : -1)
1035 if (netbus
->ElementAtIndex(i
))
1037 int bitidx
= i
- wire
->start_offset
;
1038 net
= netbus
->ElementAtIndex(i
);
1039 RTLIL::SigBit
bit(wire
, bitidx
);
1041 if (init_nets
.count(net
)) {
1042 if (init_nets
.at(net
) == '0')
1043 initval
.bits
.at(bitidx
) = State::S0
;
1044 if (init_nets
.at(net
) == '1')
1045 initval
.bits
.at(bitidx
) = State::S1
;
1046 initval_valid
= true;
1047 init_nets
.erase(net
);
1050 if (net_map
.count(net
) == 0)
1053 module
->connect(bit
, net_map_at(net
));
1056 if (i
== netbus
->RightIndex())
1061 wire
->attributes
["\\init"] = initval
;
1065 if (verific_verbose
)
1066 log(" skipping netbus %s.\n", netbus
->Name());
1069 SigSpec anyconst_sig
;
1071 SigSpec allconst_sig
;
1074 for (int i
= netbus
->RightIndex();; i
+= netbus
->IsUp() ? -1 : +1) {
1075 net
= netbus
->ElementAtIndex(i
);
1076 if (net
!= nullptr && anyconst_nets
.count(net
)) {
1077 anyconst_sig
.append(net_map_at(net
));
1078 anyconst_nets
.erase(net
);
1080 if (net
!= nullptr && anyseq_nets
.count(net
)) {
1081 anyseq_sig
.append(net_map_at(net
));
1082 anyseq_nets
.erase(net
);
1084 if (net
!= nullptr && allconst_nets
.count(net
)) {
1085 allconst_sig
.append(net_map_at(net
));
1086 allconst_nets
.erase(net
);
1088 if (net
!= nullptr && allseq_nets
.count(net
)) {
1089 allseq_sig
.append(net_map_at(net
));
1090 allseq_nets
.erase(net
);
1092 if (i
== netbus
->LeftIndex())
1096 if (GetSize(anyconst_sig
))
1097 module
->connect(anyconst_sig
, module
->Anyconst(new_verific_id(netbus
), GetSize(anyconst_sig
)));
1099 if (GetSize(anyseq_sig
))
1100 module
->connect(anyseq_sig
, module
->Anyseq(new_verific_id(netbus
), GetSize(anyseq_sig
)));
1102 if (GetSize(allconst_sig
))
1103 module
->connect(allconst_sig
, module
->Allconst(new_verific_id(netbus
), GetSize(allconst_sig
)));
1105 if (GetSize(allseq_sig
))
1106 module
->connect(allseq_sig
, module
->Allseq(new_verific_id(netbus
), GetSize(allseq_sig
)));
1109 for (auto it
: init_nets
)
1112 SigBit bit
= net_map_at(it
.first
);
1113 log_assert(bit
.wire
);
1115 if (bit
.wire
->attributes
.count("\\init"))
1116 initval
= bit
.wire
->attributes
.at("\\init");
1118 while (GetSize(initval
) < GetSize(bit
.wire
))
1119 initval
.bits
.push_back(State::Sx
);
1121 if (it
.second
== '0')
1122 initval
.bits
.at(bit
.offset
) = State::S0
;
1123 if (it
.second
== '1')
1124 initval
.bits
.at(bit
.offset
) = State::S1
;
1126 bit
.wire
->attributes
["\\init"] = initval
;
1129 for (auto net
: anyconst_nets
)
1130 module
->connect(net_map_at(net
), module
->Anyconst(new_verific_id(net
)));
1132 for (auto net
: anyseq_nets
)
1133 module
->connect(net_map_at(net
), module
->Anyseq(new_verific_id(net
)));
1135 pool
<Instance
*, hash_ptr_ops
> sva_asserts
;
1136 pool
<Instance
*, hash_ptr_ops
> sva_assumes
;
1137 pool
<Instance
*, hash_ptr_ops
> sva_covers
;
1138 pool
<Instance
*, hash_ptr_ops
> sva_triggers
;
1140 pool
<RTLIL::Cell
*> past_ffs
;
1142 FOREACH_INSTANCE_OF_NETLIST(nl
, mi
, inst
)
1144 RTLIL::IdString inst_name
= module
->uniquify(mode_names
|| inst
->IsUserDeclared() ? RTLIL::escape_id(inst
->Name()) : new_verific_id(inst
));
1146 if (verific_verbose
)
1147 log(" importing cell %s (%s) as %s.\n", inst
->Name(), inst
->View()->Owner()->Name(), log_id(inst_name
));
1150 goto import_verific_cells
;
1152 if (inst
->Type() == PRIM_PWR
) {
1153 module
->connect(net_map_at(inst
->GetOutput()), RTLIL::State::S1
);
1157 if (inst
->Type() == PRIM_GND
) {
1158 module
->connect(net_map_at(inst
->GetOutput()), RTLIL::State::S0
);
1162 if (inst
->Type() == PRIM_BUF
) {
1163 auto outnet
= inst
->GetOutput();
1164 if (!any_all_nets
.count(outnet
))
1165 module
->addBufGate(inst_name
, net_map_at(inst
->GetInput()), net_map_at(outnet
));
1169 if (inst
->Type() == PRIM_X
) {
1170 module
->connect(net_map_at(inst
->GetOutput()), RTLIL::State::Sx
);
1174 if (inst
->Type() == PRIM_Z
) {
1175 module
->connect(net_map_at(inst
->GetOutput()), RTLIL::State::Sz
);
1179 if (inst
->Type() == OPER_READ_PORT
)
1181 RTLIL::Memory
*memory
= module
->memories
.at(RTLIL::escape_id(inst
->GetInput()->Name()));
1182 int numchunks
= int(inst
->OutputSize()) / memory
->width
;
1183 int chunksbits
= ceil_log2(numchunks
);
1185 if ((numchunks
* memory
->width
) != int(inst
->OutputSize()) || (numchunks
& (numchunks
- 1)) != 0)
1186 log_error("Import of asymmetric memories of this type is not supported yet: %s %s\n", inst
->Name(), inst
->GetInput()->Name());
1188 for (int i
= 0; i
< numchunks
; i
++)
1190 RTLIL::SigSpec addr
= {operatorInput1(inst
), RTLIL::Const(i
, chunksbits
)};
1191 RTLIL::SigSpec data
= operatorOutput(inst
).extract(i
* memory
->width
, memory
->width
);
1193 RTLIL::Cell
*cell
= module
->addCell(numchunks
== 1 ? inst_name
:
1194 RTLIL::IdString(stringf("%s_%d", inst_name
.c_str(), i
)), "$memrd");
1195 cell
->parameters
["\\MEMID"] = memory
->name
.str();
1196 cell
->parameters
["\\CLK_ENABLE"] = false;
1197 cell
->parameters
["\\CLK_POLARITY"] = true;
1198 cell
->parameters
["\\TRANSPARENT"] = false;
1199 cell
->parameters
["\\ABITS"] = GetSize(addr
);
1200 cell
->parameters
["\\WIDTH"] = GetSize(data
);
1201 cell
->setPort("\\CLK", RTLIL::State::Sx
);
1202 cell
->setPort("\\EN", RTLIL::State::Sx
);
1203 cell
->setPort("\\ADDR", addr
);
1204 cell
->setPort("\\DATA", data
);
1209 if (inst
->Type() == OPER_WRITE_PORT
|| inst
->Type() == OPER_CLOCKED_WRITE_PORT
)
1211 RTLIL::Memory
*memory
= module
->memories
.at(RTLIL::escape_id(inst
->GetOutput()->Name()));
1212 int numchunks
= int(inst
->Input2Size()) / memory
->width
;
1213 int chunksbits
= ceil_log2(numchunks
);
1215 if ((numchunks
* memory
->width
) != int(inst
->Input2Size()) || (numchunks
& (numchunks
- 1)) != 0)
1216 log_error("Import of asymmetric memories of this type is not supported yet: %s %s\n", inst
->Name(), inst
->GetOutput()->Name());
1218 for (int i
= 0; i
< numchunks
; i
++)
1220 RTLIL::SigSpec addr
= {operatorInput1(inst
), RTLIL::Const(i
, chunksbits
)};
1221 RTLIL::SigSpec data
= operatorInput2(inst
).extract(i
* memory
->width
, memory
->width
);
1223 RTLIL::Cell
*cell
= module
->addCell(numchunks
== 1 ? inst_name
:
1224 RTLIL::IdString(stringf("%s_%d", inst_name
.c_str(), i
)), "$memwr");
1225 cell
->parameters
["\\MEMID"] = memory
->name
.str();
1226 cell
->parameters
["\\CLK_ENABLE"] = false;
1227 cell
->parameters
["\\CLK_POLARITY"] = true;
1228 cell
->parameters
["\\PRIORITY"] = 0;
1229 cell
->parameters
["\\ABITS"] = GetSize(addr
);
1230 cell
->parameters
["\\WIDTH"] = GetSize(data
);
1231 cell
->setPort("\\EN", RTLIL::SigSpec(net_map_at(inst
->GetControl())).repeat(GetSize(data
)));
1232 cell
->setPort("\\CLK", RTLIL::State::S0
);
1233 cell
->setPort("\\ADDR", addr
);
1234 cell
->setPort("\\DATA", data
);
1236 if (inst
->Type() == OPER_CLOCKED_WRITE_PORT
) {
1237 cell
->parameters
["\\CLK_ENABLE"] = true;
1238 cell
->setPort("\\CLK", net_map_at(inst
->GetClock()));
1245 if (import_netlist_instance_cells(inst
, inst_name
))
1247 if (inst
->IsOperator() && !verific_sva_prims
.count(inst
->Type()))
1248 log_warning("Unsupported Verific operator: %s (fallback to gate level implementation provided by verific)\n", inst
->View()->Owner()->Name());
1250 if (import_netlist_instance_gates(inst
, inst_name
))
1254 if (inst
->Type() == PRIM_SVA_ASSERT
|| inst
->Type() == PRIM_SVA_IMMEDIATE_ASSERT
)
1255 sva_asserts
.insert(inst
);
1257 if (inst
->Type() == PRIM_SVA_ASSUME
|| inst
->Type() == PRIM_SVA_IMMEDIATE_ASSUME
)
1258 sva_assumes
.insert(inst
);
1260 if (inst
->Type() == PRIM_SVA_COVER
|| inst
->Type() == PRIM_SVA_IMMEDIATE_COVER
)
1261 sva_covers
.insert(inst
);
1263 if (inst
->Type() == PRIM_SVA_TRIGGERED
)
1264 sva_triggers
.insert(inst
);
1266 if (inst
->Type() == OPER_SVA_STABLE
)
1268 VerificClocking
clocking(this, inst
->GetInput2Bit(0));
1269 log_assert(clocking
.disable_sig
== State::S0
);
1270 log_assert(clocking
.body_net
== nullptr);
1272 log_assert(inst
->Input1Size() == inst
->OutputSize());
1274 SigSpec sig_d
, sig_q
, sig_o
;
1275 sig_q
= module
->addWire(new_verific_id(inst
), inst
->Input1Size());
1277 for (int i
= int(inst
->Input1Size())-1; i
>= 0; i
--){
1278 sig_d
.append(net_map_at(inst
->GetInput1Bit(i
)));
1279 sig_o
.append(net_map_at(inst
->GetOutputBit(i
)));
1282 if (verific_verbose
) {
1283 log(" %sedge FF with D=%s, Q=%s, C=%s.\n", clocking
.posedge
? "pos" : "neg",
1284 log_signal(sig_d
), log_signal(sig_q
), log_signal(clocking
.clock_sig
));
1285 log(" XNOR with A=%s, B=%s, Y=%s.\n",
1286 log_signal(sig_d
), log_signal(sig_q
), log_signal(sig_o
));
1289 clocking
.addDff(new_verific_id(inst
), sig_d
, sig_q
);
1290 module
->addXnor(new_verific_id(inst
), sig_d
, sig_q
, sig_o
);
1296 if (inst
->Type() == PRIM_SVA_STABLE
)
1298 VerificClocking
clocking(this, inst
->GetInput2());
1299 log_assert(clocking
.disable_sig
== State::S0
);
1300 log_assert(clocking
.body_net
== nullptr);
1302 SigSpec sig_d
= net_map_at(inst
->GetInput1());
1303 SigSpec sig_o
= net_map_at(inst
->GetOutput());
1304 SigSpec sig_q
= module
->addWire(new_verific_id(inst
));
1306 if (verific_verbose
) {
1307 log(" %sedge FF with D=%s, Q=%s, C=%s.\n", clocking
.posedge
? "pos" : "neg",
1308 log_signal(sig_d
), log_signal(sig_q
), log_signal(clocking
.clock_sig
));
1309 log(" XNOR with A=%s, B=%s, Y=%s.\n",
1310 log_signal(sig_d
), log_signal(sig_q
), log_signal(sig_o
));
1313 clocking
.addDff(new_verific_id(inst
), sig_d
, sig_q
);
1314 module
->addXnor(new_verific_id(inst
), sig_d
, sig_q
, sig_o
);
1320 if (inst
->Type() == PRIM_SVA_PAST
)
1322 VerificClocking
clocking(this, inst
->GetInput2());
1323 log_assert(clocking
.disable_sig
== State::S0
);
1324 log_assert(clocking
.body_net
== nullptr);
1326 SigBit sig_d
= net_map_at(inst
->GetInput1());
1327 SigBit sig_q
= net_map_at(inst
->GetOutput());
1329 if (verific_verbose
)
1330 log(" %sedge FF with D=%s, Q=%s, C=%s.\n", clocking
.posedge
? "pos" : "neg",
1331 log_signal(sig_d
), log_signal(sig_q
), log_signal(clocking
.clock_sig
));
1333 past_ffs
.insert(clocking
.addDff(new_verific_id(inst
), sig_d
, sig_q
));
1339 if ((inst
->Type() == PRIM_SVA_ROSE
|| inst
->Type() == PRIM_SVA_FELL
))
1341 VerificClocking
clocking(this, inst
->GetInput2());
1342 log_assert(clocking
.disable_sig
== State::S0
);
1343 log_assert(clocking
.body_net
== nullptr);
1345 SigBit sig_d
= net_map_at(inst
->GetInput1());
1346 SigBit sig_o
= net_map_at(inst
->GetOutput());
1347 SigBit sig_q
= module
->addWire(new_verific_id(inst
));
1349 if (verific_verbose
)
1350 log(" %sedge FF with D=%s, Q=%s, C=%s.\n", clocking
.posedge
? "pos" : "neg",
1351 log_signal(sig_d
), log_signal(sig_q
), log_signal(clocking
.clock_sig
));
1353 clocking
.addDff(new_verific_id(inst
), sig_d
, sig_q
);
1354 module
->addEq(new_verific_id(inst
), {sig_q
, sig_d
}, Const(inst
->Type() == PRIM_SVA_ROSE
? 1 : 2, 2), sig_o
);
1360 if (!mode_keep
&& verific_sva_prims
.count(inst
->Type())) {
1361 if (verific_verbose
)
1362 log(" skipping SVA cell in non k-mode\n");
1366 if (inst
->Type() == PRIM_HDL_ASSERTION
)
1368 SigBit cond
= net_map_at(inst
->GetInput());
1370 if (verific_verbose
)
1371 log(" assert condition %s.\n", log_signal(cond
));
1373 const char *assume_attr
= nullptr; // inst->GetAttValue("assume");
1375 Cell
*cell
= nullptr;
1376 if (assume_attr
!= nullptr && !strcmp(assume_attr
, "1"))
1377 cell
= module
->addAssume(new_verific_id(inst
), cond
, State::S1
);
1379 cell
= module
->addAssert(new_verific_id(inst
), cond
, State::S1
);
1381 import_attributes(cell
->attributes
, inst
);
1385 if (inst
->IsPrimitive())
1388 log_error("Unsupported Verific primitive %s of type %s\n", inst
->Name(), inst
->View()->Owner()->Name());
1390 if (!verific_sva_prims
.count(inst
->Type()))
1391 log_warning("Unsupported Verific primitive %s of type %s\n", inst
->Name(), inst
->View()->Owner()->Name());
1394 import_verific_cells
:
1395 nl_todo
.insert(inst
->View());
1397 RTLIL::Cell
*cell
= module
->addCell(inst_name
, inst
->IsOperator() ?
1398 std::string("$verific$") + inst
->View()->Owner()->Name() : RTLIL::escape_id(inst
->View()->Owner()->Name()));
1400 if (inst
->IsPrimitive() && mode_keep
)
1401 cell
->attributes
["\\keep"] = 1;
1403 dict
<IdString
, vector
<SigBit
>> cell_port_conns
;
1405 if (verific_verbose
)
1406 log(" ports in verific db:\n");
1408 FOREACH_PORTREF_OF_INST(inst
, mi2
, pr
) {
1409 if (verific_verbose
)
1410 log(" .%s(%s)\n", pr
->GetPort()->Name(), pr
->GetNet()->Name());
1411 const char *port_name
= pr
->GetPort()->Name();
1412 int port_offset
= 0;
1413 if (pr
->GetPort()->Bus()) {
1414 port_name
= pr
->GetPort()->Bus()->Name();
1415 port_offset
= pr
->GetPort()->Bus()->IndexOf(pr
->GetPort()) -
1416 min(pr
->GetPort()->Bus()->LeftIndex(), pr
->GetPort()->Bus()->RightIndex());
1418 IdString port_name_id
= RTLIL::escape_id(port_name
);
1419 auto &sigvec
= cell_port_conns
[port_name_id
];
1420 if (GetSize(sigvec
) <= port_offset
) {
1421 SigSpec zwires
= module
->addWire(new_verific_id(inst
), port_offset
+1-GetSize(sigvec
));
1422 for (auto bit
: zwires
)
1423 sigvec
.push_back(bit
);
1425 sigvec
[port_offset
] = net_map_at(pr
->GetNet());
1428 if (verific_verbose
)
1429 log(" ports in yosys db:\n");
1431 for (auto &it
: cell_port_conns
) {
1432 if (verific_verbose
)
1433 log(" .%s(%s)\n", log_id(it
.first
), log_signal(it
.second
));
1434 cell
->setPort(it
.first
, it
.second
);
1440 for (auto inst
: sva_asserts
) {
1442 verific_import_sva_cover(this, inst
);
1443 verific_import_sva_assert(this, inst
);
1446 for (auto inst
: sva_assumes
)
1447 verific_import_sva_assume(this, inst
);
1449 for (auto inst
: sva_covers
)
1450 verific_import_sva_cover(this, inst
);
1452 for (auto inst
: sva_triggers
)
1453 verific_import_sva_trigger(this, inst
);
1455 merge_past_ffs(past_ffs
);
1459 // ==================================================================
1461 VerificClocking::VerificClocking(VerificImporter
*importer
, Net
*net
, bool sva_at_only
)
1463 module
= importer
->module
;
1465 log_assert(importer
!= nullptr);
1466 log_assert(net
!= nullptr);
1468 Instance
*inst
= net
->Driver();
1470 if (inst
!= nullptr && inst
->Type() == PRIM_SVA_AT
)
1472 net
= inst
->GetInput1();
1473 body_net
= inst
->GetInput2();
1475 inst
= net
->Driver();
1477 Instance
*body_inst
= body_net
->Driver();
1478 if (body_inst
!= nullptr && body_inst
->Type() == PRIM_SVA_DISABLE_IFF
) {
1479 disable_net
= body_inst
->GetInput1();
1480 disable_sig
= importer
->net_map_at(disable_net
);
1481 body_net
= body_inst
->GetInput2();
1490 // Use while() instead of if() to work around VIPER #13453
1491 while (inst
!= nullptr && inst
->Type() == PRIM_SVA_POSEDGE
)
1493 net
= inst
->GetInput();
1494 inst
= net
->Driver();;
1497 if (inst
!= nullptr && inst
->Type() == PRIM_INV
)
1499 net
= inst
->GetInput();
1500 inst
= net
->Driver();;
1504 // Detect clock-enable circuit
1506 if (inst
== nullptr || inst
->Type() != PRIM_AND
)
1509 Net
*net_dlatch
= inst
->GetInput1();
1510 Instance
*inst_dlatch
= net_dlatch
->Driver();
1512 if (inst_dlatch
== nullptr || inst_dlatch
->Type() != PRIM_DLATCHRS
)
1515 if (!inst_dlatch
->GetSet()->IsGnd() || !inst_dlatch
->GetReset()->IsGnd())
1518 Net
*net_enable
= inst_dlatch
->GetInput();
1519 Net
*net_not_clock
= inst_dlatch
->GetControl();
1521 if (net_enable
== nullptr || net_not_clock
== nullptr)
1524 Instance
*inst_not_clock
= net_not_clock
->Driver();
1526 if (inst_not_clock
== nullptr || inst_not_clock
->Type() != PRIM_INV
)
1529 Net
*net_clock1
= inst_not_clock
->GetInput();
1530 Net
*net_clock2
= inst
->GetInput2();
1532 if (net_clock1
== nullptr || net_clock1
!= net_clock2
)
1535 enable_net
= net_enable
;
1536 enable_sig
= importer
->net_map_at(enable_net
);
1539 inst
= net
->Driver();;
1542 // Detect condition expression
1544 if (body_net
== nullptr)
1547 Instance
*inst_mux
= body_net
->Driver();
1549 if (inst_mux
== nullptr || inst_mux
->Type() != PRIM_MUX
)
1552 if (!inst_mux
->GetInput1()->IsPwr())
1555 Net
*sva_net
= inst_mux
->GetInput2();
1556 if (!verific_is_sva_net(importer
, sva_net
))
1560 cond_net
= inst_mux
->GetControl();
1564 clock_sig
= importer
->net_map_at(clock_net
);
1566 const char *gclk_attr
= clock_net
->GetAttValue("gclk");
1567 if (gclk_attr
!= nullptr && (!strcmp(gclk_attr
, "1") || !strcmp(gclk_attr
, "'1'")))
1571 Cell
*VerificClocking::addDff(IdString name
, SigSpec sig_d
, SigSpec sig_q
, Const init_value
)
1573 log_assert(GetSize(sig_d
) == GetSize(sig_q
));
1575 if (GetSize(init_value
) != 0) {
1576 log_assert(GetSize(sig_q
) == GetSize(init_value
));
1577 if (sig_q
.is_wire()) {
1578 sig_q
.as_wire()->attributes
["\\init"] = init_value
;
1580 Wire
*w
= module
->addWire(NEW_ID
, GetSize(sig_q
));
1581 w
->attributes
["\\init"] = init_value
;
1582 module
->connect(sig_q
, w
);
1587 if (enable_sig
!= State::S1
)
1588 sig_d
= module
->Mux(NEW_ID
, sig_q
, sig_d
, enable_sig
);
1590 if (disable_sig
!= State::S0
) {
1591 log_assert(gclk
== false);
1592 log_assert(GetSize(sig_q
) == GetSize(init_value
));
1593 return module
->addAdff(name
, clock_sig
, disable_sig
, sig_d
, sig_q
, init_value
, posedge
);
1597 return module
->addFf(name
, sig_d
, sig_q
);
1599 return module
->addDff(name
, clock_sig
, sig_d
, sig_q
, posedge
);
1602 Cell
*VerificClocking::addAdff(IdString name
, RTLIL::SigSpec sig_arst
, SigSpec sig_d
, SigSpec sig_q
, Const arst_value
)
1604 log_assert(gclk
== false);
1605 log_assert(disable_sig
== State::S0
);
1607 if (enable_sig
!= State::S1
)
1608 sig_d
= module
->Mux(NEW_ID
, sig_q
, sig_d
, enable_sig
);
1610 return module
->addAdff(name
, clock_sig
, sig_arst
, sig_d
, sig_q
, arst_value
, posedge
);
1613 Cell
*VerificClocking::addDffsr(IdString name
, RTLIL::SigSpec sig_set
, RTLIL::SigSpec sig_clr
, SigSpec sig_d
, SigSpec sig_q
)
1615 log_assert(gclk
== false);
1616 log_assert(disable_sig
== State::S0
);
1618 if (enable_sig
!= State::S1
)
1619 sig_d
= module
->Mux(NEW_ID
, sig_q
, sig_d
, enable_sig
);
1621 return module
->addDffsr(name
, clock_sig
, sig_set
, sig_clr
, sig_d
, sig_q
, posedge
);
1624 // ==================================================================
1626 struct VerificExtNets
1628 int portname_cnt
= 0;
1630 // a map from Net to the same Net one level up in the design hierarchy
1631 std::map
<Net
*, Net
*> net_level_up_drive_up
;
1632 std::map
<Net
*, Net
*> net_level_up_drive_down
;
1634 Net
*route_up(Net
*net
, bool drive_up
, Net
*final_net
= nullptr)
1636 auto &net_level_up
= drive_up
? net_level_up_drive_up
: net_level_up_drive_down
;
1638 if (net_level_up
.count(net
) == 0)
1640 Netlist
*nl
= net
->Owner();
1642 // Simply return if Netlist is not unique
1643 log_assert(nl
->NumOfRefs() == 1);
1645 Instance
*up_inst
= (Instance
*)nl
->GetReferences()->GetLast();
1646 Netlist
*up_nl
= up_inst
->Owner();
1649 string name
= stringf("___extnets_%d", portname_cnt
++);
1650 Port
*new_port
= new Port(name
.c_str(), drive_up
? DIR_OUT
: DIR_IN
);
1652 net
->Connect(new_port
);
1654 // create new Net in up Netlist
1655 Net
*new_net
= final_net
;
1656 if (new_net
== nullptr || new_net
->Owner() != up_nl
) {
1657 new_net
= new Net(name
.c_str());
1658 up_nl
->Add(new_net
);
1660 up_inst
->Connect(new_port
, new_net
);
1662 net_level_up
[net
] = new_net
;
1665 return net_level_up
.at(net
);
1668 Net
*route_up(Net
*net
, bool drive_up
, Netlist
*dest
, Net
*final_net
= nullptr)
1670 while (net
->Owner() != dest
)
1671 net
= route_up(net
, drive_up
, final_net
);
1672 if (final_net
!= nullptr)
1673 log_assert(net
== final_net
);
1677 Netlist
*find_common_ancestor(Netlist
*A
, Netlist
*B
)
1679 std::set
<Netlist
*> ancestors_of_A
;
1681 Netlist
*cursor
= A
;
1683 ancestors_of_A
.insert(cursor
);
1684 if (cursor
->NumOfRefs() != 1)
1686 cursor
= ((Instance
*)cursor
->GetReferences()->GetLast())->Owner();
1691 if (ancestors_of_A
.count(cursor
))
1693 if (cursor
->NumOfRefs() != 1)
1695 cursor
= ((Instance
*)cursor
->GetReferences()->GetLast())->Owner();
1698 log_error("No common ancestor found between %s and %s.\n", get_full_netlist_name(A
).c_str(), get_full_netlist_name(B
).c_str());
1701 void run(Netlist
*nl
)
1707 vector
<tuple
<Instance
*, Port
*, Net
*>> todo_connect
;
1709 FOREACH_INSTANCE_OF_NETLIST(nl
, mi
, inst
)
1712 FOREACH_INSTANCE_OF_NETLIST(nl
, mi
, inst
)
1713 FOREACH_PORTREF_OF_INST(inst
, mi2
, pr
)
1715 Port
*port
= pr
->GetPort();
1716 Net
*net
= pr
->GetNet();
1718 if (!net
->IsExternalTo(nl
))
1721 if (verific_verbose
)
1722 log("Fixing external net reference on port %s.%s.%s:\n", get_full_netlist_name(nl
).c_str(), inst
->Name(), port
->Name());
1724 Netlist
*ext_nl
= net
->Owner();
1726 if (verific_verbose
)
1727 log(" external net owner: %s\n", get_full_netlist_name(ext_nl
).c_str());
1729 Netlist
*ca_nl
= find_common_ancestor(nl
, ext_nl
);
1731 if (verific_verbose
)
1732 log(" common ancestor: %s\n", get_full_netlist_name(ca_nl
).c_str());
1734 Net
*ca_net
= route_up(net
, !port
->IsOutput(), ca_nl
);
1735 Net
*new_net
= ca_net
;
1739 if (verific_verbose
)
1740 log(" net in common ancestor: %s\n", ca_net
->Name());
1742 string name
= stringf("___extnets_%d", portname_cnt
++);
1743 new_net
= new Net(name
.c_str());
1746 Net
*n
= route_up(new_net
, port
->IsOutput(), ca_nl
, ca_net
);
1747 log_assert(n
== ca_net
);
1750 if (verific_verbose
)
1751 log(" new local net: %s\n", new_net
->Name());
1753 log_assert(!new_net
->IsExternalTo(nl
));
1754 todo_connect
.push_back(tuple
<Instance
*, Port
*, Net
*>(inst
, port
, new_net
));
1757 for (auto it
: todo_connect
) {
1758 get
<0>(it
)->Disconnect(get
<1>(it
));
1759 get
<0>(it
)->Connect(get
<1>(it
), get
<2>(it
));
1764 void verific_import(Design
*design
, const std::map
<std::string
,std::string
> ¶meters
, std::string top
)
1766 verific_sva_fsm_limit
= 16;
1768 std::set
<Netlist
*> nl_todo
, nl_done
;
1770 VhdlLibrary
*vhdl_lib
= vhdl_file::GetLibrary("work", 1);
1771 VeriLibrary
*veri_lib
= veri_file::GetLibrary("work", 1);
1772 Array
*netlists
= NULL
;
1773 Array veri_libs
, vhdl_libs
;
1774 if (vhdl_lib
) vhdl_libs
.InsertLast(vhdl_lib
);
1775 if (veri_lib
) veri_libs
.InsertLast(veri_lib
);
1777 Map
verific_params(STRING_HASH
);
1778 for (const auto &i
: parameters
)
1779 verific_params
.Insert(i
.first
.c_str(), i
.second
.c_str());
1782 netlists
= hier_tree::ElaborateAll(&veri_libs
, &vhdl_libs
, &verific_params
);
1785 Array veri_modules
, vhdl_units
;
1788 VeriModule
*veri_module
= veri_lib
->GetModule(top
.c_str(), 1);
1790 veri_modules
.InsertLast(veri_module
);
1793 // Also elaborate all root modules since they may contain bind statements
1795 FOREACH_VERILOG_MODULE_IN_LIBRARY(veri_lib
, mi
, veri_module
) {
1796 if (!veri_module
->IsRootModule()) continue;
1797 veri_modules
.InsertLast(veri_module
);
1802 VhdlDesignUnit
*vhdl_unit
= vhdl_lib
->GetPrimUnit(top
.c_str());
1804 vhdl_units
.InsertLast(vhdl_unit
);
1807 netlists
= hier_tree::Elaborate(&veri_modules
, &vhdl_units
, &verific_params
);
1813 FOREACH_ARRAY_ITEM(netlists
, i
, nl
) {
1814 if (top
.empty() && nl
->CellBaseName() != top
)
1816 nl
->AddAtt(new Att(" \\top", NULL
));
1822 if (!verific_error_msg
.empty())
1823 log_error("%s\n", verific_error_msg
.c_str());
1825 VerificExtNets worker
;
1826 for (auto nl
: nl_todo
)
1829 while (!nl_todo
.empty()) {
1830 Netlist
*nl
= *nl_todo
.begin();
1831 if (nl_done
.count(nl
) == 0) {
1832 VerificImporter
importer(false, false, false, false, false, false);
1833 importer
.import_netlist(design
, nl
, nl_todo
);
1842 verific_incdirs
.clear();
1843 verific_libdirs
.clear();
1844 verific_import_pending
= false;
1846 if (!verific_error_msg
.empty())
1847 log_error("%s\n", verific_error_msg
.c_str());
1851 #endif /* YOSYS_ENABLE_VERIFIC */
1853 PRIVATE_NAMESPACE_BEGIN
1855 #ifdef YOSYS_ENABLE_VERIFIC
1856 bool check_noverific_env()
1858 const char *e
= getenv("YOSYS_NOVERIFIC");
1867 struct VerificPass
: public Pass
{
1868 VerificPass() : Pass("verific", "load Verilog and VHDL designs using Verific") { }
1869 void help() YS_OVERRIDE
1871 // |---v---|---v---|---v---|---v---|---v---|---v---|---v---|---v---|---v---|---v---|
1873 log(" verific {-vlog95|-vlog2k|-sv2005|-sv2009|-sv2012|-sv} <verilog-file>..\n");
1875 log("Load the specified Verilog/SystemVerilog files into Verific.\n");
1877 log("All files specified in one call to this command are one compilation unit.\n");
1878 log("Files passed to different calls to this command are treated as belonging to\n");
1879 log("different compilation units.\n");
1881 log("Additional -D<macro>[=<value>] options may be added after the option indicating\n");
1882 log("the language version (and before file names) to set additional verilog defines.\n");
1883 log("The macros SYNTHESIS and VERIFIC are defined implicitly.\n");
1886 log(" verific -formal <verilog-file>..\n");
1888 log("Like -sv, but define FORMAL instead of SYNTHESIS.\n");
1891 log(" verific {-vhdl87|-vhdl93|-vhdl2k|-vhdl2008|-vhdl} <vhdl-file>..\n");
1893 log("Load the specified VHDL files into Verific.\n");
1896 log(" verific -work <libname> {-sv|-vhdl|...} <hdl-file>\n");
1898 log("Load the specified Verilog/SystemVerilog/VHDL file into the specified library.\n");
1899 log("(default library when -work is not present: \"work\")\n");
1902 log(" verific -vlog-incdir <directory>..\n");
1904 log("Add Verilog include directories.\n");
1907 log(" verific -vlog-libdir <directory>..\n");
1909 log("Add Verilog library directories. Verific will search in this directories to\n");
1910 log("find undefined modules.\n");
1913 log(" verific -vlog-define <macro>[=<value>]..\n");
1915 log("Add Verilog defines.\n");
1918 log(" verific -vlog-undef <macro>..\n");
1920 log("Remove Verilog defines previously set with -vlog-define.\n");
1923 log(" verific -set-error <msg_id>..\n");
1924 log(" verific -set-warning <msg_id>..\n");
1925 log(" verific -set-info <msg_id>..\n");
1926 log(" verific -set-ignore <msg_id>..\n");
1928 log("Set message severity. <msg_id> is the string in square brackets when a message\n");
1929 log("is printed, such as VERI-1209.\n");
1932 log(" verific -import [options] <top-module>..\n");
1934 log("Elaborate the design for the specified top modules, import to Yosys and\n");
1935 log("reset the internal state of Verific.\n");
1937 log("Import options:\n");
1940 log(" Elaborate all modules, not just the hierarchy below the given top\n");
1941 log(" modules. With this option the list of modules to import is optional.\n");
1944 log(" Create a gate-level netlist.\n");
1947 log(" Flatten the design in Verific before importing.\n");
1950 log(" Resolve references to external nets by adding module ports as needed.\n");
1952 log(" -autocover\n");
1953 log(" Generate automatic cover statements for all asserts\n");
1955 log(" -chparam name value \n");
1956 log(" Elaborate the specified top modules (all modules when -all given) using\n");
1957 log(" this parameter value. Modules on which this parameter does not exist will\n");
1958 log(" cause Verific to produce a VERI-1928 or VHDL-1676 message. This option\n");
1959 log(" can be specified multiple times to override multiple parameters.\n");
1960 log(" String values must be passed in double quotes (\").\n");
1963 log(" Verbose log messages. (-vv is even more verbose than -v.)\n");
1965 log("The following additional import options are useful for debugging the Verific\n");
1966 log("bindings (for Yosys and/or Verific developers):\n");
1969 log(" Keep going after an unsupported verific primitive is found. The\n");
1970 log(" unsupported primitive is added as blockbox module to the design.\n");
1971 log(" This will also add all SVA related cells to the design parallel to\n");
1972 log(" the checker logic inferred by it.\n");
1975 log(" Import Verific netlist as-is without translating to Yosys cell types. \n");
1978 log(" Ignore SVA properties, do not infer checker logic.\n");
1981 log(" Maximum number of ctrl bits for SVA checker FSMs (default=16).\n");
1984 log(" Keep all Verific names on instances and nets. By default only\n");
1985 log(" user-declared names are preserved.\n");
1987 log(" -d <dump_file>\n");
1988 log(" Dump the Verific netlist as a verilog file.\n");
1990 log("Visit http://verific.com/ for more information on Verific.\n");
1993 #ifdef YOSYS_ENABLE_VERIFIC
1994 void execute(std::vector
<std::string
> args
, RTLIL::Design
*design
) YS_OVERRIDE
1996 static bool set_verific_global_flags
= true;
1998 if (check_noverific_env())
1999 log_cmd_error("This version of Yosys is built without Verific support.\n");
2001 log_header(design
, "Executing VERIFIC (loading SystemVerilog and VHDL designs using Verific).\n");
2003 if (set_verific_global_flags
)
2005 Message::SetConsoleOutput(0);
2006 Message::RegisterCallBackMsg(msg_func
);
2008 RuntimeFlags::SetVar("db_preserve_user_nets", 1);
2009 RuntimeFlags::SetVar("db_allow_external_nets", 1);
2010 RuntimeFlags::SetVar("db_infer_wide_operators", 1);
2012 RuntimeFlags::SetVar("veri_extract_dualport_rams", 0);
2013 RuntimeFlags::SetVar("veri_extract_multiport_rams", 1);
2015 RuntimeFlags::SetVar("vhdl_extract_dualport_rams", 0);
2016 RuntimeFlags::SetVar("vhdl_extract_multiport_rams", 1);
2018 RuntimeFlags::SetVar("vhdl_support_variable_slice", 1);
2019 RuntimeFlags::SetVar("vhdl_ignore_assertion_statements", 0);
2021 // Workaround for VIPER #13851
2022 RuntimeFlags::SetVar("veri_create_name_for_unnamed_gen_block", 1);
2024 // WARNING: instantiating unknown module 'XYZ' (VERI-1063)
2025 Message::SetMessageType("VERI-1063", VERIFIC_ERROR
);
2027 // https://github.com/YosysHQ/yosys/issues/1055
2028 RuntimeFlags::SetVar("veri_elaborate_top_level_modules_having_interface_ports", 1) ;
2030 #ifndef DB_PRESERVE_INITIAL_VALUE
2031 # warning Verific was built without DB_PRESERVE_INITIAL_VALUE.
2034 set_verific_global_flags
= false;
2037 verific_verbose
= 0;
2038 verific_sva_fsm_limit
= 16;
2040 const char *release_str
= Message::ReleaseString();
2041 time_t release_time
= Message::ReleaseDate();
2042 char *release_tmstr
= ctime(&release_time
);
2044 if (release_str
== nullptr)
2045 release_str
= "(no release string)";
2047 for (char *p
= release_tmstr
; *p
; p
++)
2048 if (*p
== '\n') *p
= 0;
2050 log("Built with Verific %s, released at %s.\n", release_str
, release_tmstr
);
2053 std::string work
= "work";
2055 if (GetSize(args
) > argidx
&& (args
[argidx
] == "-set-error" || args
[argidx
] == "-set-warning" ||
2056 args
[argidx
] == "-set-info" || args
[argidx
] == "-set-ignore"))
2058 msg_type_t new_type
;
2060 if (args
[argidx
] == "-set-error")
2061 new_type
= VERIFIC_ERROR
;
2062 else if (args
[argidx
] == "-set-warning")
2063 new_type
= VERIFIC_WARNING
;
2064 else if (args
[argidx
] == "-set-info")
2065 new_type
= VERIFIC_INFO
;
2066 else if (args
[argidx
] == "-set-ignore")
2067 new_type
= VERIFIC_IGNORE
;
2071 for (argidx
++; argidx
< GetSize(args
); argidx
++)
2072 Message::SetMessageType(args
[argidx
].c_str(), new_type
);
2077 if (GetSize(args
) > argidx
&& args
[argidx
] == "-vlog-incdir") {
2078 for (argidx
++; argidx
< GetSize(args
); argidx
++)
2079 verific_incdirs
.push_back(args
[argidx
]);
2083 if (GetSize(args
) > argidx
&& args
[argidx
] == "-vlog-libdir") {
2084 for (argidx
++; argidx
< GetSize(args
); argidx
++)
2085 verific_libdirs
.push_back(args
[argidx
]);
2089 if (GetSize(args
) > argidx
&& args
[argidx
] == "-vlog-define") {
2090 for (argidx
++; argidx
< GetSize(args
); argidx
++) {
2091 string name
= args
[argidx
];
2092 size_t equal
= name
.find('=');
2093 if (equal
!= std::string::npos
) {
2094 string value
= name
.substr(equal
+1);
2095 name
= name
.substr(0, equal
);
2096 veri_file::DefineCmdLineMacro(name
.c_str(), value
.c_str());
2098 veri_file::DefineCmdLineMacro(name
.c_str());
2104 if (GetSize(args
) > argidx
&& args
[argidx
] == "-vlog-undef") {
2105 for (argidx
++; argidx
< GetSize(args
); argidx
++) {
2106 string name
= args
[argidx
];
2107 veri_file::UndefineMacro(name
.c_str());
2112 for (; argidx
< GetSize(args
); argidx
++)
2114 if (args
[argidx
] == "-work" && argidx
+1 < GetSize(args
)) {
2115 work
= args
[++argidx
];
2121 if (GetSize(args
) > argidx
&& (args
[argidx
] == "-vlog95" || args
[argidx
] == "-vlog2k" || args
[argidx
] == "-sv2005" ||
2122 args
[argidx
] == "-sv2009" || args
[argidx
] == "-sv2012" || args
[argidx
] == "-sv" || args
[argidx
] == "-formal"))
2125 unsigned verilog_mode
;
2127 if (args
[argidx
] == "-vlog95")
2128 verilog_mode
= veri_file::VERILOG_95
;
2129 else if (args
[argidx
] == "-vlog2k")
2130 verilog_mode
= veri_file::VERILOG_2K
;
2131 else if (args
[argidx
] == "-sv2005")
2132 verilog_mode
= veri_file::SYSTEM_VERILOG_2005
;
2133 else if (args
[argidx
] == "-sv2009")
2134 verilog_mode
= veri_file::SYSTEM_VERILOG_2009
;
2135 else if (args
[argidx
] == "-sv2012" || args
[argidx
] == "-sv" || args
[argidx
] == "-formal")
2136 verilog_mode
= veri_file::SYSTEM_VERILOG
;
2140 veri_file::DefineMacro("VERIFIC");
2141 veri_file::DefineMacro(args
[argidx
] == "-formal" ? "FORMAL" : "SYNTHESIS");
2143 for (argidx
++; argidx
< GetSize(args
) && GetSize(args
[argidx
]) >= 2 && args
[argidx
].substr(0, 2) == "-D"; argidx
++) {
2144 std::string name
= args
[argidx
].substr(2);
2145 if (args
[argidx
] == "-D") {
2146 if (++argidx
>= GetSize(args
))
2148 name
= args
[argidx
];
2150 size_t equal
= name
.find('=');
2151 if (equal
!= std::string::npos
) {
2152 string value
= name
.substr(equal
+1);
2153 name
= name
.substr(0, equal
);
2154 veri_file::DefineMacro(name
.c_str(), value
.c_str());
2156 veri_file::DefineMacro(name
.c_str());
2160 for (auto &dir
: verific_incdirs
)
2161 veri_file::AddIncludeDir(dir
.c_str());
2162 for (auto &dir
: verific_libdirs
)
2163 veri_file::AddYDir(dir
.c_str());
2165 while (argidx
< GetSize(args
))
2166 file_names
.Insert(args
[argidx
++].c_str());
2168 if (!veri_file::AnalyzeMultipleFiles(&file_names
, verilog_mode
, work
.c_str(), veri_file::MFCU
))
2169 log_cmd_error("Reading Verilog/SystemVerilog sources failed.\n");
2171 verific_import_pending
= true;
2175 if (GetSize(args
) > argidx
&& args
[argidx
] == "-vhdl87") {
2176 vhdl_file::SetDefaultLibraryPath((proc_share_dirname() + "verific/vhdl_vdbs_1987").c_str());
2177 for (argidx
++; argidx
< GetSize(args
); argidx
++)
2178 if (!vhdl_file::Analyze(args
[argidx
].c_str(), work
.c_str(), vhdl_file::VHDL_87
))
2179 log_cmd_error("Reading `%s' in VHDL_87 mode failed.\n", args
[argidx
].c_str());
2180 verific_import_pending
= true;
2184 if (GetSize(args
) > argidx
&& args
[argidx
] == "-vhdl93") {
2185 vhdl_file::SetDefaultLibraryPath((proc_share_dirname() + "verific/vhdl_vdbs_1993").c_str());
2186 for (argidx
++; argidx
< GetSize(args
); argidx
++)
2187 if (!vhdl_file::Analyze(args
[argidx
].c_str(), work
.c_str(), vhdl_file::VHDL_93
))
2188 log_cmd_error("Reading `%s' in VHDL_93 mode failed.\n", args
[argidx
].c_str());
2189 verific_import_pending
= true;
2193 if (GetSize(args
) > argidx
&& args
[argidx
] == "-vhdl2k") {
2194 vhdl_file::SetDefaultLibraryPath((proc_share_dirname() + "verific/vhdl_vdbs_1993").c_str());
2195 for (argidx
++; argidx
< GetSize(args
); argidx
++)
2196 if (!vhdl_file::Analyze(args
[argidx
].c_str(), work
.c_str(), vhdl_file::VHDL_2K
))
2197 log_cmd_error("Reading `%s' in VHDL_2K mode failed.\n", args
[argidx
].c_str());
2198 verific_import_pending
= true;
2202 if (GetSize(args
) > argidx
&& (args
[argidx
] == "-vhdl2008" || args
[argidx
] == "-vhdl")) {
2203 vhdl_file::SetDefaultLibraryPath((proc_share_dirname() + "verific/vhdl_vdbs_2008").c_str());
2204 for (argidx
++; argidx
< GetSize(args
); argidx
++)
2205 if (!vhdl_file::Analyze(args
[argidx
].c_str(), work
.c_str(), vhdl_file::VHDL_2008
))
2206 log_cmd_error("Reading `%s' in VHDL_2008 mode failed.\n", args
[argidx
].c_str());
2207 verific_import_pending
= true;
2211 if (GetSize(args
) > argidx
&& args
[argidx
] == "-import")
2213 std::set
<Netlist
*> nl_todo
, nl_done
;
2214 bool mode_all
= false, mode_gates
= false, mode_keep
= false;
2215 bool mode_nosva
= false, mode_names
= false, mode_verific
= false;
2216 bool mode_autocover
= false;
2217 bool flatten
= false, extnets
= false;
2219 Map
parameters(STRING_HASH
);
2221 for (argidx
++; argidx
< GetSize(args
); argidx
++) {
2222 if (args
[argidx
] == "-all") {
2226 if (args
[argidx
] == "-gates") {
2230 if (args
[argidx
] == "-flatten") {
2234 if (args
[argidx
] == "-extnets") {
2238 if (args
[argidx
] == "-k") {
2242 if (args
[argidx
] == "-nosva") {
2246 if (args
[argidx
] == "-L" && argidx
+1 < GetSize(args
)) {
2247 verific_sva_fsm_limit
= atoi(args
[++argidx
].c_str());
2250 if (args
[argidx
] == "-n") {
2254 if (args
[argidx
] == "-autocover") {
2255 mode_autocover
= true;
2258 if (args
[argidx
] == "-chparam" && argidx
+2 < GetSize(args
)) {
2259 const std::string
&key
= args
[++argidx
];
2260 const std::string
&value
= args
[++argidx
];
2261 unsigned new_insertion
= parameters
.Insert(key
.c_str(), value
.c_str(),
2262 1 /* force_overwrite */);
2264 log_warning_noprefix("-chparam %s already specified: overwriting.\n", key
.c_str());
2267 if (args
[argidx
] == "-V") {
2268 mode_verific
= true;
2271 if (args
[argidx
] == "-v") {
2272 verific_verbose
= 1;
2275 if (args
[argidx
] == "-vv") {
2276 verific_verbose
= 2;
2279 if (args
[argidx
] == "-d" && argidx
+1 < GetSize(args
)) {
2280 dumpfile
= args
[++argidx
];
2286 if (argidx
> GetSize(args
) && args
[argidx
].substr(0, 1) == "-")
2287 cmd_error(args
, argidx
, "unknown option");
2291 log("Running hier_tree::ElaborateAll().\n");
2293 VhdlLibrary
*vhdl_lib
= vhdl_file::GetLibrary(work
.c_str(), 1);
2294 VeriLibrary
*veri_lib
= veri_file::GetLibrary(work
.c_str(), 1);
2296 Array veri_libs
, vhdl_libs
;
2297 if (vhdl_lib
) vhdl_libs
.InsertLast(vhdl_lib
);
2298 if (veri_lib
) veri_libs
.InsertLast(veri_lib
);
2300 Array
*netlists
= hier_tree::ElaborateAll(&veri_libs
, &vhdl_libs
, ¶meters
);
2304 FOREACH_ARRAY_ITEM(netlists
, i
, nl
)
2310 if (argidx
== GetSize(args
))
2311 log_cmd_error("No top module specified.\n");
2313 Array veri_modules
, vhdl_units
;
2314 for (; argidx
< GetSize(args
); argidx
++)
2316 const char *name
= args
[argidx
].c_str();
2317 VeriLibrary
* veri_lib
= veri_file::GetLibrary(work
.c_str(), 1);
2320 VeriModule
*veri_module
= veri_lib
->GetModule(name
, 1);
2322 log("Adding Verilog module '%s' to elaboration queue.\n", name
);
2323 veri_modules
.InsertLast(veri_module
);
2327 // Also elaborate all root modules since they may contain bind statements
2329 FOREACH_VERILOG_MODULE_IN_LIBRARY(veri_lib
, mi
, veri_module
) {
2330 if (!veri_module
->IsRootModule()) continue;
2331 veri_modules
.InsertLast(veri_module
);
2335 VhdlLibrary
*vhdl_lib
= vhdl_file::GetLibrary(work
.c_str(), 1);
2336 VhdlDesignUnit
*vhdl_unit
= vhdl_lib
->GetPrimUnit(name
);
2338 log("Adding VHDL unit '%s' to elaboration queue.\n", name
);
2339 vhdl_units
.InsertLast(vhdl_unit
);
2343 log_error("Can't find module/unit '%s'.\n", name
);
2346 log("Running hier_tree::Elaborate().\n");
2347 Array
*netlists
= hier_tree::Elaborate(&veri_modules
, &vhdl_units
, ¶meters
);
2351 FOREACH_ARRAY_ITEM(netlists
, i
, nl
) {
2352 nl
->AddAtt(new Att(" \\top", NULL
));
2358 if (!verific_error_msg
.empty())
2362 for (auto nl
: nl_todo
)
2367 VerificExtNets worker
;
2368 for (auto nl
: nl_todo
)
2372 if (!dumpfile
.empty()) {
2373 VeriWrite veri_writer
;
2374 veri_writer
.WriteFile(dumpfile
.c_str(), Netlist::PresentDesign());
2377 while (!nl_todo
.empty()) {
2378 Netlist
*nl
= *nl_todo
.begin();
2379 if (nl_done
.count(nl
) == 0) {
2380 VerificImporter
importer(mode_gates
, mode_keep
, mode_nosva
,
2381 mode_names
, mode_verific
, mode_autocover
);
2382 importer
.import_netlist(design
, nl
, nl_todo
);
2391 verific_incdirs
.clear();
2392 verific_libdirs
.clear();
2393 verific_import_pending
= false;
2397 log_cmd_error("Missing or unsupported mode parameter.\n");
2400 if (!verific_error_msg
.empty())
2401 log_error("%s\n", verific_error_msg
.c_str());
2404 #else /* YOSYS_ENABLE_VERIFIC */
2405 void execute(std::vector
<std::string
>, RTLIL::Design
*) YS_OVERRIDE
{
2406 log_cmd_error("This version of Yosys is built without Verific support.\n");
2411 struct ReadPass
: public Pass
{
2412 ReadPass() : Pass("read", "load HDL designs") { }
2413 void help() YS_OVERRIDE
2415 // |---v---|---v---|---v---|---v---|---v---|---v---|---v---|---v---|---v---|---v---|
2417 log(" read {-vlog95|-vlog2k|-sv2005|-sv2009|-sv2012|-sv|-formal} <verilog-file>..\n");
2419 log("Load the specified Verilog/SystemVerilog files. (Full SystemVerilog support\n");
2420 log("is only available via Verific.)\n");
2422 log("Additional -D<macro>[=<value>] options may be added after the option indicating\n");
2423 log("the language version (and before file names) to set additional verilog defines.\n");
2426 log(" read {-vhdl87|-vhdl93|-vhdl2k|-vhdl2008|-vhdl} <vhdl-file>..\n");
2428 log("Load the specified VHDL files. (Requires Verific.)\n");
2431 log(" read -define <macro>[=<value>]..\n");
2433 log("Set global Verilog/SystemVerilog defines.\n");
2436 log(" read -undef <macro>..\n");
2438 log("Unset global Verilog/SystemVerilog defines.\n");
2441 log(" read -incdir <directory>\n");
2443 log("Add directory to global Verilog/SystemVerilog include directories.\n");
2446 log(" read -verific\n");
2447 log(" read -noverific\n");
2449 log("Subsequent calls to 'read' will either use or not use Verific. Calling 'read'\n");
2450 log("with -verific will result in an error on Yosys binaries that are built without\n");
2451 log("Verific support. The default is to use Verific if it is available.\n");
2454 void execute(std::vector
<std::string
> args
, RTLIL::Design
*design
) YS_OVERRIDE
2456 #ifdef YOSYS_ENABLE_VERIFIC
2457 static bool verific_available
= !check_noverific_env();
2459 static bool verific_available
= false;
2461 static bool use_verific
= verific_available
;
2463 if (args
.size() < 2 || args
[1][0] != '-')
2464 log_cmd_error("Missing mode parameter.\n");
2466 if (args
[1] == "-verific" || args
[1] == "-noverific") {
2467 if (args
.size() != 2)
2468 log_cmd_error("Additional arguments to -verific/-noverific.\n");
2469 if (args
[1] == "-verific") {
2470 if (!verific_available
)
2471 log_cmd_error("This version of Yosys is built without Verific support.\n");
2474 use_verific
= false;
2479 if (args
.size() < 3)
2480 log_cmd_error("Missing file name parameter.\n");
2482 if (args
[1] == "-vlog95" || args
[1] == "-vlog2k") {
2484 args
[0] = "verific";
2486 args
[0] = "read_verilog";
2489 Pass::call(design
, args
);
2493 if (args
[1] == "-sv2005" || args
[1] == "-sv2009" || args
[1] == "-sv2012" || args
[1] == "-sv" || args
[1] == "-formal") {
2495 args
[0] = "verific";
2497 args
[0] = "read_verilog";
2498 if (args
[1] == "-formal")
2499 args
.insert(args
.begin()+1, std::string());
2501 args
.insert(args
.begin()+1, "-defer");
2503 Pass::call(design
, args
);
2507 if (args
[1] == "-vhdl87" || args
[1] == "-vhdl93" || args
[1] == "-vhdl2k" || args
[1] == "-vhdl2008" || args
[1] == "-vhdl") {
2509 args
[0] = "verific";
2510 Pass::call(design
, args
);
2512 log_cmd_error("This version of Yosys is built without Verific support.\n");
2517 if (args
[1] == "-define") {
2519 args
[0] = "verific";
2520 args
[1] = "-vlog-define";
2521 Pass::call(design
, args
);
2523 args
[0] = "verilog_defines";
2524 args
.erase(args
.begin()+1, args
.begin()+2);
2525 for (int i
= 1; i
< GetSize(args
); i
++)
2526 args
[i
] = "-D" + args
[i
];
2527 Pass::call(design
, args
);
2531 if (args
[1] == "-undef") {
2533 args
[0] = "verific";
2534 args
[1] = "-vlog-undef";
2535 Pass::call(design
, args
);
2537 args
[0] = "verilog_defines";
2538 args
.erase(args
.begin()+1, args
.begin()+2);
2539 for (int i
= 1; i
< GetSize(args
); i
++)
2540 args
[i
] = "-U" + args
[i
];
2541 Pass::call(design
, args
);
2545 if (args
[1] == "-incdir") {
2547 args
[0] = "verific";
2548 args
[1] = "-vlog-incdir";
2549 Pass::call(design
, args
);
2551 args
[0] = "verilog_defaults";
2553 for (int i
= 2; i
< GetSize(args
); i
++)
2554 args
[i
] = "-I" + args
[i
];
2555 Pass::call(design
, args
);
2559 log_cmd_error("Missing or unsupported mode parameter.\n");
2563 PRIVATE_NAMESPACE_END