2014-03-09 14:40:04 -05:00
|
|
|
/*
|
|
|
|
* yosys -- Yosys Open SYnthesis Suite
|
|
|
|
*
|
|
|
|
* Copyright (C) 2012 Clifford Wolf <clifford@clifford.at>
|
2015-07-02 04:14:30 -05:00
|
|
|
*
|
2014-03-09 14:40:04 -05:00
|
|
|
* Permission to use, copy, modify, and/or distribute this software for any
|
|
|
|
* purpose with or without fee is hereby granted, provided that the above
|
|
|
|
* copyright notice and this permission notice appear in all copies.
|
2015-07-02 04:14:30 -05:00
|
|
|
*
|
2014-03-09 14:40:04 -05:00
|
|
|
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
|
|
|
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
|
|
|
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
|
|
|
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
|
|
|
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
|
|
|
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
|
|
|
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2014-07-31 06:19:47 -05:00
|
|
|
#include "kernel/yosys.h"
|
2014-03-09 14:40:04 -05:00
|
|
|
#include "kernel/sigtools.h"
|
2019-08-07 08:31:49 -05:00
|
|
|
#include "kernel/celltypes.h"
|
2014-03-09 14:40:04 -05:00
|
|
|
#include "kernel/log.h"
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <string.h>
|
2014-10-16 11:06:54 -05:00
|
|
|
|
|
|
|
#ifndef _WIN32
|
|
|
|
# include <unistd.h>
|
|
|
|
# include <dirent.h>
|
|
|
|
#endif
|
2014-03-09 14:40:04 -05:00
|
|
|
|
2018-02-18 06:52:49 -06:00
|
|
|
#include "frontends/verific/verific.h"
|
|
|
|
|
2014-07-31 06:19:47 -05:00
|
|
|
USING_YOSYS_NAMESPACE
|
|
|
|
|
2014-03-13 11:34:31 -05:00
|
|
|
#ifdef YOSYS_ENABLE_VERIFIC
|
2014-03-09 14:40:04 -05:00
|
|
|
|
2017-07-24 06:57:16 -05:00
|
|
|
#ifdef __clang__
|
2014-03-14 05:46:13 -05:00
|
|
|
#pragma clang diagnostic push
|
|
|
|
#pragma clang diagnostic ignored "-Woverloaded-virtual"
|
2017-07-24 06:57:16 -05:00
|
|
|
#endif
|
2014-03-14 05:46:13 -05:00
|
|
|
|
2014-03-09 14:40:04 -05:00
|
|
|
#include "veri_file.h"
|
|
|
|
#include "vhdl_file.h"
|
2018-03-08 06:26:33 -06:00
|
|
|
#include "hier_tree.h"
|
2014-03-14 05:46:13 -05:00
|
|
|
#include "VeriModule.h"
|
2017-07-24 06:57:16 -05:00
|
|
|
#include "VeriWrite.h"
|
2014-03-14 05:46:13 -05:00
|
|
|
#include "VhdlUnits.h"
|
2019-03-13 17:40:00 -05:00
|
|
|
#include "VeriLibrary.h"
|
2014-03-09 14:40:04 -05:00
|
|
|
|
2019-06-02 03:14:50 -05:00
|
|
|
#ifndef SYMBIOTIC_VERIFIC_API_VERSION
|
|
|
|
# error "Only Symbiotic EDA flavored Verific is supported. Please contact office@symbioticeda.com for commercial support for Yosys+Verific."
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#if SYMBIOTIC_VERIFIC_API_VERSION < 1
|
|
|
|
# error "Please update your version of Symbiotic EDA flavored Verific."
|
|
|
|
#endif
|
|
|
|
|
2017-07-24 06:57:16 -05:00
|
|
|
#ifdef __clang__
|
2014-03-14 05:46:13 -05:00
|
|
|
#pragma clang diagnostic pop
|
2017-07-24 06:57:16 -05:00
|
|
|
#endif
|
2014-03-14 05:46:13 -05:00
|
|
|
|
2014-03-09 14:40:04 -05:00
|
|
|
#ifdef VERIFIC_NAMESPACE
|
2018-02-18 06:52:49 -06:00
|
|
|
using namespace Verific;
|
2014-03-09 14:40:04 -05:00
|
|
|
#endif
|
|
|
|
|
2017-02-04 06:36:00 -06:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef YOSYS_ENABLE_VERIFIC
|
2018-02-18 06:52:49 -06:00
|
|
|
YOSYS_NAMESPACE_BEGIN
|
2017-02-04 06:36:00 -06:00
|
|
|
|
2018-03-01 04:40:43 -06:00
|
|
|
int verific_verbose;
|
2018-06-20 16:45:01 -05:00
|
|
|
bool verific_import_pending;
|
2017-10-05 07:38:32 -05:00
|
|
|
string verific_error_msg;
|
2018-09-04 13:06:10 -05:00
|
|
|
int verific_sva_fsm_limit;
|
2017-10-04 11:56:28 -05:00
|
|
|
|
2018-07-16 11:46:06 -05:00
|
|
|
vector<string> verific_incdirs, verific_libdirs;
|
|
|
|
|
2017-02-04 06:36:00 -06:00
|
|
|
void msg_func(msg_type_t msg_type, const char *message_id, linefile_type linefile, const char *msg, va_list args)
|
2014-03-09 14:40:04 -05:00
|
|
|
{
|
2017-10-05 07:38:32 -05:00
|
|
|
string message_prefix = stringf("VERIFIC-%s [%s] ",
|
2014-03-09 14:40:04 -05:00
|
|
|
msg_type == VERIFIC_NONE ? "NONE" :
|
|
|
|
msg_type == VERIFIC_ERROR ? "ERROR" :
|
|
|
|
msg_type == VERIFIC_WARNING ? "WARNING" :
|
|
|
|
msg_type == VERIFIC_IGNORE ? "IGNORE" :
|
|
|
|
msg_type == VERIFIC_INFO ? "INFO" :
|
|
|
|
msg_type == VERIFIC_COMMENT ? "COMMENT" :
|
|
|
|
msg_type == VERIFIC_PROGRAM_ERROR ? "PROGRAM_ERROR" : "UNKNOWN", message_id);
|
2017-02-11 04:39:50 -06:00
|
|
|
|
2017-10-05 07:38:32 -05:00
|
|
|
string message = linefile ? stringf("%s:%d: ", LineFile::GetFileName(linefile), LineFile::GetLineNo(linefile)) : "";
|
2017-02-11 04:39:50 -06:00
|
|
|
message += vstringf(msg, args);
|
|
|
|
|
|
|
|
if (msg_type == VERIFIC_ERROR || msg_type == VERIFIC_WARNING || msg_type == VERIFIC_PROGRAM_ERROR)
|
2017-10-05 07:38:32 -05:00
|
|
|
log_warning_noprefix("%s%s\n", message_prefix.c_str(), message.c_str());
|
2017-02-11 04:39:50 -06:00
|
|
|
else
|
2017-10-05 07:38:32 -05:00
|
|
|
log("%s%s\n", message_prefix.c_str(), message.c_str());
|
2017-10-04 11:56:28 -05:00
|
|
|
|
2017-10-05 07:38:32 -05:00
|
|
|
if (verific_error_msg.empty() && (msg_type == VERIFIC_ERROR || msg_type == VERIFIC_PROGRAM_ERROR))
|
|
|
|
verific_error_msg = message;
|
2014-03-09 14:40:04 -05:00
|
|
|
}
|
|
|
|
|
2017-07-25 07:53:11 -05:00
|
|
|
string get_full_netlist_name(Netlist *nl)
|
|
|
|
{
|
|
|
|
if (nl->NumOfRefs() == 1) {
|
|
|
|
Instance *inst = (Instance*)nl->GetReferences()->GetLast();
|
|
|
|
return get_full_netlist_name(inst->Owner()) + "." + inst->Name();
|
|
|
|
}
|
|
|
|
|
|
|
|
return nl->CellBaseName();
|
|
|
|
}
|
|
|
|
|
2018-02-18 06:52:49 -06:00
|
|
|
// ==================================================================
|
2017-07-27 04:40:07 -05:00
|
|
|
|
2019-08-07 08:31:49 -05:00
|
|
|
VerificImporter::VerificImporter(bool mode_gates, bool mode_keep, bool mode_nosva, bool mode_names, bool mode_verific, bool mode_autocover, bool mode_fullinit) :
|
2018-02-18 06:52:49 -06:00
|
|
|
mode_gates(mode_gates), mode_keep(mode_keep), mode_nosva(mode_nosva),
|
2019-08-07 08:31:49 -05:00
|
|
|
mode_names(mode_names), mode_verific(mode_verific), mode_autocover(mode_autocover),
|
|
|
|
mode_fullinit(mode_fullinit)
|
2014-03-09 14:40:04 -05:00
|
|
|
{
|
2018-02-18 06:52:49 -06:00
|
|
|
}
|
2017-07-24 04:29:06 -05:00
|
|
|
|
2018-02-18 06:52:49 -06:00
|
|
|
RTLIL::SigBit VerificImporter::net_map_at(Net *net)
|
|
|
|
{
|
|
|
|
if (net->IsExternalTo(netlist))
|
|
|
|
log_error("Found external reference to '%s.%s' in netlist '%s', please use -flatten or -extnets.\n",
|
|
|
|
get_full_netlist_name(net->Owner()).c_str(), net->Name(), get_full_netlist_name(netlist).c_str());
|
2014-03-09 14:40:04 -05:00
|
|
|
|
2018-02-18 06:52:49 -06:00
|
|
|
return net_map.at(net);
|
|
|
|
}
|
2017-07-24 04:29:06 -05:00
|
|
|
|
2018-10-07 12:48:42 -05:00
|
|
|
bool is_blackbox(Netlist *nl)
|
|
|
|
{
|
2019-11-20 05:56:31 -06:00
|
|
|
if (nl->IsBlackBox() || nl->IsEmptyBox())
|
2018-10-07 12:48:42 -05:00
|
|
|
return true;
|
|
|
|
|
|
|
|
const char *attr = nl->GetAttValue("blackbox");
|
|
|
|
if (attr != nullptr && strcmp(attr, "0"))
|
|
|
|
return true;
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2018-12-18 09:01:22 -06:00
|
|
|
RTLIL::IdString VerificImporter::new_verific_id(Verific::DesignObj *obj)
|
|
|
|
{
|
|
|
|
std::string s = stringf("$verific$%s", obj->Name());
|
|
|
|
if (obj->Linefile())
|
|
|
|
s += stringf("$%s:%d", Verific::LineFile::GetFileName(obj->Linefile()), Verific::LineFile::GetLineNo(obj->Linefile()));
|
|
|
|
s += stringf("$%d", autoidx++);
|
|
|
|
return s;
|
|
|
|
}
|
|
|
|
|
2020-04-27 10:43:54 -05:00
|
|
|
void VerificImporter::import_attributes(dict<RTLIL::IdString, RTLIL::Const> &attributes, DesignObj *obj, Netlist *nl)
|
2018-02-18 06:52:49 -06:00
|
|
|
{
|
|
|
|
MapIter mi;
|
|
|
|
Att *attr;
|
2017-07-24 04:29:06 -05:00
|
|
|
|
2018-02-18 06:52:49 -06:00
|
|
|
if (obj->Linefile())
|
2020-03-12 14:57:01 -05:00
|
|
|
attributes[ID::src] = stringf("%s:%d", LineFile::GetFileName(obj->Linefile()), LineFile::GetLineNo(obj->Linefile()));
|
2017-07-24 04:29:06 -05:00
|
|
|
|
2018-02-18 06:52:49 -06:00
|
|
|
// FIXME: Parse numeric attributes
|
2018-04-06 14:23:47 -05:00
|
|
|
FOREACH_ATTRIBUTE(obj, mi, attr) {
|
|
|
|
if (attr->Key()[0] == ' ' || attr->Value() == nullptr)
|
|
|
|
continue;
|
2018-02-18 06:52:49 -06:00
|
|
|
attributes[RTLIL::escape_id(attr->Key())] = RTLIL::Const(std::string(attr->Value()));
|
2018-04-06 14:23:47 -05:00
|
|
|
}
|
2020-04-27 10:43:54 -05:00
|
|
|
|
|
|
|
if (nl) {
|
|
|
|
auto type_range = nl->GetTypeRange(obj->Name());
|
|
|
|
if (!type_range)
|
|
|
|
return;
|
|
|
|
if (!type_range->IsTypeEnum())
|
|
|
|
return;
|
2020-04-27 17:17:13 -05:00
|
|
|
if (nl->IsFromVhdl() && strcmp(type_range->GetTypeName(), "STD_LOGIC") == 0)
|
|
|
|
return;
|
2020-04-30 09:48:47 -05:00
|
|
|
auto type_name = type_range->GetTypeName();
|
|
|
|
if (!type_name)
|
|
|
|
return;
|
|
|
|
attributes.emplace(ID::wiretype, RTLIL::escape_id(type_name));
|
2020-04-27 10:43:54 -05:00
|
|
|
|
|
|
|
MapIter mi;
|
|
|
|
const char *k, *v;
|
|
|
|
FOREACH_MAP_ITEM(type_range->GetEnumIdMap(), mi, &k, &v) {
|
2020-04-27 17:17:13 -05:00
|
|
|
if (nl->IsFromVerilog()) {
|
|
|
|
// Expect <decimal>'b<binary>
|
|
|
|
auto p = strchr(v, '\'');
|
|
|
|
if (p) {
|
|
|
|
if (*(p+1) != 'b')
|
|
|
|
p = nullptr;
|
|
|
|
else
|
|
|
|
for (auto q = p+2; *q != '\0'; q++)
|
|
|
|
if (*q != '0' && *q != '1') {
|
|
|
|
p = nullptr;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (p == nullptr)
|
|
|
|
log_error("Expected TypeRange value '%s' to be of form <decimal>'b<binary>.\n", v);
|
|
|
|
attributes.emplace(stringf("\\enum_value_%s", p+2), RTLIL::escape_id(k));
|
|
|
|
}
|
|
|
|
else if (nl->IsFromVhdl()) {
|
|
|
|
// Expect "<binary>"
|
|
|
|
auto p = v;
|
|
|
|
if (p) {
|
|
|
|
if (*p != '"')
|
|
|
|
p = nullptr;
|
|
|
|
else {
|
|
|
|
auto *q = p+1;
|
|
|
|
for (; *q != '"'; q++)
|
|
|
|
if (*q != '0' && *q != '1') {
|
|
|
|
p = nullptr;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
if (p && *(q+1) != '\0')
|
2020-04-27 10:43:54 -05:00
|
|
|
p = nullptr;
|
2020-04-27 17:17:13 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
if (p == nullptr)
|
|
|
|
log_error("Expected TypeRange value '%s' to be of form \"<binary>\".\n", v);
|
|
|
|
auto l = strlen(p);
|
|
|
|
auto q = (char*)malloc(l+1-2);
|
|
|
|
strncpy(q, p+1, l-2);
|
|
|
|
q[l-2] = '\0';
|
|
|
|
attributes.emplace(stringf("\\enum_value_%s", q), RTLIL::escape_id(k));
|
|
|
|
free(q);
|
2020-04-27 10:43:54 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2018-02-18 06:52:49 -06:00
|
|
|
}
|
2017-07-24 04:29:06 -05:00
|
|
|
|
2018-02-18 06:52:49 -06:00
|
|
|
RTLIL::SigSpec VerificImporter::operatorInput(Instance *inst)
|
|
|
|
{
|
|
|
|
RTLIL::SigSpec sig;
|
|
|
|
for (int i = int(inst->InputSize())-1; i >= 0; i--)
|
|
|
|
if (inst->GetInputBit(i))
|
|
|
|
sig.append(net_map_at(inst->GetInputBit(i)));
|
|
|
|
else
|
|
|
|
sig.append(RTLIL::State::Sz);
|
|
|
|
return sig;
|
|
|
|
}
|
2014-03-10 06:06:57 -05:00
|
|
|
|
2018-02-18 06:52:49 -06:00
|
|
|
RTLIL::SigSpec VerificImporter::operatorInput1(Instance *inst)
|
|
|
|
{
|
|
|
|
RTLIL::SigSpec sig;
|
|
|
|
for (int i = int(inst->Input1Size())-1; i >= 0; i--)
|
|
|
|
if (inst->GetInput1Bit(i))
|
|
|
|
sig.append(net_map_at(inst->GetInput1Bit(i)));
|
|
|
|
else
|
|
|
|
sig.append(RTLIL::State::Sz);
|
|
|
|
return sig;
|
|
|
|
}
|
2014-03-10 06:06:57 -05:00
|
|
|
|
2018-02-18 06:52:49 -06:00
|
|
|
RTLIL::SigSpec VerificImporter::operatorInput2(Instance *inst)
|
|
|
|
{
|
|
|
|
RTLIL::SigSpec sig;
|
|
|
|
for (int i = int(inst->Input2Size())-1; i >= 0; i--)
|
|
|
|
if (inst->GetInput2Bit(i))
|
|
|
|
sig.append(net_map_at(inst->GetInput2Bit(i)));
|
|
|
|
else
|
|
|
|
sig.append(RTLIL::State::Sz);
|
|
|
|
return sig;
|
|
|
|
}
|
2014-03-10 06:06:57 -05:00
|
|
|
|
2018-02-18 06:52:49 -06:00
|
|
|
RTLIL::SigSpec VerificImporter::operatorInport(Instance *inst, const char *portname)
|
|
|
|
{
|
|
|
|
PortBus *portbus = inst->View()->GetPortBus(portname);
|
|
|
|
if (portbus) {
|
2014-03-16 20:43:53 -05:00
|
|
|
RTLIL::SigSpec sig;
|
2018-02-18 06:52:49 -06:00
|
|
|
for (unsigned i = 0; i < portbus->Size(); i++) {
|
|
|
|
Net *net = inst->GetNet(portbus->ElementAtIndex(i));
|
|
|
|
if (net) {
|
|
|
|
if (net->IsGnd())
|
|
|
|
sig.append(RTLIL::State::S0);
|
|
|
|
else if (net->IsPwr())
|
|
|
|
sig.append(RTLIL::State::S1);
|
|
|
|
else
|
|
|
|
sig.append(net_map_at(net));
|
|
|
|
} else
|
2014-03-16 20:43:53 -05:00
|
|
|
sig.append(RTLIL::State::Sz);
|
2018-02-18 06:52:49 -06:00
|
|
|
}
|
2014-03-16 20:43:53 -05:00
|
|
|
return sig;
|
2018-02-18 06:52:49 -06:00
|
|
|
} else {
|
|
|
|
Port *port = inst->View()->GetPort(portname);
|
|
|
|
log_assert(port != NULL);
|
|
|
|
Net *net = inst->GetNet(port);
|
|
|
|
return net_map_at(net);
|
2014-03-16 20:43:53 -05:00
|
|
|
}
|
2018-02-18 06:52:49 -06:00
|
|
|
}
|
2014-03-16 20:43:53 -05:00
|
|
|
|
2018-05-24 10:07:06 -05:00
|
|
|
RTLIL::SigSpec VerificImporter::operatorOutput(Instance *inst, const pool<Net*, hash_ptr_ops> *any_all_nets)
|
2018-02-18 06:52:49 -06:00
|
|
|
{
|
|
|
|
RTLIL::SigSpec sig;
|
|
|
|
RTLIL::Wire *dummy_wire = NULL;
|
|
|
|
for (int i = int(inst->OutputSize())-1; i >= 0; i--)
|
2018-05-24 10:07:06 -05:00
|
|
|
if (inst->GetOutputBit(i) && (!any_all_nets || !any_all_nets->count(inst->GetOutputBit(i)))) {
|
2018-02-18 06:52:49 -06:00
|
|
|
sig.append(net_map_at(inst->GetOutputBit(i)));
|
|
|
|
dummy_wire = NULL;
|
|
|
|
} else {
|
|
|
|
if (dummy_wire == NULL)
|
2018-12-18 09:01:22 -06:00
|
|
|
dummy_wire = module->addWire(new_verific_id(inst));
|
2014-03-10 06:06:57 -05:00
|
|
|
else
|
2018-02-18 06:52:49 -06:00
|
|
|
dummy_wire->width++;
|
|
|
|
sig.append(RTLIL::SigSpec(dummy_wire, dummy_wire->width - 1));
|
|
|
|
}
|
|
|
|
return sig;
|
|
|
|
}
|
2014-03-14 05:46:13 -05:00
|
|
|
|
2018-02-18 06:52:49 -06:00
|
|
|
bool VerificImporter::import_netlist_instance_gates(Instance *inst, RTLIL::IdString inst_name)
|
|
|
|
{
|
|
|
|
if (inst->Type() == PRIM_AND) {
|
|
|
|
module->addAndGate(inst_name, net_map_at(inst->GetInput1()), net_map_at(inst->GetInput2()), net_map_at(inst->GetOutput()));
|
|
|
|
return true;
|
2014-03-17 08:42:07 -05:00
|
|
|
}
|
|
|
|
|
2018-02-18 06:52:49 -06:00
|
|
|
if (inst->Type() == PRIM_NAND) {
|
2018-12-18 09:01:22 -06:00
|
|
|
RTLIL::SigSpec tmp = module->addWire(new_verific_id(inst));
|
|
|
|
module->addAndGate(new_verific_id(inst), net_map_at(inst->GetInput1()), net_map_at(inst->GetInput2()), tmp);
|
2018-02-18 06:52:49 -06:00
|
|
|
module->addNotGate(inst_name, tmp, net_map_at(inst->GetOutput()));
|
|
|
|
return true;
|
2014-03-14 05:46:13 -05:00
|
|
|
}
|
|
|
|
|
2018-02-18 06:52:49 -06:00
|
|
|
if (inst->Type() == PRIM_OR) {
|
|
|
|
module->addOrGate(inst_name, net_map_at(inst->GetInput1()), net_map_at(inst->GetInput2()), net_map_at(inst->GetOutput()));
|
|
|
|
return true;
|
2016-02-13 01:19:30 -06:00
|
|
|
}
|
|
|
|
|
2018-02-18 06:52:49 -06:00
|
|
|
if (inst->Type() == PRIM_NOR) {
|
2018-12-18 09:01:22 -06:00
|
|
|
RTLIL::SigSpec tmp = module->addWire(new_verific_id(inst));
|
|
|
|
module->addOrGate(new_verific_id(inst), net_map_at(inst->GetInput1()), net_map_at(inst->GetInput2()), tmp);
|
2018-02-18 06:52:49 -06:00
|
|
|
module->addNotGate(inst_name, tmp, net_map_at(inst->GetOutput()));
|
|
|
|
return true;
|
|
|
|
}
|
2014-03-14 05:46:13 -05:00
|
|
|
|
2018-02-18 06:52:49 -06:00
|
|
|
if (inst->Type() == PRIM_XOR) {
|
|
|
|
module->addXorGate(inst_name, net_map_at(inst->GetInput1()), net_map_at(inst->GetInput2()), net_map_at(inst->GetOutput()));
|
|
|
|
return true;
|
|
|
|
}
|
2014-03-14 05:46:13 -05:00
|
|
|
|
2018-02-18 06:52:49 -06:00
|
|
|
if (inst->Type() == PRIM_XNOR) {
|
|
|
|
module->addXnorGate(inst_name, net_map_at(inst->GetInput1()), net_map_at(inst->GetInput2()), net_map_at(inst->GetOutput()));
|
|
|
|
return true;
|
|
|
|
}
|
2014-03-17 08:42:07 -05:00
|
|
|
|
2018-02-18 06:52:49 -06:00
|
|
|
if (inst->Type() == PRIM_BUF) {
|
2018-05-25 08:41:45 -05:00
|
|
|
auto outnet = inst->GetOutput();
|
|
|
|
if (!any_all_nets.count(outnet))
|
|
|
|
module->addBufGate(inst_name, net_map_at(inst->GetInput()), net_map_at(outnet));
|
2018-02-18 06:52:49 -06:00
|
|
|
return true;
|
|
|
|
}
|
2014-03-14 05:46:13 -05:00
|
|
|
|
2018-02-18 06:52:49 -06:00
|
|
|
if (inst->Type() == PRIM_INV) {
|
|
|
|
module->addNotGate(inst_name, net_map_at(inst->GetInput()), net_map_at(inst->GetOutput()));
|
|
|
|
return true;
|
|
|
|
}
|
2014-03-17 08:42:07 -05:00
|
|
|
|
2018-02-18 06:52:49 -06:00
|
|
|
if (inst->Type() == PRIM_MUX) {
|
|
|
|
module->addMuxGate(inst_name, net_map_at(inst->GetInput1()), net_map_at(inst->GetInput2()), net_map_at(inst->GetControl()), net_map_at(inst->GetOutput()));
|
|
|
|
return true;
|
|
|
|
}
|
2014-03-14 05:46:13 -05:00
|
|
|
|
2018-02-18 06:52:49 -06:00
|
|
|
if (inst->Type() == PRIM_TRI) {
|
|
|
|
module->addMuxGate(inst_name, RTLIL::State::Sz, net_map_at(inst->GetInput()), net_map_at(inst->GetControl()), net_map_at(inst->GetOutput()));
|
|
|
|
return true;
|
2014-03-14 05:46:13 -05:00
|
|
|
}
|
|
|
|
|
2018-02-18 06:52:49 -06:00
|
|
|
if (inst->Type() == PRIM_FADD)
|
2017-02-04 06:36:00 -06:00
|
|
|
{
|
2018-02-18 06:52:49 -06:00
|
|
|
RTLIL::SigSpec a = net_map_at(inst->GetInput1()), b = net_map_at(inst->GetInput2()), c = net_map_at(inst->GetCin());
|
2018-12-18 09:01:22 -06:00
|
|
|
RTLIL::SigSpec x = inst->GetCout() ? net_map_at(inst->GetCout()) : module->addWire(new_verific_id(inst));
|
|
|
|
RTLIL::SigSpec y = inst->GetOutput() ? net_map_at(inst->GetOutput()) : module->addWire(new_verific_id(inst));
|
|
|
|
RTLIL::SigSpec tmp1 = module->addWire(new_verific_id(inst));
|
|
|
|
RTLIL::SigSpec tmp2 = module->addWire(new_verific_id(inst));
|
|
|
|
RTLIL::SigSpec tmp3 = module->addWire(new_verific_id(inst));
|
|
|
|
module->addXorGate(new_verific_id(inst), a, b, tmp1);
|
2018-02-18 06:52:49 -06:00
|
|
|
module->addXorGate(inst_name, tmp1, c, y);
|
2018-12-18 09:01:22 -06:00
|
|
|
module->addAndGate(new_verific_id(inst), tmp1, c, tmp2);
|
|
|
|
module->addAndGate(new_verific_id(inst), a, b, tmp3);
|
|
|
|
module->addOrGate(new_verific_id(inst), tmp2, tmp3, x);
|
2018-02-18 06:52:49 -06:00
|
|
|
return true;
|
|
|
|
}
|
2014-03-14 05:46:13 -05:00
|
|
|
|
2018-02-18 06:52:49 -06:00
|
|
|
if (inst->Type() == PRIM_DFFRS)
|
|
|
|
{
|
2018-03-04 06:48:53 -06:00
|
|
|
VerificClocking clocking(this, inst->GetClock());
|
|
|
|
log_assert(clocking.disable_sig == State::S0);
|
|
|
|
log_assert(clocking.body_net == nullptr);
|
|
|
|
|
2018-02-18 06:52:49 -06:00
|
|
|
if (inst->GetSet()->IsGnd() && inst->GetReset()->IsGnd())
|
2018-03-04 06:48:53 -06:00
|
|
|
clocking.addDff(inst_name, net_map_at(inst->GetInput()), net_map_at(inst->GetOutput()));
|
2018-02-18 06:52:49 -06:00
|
|
|
else if (inst->GetSet()->IsGnd())
|
2018-03-04 06:48:53 -06:00
|
|
|
clocking.addAdff(inst_name, net_map_at(inst->GetReset()), net_map_at(inst->GetInput()), net_map_at(inst->GetOutput()), State::S0);
|
2018-02-18 06:52:49 -06:00
|
|
|
else if (inst->GetReset()->IsGnd())
|
2018-03-04 06:48:53 -06:00
|
|
|
clocking.addAdff(inst_name, net_map_at(inst->GetSet()), net_map_at(inst->GetInput()), net_map_at(inst->GetOutput()), State::S1);
|
2018-02-18 06:52:49 -06:00
|
|
|
else
|
2018-03-04 06:48:53 -06:00
|
|
|
clocking.addDffsr(inst_name, net_map_at(inst->GetSet()), net_map_at(inst->GetReset()),
|
2018-02-18 06:52:49 -06:00
|
|
|
net_map_at(inst->GetInput()), net_map_at(inst->GetOutput()));
|
|
|
|
return true;
|
|
|
|
}
|
2014-03-14 05:46:13 -05:00
|
|
|
|
2018-02-18 06:52:49 -06:00
|
|
|
return false;
|
|
|
|
}
|
2014-03-17 08:42:07 -05:00
|
|
|
|
2018-02-18 06:52:49 -06:00
|
|
|
bool VerificImporter::import_netlist_instance_cells(Instance *inst, RTLIL::IdString inst_name)
|
|
|
|
{
|
2018-12-18 09:01:22 -06:00
|
|
|
RTLIL::Cell *cell = nullptr;
|
|
|
|
|
2018-02-18 06:52:49 -06:00
|
|
|
if (inst->Type() == PRIM_AND) {
|
2018-12-18 09:01:22 -06:00
|
|
|
cell = module->addAnd(inst_name, net_map_at(inst->GetInput1()), net_map_at(inst->GetInput2()), net_map_at(inst->GetOutput()));
|
|
|
|
import_attributes(cell->attributes, inst);
|
2018-02-18 06:52:49 -06:00
|
|
|
return true;
|
|
|
|
}
|
2014-03-16 20:43:53 -05:00
|
|
|
|
2018-02-18 06:52:49 -06:00
|
|
|
if (inst->Type() == PRIM_NAND) {
|
2018-12-18 09:01:22 -06:00
|
|
|
RTLIL::SigSpec tmp = module->addWire(new_verific_id(inst));
|
|
|
|
cell = module->addAnd(new_verific_id(inst), net_map_at(inst->GetInput1()), net_map_at(inst->GetInput2()), tmp);
|
|
|
|
import_attributes(cell->attributes, inst);
|
|
|
|
cell = module->addNot(inst_name, tmp, net_map_at(inst->GetOutput()));
|
|
|
|
import_attributes(cell->attributes, inst);
|
2018-02-18 06:52:49 -06:00
|
|
|
return true;
|
|
|
|
}
|
2014-03-14 05:46:13 -05:00
|
|
|
|
2018-02-18 06:52:49 -06:00
|
|
|
if (inst->Type() == PRIM_OR) {
|
2018-12-18 09:01:22 -06:00
|
|
|
cell = module->addOr(inst_name, net_map_at(inst->GetInput1()), net_map_at(inst->GetInput2()), net_map_at(inst->GetOutput()));
|
|
|
|
import_attributes(cell->attributes, inst);
|
2018-02-18 06:52:49 -06:00
|
|
|
return true;
|
|
|
|
}
|
2014-03-14 05:46:13 -05:00
|
|
|
|
2018-02-18 06:52:49 -06:00
|
|
|
if (inst->Type() == PRIM_NOR) {
|
2018-12-18 09:01:22 -06:00
|
|
|
RTLIL::SigSpec tmp = module->addWire(new_verific_id(inst));
|
|
|
|
cell = module->addOr(new_verific_id(inst), net_map_at(inst->GetInput1()), net_map_at(inst->GetInput2()), tmp);
|
|
|
|
import_attributes(cell->attributes, inst);
|
|
|
|
cell = module->addNot(inst_name, tmp, net_map_at(inst->GetOutput()));
|
|
|
|
import_attributes(cell->attributes, inst);
|
2018-02-18 06:52:49 -06:00
|
|
|
return true;
|
|
|
|
}
|
2014-03-14 05:46:13 -05:00
|
|
|
|
2018-02-18 06:52:49 -06:00
|
|
|
if (inst->Type() == PRIM_XOR) {
|
2018-12-18 09:01:22 -06:00
|
|
|
cell = module->addXor(inst_name, net_map_at(inst->GetInput1()), net_map_at(inst->GetInput2()), net_map_at(inst->GetOutput()));
|
|
|
|
import_attributes(cell->attributes, inst);
|
2018-02-18 06:52:49 -06:00
|
|
|
return true;
|
|
|
|
}
|
2014-03-14 05:46:13 -05:00
|
|
|
|
2018-02-18 06:52:49 -06:00
|
|
|
if (inst->Type() == PRIM_XNOR) {
|
2018-12-18 09:01:22 -06:00
|
|
|
cell = module->addXnor(inst_name, net_map_at(inst->GetInput1()), net_map_at(inst->GetInput2()), net_map_at(inst->GetOutput()));
|
|
|
|
import_attributes(cell->attributes, inst);
|
2018-02-18 06:52:49 -06:00
|
|
|
return true;
|
|
|
|
}
|
2014-03-09 14:40:04 -05:00
|
|
|
|
2018-02-18 06:52:49 -06:00
|
|
|
if (inst->Type() == PRIM_INV) {
|
2018-12-18 09:01:22 -06:00
|
|
|
cell = module->addNot(inst_name, net_map_at(inst->GetInput()), net_map_at(inst->GetOutput()));
|
|
|
|
import_attributes(cell->attributes, inst);
|
2018-02-18 06:52:49 -06:00
|
|
|
return true;
|
|
|
|
}
|
2014-03-09 14:40:04 -05:00
|
|
|
|
2018-02-18 06:52:49 -06:00
|
|
|
if (inst->Type() == PRIM_MUX) {
|
2018-12-18 09:01:22 -06:00
|
|
|
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()));
|
|
|
|
import_attributes(cell->attributes, inst);
|
2018-02-18 06:52:49 -06:00
|
|
|
return true;
|
|
|
|
}
|
2014-03-09 14:40:04 -05:00
|
|
|
|
2018-02-18 06:52:49 -06:00
|
|
|
if (inst->Type() == PRIM_TRI) {
|
2018-12-18 09:01:22 -06:00
|
|
|
cell = module->addMux(inst_name, RTLIL::State::Sz, net_map_at(inst->GetInput()), net_map_at(inst->GetControl()), net_map_at(inst->GetOutput()));
|
|
|
|
import_attributes(cell->attributes, inst);
|
2018-02-18 06:52:49 -06:00
|
|
|
return true;
|
2017-02-04 06:36:00 -06:00
|
|
|
}
|
2014-03-09 14:40:04 -05:00
|
|
|
|
2018-02-18 06:52:49 -06:00
|
|
|
if (inst->Type() == PRIM_FADD)
|
2017-07-28 17:07:02 -05:00
|
|
|
{
|
2018-12-18 09:01:22 -06:00
|
|
|
RTLIL::SigSpec a_plus_b = module->addWire(new_verific_id(inst), 2);
|
|
|
|
RTLIL::SigSpec y = inst->GetOutput() ? net_map_at(inst->GetOutput()) : module->addWire(new_verific_id(inst));
|
2018-02-18 06:52:49 -06:00
|
|
|
if (inst->GetCout())
|
|
|
|
y.append(net_map_at(inst->GetCout()));
|
2018-12-18 09:01:22 -06:00
|
|
|
cell = module->addAdd(new_verific_id(inst), net_map_at(inst->GetInput1()), net_map_at(inst->GetInput2()), a_plus_b);
|
|
|
|
import_attributes(cell->attributes, inst);
|
|
|
|
cell = module->addAdd(inst_name, a_plus_b, net_map_at(inst->GetCin()), y);
|
|
|
|
import_attributes(cell->attributes, inst);
|
2018-02-18 06:52:49 -06:00
|
|
|
return true;
|
2017-07-28 17:07:02 -05:00
|
|
|
}
|
|
|
|
|
2018-02-18 06:52:49 -06:00
|
|
|
if (inst->Type() == PRIM_DFFRS)
|
2017-07-28 17:07:02 -05:00
|
|
|
{
|
2018-03-04 06:48:53 -06:00
|
|
|
VerificClocking clocking(this, inst->GetClock());
|
|
|
|
log_assert(clocking.disable_sig == State::S0);
|
|
|
|
log_assert(clocking.body_net == nullptr);
|
|
|
|
|
2018-02-18 06:52:49 -06:00
|
|
|
if (inst->GetSet()->IsGnd() && inst->GetReset()->IsGnd())
|
2018-12-18 09:01:22 -06:00
|
|
|
cell = clocking.addDff(inst_name, net_map_at(inst->GetInput()), net_map_at(inst->GetOutput()));
|
2018-02-18 06:52:49 -06:00
|
|
|
else if (inst->GetSet()->IsGnd())
|
2018-12-18 09:01:22 -06:00
|
|
|
cell = clocking.addAdff(inst_name, net_map_at(inst->GetReset()), net_map_at(inst->GetInput()), net_map_at(inst->GetOutput()), RTLIL::State::S0);
|
2018-02-18 06:52:49 -06:00
|
|
|
else if (inst->GetReset()->IsGnd())
|
2018-12-18 09:01:22 -06:00
|
|
|
cell = clocking.addAdff(inst_name, net_map_at(inst->GetSet()), net_map_at(inst->GetInput()), net_map_at(inst->GetOutput()), RTLIL::State::S1);
|
2018-02-18 06:52:49 -06:00
|
|
|
else
|
2018-12-18 09:01:22 -06:00
|
|
|
cell = clocking.addDffsr(inst_name, net_map_at(inst->GetSet()), net_map_at(inst->GetReset()),
|
2018-02-18 06:52:49 -06:00
|
|
|
net_map_at(inst->GetInput()), net_map_at(inst->GetOutput()));
|
2018-12-18 09:01:22 -06:00
|
|
|
import_attributes(cell->attributes, inst);
|
2018-02-18 06:52:49 -06:00
|
|
|
return true;
|
2017-07-28 17:07:02 -05:00
|
|
|
}
|
|
|
|
|
2018-02-18 06:52:49 -06:00
|
|
|
if (inst->Type() == PRIM_DLATCHRS)
|
2014-03-09 14:40:04 -05:00
|
|
|
{
|
2018-02-18 06:52:49 -06:00
|
|
|
if (inst->GetSet()->IsGnd() && inst->GetReset()->IsGnd())
|
2018-12-18 09:01:22 -06:00
|
|
|
cell = module->addDlatch(inst_name, net_map_at(inst->GetControl()), net_map_at(inst->GetInput()), net_map_at(inst->GetOutput()));
|
2018-02-18 06:52:49 -06:00
|
|
|
else
|
2018-12-18 09:01:22 -06:00
|
|
|
cell = module->addDlatchsr(inst_name, net_map_at(inst->GetControl()), net_map_at(inst->GetSet()), net_map_at(inst->GetReset()),
|
2018-02-18 06:52:49 -06:00
|
|
|
net_map_at(inst->GetInput()), net_map_at(inst->GetOutput()));
|
2018-12-18 09:01:22 -06:00
|
|
|
import_attributes(cell->attributes, inst);
|
2018-02-18 06:52:49 -06:00
|
|
|
return true;
|
|
|
|
}
|
2014-03-09 14:40:04 -05:00
|
|
|
|
2018-02-18 06:52:49 -06:00
|
|
|
#define IN operatorInput(inst)
|
|
|
|
#define IN1 operatorInput1(inst)
|
|
|
|
#define IN2 operatorInput2(inst)
|
|
|
|
#define OUT operatorOutput(inst)
|
2018-05-24 10:07:06 -05:00
|
|
|
#define FILTERED_OUT operatorOutput(inst, &any_all_nets)
|
2018-02-18 06:52:49 -06:00
|
|
|
#define SIGNED inst->View()->IsSigned()
|
|
|
|
|
|
|
|
if (inst->Type() == OPER_ADDER) {
|
|
|
|
RTLIL::SigSpec out = OUT;
|
|
|
|
if (inst->GetCout() != NULL)
|
|
|
|
out.append(net_map_at(inst->GetCout()));
|
|
|
|
if (inst->GetCin()->IsGnd()) {
|
2018-12-18 09:01:22 -06:00
|
|
|
cell = module->addAdd(inst_name, IN1, IN2, out, SIGNED);
|
|
|
|
import_attributes(cell->attributes, inst);
|
2017-07-22 09:16:44 -05:00
|
|
|
} else {
|
2018-12-18 09:01:22 -06:00
|
|
|
RTLIL::SigSpec tmp = module->addWire(new_verific_id(inst), GetSize(out));
|
|
|
|
cell = module->addAdd(new_verific_id(inst), IN1, IN2, tmp, SIGNED);
|
|
|
|
import_attributes(cell->attributes, inst);
|
|
|
|
cell = module->addAdd(inst_name, tmp, net_map_at(inst->GetCin()), out, false);
|
|
|
|
import_attributes(cell->attributes, inst);
|
2017-12-09 17:26:26 -06:00
|
|
|
}
|
2018-02-18 06:52:49 -06:00
|
|
|
return true;
|
|
|
|
}
|
2017-12-09 17:26:26 -06:00
|
|
|
|
2018-02-18 06:52:49 -06:00
|
|
|
if (inst->Type() == OPER_MULTIPLIER) {
|
2018-12-18 09:01:22 -06:00
|
|
|
cell = module->addMul(inst_name, IN1, IN2, OUT, SIGNED);
|
|
|
|
import_attributes(cell->attributes, inst);
|
2018-02-18 06:52:49 -06:00
|
|
|
return true;
|
|
|
|
}
|
2014-03-09 14:40:04 -05:00
|
|
|
|
2018-02-18 06:52:49 -06:00
|
|
|
if (inst->Type() == OPER_DIVIDER) {
|
2018-12-18 09:01:22 -06:00
|
|
|
cell = module->addDiv(inst_name, IN1, IN2, OUT, SIGNED);
|
|
|
|
import_attributes(cell->attributes, inst);
|
2018-02-18 06:52:49 -06:00
|
|
|
return true;
|
|
|
|
}
|
2017-02-04 06:36:00 -06:00
|
|
|
|
2018-02-18 06:52:49 -06:00
|
|
|
if (inst->Type() == OPER_MODULO) {
|
2018-12-18 09:01:22 -06:00
|
|
|
cell = module->addMod(inst_name, IN1, IN2, OUT, SIGNED);
|
|
|
|
import_attributes(cell->attributes, inst);
|
2018-02-18 06:52:49 -06:00
|
|
|
return true;
|
|
|
|
}
|
2014-03-09 14:40:04 -05:00
|
|
|
|
2018-02-18 06:52:49 -06:00
|
|
|
if (inst->Type() == OPER_REMAINDER) {
|
2018-12-18 09:01:22 -06:00
|
|
|
cell = module->addMod(inst_name, IN1, IN2, OUT, SIGNED);
|
|
|
|
import_attributes(cell->attributes, inst);
|
2018-02-18 06:52:49 -06:00
|
|
|
return true;
|
|
|
|
}
|
2014-03-09 14:40:04 -05:00
|
|
|
|
2018-02-18 06:52:49 -06:00
|
|
|
if (inst->Type() == OPER_SHIFT_LEFT) {
|
2018-12-18 09:01:22 -06:00
|
|
|
cell = module->addShl(inst_name, IN1, IN2, OUT, false);
|
|
|
|
import_attributes(cell->attributes, inst);
|
2018-02-18 06:52:49 -06:00
|
|
|
return true;
|
|
|
|
}
|
2014-03-09 14:40:04 -05:00
|
|
|
|
2018-02-18 06:52:49 -06:00
|
|
|
if (inst->Type() == OPER_ENABLED_DECODER) {
|
|
|
|
RTLIL::SigSpec vec;
|
|
|
|
vec.append(net_map_at(inst->GetControl()));
|
|
|
|
for (unsigned i = 1; i < inst->OutputSize(); i++) {
|
|
|
|
vec.append(RTLIL::State::S0);
|
2014-03-09 14:40:04 -05:00
|
|
|
}
|
2018-12-18 09:01:22 -06:00
|
|
|
cell = module->addShl(inst_name, vec, IN, OUT, false);
|
|
|
|
import_attributes(cell->attributes, inst);
|
2018-02-18 06:52:49 -06:00
|
|
|
return true;
|
|
|
|
}
|
2014-03-09 14:40:04 -05:00
|
|
|
|
2018-02-18 06:52:49 -06:00
|
|
|
if (inst->Type() == OPER_DECODER) {
|
|
|
|
RTLIL::SigSpec vec;
|
|
|
|
vec.append(RTLIL::State::S1);
|
|
|
|
for (unsigned i = 1; i < inst->OutputSize(); i++) {
|
|
|
|
vec.append(RTLIL::State::S0);
|
2017-02-04 06:36:00 -06:00
|
|
|
}
|
2018-12-18 09:01:22 -06:00
|
|
|
cell = module->addShl(inst_name, vec, IN, OUT, false);
|
|
|
|
import_attributes(cell->attributes, inst);
|
2018-02-18 06:52:49 -06:00
|
|
|
return true;
|
|
|
|
}
|
2014-03-09 14:40:04 -05:00
|
|
|
|
2018-02-18 06:52:49 -06:00
|
|
|
if (inst->Type() == OPER_SHIFT_RIGHT) {
|
|
|
|
Net *net_cin = inst->GetCin();
|
|
|
|
Net *net_a_msb = inst->GetInput1Bit(0);
|
|
|
|
if (net_cin->IsGnd())
|
2018-12-18 09:01:22 -06:00
|
|
|
cell = module->addShr(inst_name, IN1, IN2, OUT, false);
|
2018-02-18 06:52:49 -06:00
|
|
|
else if (net_cin == net_a_msb)
|
2018-12-18 09:01:22 -06:00
|
|
|
cell = module->addSshr(inst_name, IN1, IN2, OUT, true);
|
2018-02-18 06:52:49 -06:00
|
|
|
else
|
|
|
|
log_error("Can't import Verific OPER_SHIFT_RIGHT instance %s: carry_in is neither 0 nor msb of left input\n", inst->Name());
|
2018-12-18 09:01:22 -06:00
|
|
|
import_attributes(cell->attributes, inst);
|
2018-02-18 06:52:49 -06:00
|
|
|
return true;
|
|
|
|
}
|
2017-02-04 06:36:00 -06:00
|
|
|
|
2018-02-18 06:52:49 -06:00
|
|
|
if (inst->Type() == OPER_REDUCE_AND) {
|
2018-12-18 09:01:22 -06:00
|
|
|
cell = module->addReduceAnd(inst_name, IN, net_map_at(inst->GetOutput()), SIGNED);
|
|
|
|
import_attributes(cell->attributes, inst);
|
2018-02-18 06:52:49 -06:00
|
|
|
return true;
|
|
|
|
}
|
2017-02-11 04:40:18 -06:00
|
|
|
|
2020-01-30 11:01:13 -06:00
|
|
|
if (inst->Type() == OPER_REDUCE_NAND) {
|
|
|
|
Wire *tmp = module->addWire(NEW_ID);
|
|
|
|
cell = module->addReduceAnd(inst_name, IN, tmp, SIGNED);
|
|
|
|
module->addNot(NEW_ID, tmp, net_map_at(inst->GetOutput()));
|
|
|
|
import_attributes(cell->attributes, inst);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2018-02-18 06:52:49 -06:00
|
|
|
if (inst->Type() == OPER_REDUCE_OR) {
|
2018-12-18 09:01:22 -06:00
|
|
|
cell = module->addReduceOr(inst_name, IN, net_map_at(inst->GetOutput()), SIGNED);
|
|
|
|
import_attributes(cell->attributes, inst);
|
2018-02-18 06:52:49 -06:00
|
|
|
return true;
|
|
|
|
}
|
2017-02-11 04:40:18 -06:00
|
|
|
|
2018-02-18 06:52:49 -06:00
|
|
|
if (inst->Type() == OPER_REDUCE_XOR) {
|
2018-12-18 09:01:22 -06:00
|
|
|
cell = module->addReduceXor(inst_name, IN, net_map_at(inst->GetOutput()), SIGNED);
|
|
|
|
import_attributes(cell->attributes, inst);
|
2018-02-18 06:52:49 -06:00
|
|
|
return true;
|
|
|
|
}
|
2017-02-11 04:40:18 -06:00
|
|
|
|
2018-02-18 06:52:49 -06:00
|
|
|
if (inst->Type() == OPER_REDUCE_XNOR) {
|
2018-12-18 09:01:22 -06:00
|
|
|
cell = module->addReduceXnor(inst_name, IN, net_map_at(inst->GetOutput()), SIGNED);
|
|
|
|
import_attributes(cell->attributes, inst);
|
2018-02-18 06:52:49 -06:00
|
|
|
return true;
|
|
|
|
}
|
2017-02-11 04:40:18 -06:00
|
|
|
|
2018-02-26 08:26:01 -06:00
|
|
|
if (inst->Type() == OPER_REDUCE_NOR) {
|
2018-12-18 09:01:22 -06:00
|
|
|
SigSpec t = module->ReduceOr(new_verific_id(inst), IN, SIGNED);
|
|
|
|
cell = module->addNot(inst_name, t, net_map_at(inst->GetOutput()));
|
|
|
|
import_attributes(cell->attributes, inst);
|
2018-02-26 08:26:01 -06:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2018-02-18 06:52:49 -06:00
|
|
|
if (inst->Type() == OPER_LESSTHAN) {
|
|
|
|
Net *net_cin = inst->GetCin();
|
|
|
|
if (net_cin->IsGnd())
|
2018-12-18 09:01:22 -06:00
|
|
|
cell = module->addLt(inst_name, IN1, IN2, net_map_at(inst->GetOutput()), SIGNED);
|
2018-02-18 06:52:49 -06:00
|
|
|
else if (net_cin->IsPwr())
|
2018-12-18 09:01:22 -06:00
|
|
|
cell = module->addLe(inst_name, IN1, IN2, net_map_at(inst->GetOutput()), SIGNED);
|
2018-02-18 06:52:49 -06:00
|
|
|
else
|
|
|
|
log_error("Can't import Verific OPER_LESSTHAN instance %s: carry_in is neither 0 nor 1\n", inst->Name());
|
2018-12-18 09:01:22 -06:00
|
|
|
import_attributes(cell->attributes, inst);
|
2018-02-18 06:52:49 -06:00
|
|
|
return true;
|
|
|
|
}
|
2017-02-11 04:40:18 -06:00
|
|
|
|
2018-02-18 06:52:49 -06:00
|
|
|
if (inst->Type() == OPER_WIDE_AND) {
|
2018-12-18 09:01:22 -06:00
|
|
|
cell = module->addAnd(inst_name, IN1, IN2, OUT, SIGNED);
|
|
|
|
import_attributes(cell->attributes, inst);
|
2018-02-18 06:52:49 -06:00
|
|
|
return true;
|
|
|
|
}
|
2017-02-09 05:53:46 -06:00
|
|
|
|
2018-02-18 06:52:49 -06:00
|
|
|
if (inst->Type() == OPER_WIDE_OR) {
|
2018-12-18 09:01:22 -06:00
|
|
|
cell = module->addOr(inst_name, IN1, IN2, OUT, SIGNED);
|
|
|
|
import_attributes(cell->attributes, inst);
|
2018-02-18 06:52:49 -06:00
|
|
|
return true;
|
|
|
|
}
|
2017-02-09 05:53:46 -06:00
|
|
|
|
2018-02-18 06:52:49 -06:00
|
|
|
if (inst->Type() == OPER_WIDE_XOR) {
|
2018-12-18 09:01:22 -06:00
|
|
|
cell = module->addXor(inst_name, IN1, IN2, OUT, SIGNED);
|
|
|
|
import_attributes(cell->attributes, inst);
|
2018-02-18 06:52:49 -06:00
|
|
|
return true;
|
|
|
|
}
|
2014-03-09 14:40:04 -05:00
|
|
|
|
2018-02-18 06:52:49 -06:00
|
|
|
if (inst->Type() == OPER_WIDE_XNOR) {
|
2018-12-18 09:01:22 -06:00
|
|
|
cell = module->addXnor(inst_name, IN1, IN2, OUT, SIGNED);
|
|
|
|
import_attributes(cell->attributes, inst);
|
2018-02-18 06:52:49 -06:00
|
|
|
return true;
|
|
|
|
}
|
2017-07-28 17:07:02 -05:00
|
|
|
|
2018-02-18 06:52:49 -06:00
|
|
|
if (inst->Type() == OPER_WIDE_BUF) {
|
2018-12-18 09:01:22 -06:00
|
|
|
cell = module->addPos(inst_name, IN, FILTERED_OUT, SIGNED);
|
|
|
|
import_attributes(cell->attributes, inst);
|
2018-02-18 06:52:49 -06:00
|
|
|
return true;
|
|
|
|
}
|
2014-03-09 14:40:04 -05:00
|
|
|
|
2018-02-18 06:52:49 -06:00
|
|
|
if (inst->Type() == OPER_WIDE_INV) {
|
2018-12-18 09:01:22 -06:00
|
|
|
cell = module->addNot(inst_name, IN, OUT, SIGNED);
|
|
|
|
import_attributes(cell->attributes, inst);
|
2018-02-18 06:52:49 -06:00
|
|
|
return true;
|
|
|
|
}
|
2014-03-09 14:40:04 -05:00
|
|
|
|
2018-02-18 06:52:49 -06:00
|
|
|
if (inst->Type() == OPER_MINUS) {
|
2018-12-18 09:01:22 -06:00
|
|
|
cell = module->addSub(inst_name, IN1, IN2, OUT, SIGNED);
|
|
|
|
import_attributes(cell->attributes, inst);
|
2018-02-18 06:52:49 -06:00
|
|
|
return true;
|
|
|
|
}
|
2014-03-09 14:40:04 -05:00
|
|
|
|
2018-02-18 06:52:49 -06:00
|
|
|
if (inst->Type() == OPER_UMINUS) {
|
2018-12-18 09:01:22 -06:00
|
|
|
cell = module->addNeg(inst_name, IN, OUT, SIGNED);
|
|
|
|
import_attributes(cell->attributes, inst);
|
2018-02-18 06:52:49 -06:00
|
|
|
return true;
|
|
|
|
}
|
2014-03-09 14:40:04 -05:00
|
|
|
|
2018-02-18 06:52:49 -06:00
|
|
|
if (inst->Type() == OPER_EQUAL) {
|
2018-12-18 09:01:22 -06:00
|
|
|
cell = module->addEq(inst_name, IN1, IN2, net_map_at(inst->GetOutput()), SIGNED);
|
|
|
|
import_attributes(cell->attributes, inst);
|
2018-02-18 06:52:49 -06:00
|
|
|
return true;
|
|
|
|
}
|
2017-02-04 06:36:00 -06:00
|
|
|
|
2018-02-18 06:52:49 -06:00
|
|
|
if (inst->Type() == OPER_NEQUAL) {
|
2018-12-18 09:01:22 -06:00
|
|
|
cell = module->addNe(inst_name, IN1, IN2, net_map_at(inst->GetOutput()), SIGNED);
|
|
|
|
import_attributes(cell->attributes, inst);
|
2018-02-18 06:52:49 -06:00
|
|
|
return true;
|
|
|
|
}
|
2015-11-16 05:38:56 -06:00
|
|
|
|
2018-02-18 06:52:49 -06:00
|
|
|
if (inst->Type() == OPER_WIDE_MUX) {
|
2018-12-18 09:01:22 -06:00
|
|
|
cell = module->addMux(inst_name, IN1, IN2, net_map_at(inst->GetControl()), OUT);
|
|
|
|
import_attributes(cell->attributes, inst);
|
2018-02-18 06:52:49 -06:00
|
|
|
return true;
|
|
|
|
}
|
2017-02-04 06:36:00 -06:00
|
|
|
|
2018-02-26 08:02:03 -06:00
|
|
|
if (inst->Type() == OPER_NTO1MUX) {
|
2018-12-18 09:01:22 -06:00
|
|
|
cell = module->addShr(inst_name, IN2, IN1, net_map_at(inst->GetOutput()));
|
|
|
|
import_attributes(cell->attributes, inst);
|
2018-02-26 08:02:03 -06:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (inst->Type() == OPER_WIDE_NTO1MUX)
|
|
|
|
{
|
|
|
|
SigSpec data = IN2, out = OUT;
|
|
|
|
|
|
|
|
int wordsize_bits = ceil_log2(GetSize(out));
|
|
|
|
int wordsize = 1 << wordsize_bits;
|
|
|
|
|
|
|
|
SigSpec sel = {IN1, SigSpec(State::S0, wordsize_bits)};
|
|
|
|
|
|
|
|
SigSpec padded_data;
|
|
|
|
for (int i = 0; i < GetSize(data); i += GetSize(out)) {
|
|
|
|
SigSpec d = data.extract(i, GetSize(out));
|
|
|
|
d.extend_u0(wordsize);
|
|
|
|
padded_data.append(d);
|
|
|
|
}
|
|
|
|
|
2018-12-18 09:01:22 -06:00
|
|
|
cell = module->addShr(inst_name, padded_data, sel, out);
|
|
|
|
import_attributes(cell->attributes, inst);
|
2018-02-26 08:02:03 -06:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2018-02-26 08:20:27 -06:00
|
|
|
if (inst->Type() == OPER_SELECTOR)
|
|
|
|
{
|
2018-12-18 09:01:22 -06:00
|
|
|
cell = module->addPmux(inst_name, State::S0, IN2, IN1, net_map_at(inst->GetOutput()));
|
|
|
|
import_attributes(cell->attributes, inst);
|
2018-02-26 08:20:27 -06:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (inst->Type() == OPER_WIDE_SELECTOR)
|
|
|
|
{
|
|
|
|
SigSpec out = OUT;
|
2018-12-18 09:01:22 -06:00
|
|
|
cell = module->addPmux(inst_name, SigSpec(State::S0, GetSize(out)), IN2, IN1, out);
|
|
|
|
import_attributes(cell->attributes, inst);
|
2018-02-26 08:20:27 -06:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2018-02-18 06:52:49 -06:00
|
|
|
if (inst->Type() == OPER_WIDE_TRI) {
|
2018-12-18 09:01:22 -06:00
|
|
|
cell = module->addMux(inst_name, RTLIL::SigSpec(RTLIL::State::Sz, inst->OutputSize()), IN, net_map_at(inst->GetControl()), OUT);
|
|
|
|
import_attributes(cell->attributes, inst);
|
2018-02-18 06:52:49 -06:00
|
|
|
return true;
|
|
|
|
}
|
2015-11-16 05:38:56 -06:00
|
|
|
|
2018-03-04 06:48:53 -06:00
|
|
|
if (inst->Type() == OPER_WIDE_DFFRS)
|
|
|
|
{
|
|
|
|
VerificClocking clocking(this, inst->GetClock());
|
|
|
|
log_assert(clocking.disable_sig == State::S0);
|
|
|
|
log_assert(clocking.body_net == nullptr);
|
|
|
|
|
2018-02-18 06:52:49 -06:00
|
|
|
RTLIL::SigSpec sig_set = operatorInport(inst, "set");
|
|
|
|
RTLIL::SigSpec sig_reset = operatorInport(inst, "reset");
|
2018-03-04 06:48:53 -06:00
|
|
|
|
2018-02-18 06:52:49 -06:00
|
|
|
if (sig_set.is_fully_const() && !sig_set.as_bool() && sig_reset.is_fully_const() && !sig_reset.as_bool())
|
2018-12-18 09:01:22 -06:00
|
|
|
cell = clocking.addDff(inst_name, IN, OUT);
|
2018-02-18 06:52:49 -06:00
|
|
|
else
|
2018-12-18 09:01:22 -06:00
|
|
|
cell = clocking.addDffsr(inst_name, sig_set, sig_reset, IN, OUT);
|
|
|
|
import_attributes(cell->attributes, inst);
|
2018-03-04 06:48:53 -06:00
|
|
|
|
2018-02-18 06:52:49 -06:00
|
|
|
return true;
|
|
|
|
}
|
2017-02-04 06:36:00 -06:00
|
|
|
|
2018-02-18 06:52:49 -06:00
|
|
|
#undef IN
|
|
|
|
#undef IN1
|
|
|
|
#undef IN2
|
|
|
|
#undef OUT
|
|
|
|
#undef SIGNED
|
2017-02-04 06:36:00 -06:00
|
|
|
|
2018-02-18 06:52:49 -06:00
|
|
|
return false;
|
|
|
|
}
|
2017-07-26 11:00:01 -05:00
|
|
|
|
2018-02-18 06:52:49 -06:00
|
|
|
void VerificImporter::merge_past_ffs_clock(pool<RTLIL::Cell*> &candidates, SigBit clock, bool clock_pol)
|
|
|
|
{
|
|
|
|
bool keep_running = true;
|
|
|
|
SigMap sigmap;
|
2017-07-26 11:00:01 -05:00
|
|
|
|
2018-02-18 06:52:49 -06:00
|
|
|
while (keep_running)
|
|
|
|
{
|
|
|
|
keep_running = false;
|
2017-07-26 11:00:01 -05:00
|
|
|
|
2018-02-18 06:52:49 -06:00
|
|
|
dict<SigBit, pool<RTLIL::Cell*>> dbits_db;
|
|
|
|
SigSpec dbits;
|
2017-12-09 17:59:44 -06:00
|
|
|
|
2018-02-18 06:52:49 -06:00
|
|
|
for (auto cell : candidates) {
|
2020-04-02 11:51:32 -05:00
|
|
|
SigBit bit = sigmap(cell->getPort(ID::D));
|
2018-02-18 06:52:49 -06:00
|
|
|
dbits_db[bit].insert(cell);
|
|
|
|
dbits.append(bit);
|
|
|
|
}
|
2017-12-09 17:59:44 -06:00
|
|
|
|
2018-02-18 06:52:49 -06:00
|
|
|
dbits.sort_and_unify();
|
2017-12-09 17:59:44 -06:00
|
|
|
|
2018-02-18 06:52:49 -06:00
|
|
|
for (auto chunk : dbits.chunks())
|
|
|
|
{
|
|
|
|
SigSpec sig_d = chunk;
|
2017-12-09 17:59:44 -06:00
|
|
|
|
2018-02-18 06:52:49 -06:00
|
|
|
if (chunk.wire == nullptr || GetSize(sig_d) == 1)
|
|
|
|
continue;
|
2018-02-01 05:51:49 -06:00
|
|
|
|
2018-02-18 06:52:49 -06:00
|
|
|
SigSpec sig_q = module->addWire(NEW_ID, GetSize(sig_d));
|
|
|
|
RTLIL::Cell *new_ff = module->addDff(NEW_ID, clock, sig_d, sig_q, clock_pol);
|
2018-02-01 05:51:49 -06:00
|
|
|
|
2018-02-28 04:45:04 -06:00
|
|
|
if (verific_verbose)
|
2018-02-18 06:52:49 -06:00
|
|
|
log(" merging single-bit past_ffs into new %d-bit ff %s.\n", GetSize(sig_d), log_id(new_ff));
|
2018-02-01 05:51:49 -06:00
|
|
|
|
2018-02-18 06:52:49 -06:00
|
|
|
for (int i = 0; i < GetSize(sig_d); i++)
|
|
|
|
for (auto old_ff : dbits_db[sig_d[i]])
|
|
|
|
{
|
2018-02-28 04:45:04 -06:00
|
|
|
if (verific_verbose)
|
2018-02-18 06:52:49 -06:00
|
|
|
log(" replacing old ff %s on bit %d.\n", log_id(old_ff), i);
|
2018-02-01 05:51:49 -06:00
|
|
|
|
2020-04-02 11:51:32 -05:00
|
|
|
SigBit old_q = old_ff->getPort(ID::Q);
|
2018-02-18 06:52:49 -06:00
|
|
|
SigBit new_q = sig_q[i];
|
2018-02-01 05:51:49 -06:00
|
|
|
|
2018-02-18 06:52:49 -06:00
|
|
|
sigmap.add(old_q, new_q);
|
|
|
|
module->connect(old_q, new_q);
|
|
|
|
candidates.erase(old_ff);
|
|
|
|
module->remove(old_ff);
|
|
|
|
keep_running = true;
|
2017-12-09 17:59:44 -06:00
|
|
|
}
|
2018-02-18 06:52:49 -06:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2017-12-09 17:59:44 -06:00
|
|
|
|
2018-02-18 06:52:49 -06:00
|
|
|
void VerificImporter::merge_past_ffs(pool<RTLIL::Cell*> &candidates)
|
|
|
|
{
|
|
|
|
dict<pair<SigBit, int>, pool<RTLIL::Cell*>> database;
|
2017-12-09 17:59:44 -06:00
|
|
|
|
2018-02-18 06:52:49 -06:00
|
|
|
for (auto cell : candidates)
|
|
|
|
{
|
2020-04-02 11:51:32 -05:00
|
|
|
SigBit clock = cell->getPort(ID::CLK);
|
|
|
|
bool clock_pol = cell->getParam(ID::CLK_POLARITY).as_bool();
|
2018-02-18 06:52:49 -06:00
|
|
|
database[make_pair(clock, int(clock_pol))].insert(cell);
|
|
|
|
}
|
2017-12-09 17:59:44 -06:00
|
|
|
|
2018-02-18 06:52:49 -06:00
|
|
|
for (auto it : database)
|
|
|
|
merge_past_ffs_clock(it.second, it.first.first, it.first.second);
|
|
|
|
}
|
2017-07-27 04:40:07 -05:00
|
|
|
|
2019-11-20 05:54:10 -06:00
|
|
|
void VerificImporter::import_netlist(RTLIL::Design *design, Netlist *nl, std::set<Netlist*> &nl_todo, bool norename)
|
2018-02-18 06:52:49 -06:00
|
|
|
{
|
2019-03-13 17:05:55 -05:00
|
|
|
std::string netlist_name = nl->GetAtt(" \\top") ? nl->CellBaseName() : nl->Owner()->Name();
|
2019-10-24 05:13:37 -05:00
|
|
|
std::string module_name = netlist_name;
|
|
|
|
|
2019-11-22 09:00:07 -06:00
|
|
|
if (nl->IsOperator() || nl->IsPrimitive()) {
|
2019-10-24 05:13:37 -05:00
|
|
|
module_name = "$verific$" + module_name;
|
|
|
|
} else {
|
2019-11-20 05:54:10 -06:00
|
|
|
if (!norename && *nl->Name()) {
|
2019-10-24 05:13:37 -05:00
|
|
|
module_name += "(";
|
|
|
|
module_name += nl->Name();
|
|
|
|
module_name += ")";
|
|
|
|
}
|
|
|
|
module_name = "\\" + module_name;
|
|
|
|
}
|
2017-07-27 04:40:07 -05:00
|
|
|
|
2018-02-18 06:52:49 -06:00
|
|
|
netlist = nl;
|
2017-07-27 04:40:07 -05:00
|
|
|
|
2018-02-18 06:52:49 -06:00
|
|
|
if (design->has(module_name)) {
|
2018-10-07 12:48:42 -05:00
|
|
|
if (!nl->IsOperator() && !is_blackbox(nl))
|
2019-03-13 14:42:18 -05:00
|
|
|
log_cmd_error("Re-definition of module `%s'.\n", netlist_name.c_str());
|
2018-02-18 06:52:49 -06:00
|
|
|
return;
|
|
|
|
}
|
2017-07-27 04:40:07 -05:00
|
|
|
|
2018-02-18 06:52:49 -06:00
|
|
|
module = new RTLIL::Module;
|
|
|
|
module->name = module_name;
|
|
|
|
design->add(module);
|
2017-07-27 04:40:07 -05:00
|
|
|
|
2018-10-07 12:48:42 -05:00
|
|
|
if (is_blackbox(nl)) {
|
2018-02-18 06:52:49 -06:00
|
|
|
log("Importing blackbox module %s.\n", RTLIL::id2cstr(module->name));
|
2020-04-02 11:51:32 -05:00
|
|
|
module->set_bool_attribute(ID::blackbox);
|
2018-02-18 06:52:49 -06:00
|
|
|
} else {
|
|
|
|
log("Importing module %s.\n", RTLIL::id2cstr(module->name));
|
|
|
|
}
|
2017-07-26 11:00:01 -05:00
|
|
|
|
2018-02-18 06:52:49 -06:00
|
|
|
SetIter si;
|
|
|
|
MapIter mi, mi2;
|
|
|
|
Port *port;
|
|
|
|
PortBus *portbus;
|
|
|
|
Net *net;
|
|
|
|
NetBus *netbus;
|
|
|
|
Instance *inst;
|
|
|
|
PortRef *pr;
|
2017-10-04 11:56:28 -05:00
|
|
|
|
2018-02-18 06:52:49 -06:00
|
|
|
FOREACH_PORT_OF_NETLIST(nl, mi, port)
|
|
|
|
{
|
|
|
|
if (port->Bus())
|
|
|
|
continue;
|
2017-02-04 06:36:00 -06:00
|
|
|
|
2018-02-28 04:45:04 -06:00
|
|
|
if (verific_verbose)
|
2018-02-18 06:52:49 -06:00
|
|
|
log(" importing port %s.\n", port->Name());
|
2017-07-24 04:29:06 -05:00
|
|
|
|
2018-02-18 06:52:49 -06:00
|
|
|
RTLIL::Wire *wire = module->addWire(RTLIL::escape_id(port->Name()));
|
2020-04-27 10:43:54 -05:00
|
|
|
import_attributes(wire->attributes, port, nl);
|
2017-07-26 11:00:01 -05:00
|
|
|
|
2018-02-18 06:52:49 -06:00
|
|
|
wire->port_id = nl->IndexOf(port) + 1;
|
2017-07-26 11:00:01 -05:00
|
|
|
|
2018-02-18 06:52:49 -06:00
|
|
|
if (port->GetDir() == DIR_INOUT || port->GetDir() == DIR_IN)
|
|
|
|
wire->port_input = true;
|
|
|
|
if (port->GetDir() == DIR_INOUT || port->GetDir() == DIR_OUT)
|
|
|
|
wire->port_output = true;
|
2017-07-26 11:00:01 -05:00
|
|
|
|
2018-02-18 06:52:49 -06:00
|
|
|
if (port->GetNet()) {
|
|
|
|
net = port->GetNet();
|
|
|
|
if (net_map.count(net) == 0)
|
|
|
|
net_map[net] = wire;
|
|
|
|
else if (wire->port_input)
|
|
|
|
module->connect(net_map_at(net), wire);
|
|
|
|
else
|
|
|
|
module->connect(wire, net_map_at(net));
|
|
|
|
}
|
|
|
|
}
|
2017-07-28 17:07:02 -05:00
|
|
|
|
2018-02-18 06:52:49 -06:00
|
|
|
FOREACH_PORTBUS_OF_NETLIST(nl, mi, portbus)
|
|
|
|
{
|
2018-02-28 04:45:04 -06:00
|
|
|
if (verific_verbose)
|
2018-02-18 06:52:49 -06:00
|
|
|
log(" importing portbus %s.\n", portbus->Name());
|
|
|
|
|
|
|
|
RTLIL::Wire *wire = module->addWire(RTLIL::escape_id(portbus->Name()), portbus->Size());
|
|
|
|
wire->start_offset = min(portbus->LeftIndex(), portbus->RightIndex());
|
2020-04-27 10:43:54 -05:00
|
|
|
import_attributes(wire->attributes, portbus, nl);
|
2018-02-18 06:52:49 -06:00
|
|
|
|
|
|
|
if (portbus->GetDir() == DIR_INOUT || portbus->GetDir() == DIR_IN)
|
|
|
|
wire->port_input = true;
|
|
|
|
if (portbus->GetDir() == DIR_INOUT || portbus->GetDir() == DIR_OUT)
|
|
|
|
wire->port_output = true;
|
|
|
|
|
|
|
|
for (int i = portbus->LeftIndex();; i += portbus->IsUp() ? +1 : -1) {
|
|
|
|
if (portbus->ElementAtIndex(i) && portbus->ElementAtIndex(i)->GetNet()) {
|
|
|
|
net = portbus->ElementAtIndex(i)->GetNet();
|
|
|
|
RTLIL::SigBit bit(wire, i - wire->start_offset);
|
|
|
|
if (net_map.count(net) == 0)
|
|
|
|
net_map[net] = bit;
|
|
|
|
else if (wire->port_input)
|
|
|
|
module->connect(net_map_at(net), bit);
|
|
|
|
else
|
|
|
|
module->connect(bit, net_map_at(net));
|
|
|
|
}
|
|
|
|
if (i == portbus->RightIndex())
|
|
|
|
break;
|
2017-07-27 04:54:45 -05:00
|
|
|
}
|
2014-03-09 14:40:04 -05:00
|
|
|
}
|
|
|
|
|
2018-02-18 06:52:49 -06:00
|
|
|
module->fixup_ports();
|
2017-07-27 04:40:07 -05:00
|
|
|
|
2018-02-18 06:52:49 -06:00
|
|
|
dict<Net*, char, hash_ptr_ops> init_nets;
|
2018-04-06 07:19:55 -05:00
|
|
|
pool<Net*, hash_ptr_ops> anyconst_nets, anyseq_nets;
|
|
|
|
pool<Net*, hash_ptr_ops> allconst_nets, allseq_nets;
|
2018-05-24 10:07:06 -05:00
|
|
|
any_all_nets.clear();
|
2018-02-18 06:52:49 -06:00
|
|
|
|
|
|
|
FOREACH_NET_OF_NETLIST(nl, mi, net)
|
2017-07-28 10:37:09 -05:00
|
|
|
{
|
2018-02-18 06:52:49 -06:00
|
|
|
if (net->IsRamNet())
|
|
|
|
{
|
|
|
|
RTLIL::Memory *memory = new RTLIL::Memory;
|
|
|
|
memory->name = RTLIL::escape_id(net->Name());
|
|
|
|
log_assert(module->count_id(memory->name) == 0);
|
|
|
|
module->memories[memory->name] = memory;
|
|
|
|
|
|
|
|
int number_of_bits = net->Size();
|
2020-06-01 03:30:03 -05:00
|
|
|
number_of_bits = 1 << ceil_log2(number_of_bits);
|
2018-02-18 06:52:49 -06:00
|
|
|
int bits_in_word = number_of_bits;
|
|
|
|
FOREACH_PORTREF_OF_NET(net, si, pr) {
|
|
|
|
if (pr->GetInst()->Type() == OPER_READ_PORT) {
|
|
|
|
bits_in_word = min<int>(bits_in_word, pr->GetInst()->OutputSize());
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
if (pr->GetInst()->Type() == OPER_WRITE_PORT || pr->GetInst()->Type() == OPER_CLOCKED_WRITE_PORT) {
|
|
|
|
bits_in_word = min<int>(bits_in_word, pr->GetInst()->Input2Size());
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
log_error("Verific RamNet %s is connected to unsupported instance type %s (%s).\n",
|
|
|
|
net->Name(), pr->GetInst()->View()->Owner()->Name(), pr->GetInst()->Name());
|
|
|
|
}
|
2017-07-28 10:37:09 -05:00
|
|
|
|
2018-02-18 06:52:49 -06:00
|
|
|
memory->width = bits_in_word;
|
|
|
|
memory->size = number_of_bits / bits_in_word;
|
|
|
|
|
|
|
|
const char *ascii_initdata = net->GetWideInitialValue();
|
|
|
|
if (ascii_initdata) {
|
|
|
|
while (*ascii_initdata != 0 && *ascii_initdata != '\'')
|
|
|
|
ascii_initdata++;
|
|
|
|
if (*ascii_initdata == '\'')
|
|
|
|
ascii_initdata++;
|
|
|
|
if (*ascii_initdata != 0) {
|
|
|
|
log_assert(*ascii_initdata == 'b');
|
|
|
|
ascii_initdata++;
|
|
|
|
}
|
|
|
|
for (int word_idx = 0; word_idx < memory->size; word_idx++) {
|
|
|
|
Const initval = Const(State::Sx, memory->width);
|
|
|
|
bool initval_valid = false;
|
|
|
|
for (int bit_idx = memory->width-1; bit_idx >= 0; bit_idx--) {
|
|
|
|
if (*ascii_initdata == 0)
|
|
|
|
break;
|
|
|
|
if (*ascii_initdata == '0' || *ascii_initdata == '1') {
|
|
|
|
initval[bit_idx] = (*ascii_initdata == '0') ? State::S0 : State::S1;
|
|
|
|
initval_valid = true;
|
|
|
|
}
|
|
|
|
ascii_initdata++;
|
|
|
|
}
|
|
|
|
if (initval_valid) {
|
2020-04-02 11:51:32 -05:00
|
|
|
RTLIL::Cell *cell = module->addCell(new_verific_id(net), ID($meminit));
|
|
|
|
cell->parameters[ID::WORDS] = 1;
|
2018-02-18 06:52:49 -06:00
|
|
|
if (net->GetOrigTypeRange()->LeftRangeBound() < net->GetOrigTypeRange()->RightRangeBound())
|
2020-04-02 11:51:32 -05:00
|
|
|
cell->setPort(ID::ADDR, word_idx);
|
2018-02-18 06:52:49 -06:00
|
|
|
else
|
2020-04-02 11:51:32 -05:00
|
|
|
cell->setPort(ID::ADDR, memory->size - word_idx - 1);
|
|
|
|
cell->setPort(ID::DATA, initval);
|
|
|
|
cell->parameters[ID::MEMID] = RTLIL::Const(memory->name.str());
|
|
|
|
cell->parameters[ID::ABITS] = 32;
|
|
|
|
cell->parameters[ID::WIDTH] = memory->width;
|
|
|
|
cell->parameters[ID::PRIORITY] = RTLIL::Const(autoidx-1);
|
2018-02-18 06:52:49 -06:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
continue;
|
2017-07-28 10:37:09 -05:00
|
|
|
}
|
2017-07-27 04:40:07 -05:00
|
|
|
|
2018-02-18 06:52:49 -06:00
|
|
|
if (net->GetInitialValue())
|
|
|
|
init_nets[net] = net->GetInitialValue();
|
2017-07-27 04:40:07 -05:00
|
|
|
|
2018-02-18 06:52:49 -06:00
|
|
|
const char *rand_const_attr = net->GetAttValue(" rand_const");
|
|
|
|
const char *rand_attr = net->GetAttValue(" rand");
|
2017-10-10 08:16:39 -05:00
|
|
|
|
2018-04-06 07:19:55 -05:00
|
|
|
const char *anyconst_attr = net->GetAttValue("anyconst");
|
|
|
|
const char *anyseq_attr = net->GetAttValue("anyseq");
|
|
|
|
|
|
|
|
const char *allconst_attr = net->GetAttValue("allconst");
|
|
|
|
const char *allseq_attr = net->GetAttValue("allseq");
|
|
|
|
|
2018-05-24 10:07:06 -05:00
|
|
|
if (rand_const_attr != nullptr && (!strcmp(rand_const_attr, "1") || !strcmp(rand_const_attr, "'1'"))) {
|
2018-02-18 06:52:49 -06:00
|
|
|
anyconst_nets.insert(net);
|
2018-05-24 10:07:06 -05:00
|
|
|
any_all_nets.insert(net);
|
|
|
|
}
|
|
|
|
else if (rand_attr != nullptr && (!strcmp(rand_attr, "1") || !strcmp(rand_attr, "'1'"))) {
|
2018-02-18 06:52:49 -06:00
|
|
|
anyseq_nets.insert(net);
|
2018-05-24 10:07:06 -05:00
|
|
|
any_all_nets.insert(net);
|
|
|
|
}
|
|
|
|
else if (anyconst_attr != nullptr && (!strcmp(anyconst_attr, "1") || !strcmp(anyconst_attr, "'1'"))) {
|
2018-04-06 07:19:55 -05:00
|
|
|
anyconst_nets.insert(net);
|
2018-05-24 10:07:06 -05:00
|
|
|
any_all_nets.insert(net);
|
|
|
|
}
|
|
|
|
else if (anyseq_attr != nullptr && (!strcmp(anyseq_attr, "1") || !strcmp(anyseq_attr, "'1'"))) {
|
2018-04-06 07:19:55 -05:00
|
|
|
anyseq_nets.insert(net);
|
2018-05-24 10:07:06 -05:00
|
|
|
any_all_nets.insert(net);
|
|
|
|
}
|
|
|
|
else if (allconst_attr != nullptr && (!strcmp(allconst_attr, "1") || !strcmp(allconst_attr, "'1'"))) {
|
2018-04-06 07:19:55 -05:00
|
|
|
allconst_nets.insert(net);
|
2018-05-24 10:07:06 -05:00
|
|
|
any_all_nets.insert(net);
|
|
|
|
}
|
|
|
|
else if (allseq_attr != nullptr && (!strcmp(allseq_attr, "1") || !strcmp(allseq_attr, "'1'"))) {
|
2018-04-06 07:19:55 -05:00
|
|
|
allseq_nets.insert(net);
|
2018-05-24 10:07:06 -05:00
|
|
|
any_all_nets.insert(net);
|
|
|
|
}
|
2018-04-06 07:19:55 -05:00
|
|
|
|
2018-02-18 06:52:49 -06:00
|
|
|
if (net_map.count(net)) {
|
2018-02-28 04:45:04 -06:00
|
|
|
if (verific_verbose)
|
2018-02-18 06:52:49 -06:00
|
|
|
log(" skipping net %s.\n", net->Name());
|
|
|
|
continue;
|
|
|
|
}
|
2018-02-18 06:28:08 -06:00
|
|
|
|
2018-02-18 06:52:49 -06:00
|
|
|
if (net->Bus())
|
|
|
|
continue;
|
2018-02-18 06:28:08 -06:00
|
|
|
|
2018-12-18 09:01:22 -06:00
|
|
|
RTLIL::IdString wire_name = module->uniquify(mode_names || net->IsUserDeclared() ? RTLIL::escape_id(net->Name()) : new_verific_id(net));
|
2017-10-10 08:16:39 -05:00
|
|
|
|
2018-02-28 04:45:04 -06:00
|
|
|
if (verific_verbose)
|
2018-02-18 06:52:49 -06:00
|
|
|
log(" importing net %s as %s.\n", net->Name(), log_id(wire_name));
|
2017-10-10 08:16:39 -05:00
|
|
|
|
2018-02-18 06:52:49 -06:00
|
|
|
RTLIL::Wire *wire = module->addWire(wire_name);
|
2020-04-27 10:43:54 -05:00
|
|
|
import_attributes(wire->attributes, net, nl);
|
2017-10-10 08:16:39 -05:00
|
|
|
|
2018-02-18 06:52:49 -06:00
|
|
|
net_map[net] = wire;
|
|
|
|
}
|
2017-10-10 08:16:39 -05:00
|
|
|
|
2018-02-18 06:52:49 -06:00
|
|
|
FOREACH_NETBUS_OF_NETLIST(nl, mi, netbus)
|
|
|
|
{
|
|
|
|
bool found_new_net = false;
|
|
|
|
for (int i = netbus->LeftIndex();; i += netbus->IsUp() ? +1 : -1) {
|
|
|
|
net = netbus->ElementAtIndex(i);
|
|
|
|
if (net_map.count(net) == 0)
|
|
|
|
found_new_net = true;
|
|
|
|
if (i == netbus->RightIndex())
|
|
|
|
break;
|
|
|
|
}
|
2017-10-10 08:16:39 -05:00
|
|
|
|
2018-02-18 06:52:49 -06:00
|
|
|
if (found_new_net)
|
|
|
|
{
|
2018-12-18 09:01:22 -06:00
|
|
|
RTLIL::IdString wire_name = module->uniquify(mode_names || netbus->IsUserDeclared() ? RTLIL::escape_id(netbus->Name()) : new_verific_id(netbus));
|
2017-10-10 08:16:39 -05:00
|
|
|
|
2018-02-28 04:45:04 -06:00
|
|
|
if (verific_verbose)
|
2018-02-18 06:52:49 -06:00
|
|
|
log(" importing netbus %s as %s.\n", netbus->Name(), log_id(wire_name));
|
2017-10-10 08:16:39 -05:00
|
|
|
|
2018-02-18 06:52:49 -06:00
|
|
|
RTLIL::Wire *wire = module->addWire(wire_name, netbus->Size());
|
|
|
|
wire->start_offset = min(netbus->LeftIndex(), netbus->RightIndex());
|
2020-04-27 10:43:54 -05:00
|
|
|
import_attributes(wire->attributes, netbus, nl);
|
2017-10-10 08:16:39 -05:00
|
|
|
|
2018-02-18 06:52:49 -06:00
|
|
|
RTLIL::Const initval = Const(State::Sx, GetSize(wire));
|
|
|
|
bool initval_valid = false;
|
2017-10-10 08:16:39 -05:00
|
|
|
|
2018-02-18 06:52:49 -06:00
|
|
|
for (int i = netbus->LeftIndex();; i += netbus->IsUp() ? +1 : -1)
|
|
|
|
{
|
|
|
|
if (netbus->ElementAtIndex(i))
|
|
|
|
{
|
|
|
|
int bitidx = i - wire->start_offset;
|
|
|
|
net = netbus->ElementAtIndex(i);
|
|
|
|
RTLIL::SigBit bit(wire, bitidx);
|
|
|
|
|
|
|
|
if (init_nets.count(net)) {
|
|
|
|
if (init_nets.at(net) == '0')
|
|
|
|
initval.bits.at(bitidx) = State::S0;
|
|
|
|
if (init_nets.at(net) == '1')
|
|
|
|
initval.bits.at(bitidx) = State::S1;
|
|
|
|
initval_valid = true;
|
|
|
|
init_nets.erase(net);
|
|
|
|
}
|
2018-02-18 06:28:08 -06:00
|
|
|
|
2018-02-18 06:52:49 -06:00
|
|
|
if (net_map.count(net) == 0)
|
|
|
|
net_map[net] = bit;
|
|
|
|
else
|
|
|
|
module->connect(bit, net_map_at(net));
|
|
|
|
}
|
2017-12-09 18:10:03 -06:00
|
|
|
|
2018-02-18 06:52:49 -06:00
|
|
|
if (i == netbus->RightIndex())
|
|
|
|
break;
|
2017-10-10 08:16:39 -05:00
|
|
|
}
|
|
|
|
|
2018-02-18 06:52:49 -06:00
|
|
|
if (initval_valid)
|
2020-04-02 11:51:32 -05:00
|
|
|
wire->attributes[ID::init] = initval;
|
2017-10-10 08:16:39 -05:00
|
|
|
}
|
2018-02-18 06:52:49 -06:00
|
|
|
else
|
2017-10-10 08:16:39 -05:00
|
|
|
{
|
2018-02-28 04:45:04 -06:00
|
|
|
if (verific_verbose)
|
2018-02-18 06:52:49 -06:00
|
|
|
log(" skipping netbus %s.\n", netbus->Name());
|
2017-12-09 18:10:03 -06:00
|
|
|
}
|
|
|
|
|
2018-02-18 06:52:49 -06:00
|
|
|
SigSpec anyconst_sig;
|
|
|
|
SigSpec anyseq_sig;
|
2018-04-06 07:19:55 -05:00
|
|
|
SigSpec allconst_sig;
|
|
|
|
SigSpec allseq_sig;
|
2018-02-18 06:52:49 -06:00
|
|
|
|
|
|
|
for (int i = netbus->RightIndex();; i += netbus->IsUp() ? -1 : +1) {
|
|
|
|
net = netbus->ElementAtIndex(i);
|
|
|
|
if (net != nullptr && anyconst_nets.count(net)) {
|
|
|
|
anyconst_sig.append(net_map_at(net));
|
|
|
|
anyconst_nets.erase(net);
|
2017-12-09 18:10:03 -06:00
|
|
|
}
|
2018-02-18 06:52:49 -06:00
|
|
|
if (net != nullptr && anyseq_nets.count(net)) {
|
|
|
|
anyseq_sig.append(net_map_at(net));
|
|
|
|
anyseq_nets.erase(net);
|
|
|
|
}
|
2018-04-06 07:19:55 -05:00
|
|
|
if (net != nullptr && allconst_nets.count(net)) {
|
|
|
|
allconst_sig.append(net_map_at(net));
|
|
|
|
allconst_nets.erase(net);
|
|
|
|
}
|
|
|
|
if (net != nullptr && allseq_nets.count(net)) {
|
|
|
|
allseq_sig.append(net_map_at(net));
|
|
|
|
allseq_nets.erase(net);
|
|
|
|
}
|
2018-02-18 06:52:49 -06:00
|
|
|
if (i == netbus->LeftIndex())
|
|
|
|
break;
|
2017-10-10 08:16:39 -05:00
|
|
|
}
|
|
|
|
|
2018-02-18 06:52:49 -06:00
|
|
|
if (GetSize(anyconst_sig))
|
2018-12-18 09:01:22 -06:00
|
|
|
module->connect(anyconst_sig, module->Anyconst(new_verific_id(netbus), GetSize(anyconst_sig)));
|
2018-02-18 06:52:49 -06:00
|
|
|
|
|
|
|
if (GetSize(anyseq_sig))
|
2018-12-18 09:01:22 -06:00
|
|
|
module->connect(anyseq_sig, module->Anyseq(new_verific_id(netbus), GetSize(anyseq_sig)));
|
2018-04-06 07:19:55 -05:00
|
|
|
|
|
|
|
if (GetSize(allconst_sig))
|
2018-12-18 09:01:22 -06:00
|
|
|
module->connect(allconst_sig, module->Allconst(new_verific_id(netbus), GetSize(allconst_sig)));
|
2018-04-06 07:19:55 -05:00
|
|
|
|
|
|
|
if (GetSize(allseq_sig))
|
2018-12-18 09:01:22 -06:00
|
|
|
module->connect(allseq_sig, module->Allseq(new_verific_id(netbus), GetSize(allseq_sig)));
|
2017-10-10 08:16:39 -05:00
|
|
|
}
|
|
|
|
|
2018-02-18 06:52:49 -06:00
|
|
|
for (auto it : init_nets)
|
2017-10-10 08:16:39 -05:00
|
|
|
{
|
2018-02-18 06:52:49 -06:00
|
|
|
Const initval;
|
|
|
|
SigBit bit = net_map_at(it.first);
|
|
|
|
log_assert(bit.wire);
|
2017-10-10 08:16:39 -05:00
|
|
|
|
2020-04-02 11:51:32 -05:00
|
|
|
if (bit.wire->attributes.count(ID::init))
|
|
|
|
initval = bit.wire->attributes.at(ID::init);
|
2017-07-26 11:00:01 -05:00
|
|
|
|
2018-02-18 06:52:49 -06:00
|
|
|
while (GetSize(initval) < GetSize(bit.wire))
|
|
|
|
initval.bits.push_back(State::Sx);
|
2017-07-27 03:39:39 -05:00
|
|
|
|
2018-02-18 06:52:49 -06:00
|
|
|
if (it.second == '0')
|
|
|
|
initval.bits.at(bit.offset) = State::S0;
|
|
|
|
if (it.second == '1')
|
|
|
|
initval.bits.at(bit.offset) = State::S1;
|
2017-07-27 03:39:39 -05:00
|
|
|
|
2020-04-02 11:51:32 -05:00
|
|
|
bit.wire->attributes[ID::init] = initval;
|
2018-02-18 06:52:49 -06:00
|
|
|
}
|
2017-07-27 03:39:39 -05:00
|
|
|
|
2018-02-18 06:52:49 -06:00
|
|
|
for (auto net : anyconst_nets)
|
2018-12-18 09:01:22 -06:00
|
|
|
module->connect(net_map_at(net), module->Anyconst(new_verific_id(net)));
|
2017-07-27 03:39:39 -05:00
|
|
|
|
2018-02-18 06:52:49 -06:00
|
|
|
for (auto net : anyseq_nets)
|
2018-12-18 09:01:22 -06:00
|
|
|
module->connect(net_map_at(net), module->Anyseq(new_verific_id(net)));
|
2017-07-27 03:39:39 -05:00
|
|
|
|
2018-02-18 06:52:49 -06:00
|
|
|
pool<Instance*, hash_ptr_ops> sva_asserts;
|
|
|
|
pool<Instance*, hash_ptr_ops> sva_assumes;
|
|
|
|
pool<Instance*, hash_ptr_ops> sva_covers;
|
2018-03-04 12:29:26 -06:00
|
|
|
pool<Instance*, hash_ptr_ops> sva_triggers;
|
2017-07-27 03:39:39 -05:00
|
|
|
|
2018-02-18 06:52:49 -06:00
|
|
|
pool<RTLIL::Cell*> past_ffs;
|
2017-07-27 03:39:39 -05:00
|
|
|
|
2018-02-18 06:52:49 -06:00
|
|
|
FOREACH_INSTANCE_OF_NETLIST(nl, mi, inst)
|
2017-07-26 11:00:01 -05:00
|
|
|
{
|
2018-12-18 09:01:22 -06:00
|
|
|
RTLIL::IdString inst_name = module->uniquify(mode_names || inst->IsUserDeclared() ? RTLIL::escape_id(inst->Name()) : new_verific_id(inst));
|
2017-07-26 11:00:01 -05:00
|
|
|
|
2018-02-28 04:45:04 -06:00
|
|
|
if (verific_verbose)
|
2018-02-18 06:52:49 -06:00
|
|
|
log(" importing cell %s (%s) as %s.\n", inst->Name(), inst->View()->Owner()->Name(), log_id(inst_name));
|
2017-07-28 10:37:09 -05:00
|
|
|
|
2018-03-07 12:40:34 -06:00
|
|
|
if (mode_verific)
|
|
|
|
goto import_verific_cells;
|
|
|
|
|
2018-02-18 06:52:49 -06:00
|
|
|
if (inst->Type() == PRIM_PWR) {
|
|
|
|
module->connect(net_map_at(inst->GetOutput()), RTLIL::State::S1);
|
|
|
|
continue;
|
2017-07-27 03:39:39 -05:00
|
|
|
}
|
|
|
|
|
2018-02-18 06:52:49 -06:00
|
|
|
if (inst->Type() == PRIM_GND) {
|
|
|
|
module->connect(net_map_at(inst->GetOutput()), RTLIL::State::S0);
|
|
|
|
continue;
|
|
|
|
}
|
2017-07-28 10:37:09 -05:00
|
|
|
|
2018-02-18 06:52:49 -06:00
|
|
|
if (inst->Type() == PRIM_BUF) {
|
2018-05-24 10:07:06 -05:00
|
|
|
auto outnet = inst->GetOutput();
|
2018-05-25 08:41:45 -05:00
|
|
|
if (!any_all_nets.count(outnet))
|
2018-05-24 10:07:06 -05:00
|
|
|
module->addBufGate(inst_name, net_map_at(inst->GetInput()), net_map_at(outnet));
|
2018-02-18 06:52:49 -06:00
|
|
|
continue;
|
2017-07-27 03:39:39 -05:00
|
|
|
}
|
|
|
|
|
2018-02-18 06:52:49 -06:00
|
|
|
if (inst->Type() == PRIM_X) {
|
|
|
|
module->connect(net_map_at(inst->GetOutput()), RTLIL::State::Sx);
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (inst->Type() == PRIM_Z) {
|
|
|
|
module->connect(net_map_at(inst->GetOutput()), RTLIL::State::Sz);
|
|
|
|
continue;
|
2017-07-27 03:39:39 -05:00
|
|
|
}
|
2017-07-26 11:00:01 -05:00
|
|
|
|
2018-02-18 06:52:49 -06:00
|
|
|
if (inst->Type() == OPER_READ_PORT)
|
|
|
|
{
|
2020-06-10 04:27:44 -05:00
|
|
|
RTLIL::Memory *memory = module->memories.at(RTLIL::escape_id(inst->GetInput()->Name()), nullptr);
|
|
|
|
if (!memory)
|
|
|
|
log_error("Memory net '%s' missing, possibly no driver, use verific -flatten.\n", inst->GetInput()->Name());
|
|
|
|
|
2018-03-15 12:20:37 -05:00
|
|
|
int numchunks = int(inst->OutputSize()) / memory->width;
|
|
|
|
int chunksbits = ceil_log2(numchunks);
|
2018-02-18 06:52:49 -06:00
|
|
|
|
2018-03-15 12:20:37 -05:00
|
|
|
for (int i = 0; i < numchunks; i++)
|
|
|
|
{
|
|
|
|
RTLIL::SigSpec addr = {operatorInput1(inst), RTLIL::Const(i, chunksbits)};
|
|
|
|
RTLIL::SigSpec data = operatorOutput(inst).extract(i * memory->width, memory->width);
|
|
|
|
|
|
|
|
RTLIL::Cell *cell = module->addCell(numchunks == 1 ? inst_name :
|
2020-04-02 11:51:32 -05:00
|
|
|
RTLIL::IdString(stringf("%s_%d", inst_name.c_str(), i)), ID($memrd));
|
|
|
|
cell->parameters[ID::MEMID] = memory->name.str();
|
|
|
|
cell->parameters[ID::CLK_ENABLE] = false;
|
|
|
|
cell->parameters[ID::CLK_POLARITY] = true;
|
|
|
|
cell->parameters[ID::TRANSPARENT] = false;
|
|
|
|
cell->parameters[ID::ABITS] = GetSize(addr);
|
|
|
|
cell->parameters[ID::WIDTH] = GetSize(data);
|
|
|
|
cell->setPort(ID::CLK, RTLIL::State::Sx);
|
|
|
|
cell->setPort(ID::EN, RTLIL::State::Sx);
|
|
|
|
cell->setPort(ID::ADDR, addr);
|
|
|
|
cell->setPort(ID::DATA, data);
|
2018-03-15 12:20:37 -05:00
|
|
|
}
|
2018-02-18 06:52:49 -06:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (inst->Type() == OPER_WRITE_PORT || inst->Type() == OPER_CLOCKED_WRITE_PORT)
|
2017-07-27 07:05:09 -05:00
|
|
|
{
|
2020-06-10 04:27:44 -05:00
|
|
|
RTLIL::Memory *memory = module->memories.at(RTLIL::escape_id(inst->GetOutput()->Name()), nullptr);
|
|
|
|
if (!memory)
|
|
|
|
log_error("Memory net '%s' missing, possibly no driver, use verific -flatten.\n", inst->GetInput()->Name());
|
2019-01-02 08:33:43 -06:00
|
|
|
int numchunks = int(inst->Input2Size()) / memory->width;
|
|
|
|
int chunksbits = ceil_log2(numchunks);
|
|
|
|
|
|
|
|
for (int i = 0; i < numchunks; i++)
|
|
|
|
{
|
|
|
|
RTLIL::SigSpec addr = {operatorInput1(inst), RTLIL::Const(i, chunksbits)};
|
|
|
|
RTLIL::SigSpec data = operatorInput2(inst).extract(i * memory->width, memory->width);
|
|
|
|
|
|
|
|
RTLIL::Cell *cell = module->addCell(numchunks == 1 ? inst_name :
|
2020-04-02 11:51:32 -05:00
|
|
|
RTLIL::IdString(stringf("%s_%d", inst_name.c_str(), i)), ID($memwr));
|
|
|
|
cell->parameters[ID::MEMID] = memory->name.str();
|
|
|
|
cell->parameters[ID::CLK_ENABLE] = false;
|
|
|
|
cell->parameters[ID::CLK_POLARITY] = true;
|
|
|
|
cell->parameters[ID::PRIORITY] = 0;
|
|
|
|
cell->parameters[ID::ABITS] = GetSize(addr);
|
|
|
|
cell->parameters[ID::WIDTH] = GetSize(data);
|
|
|
|
cell->setPort(ID::EN, RTLIL::SigSpec(net_map_at(inst->GetControl())).repeat(GetSize(data)));
|
|
|
|
cell->setPort(ID::CLK, RTLIL::State::S0);
|
|
|
|
cell->setPort(ID::ADDR, addr);
|
|
|
|
cell->setPort(ID::DATA, data);
|
2019-01-02 08:33:43 -06:00
|
|
|
|
|
|
|
if (inst->Type() == OPER_CLOCKED_WRITE_PORT) {
|
2020-04-02 11:51:32 -05:00
|
|
|
cell->parameters[ID::CLK_ENABLE] = true;
|
|
|
|
cell->setPort(ID::CLK, net_map_at(inst->GetClock()));
|
2019-01-02 08:33:43 -06:00
|
|
|
}
|
2018-02-18 06:52:49 -06:00
|
|
|
}
|
|
|
|
continue;
|
|
|
|
}
|
2017-07-27 07:05:09 -05:00
|
|
|
|
2018-02-18 06:52:49 -06:00
|
|
|
if (!mode_gates) {
|
|
|
|
if (import_netlist_instance_cells(inst, inst_name))
|
|
|
|
continue;
|
|
|
|
if (inst->IsOperator() && !verific_sva_prims.count(inst->Type()))
|
|
|
|
log_warning("Unsupported Verific operator: %s (fallback to gate level implementation provided by verific)\n", inst->View()->Owner()->Name());
|
|
|
|
} else {
|
|
|
|
if (import_netlist_instance_gates(inst, inst_name))
|
|
|
|
continue;
|
|
|
|
}
|
2017-07-27 07:05:09 -05:00
|
|
|
|
2018-02-18 06:52:49 -06:00
|
|
|
if (inst->Type() == PRIM_SVA_ASSERT || inst->Type() == PRIM_SVA_IMMEDIATE_ASSERT)
|
|
|
|
sva_asserts.insert(inst);
|
2017-07-27 07:05:09 -05:00
|
|
|
|
2019-10-21 05:39:28 -05:00
|
|
|
if (inst->Type() == PRIM_SVA_ASSUME || inst->Type() == PRIM_SVA_IMMEDIATE_ASSUME || inst->Type() == PRIM_SVA_RESTRICT)
|
2018-02-18 06:52:49 -06:00
|
|
|
sva_assumes.insert(inst);
|
2017-07-27 07:05:09 -05:00
|
|
|
|
2018-02-18 06:52:49 -06:00
|
|
|
if (inst->Type() == PRIM_SVA_COVER || inst->Type() == PRIM_SVA_IMMEDIATE_COVER)
|
|
|
|
sva_covers.insert(inst);
|
2017-07-27 07:05:09 -05:00
|
|
|
|
2018-03-04 12:29:26 -06:00
|
|
|
if (inst->Type() == PRIM_SVA_TRIGGERED)
|
|
|
|
sva_triggers.insert(inst);
|
|
|
|
|
2018-03-01 03:12:15 -06:00
|
|
|
if (inst->Type() == OPER_SVA_STABLE)
|
2017-07-27 07:05:09 -05:00
|
|
|
{
|
2018-03-04 06:48:53 -06:00
|
|
|
VerificClocking clocking(this, inst->GetInput2Bit(0));
|
2018-03-07 13:06:02 -06:00
|
|
|
log_assert(clocking.disable_sig == State::S0);
|
|
|
|
log_assert(clocking.body_net == nullptr);
|
2017-07-27 07:05:09 -05:00
|
|
|
|
2018-02-18 06:52:49 -06:00
|
|
|
log_assert(inst->Input1Size() == inst->OutputSize());
|
2017-07-27 07:05:09 -05:00
|
|
|
|
2018-02-18 06:52:49 -06:00
|
|
|
SigSpec sig_d, sig_q, sig_o;
|
2018-12-18 09:01:22 -06:00
|
|
|
sig_q = module->addWire(new_verific_id(inst), inst->Input1Size());
|
2017-07-27 07:05:09 -05:00
|
|
|
|
2018-02-18 06:52:49 -06:00
|
|
|
for (int i = int(inst->Input1Size())-1; i >= 0; i--){
|
|
|
|
sig_d.append(net_map_at(inst->GetInput1Bit(i)));
|
|
|
|
sig_o.append(net_map_at(inst->GetOutputBit(i)));
|
2017-07-27 07:05:09 -05:00
|
|
|
}
|
|
|
|
|
2018-02-28 04:45:04 -06:00
|
|
|
if (verific_verbose) {
|
2018-03-04 06:48:53 -06:00
|
|
|
log(" %sedge FF with D=%s, Q=%s, C=%s.\n", clocking.posedge ? "pos" : "neg",
|
|
|
|
log_signal(sig_d), log_signal(sig_q), log_signal(clocking.clock_sig));
|
2018-02-18 06:52:49 -06:00
|
|
|
log(" XNOR with A=%s, B=%s, Y=%s.\n",
|
|
|
|
log_signal(sig_d), log_signal(sig_q), log_signal(sig_o));
|
|
|
|
}
|
2017-07-26 11:00:01 -05:00
|
|
|
|
2018-12-18 09:01:22 -06:00
|
|
|
clocking.addDff(new_verific_id(inst), sig_d, sig_q);
|
|
|
|
module->addXnor(new_verific_id(inst), sig_d, sig_q, sig_o);
|
2017-07-26 11:00:01 -05:00
|
|
|
|
2018-02-18 06:52:49 -06:00
|
|
|
if (!mode_keep)
|
|
|
|
continue;
|
|
|
|
}
|
2018-01-23 10:42:40 -06:00
|
|
|
|
2018-03-01 03:12:15 -06:00
|
|
|
if (inst->Type() == PRIM_SVA_STABLE)
|
2018-02-18 06:52:49 -06:00
|
|
|
{
|
2018-03-04 06:48:53 -06:00
|
|
|
VerificClocking clocking(this, inst->GetInput2());
|
2018-03-07 13:06:02 -06:00
|
|
|
log_assert(clocking.disable_sig == State::S0);
|
|
|
|
log_assert(clocking.body_net == nullptr);
|
2017-07-26 11:00:01 -05:00
|
|
|
|
2018-02-18 06:52:49 -06:00
|
|
|
SigSpec sig_d = net_map_at(inst->GetInput1());
|
|
|
|
SigSpec sig_o = net_map_at(inst->GetOutput());
|
2018-12-18 09:01:22 -06:00
|
|
|
SigSpec sig_q = module->addWire(new_verific_id(inst));
|
2018-01-23 10:42:40 -06:00
|
|
|
|
2018-02-28 04:45:04 -06:00
|
|
|
if (verific_verbose) {
|
2018-03-04 06:48:53 -06:00
|
|
|
log(" %sedge FF with D=%s, Q=%s, C=%s.\n", clocking.posedge ? "pos" : "neg",
|
|
|
|
log_signal(sig_d), log_signal(sig_q), log_signal(clocking.clock_sig));
|
2018-02-18 06:52:49 -06:00
|
|
|
log(" XNOR with A=%s, B=%s, Y=%s.\n",
|
|
|
|
log_signal(sig_d), log_signal(sig_q), log_signal(sig_o));
|
2018-01-23 10:42:40 -06:00
|
|
|
}
|
|
|
|
|
2018-12-18 09:01:22 -06:00
|
|
|
clocking.addDff(new_verific_id(inst), sig_d, sig_q);
|
|
|
|
module->addXnor(new_verific_id(inst), sig_d, sig_q, sig_o);
|
2018-01-23 10:42:40 -06:00
|
|
|
|
2018-02-18 06:52:49 -06:00
|
|
|
if (!mode_keep)
|
|
|
|
continue;
|
|
|
|
}
|
2017-07-26 11:00:01 -05:00
|
|
|
|
2018-03-01 03:12:15 -06:00
|
|
|
if (inst->Type() == PRIM_SVA_PAST)
|
2018-02-18 06:52:49 -06:00
|
|
|
{
|
2018-03-04 06:48:53 -06:00
|
|
|
VerificClocking clocking(this, inst->GetInput2());
|
2018-03-07 13:06:02 -06:00
|
|
|
log_assert(clocking.disable_sig == State::S0);
|
|
|
|
log_assert(clocking.body_net == nullptr);
|
2017-07-26 11:00:01 -05:00
|
|
|
|
2018-02-18 06:52:49 -06:00
|
|
|
SigBit sig_d = net_map_at(inst->GetInput1());
|
|
|
|
SigBit sig_q = net_map_at(inst->GetOutput());
|
2017-07-26 11:00:01 -05:00
|
|
|
|
2018-02-28 04:45:04 -06:00
|
|
|
if (verific_verbose)
|
2018-03-04 06:48:53 -06:00
|
|
|
log(" %sedge FF with D=%s, Q=%s, C=%s.\n", clocking.posedge ? "pos" : "neg",
|
|
|
|
log_signal(sig_d), log_signal(sig_q), log_signal(clocking.clock_sig));
|
2017-07-26 11:00:01 -05:00
|
|
|
|
2018-12-18 09:01:22 -06:00
|
|
|
past_ffs.insert(clocking.addDff(new_verific_id(inst), sig_d, sig_q));
|
2017-10-12 04:59:11 -05:00
|
|
|
|
2018-02-18 06:52:49 -06:00
|
|
|
if (!mode_keep)
|
2017-10-12 04:59:11 -05:00
|
|
|
continue;
|
2018-02-18 06:52:49 -06:00
|
|
|
}
|
2017-10-12 04:59:11 -05:00
|
|
|
|
2018-03-01 03:12:15 -06:00
|
|
|
if ((inst->Type() == PRIM_SVA_ROSE || inst->Type() == PRIM_SVA_FELL))
|
|
|
|
{
|
2018-03-04 06:48:53 -06:00
|
|
|
VerificClocking clocking(this, inst->GetInput2());
|
2018-03-07 13:06:02 -06:00
|
|
|
log_assert(clocking.disable_sig == State::S0);
|
|
|
|
log_assert(clocking.body_net == nullptr);
|
2018-03-01 03:12:15 -06:00
|
|
|
|
|
|
|
SigBit sig_d = net_map_at(inst->GetInput1());
|
|
|
|
SigBit sig_o = net_map_at(inst->GetOutput());
|
2018-12-18 09:01:22 -06:00
|
|
|
SigBit sig_q = module->addWire(new_verific_id(inst));
|
2018-03-01 03:12:15 -06:00
|
|
|
|
|
|
|
if (verific_verbose)
|
2018-03-04 06:48:53 -06:00
|
|
|
log(" %sedge FF with D=%s, Q=%s, C=%s.\n", clocking.posedge ? "pos" : "neg",
|
|
|
|
log_signal(sig_d), log_signal(sig_q), log_signal(clocking.clock_sig));
|
2018-03-01 03:12:15 -06:00
|
|
|
|
2018-12-18 09:01:22 -06:00
|
|
|
clocking.addDff(new_verific_id(inst), sig_d, sig_q);
|
|
|
|
module->addEq(new_verific_id(inst), {sig_q, sig_d}, Const(inst->Type() == PRIM_SVA_ROSE ? 1 : 2, 2), sig_o);
|
2018-03-01 03:12:15 -06:00
|
|
|
|
|
|
|
if (!mode_keep)
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2018-02-18 06:52:49 -06:00
|
|
|
if (!mode_keep && verific_sva_prims.count(inst->Type())) {
|
2018-02-28 04:45:04 -06:00
|
|
|
if (verific_verbose)
|
2018-02-18 06:52:49 -06:00
|
|
|
log(" skipping SVA cell in non k-mode\n");
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2018-04-07 11:38:42 -05:00
|
|
|
if (inst->Type() == PRIM_HDL_ASSERTION)
|
2018-02-18 06:52:49 -06:00
|
|
|
{
|
2018-04-07 11:38:42 -05:00
|
|
|
SigBit cond = net_map_at(inst->GetInput());
|
|
|
|
|
|
|
|
if (verific_verbose)
|
|
|
|
log(" assert condition %s.\n", log_signal(cond));
|
|
|
|
|
|
|
|
const char *assume_attr = nullptr; // inst->GetAttValue("assume");
|
|
|
|
|
|
|
|
Cell *cell = nullptr;
|
|
|
|
if (assume_attr != nullptr && !strcmp(assume_attr, "1"))
|
2018-12-18 09:01:22 -06:00
|
|
|
cell = module->addAssume(new_verific_id(inst), cond, State::S1);
|
2018-04-07 11:38:42 -05:00
|
|
|
else
|
2018-12-18 09:01:22 -06:00
|
|
|
cell = module->addAssert(new_verific_id(inst), cond, State::S1);
|
2018-04-07 11:38:42 -05:00
|
|
|
|
|
|
|
import_attributes(cell->attributes, inst);
|
|
|
|
continue;
|
|
|
|
}
|
2017-10-12 04:59:11 -05:00
|
|
|
|
2018-04-07 11:38:42 -05:00
|
|
|
if (inst->IsPrimitive())
|
|
|
|
{
|
2018-02-18 06:52:49 -06:00
|
|
|
if (!mode_keep)
|
|
|
|
log_error("Unsupported Verific primitive %s of type %s\n", inst->Name(), inst->View()->Owner()->Name());
|
|
|
|
|
|
|
|
if (!verific_sva_prims.count(inst->Type()))
|
|
|
|
log_warning("Unsupported Verific primitive %s of type %s\n", inst->Name(), inst->View()->Owner()->Name());
|
2017-07-26 11:00:01 -05:00
|
|
|
}
|
|
|
|
|
2018-03-07 12:40:34 -06:00
|
|
|
import_verific_cells:
|
2018-02-18 06:52:49 -06:00
|
|
|
nl_todo.insert(inst->View());
|
2017-07-26 11:00:01 -05:00
|
|
|
|
2019-10-24 05:13:37 -05:00
|
|
|
std::string inst_type = inst->View()->Owner()->Name();
|
|
|
|
|
2019-11-22 09:00:07 -06:00
|
|
|
if (inst->View()->IsOperator() || inst->View()->IsPrimitive()) {
|
2019-10-24 05:13:37 -05:00
|
|
|
inst_type = "$verific$" + inst_type;
|
|
|
|
} else {
|
|
|
|
if (*inst->View()->Name()) {
|
|
|
|
inst_type += "(";
|
|
|
|
inst_type += inst->View()->Name();
|
|
|
|
inst_type += ")";
|
|
|
|
}
|
|
|
|
inst_type = "\\" + inst_type;
|
|
|
|
}
|
|
|
|
|
|
|
|
RTLIL::Cell *cell = module->addCell(inst_name, inst_type);
|
2017-07-26 11:00:01 -05:00
|
|
|
|
2018-02-18 06:52:49 -06:00
|
|
|
if (inst->IsPrimitive() && mode_keep)
|
2020-04-02 11:51:32 -05:00
|
|
|
cell->attributes[ID::keep] = 1;
|
2017-07-26 11:00:01 -05:00
|
|
|
|
2018-02-18 06:52:49 -06:00
|
|
|
dict<IdString, vector<SigBit>> cell_port_conns;
|
2018-01-31 12:06:51 -06:00
|
|
|
|
2018-02-28 04:45:04 -06:00
|
|
|
if (verific_verbose)
|
2018-02-18 06:52:49 -06:00
|
|
|
log(" ports in verific db:\n");
|
|
|
|
|
|
|
|
FOREACH_PORTREF_OF_INST(inst, mi2, pr) {
|
2018-02-28 04:45:04 -06:00
|
|
|
if (verific_verbose)
|
2018-02-18 06:52:49 -06:00
|
|
|
log(" .%s(%s)\n", pr->GetPort()->Name(), pr->GetNet()->Name());
|
|
|
|
const char *port_name = pr->GetPort()->Name();
|
|
|
|
int port_offset = 0;
|
|
|
|
if (pr->GetPort()->Bus()) {
|
|
|
|
port_name = pr->GetPort()->Bus()->Name();
|
|
|
|
port_offset = pr->GetPort()->Bus()->IndexOf(pr->GetPort()) -
|
|
|
|
min(pr->GetPort()->Bus()->LeftIndex(), pr->GetPort()->Bus()->RightIndex());
|
|
|
|
}
|
|
|
|
IdString port_name_id = RTLIL::escape_id(port_name);
|
|
|
|
auto &sigvec = cell_port_conns[port_name_id];
|
|
|
|
if (GetSize(sigvec) <= port_offset) {
|
2018-12-18 09:01:22 -06:00
|
|
|
SigSpec zwires = module->addWire(new_verific_id(inst), port_offset+1-GetSize(sigvec));
|
2018-02-18 06:52:49 -06:00
|
|
|
for (auto bit : zwires)
|
|
|
|
sigvec.push_back(bit);
|
|
|
|
}
|
|
|
|
sigvec[port_offset] = net_map_at(pr->GetNet());
|
2017-10-12 04:59:11 -05:00
|
|
|
}
|
2018-01-31 12:06:51 -06:00
|
|
|
|
2018-02-28 04:45:04 -06:00
|
|
|
if (verific_verbose)
|
2018-02-18 06:52:49 -06:00
|
|
|
log(" ports in yosys db:\n");
|
|
|
|
|
|
|
|
for (auto &it : cell_port_conns) {
|
2018-02-28 04:45:04 -06:00
|
|
|
if (verific_verbose)
|
2018-02-18 06:52:49 -06:00
|
|
|
log(" .%s(%s)\n", log_id(it.first), log_signal(it.second));
|
|
|
|
cell->setPort(it.first, it.second);
|
|
|
|
}
|
2017-07-26 11:00:01 -05:00
|
|
|
}
|
|
|
|
|
2018-02-18 06:52:49 -06:00
|
|
|
if (!mode_nosva)
|
|
|
|
{
|
2018-04-06 07:10:57 -05:00
|
|
|
for (auto inst : sva_asserts) {
|
|
|
|
if (mode_autocover)
|
|
|
|
verific_import_sva_cover(this, inst);
|
2018-03-07 13:06:02 -06:00
|
|
|
verific_import_sva_assert(this, inst);
|
2018-04-06 07:10:57 -05:00
|
|
|
}
|
2018-02-18 06:28:08 -06:00
|
|
|
|
2018-02-18 06:52:49 -06:00
|
|
|
for (auto inst : sva_assumes)
|
2018-03-07 13:06:02 -06:00
|
|
|
verific_import_sva_assume(this, inst);
|
2018-02-18 06:28:08 -06:00
|
|
|
|
2018-02-18 06:52:49 -06:00
|
|
|
for (auto inst : sva_covers)
|
2018-03-07 13:06:02 -06:00
|
|
|
verific_import_sva_cover(this, inst);
|
2018-02-18 06:28:08 -06:00
|
|
|
|
2018-03-04 12:29:26 -06:00
|
|
|
for (auto inst : sva_triggers)
|
2018-03-07 13:06:02 -06:00
|
|
|
verific_import_sva_trigger(this, inst);
|
2018-03-04 12:29:26 -06:00
|
|
|
|
2018-02-18 06:52:49 -06:00
|
|
|
merge_past_ffs(past_ffs);
|
|
|
|
}
|
2019-08-07 08:31:49 -05:00
|
|
|
|
|
|
|
if (!mode_fullinit)
|
|
|
|
{
|
|
|
|
pool<SigBit> non_ff_bits;
|
|
|
|
CellTypes ff_types;
|
|
|
|
|
|
|
|
ff_types.setup_internals_ff();
|
|
|
|
ff_types.setup_stdcells_mem();
|
|
|
|
|
|
|
|
for (auto cell : module->cells())
|
|
|
|
{
|
|
|
|
if (ff_types.cell_known(cell->type))
|
|
|
|
continue;
|
|
|
|
|
|
|
|
for (auto conn : cell->connections())
|
|
|
|
{
|
|
|
|
if (!cell->output(conn.first))
|
|
|
|
continue;
|
|
|
|
|
|
|
|
for (auto bit : conn.second)
|
|
|
|
if (bit.wire != nullptr)
|
|
|
|
non_ff_bits.insert(bit);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
for (auto wire : module->wires())
|
|
|
|
{
|
2020-04-02 11:51:32 -05:00
|
|
|
if (!wire->attributes.count(ID::init))
|
2019-08-07 08:31:49 -05:00
|
|
|
continue;
|
|
|
|
|
2020-04-02 11:51:32 -05:00
|
|
|
Const &initval = wire->attributes.at(ID::init);
|
2019-08-07 08:31:49 -05:00
|
|
|
for (int i = 0; i < GetSize(initval); i++)
|
|
|
|
{
|
|
|
|
if (initval[i] != State::S0 && initval[i] != State::S1)
|
|
|
|
continue;
|
|
|
|
|
|
|
|
if (non_ff_bits.count(SigBit(wire, i)))
|
|
|
|
initval[i] = State::Sx;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (initval.is_fully_undef())
|
2020-04-02 11:51:32 -05:00
|
|
|
wire->attributes.erase(ID::init);
|
2019-08-07 08:31:49 -05:00
|
|
|
}
|
|
|
|
}
|
2017-07-26 11:00:01 -05:00
|
|
|
}
|
|
|
|
|
2018-02-18 06:52:49 -06:00
|
|
|
// ==================================================================
|
2017-07-26 11:00:01 -05:00
|
|
|
|
2018-03-26 06:04:10 -05:00
|
|
|
VerificClocking::VerificClocking(VerificImporter *importer, Net *net, bool sva_at_only)
|
2017-07-26 11:00:01 -05:00
|
|
|
{
|
2018-03-04 06:48:53 -06:00
|
|
|
module = importer->module;
|
|
|
|
|
2018-02-18 06:52:49 -06:00
|
|
|
log_assert(importer != nullptr);
|
2018-03-04 06:48:53 -06:00
|
|
|
log_assert(net != nullptr);
|
2018-02-18 06:52:49 -06:00
|
|
|
|
2018-03-04 06:48:53 -06:00
|
|
|
Instance *inst = net->Driver();
|
|
|
|
|
|
|
|
if (inst != nullptr && inst->Type() == PRIM_SVA_AT)
|
2018-02-18 06:52:49 -06:00
|
|
|
{
|
2018-03-04 06:48:53 -06:00
|
|
|
net = inst->GetInput1();
|
|
|
|
body_net = inst->GetInput2();
|
|
|
|
|
|
|
|
inst = net->Driver();
|
2018-02-18 06:52:49 -06:00
|
|
|
|
2018-03-04 06:48:53 -06:00
|
|
|
Instance *body_inst = body_net->Driver();
|
|
|
|
if (body_inst != nullptr && body_inst->Type() == PRIM_SVA_DISABLE_IFF) {
|
|
|
|
disable_net = body_inst->GetInput1();
|
|
|
|
disable_sig = importer->net_map_at(disable_net);
|
|
|
|
body_net = body_inst->GetInput2();
|
2018-02-18 06:52:49 -06:00
|
|
|
}
|
2018-03-04 06:48:53 -06:00
|
|
|
}
|
2018-03-26 06:04:10 -05:00
|
|
|
else
|
|
|
|
{
|
|
|
|
if (sva_at_only)
|
|
|
|
return;
|
|
|
|
}
|
2018-02-18 06:52:49 -06:00
|
|
|
|
2018-05-28 06:36:35 -05:00
|
|
|
// Use while() instead of if() to work around VIPER #13453
|
2018-05-24 11:13:38 -05:00
|
|
|
while (inst != nullptr && inst->Type() == PRIM_SVA_POSEDGE)
|
2018-03-04 06:48:53 -06:00
|
|
|
{
|
|
|
|
net = inst->GetInput();
|
|
|
|
inst = net->Driver();;
|
2018-02-18 06:52:49 -06:00
|
|
|
}
|
2018-03-04 06:48:53 -06:00
|
|
|
|
|
|
|
if (inst != nullptr && inst->Type() == PRIM_INV)
|
|
|
|
{
|
|
|
|
net = inst->GetInput();
|
|
|
|
inst = net->Driver();;
|
|
|
|
posedge = false;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Detect clock-enable circuit
|
|
|
|
do {
|
|
|
|
if (inst == nullptr || inst->Type() != PRIM_AND)
|
|
|
|
break;
|
|
|
|
|
|
|
|
Net *net_dlatch = inst->GetInput1();
|
|
|
|
Instance *inst_dlatch = net_dlatch->Driver();
|
|
|
|
|
|
|
|
if (inst_dlatch == nullptr || inst_dlatch->Type() != PRIM_DLATCHRS)
|
|
|
|
break;
|
|
|
|
|
|
|
|
if (!inst_dlatch->GetSet()->IsGnd() || !inst_dlatch->GetReset()->IsGnd())
|
|
|
|
break;
|
|
|
|
|
|
|
|
Net *net_enable = inst_dlatch->GetInput();
|
|
|
|
Net *net_not_clock = inst_dlatch->GetControl();
|
|
|
|
|
|
|
|
if (net_enable == nullptr || net_not_clock == nullptr)
|
|
|
|
break;
|
|
|
|
|
|
|
|
Instance *inst_not_clock = net_not_clock->Driver();
|
|
|
|
|
|
|
|
if (inst_not_clock == nullptr || inst_not_clock->Type() != PRIM_INV)
|
|
|
|
break;
|
|
|
|
|
|
|
|
Net *net_clock1 = inst_not_clock->GetInput();
|
|
|
|
Net *net_clock2 = inst->GetInput2();
|
|
|
|
|
|
|
|
if (net_clock1 == nullptr || net_clock1 != net_clock2)
|
|
|
|
break;
|
|
|
|
|
|
|
|
enable_net = net_enable;
|
|
|
|
enable_sig = importer->net_map_at(enable_net);
|
|
|
|
|
|
|
|
net = net_clock1;
|
|
|
|
inst = net->Driver();;
|
|
|
|
} while (0);
|
|
|
|
|
2018-03-07 13:06:02 -06:00
|
|
|
// Detect condition expression
|
|
|
|
do {
|
|
|
|
if (body_net == nullptr)
|
|
|
|
break;
|
|
|
|
|
|
|
|
Instance *inst_mux = body_net->Driver();
|
|
|
|
|
|
|
|
if (inst_mux == nullptr || inst_mux->Type() != PRIM_MUX)
|
|
|
|
break;
|
|
|
|
|
|
|
|
if (!inst_mux->GetInput1()->IsPwr())
|
|
|
|
break;
|
|
|
|
|
|
|
|
Net *sva_net = inst_mux->GetInput2();
|
|
|
|
if (!verific_is_sva_net(importer, sva_net))
|
|
|
|
break;
|
|
|
|
|
|
|
|
body_net = sva_net;
|
|
|
|
cond_net = inst_mux->GetControl();
|
|
|
|
} while (0);
|
|
|
|
|
2018-03-04 06:48:53 -06:00
|
|
|
clock_net = net;
|
|
|
|
clock_sig = importer->net_map_at(clock_net);
|
2018-06-01 06:25:42 -05:00
|
|
|
|
|
|
|
const char *gclk_attr = clock_net->GetAttValue("gclk");
|
|
|
|
if (gclk_attr != nullptr && (!strcmp(gclk_attr, "1") || !strcmp(gclk_attr, "'1'")))
|
|
|
|
gclk = true;
|
2018-03-04 06:48:53 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
Cell *VerificClocking::addDff(IdString name, SigSpec sig_d, SigSpec sig_q, Const init_value)
|
|
|
|
{
|
|
|
|
log_assert(GetSize(sig_d) == GetSize(sig_q));
|
|
|
|
|
|
|
|
if (GetSize(init_value) != 0) {
|
|
|
|
log_assert(GetSize(sig_q) == GetSize(init_value));
|
|
|
|
if (sig_q.is_wire()) {
|
2020-04-02 11:51:32 -05:00
|
|
|
sig_q.as_wire()->attributes[ID::init] = init_value;
|
2018-03-04 06:48:53 -06:00
|
|
|
} else {
|
|
|
|
Wire *w = module->addWire(NEW_ID, GetSize(sig_q));
|
2020-04-02 11:51:32 -05:00
|
|
|
w->attributes[ID::init] = init_value;
|
2018-03-04 06:48:53 -06:00
|
|
|
module->connect(sig_q, w);
|
|
|
|
sig_q = w;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (enable_sig != State::S1)
|
|
|
|
sig_d = module->Mux(NEW_ID, sig_q, sig_d, enable_sig);
|
|
|
|
|
|
|
|
if (disable_sig != State::S0) {
|
2018-06-01 06:25:42 -05:00
|
|
|
log_assert(gclk == false);
|
2018-03-04 06:48:53 -06:00
|
|
|
log_assert(GetSize(sig_q) == GetSize(init_value));
|
|
|
|
return module->addAdff(name, clock_sig, disable_sig, sig_d, sig_q, init_value, posedge);
|
|
|
|
}
|
|
|
|
|
2018-06-01 06:25:42 -05:00
|
|
|
if (gclk)
|
|
|
|
return module->addFf(name, sig_d, sig_q);
|
|
|
|
|
2018-03-04 06:48:53 -06:00
|
|
|
return module->addDff(name, clock_sig, sig_d, sig_q, posedge);
|
|
|
|
}
|
|
|
|
|
|
|
|
Cell *VerificClocking::addAdff(IdString name, RTLIL::SigSpec sig_arst, SigSpec sig_d, SigSpec sig_q, Const arst_value)
|
|
|
|
{
|
2018-06-01 06:25:42 -05:00
|
|
|
log_assert(gclk == false);
|
2018-03-04 06:48:53 -06:00
|
|
|
log_assert(disable_sig == State::S0);
|
|
|
|
|
|
|
|
if (enable_sig != State::S1)
|
|
|
|
sig_d = module->Mux(NEW_ID, sig_q, sig_d, enable_sig);
|
|
|
|
|
|
|
|
return module->addAdff(name, clock_sig, sig_arst, sig_d, sig_q, arst_value, posedge);
|
|
|
|
}
|
|
|
|
|
|
|
|
Cell *VerificClocking::addDffsr(IdString name, RTLIL::SigSpec sig_set, RTLIL::SigSpec sig_clr, SigSpec sig_d, SigSpec sig_q)
|
|
|
|
{
|
2018-06-01 06:25:42 -05:00
|
|
|
log_assert(gclk == false);
|
2018-03-04 06:48:53 -06:00
|
|
|
log_assert(disable_sig == State::S0);
|
|
|
|
|
|
|
|
if (enable_sig != State::S1)
|
|
|
|
sig_d = module->Mux(NEW_ID, sig_q, sig_d, enable_sig);
|
|
|
|
|
|
|
|
return module->addDffsr(name, clock_sig, sig_set, sig_clr, sig_d, sig_q, posedge);
|
2017-07-26 11:00:01 -05:00
|
|
|
}
|
|
|
|
|
2017-10-10 08:16:39 -05:00
|
|
|
// ==================================================================
|
|
|
|
|
2017-07-25 07:53:11 -05:00
|
|
|
struct VerificExtNets
|
|
|
|
{
|
|
|
|
int portname_cnt = 0;
|
|
|
|
|
2017-07-25 08:13:22 -05:00
|
|
|
// a map from Net to the same Net one level up in the design hierarchy
|
2019-03-26 08:17:46 -05:00
|
|
|
std::map<Net*, Net*> net_level_up_drive_up;
|
|
|
|
std::map<Net*, Net*> net_level_up_drive_down;
|
2017-07-25 08:13:22 -05:00
|
|
|
|
2019-03-26 08:17:46 -05:00
|
|
|
Net *route_up(Net *net, bool drive_up, Net *final_net = nullptr)
|
2017-07-25 07:53:11 -05:00
|
|
|
{
|
2019-03-26 08:17:46 -05:00
|
|
|
auto &net_level_up = drive_up ? net_level_up_drive_up : net_level_up_drive_down;
|
|
|
|
|
2017-07-25 07:53:11 -05:00
|
|
|
if (net_level_up.count(net) == 0)
|
|
|
|
{
|
|
|
|
Netlist *nl = net->Owner();
|
|
|
|
|
2017-07-25 08:13:22 -05:00
|
|
|
// Simply return if Netlist is not unique
|
2019-03-26 08:17:46 -05:00
|
|
|
log_assert(nl->NumOfRefs() == 1);
|
2017-07-25 07:53:11 -05:00
|
|
|
|
|
|
|
Instance *up_inst = (Instance*)nl->GetReferences()->GetLast();
|
|
|
|
Netlist *up_nl = up_inst->Owner();
|
|
|
|
|
|
|
|
// create new Port
|
|
|
|
string name = stringf("___extnets_%d", portname_cnt++);
|
2019-03-26 08:17:46 -05:00
|
|
|
Port *new_port = new Port(name.c_str(), drive_up ? DIR_OUT : DIR_IN);
|
2017-07-25 07:53:11 -05:00
|
|
|
nl->Add(new_port);
|
|
|
|
net->Connect(new_port);
|
|
|
|
|
|
|
|
// create new Net in up Netlist
|
2019-03-26 08:17:46 -05:00
|
|
|
Net *new_net = final_net;
|
|
|
|
if (new_net == nullptr || new_net->Owner() != up_nl) {
|
|
|
|
new_net = new Net(name.c_str());
|
|
|
|
up_nl->Add(new_net);
|
|
|
|
}
|
2017-07-25 07:53:11 -05:00
|
|
|
up_inst->Connect(new_port, new_net);
|
|
|
|
|
|
|
|
net_level_up[net] = new_net;
|
|
|
|
}
|
|
|
|
|
|
|
|
return net_level_up.at(net);
|
|
|
|
}
|
|
|
|
|
2019-03-26 08:17:46 -05:00
|
|
|
Net *route_up(Net *net, bool drive_up, Netlist *dest, Net *final_net = nullptr)
|
|
|
|
{
|
|
|
|
while (net->Owner() != dest)
|
|
|
|
net = route_up(net, drive_up, final_net);
|
|
|
|
if (final_net != nullptr)
|
|
|
|
log_assert(net == final_net);
|
|
|
|
return net;
|
|
|
|
}
|
|
|
|
|
|
|
|
Netlist *find_common_ancestor(Netlist *A, Netlist *B)
|
|
|
|
{
|
|
|
|
std::set<Netlist*> ancestors_of_A;
|
|
|
|
|
|
|
|
Netlist *cursor = A;
|
|
|
|
while (1) {
|
|
|
|
ancestors_of_A.insert(cursor);
|
|
|
|
if (cursor->NumOfRefs() != 1)
|
|
|
|
break;
|
|
|
|
cursor = ((Instance*)cursor->GetReferences()->GetLast())->Owner();
|
|
|
|
}
|
|
|
|
|
|
|
|
cursor = B;
|
|
|
|
while (1) {
|
|
|
|
if (ancestors_of_A.count(cursor))
|
|
|
|
return cursor;
|
|
|
|
if (cursor->NumOfRefs() != 1)
|
|
|
|
break;
|
|
|
|
cursor = ((Instance*)cursor->GetReferences()->GetLast())->Owner();
|
|
|
|
}
|
|
|
|
|
|
|
|
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());
|
|
|
|
}
|
|
|
|
|
2017-07-25 07:53:11 -05:00
|
|
|
void run(Netlist *nl)
|
|
|
|
{
|
|
|
|
MapIter mi, mi2;
|
|
|
|
Instance *inst;
|
|
|
|
PortRef *pr;
|
|
|
|
|
|
|
|
vector<tuple<Instance*, Port*, Net*>> todo_connect;
|
|
|
|
|
|
|
|
FOREACH_INSTANCE_OF_NETLIST(nl, mi, inst)
|
|
|
|
run(inst->View());
|
|
|
|
|
|
|
|
FOREACH_INSTANCE_OF_NETLIST(nl, mi, inst)
|
|
|
|
FOREACH_PORTREF_OF_INST(inst, mi2, pr)
|
|
|
|
{
|
|
|
|
Port *port = pr->GetPort();
|
|
|
|
Net *net = pr->GetNet();
|
|
|
|
|
|
|
|
if (!net->IsExternalTo(nl))
|
|
|
|
continue;
|
|
|
|
|
2018-02-28 04:45:04 -06:00
|
|
|
if (verific_verbose)
|
2017-07-25 07:53:11 -05:00
|
|
|
log("Fixing external net reference on port %s.%s.%s:\n", get_full_netlist_name(nl).c_str(), inst->Name(), port->Name());
|
|
|
|
|
2019-03-26 08:17:46 -05:00
|
|
|
Netlist *ext_nl = net->Owner();
|
2017-07-25 07:53:11 -05:00
|
|
|
|
2019-03-26 08:17:46 -05:00
|
|
|
if (verific_verbose)
|
|
|
|
log(" external net owner: %s\n", get_full_netlist_name(ext_nl).c_str());
|
|
|
|
|
|
|
|
Netlist *ca_nl = find_common_ancestor(nl, ext_nl);
|
|
|
|
|
|
|
|
if (verific_verbose)
|
|
|
|
log(" common ancestor: %s\n", get_full_netlist_name(ca_nl).c_str());
|
|
|
|
|
|
|
|
Net *ca_net = route_up(net, !port->IsOutput(), ca_nl);
|
|
|
|
Net *new_net = ca_net;
|
|
|
|
|
|
|
|
if (ca_nl != nl)
|
|
|
|
{
|
2018-02-28 04:45:04 -06:00
|
|
|
if (verific_verbose)
|
2019-03-26 08:17:46 -05:00
|
|
|
log(" net in common ancestor: %s\n", ca_net->Name());
|
|
|
|
|
|
|
|
string name = stringf("___extnets_%d", portname_cnt++);
|
|
|
|
new_net = new Net(name.c_str());
|
|
|
|
nl->Add(new_net);
|
|
|
|
|
2019-08-17 07:47:02 -05:00
|
|
|
Net *n YS_ATTRIBUTE(unused) = route_up(new_net, port->IsOutput(), ca_nl, ca_net);
|
2019-03-26 08:17:46 -05:00
|
|
|
log_assert(n == ca_net);
|
2017-07-25 07:53:11 -05:00
|
|
|
}
|
|
|
|
|
2018-02-28 04:45:04 -06:00
|
|
|
if (verific_verbose)
|
2019-03-26 08:17:46 -05:00
|
|
|
log(" new local net: %s\n", new_net->Name());
|
|
|
|
|
|
|
|
log_assert(!new_net->IsExternalTo(nl));
|
|
|
|
todo_connect.push_back(tuple<Instance*, Port*, Net*>(inst, port, new_net));
|
2017-07-25 07:53:11 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
for (auto it : todo_connect) {
|
|
|
|
get<0>(it)->Disconnect(get<1>(it));
|
|
|
|
get<0>(it)->Connect(get<1>(it), get<2>(it));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2019-03-13 14:42:18 -05:00
|
|
|
void verific_import(Design *design, const std::map<std::string,std::string> ¶meters, std::string top)
|
2018-06-20 16:45:01 -05:00
|
|
|
{
|
2018-09-04 13:06:10 -05:00
|
|
|
verific_sva_fsm_limit = 16;
|
|
|
|
|
2018-06-20 16:45:01 -05:00
|
|
|
std::set<Netlist*> nl_todo, nl_done;
|
|
|
|
|
2019-03-12 19:02:04 -05:00
|
|
|
VhdlLibrary *vhdl_lib = vhdl_file::GetLibrary("work", 1);
|
|
|
|
VeriLibrary *veri_lib = veri_file::GetLibrary("work", 1);
|
|
|
|
Array *netlists = NULL;
|
|
|
|
Array veri_libs, vhdl_libs;
|
|
|
|
if (vhdl_lib) vhdl_libs.InsertLast(vhdl_lib);
|
|
|
|
if (veri_lib) veri_libs.InsertLast(veri_lib);
|
|
|
|
|
2019-03-13 14:42:18 -05:00
|
|
|
Map verific_params(STRING_HASH);
|
2019-03-13 17:05:55 -05:00
|
|
|
for (const auto &i : parameters)
|
2019-03-13 14:42:18 -05:00
|
|
|
verific_params.Insert(i.first.c_str(), i.second.c_str());
|
|
|
|
|
2019-03-12 19:02:04 -05:00
|
|
|
if (top.empty()) {
|
2019-03-13 14:42:18 -05:00
|
|
|
netlists = hier_tree::ElaborateAll(&veri_libs, &vhdl_libs, &verific_params);
|
2019-03-12 19:02:04 -05:00
|
|
|
}
|
|
|
|
else {
|
2019-03-13 17:40:00 -05:00
|
|
|
Array veri_modules, vhdl_units;
|
|
|
|
|
|
|
|
if (veri_lib) {
|
|
|
|
VeriModule *veri_module = veri_lib->GetModule(top.c_str(), 1);
|
|
|
|
if (veri_module) {
|
|
|
|
veri_modules.InsertLast(veri_module);
|
|
|
|
}
|
|
|
|
|
|
|
|
// Also elaborate all root modules since they may contain bind statements
|
|
|
|
MapIter mi;
|
|
|
|
FOREACH_VERILOG_MODULE_IN_LIBRARY(veri_lib, mi, veri_module) {
|
|
|
|
if (!veri_module->IsRootModule()) continue;
|
|
|
|
veri_modules.InsertLast(veri_module);
|
2019-03-12 19:02:04 -05:00
|
|
|
}
|
2019-03-13 17:40:00 -05:00
|
|
|
}
|
2018-06-20 16:45:01 -05:00
|
|
|
|
2019-03-13 17:40:00 -05:00
|
|
|
if (vhdl_lib) {
|
|
|
|
VhdlDesignUnit *vhdl_unit = vhdl_lib->GetPrimUnit(top.c_str());
|
|
|
|
if (vhdl_unit)
|
|
|
|
vhdl_units.InsertLast(vhdl_unit);
|
2018-06-20 16:45:01 -05:00
|
|
|
}
|
2019-03-13 17:40:00 -05:00
|
|
|
|
|
|
|
netlists = hier_tree::Elaborate(&veri_modules, &vhdl_units, &verific_params);
|
2019-03-12 19:02:04 -05:00
|
|
|
}
|
2018-06-20 16:45:01 -05:00
|
|
|
|
2019-03-12 19:02:04 -05:00
|
|
|
Netlist *nl;
|
|
|
|
int i;
|
|
|
|
|
|
|
|
FOREACH_ARRAY_ITEM(netlists, i, nl) {
|
2019-03-13 17:05:55 -05:00
|
|
|
if (top.empty() && nl->CellBaseName() != top)
|
|
|
|
continue;
|
|
|
|
nl->AddAtt(new Att(" \\top", NULL));
|
|
|
|
nl_todo.insert(nl);
|
2018-06-20 16:45:01 -05:00
|
|
|
}
|
|
|
|
|
2019-03-12 19:02:04 -05:00
|
|
|
delete netlists;
|
|
|
|
|
2018-06-20 16:45:01 -05:00
|
|
|
if (!verific_error_msg.empty())
|
|
|
|
log_error("%s\n", verific_error_msg.c_str());
|
|
|
|
|
2020-01-27 12:15:22 -06:00
|
|
|
for (auto nl : nl_todo)
|
|
|
|
nl->ChangePortBusStructures(1 /* hierarchical */);
|
|
|
|
|
2018-06-21 09:56:55 -05:00
|
|
|
VerificExtNets worker;
|
|
|
|
for (auto nl : nl_todo)
|
|
|
|
worker.run(nl);
|
|
|
|
|
2018-06-20 16:45:01 -05:00
|
|
|
while (!nl_todo.empty()) {
|
|
|
|
Netlist *nl = *nl_todo.begin();
|
|
|
|
if (nl_done.count(nl) == 0) {
|
2019-08-07 08:31:49 -05:00
|
|
|
VerificImporter importer(false, false, false, false, false, false, false);
|
2019-11-20 05:54:10 -06:00
|
|
|
importer.import_netlist(design, nl, nl_todo, nl->Owner()->Name() == top);
|
2018-06-20 16:45:01 -05:00
|
|
|
}
|
|
|
|
nl_todo.erase(nl);
|
|
|
|
nl_done.insert(nl);
|
|
|
|
}
|
|
|
|
|
|
|
|
veri_file::Reset();
|
|
|
|
vhdl_file::Reset();
|
|
|
|
Libset::Reset();
|
2018-07-16 11:46:06 -05:00
|
|
|
verific_incdirs.clear();
|
|
|
|
verific_libdirs.clear();
|
2018-06-20 16:45:01 -05:00
|
|
|
verific_import_pending = false;
|
|
|
|
|
|
|
|
if (!verific_error_msg.empty())
|
|
|
|
log_error("%s\n", verific_error_msg.c_str());
|
|
|
|
}
|
|
|
|
|
2018-02-18 06:52:49 -06:00
|
|
|
YOSYS_NAMESPACE_END
|
2014-03-13 11:34:31 -05:00
|
|
|
#endif /* YOSYS_ENABLE_VERIFIC */
|
2014-03-09 14:40:04 -05:00
|
|
|
|
2018-02-18 06:52:49 -06:00
|
|
|
PRIVATE_NAMESPACE_BEGIN
|
|
|
|
|
2018-10-05 02:26:10 -05:00
|
|
|
#ifdef YOSYS_ENABLE_VERIFIC
|
2018-06-22 13:40:22 -05:00
|
|
|
bool check_noverific_env()
|
|
|
|
{
|
|
|
|
const char *e = getenv("YOSYS_NOVERIFIC");
|
|
|
|
if (e == nullptr)
|
|
|
|
return false;
|
|
|
|
if (atoi(e) == 0)
|
|
|
|
return false;
|
|
|
|
return true;
|
|
|
|
}
|
2018-10-05 02:26:10 -05:00
|
|
|
#endif
|
2018-06-22 13:40:22 -05:00
|
|
|
|
2014-03-09 14:40:04 -05:00
|
|
|
struct VerificPass : public Pass {
|
|
|
|
VerificPass() : Pass("verific", "load Verilog and VHDL designs using Verific") { }
|
2018-07-21 01:41:18 -05:00
|
|
|
void help() YS_OVERRIDE
|
2014-03-09 14:40:04 -05:00
|
|
|
{
|
|
|
|
// |---v---|---v---|---v---|---v---|---v---|---v---|---v---|---v---|---v---|---v---|
|
|
|
|
log("\n");
|
2017-07-28 08:32:54 -05:00
|
|
|
log(" verific {-vlog95|-vlog2k|-sv2005|-sv2009|-sv2012|-sv} <verilog-file>..\n");
|
2014-03-09 14:40:04 -05:00
|
|
|
log("\n");
|
|
|
|
log("Load the specified Verilog/SystemVerilog files into Verific.\n");
|
|
|
|
log("\n");
|
2018-03-14 14:22:11 -05:00
|
|
|
log("All files specified in one call to this command are one compilation unit.\n");
|
|
|
|
log("Files passed to different calls to this command are treated as belonging to\n");
|
|
|
|
log("different compilation units.\n");
|
|
|
|
log("\n");
|
2018-06-28 16:58:15 -05:00
|
|
|
log("Additional -D<macro>[=<value>] options may be added after the option indicating\n");
|
|
|
|
log("the language version (and before file names) to set additional verilog defines.\n");
|
2018-06-29 03:02:27 -05:00
|
|
|
log("The macros SYNTHESIS and VERIFIC are defined implicitly.\n");
|
2018-06-28 16:58:15 -05:00
|
|
|
log("\n");
|
2014-03-09 14:40:04 -05:00
|
|
|
log("\n");
|
2018-06-29 03:02:27 -05:00
|
|
|
log(" verific -formal <verilog-file>..\n");
|
|
|
|
log("\n");
|
|
|
|
log("Like -sv, but define FORMAL instead of SYNTHESIS.\n");
|
|
|
|
log("\n");
|
2018-08-22 10:22:24 -05:00
|
|
|
log("\n");
|
2017-10-20 06:14:04 -05:00
|
|
|
log(" verific {-vhdl87|-vhdl93|-vhdl2k|-vhdl2008|-vhdl} <vhdl-file>..\n");
|
2014-03-09 14:40:04 -05:00
|
|
|
log("\n");
|
|
|
|
log("Load the specified VHDL files into Verific.\n");
|
|
|
|
log("\n");
|
|
|
|
log("\n");
|
2019-10-24 02:14:03 -05:00
|
|
|
log(" verific [-work <libname>] {-sv|-vhdl|...} <hdl-file>\n");
|
2018-08-22 10:22:24 -05:00
|
|
|
log("\n");
|
|
|
|
log("Load the specified Verilog/SystemVerilog/VHDL file into the specified library.\n");
|
|
|
|
log("(default library when -work is not present: \"work\")\n");
|
|
|
|
log("\n");
|
|
|
|
log("\n");
|
2019-10-24 02:14:03 -05:00
|
|
|
log(" verific [-L <libname>] {-sv|-vhdl|...} <hdl-file>\n");
|
|
|
|
log("\n");
|
|
|
|
log("Look up external definitions in the specified library.\n");
|
|
|
|
log("(-L may be used more than once)\n");
|
|
|
|
log("\n");
|
|
|
|
log("\n");
|
2017-10-13 13:12:51 -05:00
|
|
|
log(" verific -vlog-incdir <directory>..\n");
|
|
|
|
log("\n");
|
|
|
|
log("Add Verilog include directories.\n");
|
|
|
|
log("\n");
|
|
|
|
log("\n");
|
2017-10-13 13:23:19 -05:00
|
|
|
log(" verific -vlog-libdir <directory>..\n");
|
|
|
|
log("\n");
|
|
|
|
log("Add Verilog library directories. Verific will search in this directories to\n");
|
|
|
|
log("find undefined modules.\n");
|
|
|
|
log("\n");
|
|
|
|
log("\n");
|
2017-10-13 13:12:51 -05:00
|
|
|
log(" verific -vlog-define <macro>[=<value>]..\n");
|
|
|
|
log("\n");
|
2018-06-29 03:02:27 -05:00
|
|
|
log("Add Verilog defines.\n");
|
2017-10-13 13:12:51 -05:00
|
|
|
log("\n");
|
|
|
|
log("\n");
|
2018-06-28 16:43:38 -05:00
|
|
|
log(" verific -vlog-undef <macro>..\n");
|
|
|
|
log("\n");
|
|
|
|
log("Remove Verilog defines previously set with -vlog-define.\n");
|
|
|
|
log("\n");
|
|
|
|
log("\n");
|
2018-08-16 04:49:17 -05:00
|
|
|
log(" verific -set-error <msg_id>..\n");
|
|
|
|
log(" verific -set-warning <msg_id>..\n");
|
|
|
|
log(" verific -set-info <msg_id>..\n");
|
|
|
|
log(" verific -set-ignore <msg_id>..\n");
|
|
|
|
log("\n");
|
|
|
|
log("Set message severity. <msg_id> is the string in square brackets when a message\n");
|
|
|
|
log("is printed, such as VERI-1209.\n");
|
|
|
|
log("\n");
|
|
|
|
log("\n");
|
2017-07-25 06:33:25 -05:00
|
|
|
log(" verific -import [options] <top-module>..\n");
|
2014-03-09 14:40:04 -05:00
|
|
|
log("\n");
|
2015-08-14 03:56:05 -05:00
|
|
|
log("Elaborate the design for the specified top modules, import to Yosys and\n");
|
2017-07-25 08:13:22 -05:00
|
|
|
log("reset the internal state of Verific.\n");
|
2017-07-24 04:29:06 -05:00
|
|
|
log("\n");
|
2017-07-24 06:57:16 -05:00
|
|
|
log("Import options:\n");
|
|
|
|
log("\n");
|
2017-07-25 06:33:25 -05:00
|
|
|
log(" -all\n");
|
|
|
|
log(" Elaborate all modules, not just the hierarchy below the given top\n");
|
|
|
|
log(" modules. With this option the list of modules to import is optional.\n");
|
|
|
|
log("\n");
|
2017-07-24 06:57:16 -05:00
|
|
|
log(" -gates\n");
|
|
|
|
log(" Create a gate-level netlist.\n");
|
2017-07-24 04:29:06 -05:00
|
|
|
log("\n");
|
2017-07-24 06:57:16 -05:00
|
|
|
log(" -flatten\n");
|
|
|
|
log(" Flatten the design in Verific before importing.\n");
|
2017-07-24 04:29:06 -05:00
|
|
|
log("\n");
|
2017-07-25 07:53:11 -05:00
|
|
|
log(" -extnets\n");
|
|
|
|
log(" Resolve references to external nets by adding module ports as needed.\n");
|
|
|
|
log("\n");
|
2018-04-06 07:10:57 -05:00
|
|
|
log(" -autocover\n");
|
|
|
|
log(" Generate automatic cover statements for all asserts\n");
|
|
|
|
log("\n");
|
2019-08-07 08:31:49 -05:00
|
|
|
log(" -fullinit\n");
|
|
|
|
log(" Keep all register initializations, even those for non-FF registers.\n");
|
|
|
|
log("\n");
|
2019-03-08 19:54:01 -06:00
|
|
|
log(" -chparam name value \n");
|
|
|
|
log(" Elaborate the specified top modules (all modules when -all given) using\n");
|
2019-03-08 19:56:16 -06:00
|
|
|
log(" this parameter value. Modules on which this parameter does not exist will\n");
|
|
|
|
log(" cause Verific to produce a VERI-1928 or VHDL-1676 message. This option\n");
|
2019-03-08 19:54:01 -06:00
|
|
|
log(" can be specified multiple times to override multiple parameters.\n");
|
|
|
|
log(" String values must be passed in double quotes (\").\n");
|
|
|
|
log("\n");
|
2018-03-01 04:40:43 -06:00
|
|
|
log(" -v, -vv\n");
|
|
|
|
log(" Verbose log messages. (-vv is even more verbose than -v.)\n");
|
2017-07-24 06:57:16 -05:00
|
|
|
log("\n");
|
2017-07-28 10:37:09 -05:00
|
|
|
log("The following additional import options are useful for debugging the Verific\n");
|
|
|
|
log("bindings (for Yosys and/or Verific developers):\n");
|
|
|
|
log("\n");
|
2017-07-24 06:57:16 -05:00
|
|
|
log(" -k\n");
|
|
|
|
log(" Keep going after an unsupported verific primitive is found. The\n");
|
|
|
|
log(" unsupported primitive is added as blockbox module to the design.\n");
|
2017-07-27 04:54:45 -05:00
|
|
|
log(" This will also add all SVA related cells to the design parallel to\n");
|
|
|
|
log(" the checker logic inferred by it.\n");
|
|
|
|
log("\n");
|
2018-03-07 12:40:34 -06:00
|
|
|
log(" -V\n");
|
|
|
|
log(" Import Verific netlist as-is without translating to Yosys cell types. \n");
|
|
|
|
log("\n");
|
2017-10-10 08:16:39 -05:00
|
|
|
log(" -nosva\n");
|
2017-10-20 06:14:04 -05:00
|
|
|
log(" Ignore SVA properties, do not infer checker logic.\n");
|
2017-10-10 08:16:39 -05:00
|
|
|
log("\n");
|
2018-09-04 13:06:10 -05:00
|
|
|
log(" -L <int>\n");
|
|
|
|
log(" Maximum number of ctrl bits for SVA checker FSMs (default=16).\n");
|
|
|
|
log("\n");
|
2017-07-27 04:54:45 -05:00
|
|
|
log(" -n\n");
|
|
|
|
log(" Keep all Verific names on instances and nets. By default only\n");
|
|
|
|
log(" user-declared names are preserved.\n");
|
2017-07-24 06:57:16 -05:00
|
|
|
log("\n");
|
|
|
|
log(" -d <dump_file>\n");
|
|
|
|
log(" Dump the Verific netlist as a verilog file.\n");
|
2014-03-09 14:40:04 -05:00
|
|
|
log("\n");
|
2019-12-18 06:06:34 -06:00
|
|
|
log("\n");
|
|
|
|
log("Use Symbiotic EDA Suite if you need Yosys+Verifc.\n");
|
|
|
|
log("https://www.symbioticeda.com/seda-suite\n");
|
|
|
|
log("\n");
|
|
|
|
log("Contact office@symbioticeda.com for free evaluation\n");
|
|
|
|
log("binaries of Symbiotic EDA Suite.\n");
|
2014-03-09 14:40:04 -05:00
|
|
|
log("\n");
|
|
|
|
}
|
2014-03-13 11:34:31 -05:00
|
|
|
#ifdef YOSYS_ENABLE_VERIFIC
|
2018-07-21 01:41:18 -05:00
|
|
|
void execute(std::vector<std::string> args, RTLIL::Design *design) YS_OVERRIDE
|
2014-03-09 14:40:04 -05:00
|
|
|
{
|
2018-08-16 04:49:17 -05:00
|
|
|
static bool set_verific_global_flags = true;
|
|
|
|
|
2018-06-22 13:40:22 -05:00
|
|
|
if (check_noverific_env())
|
2019-12-18 06:06:34 -06:00
|
|
|
log_cmd_error("This version of Yosys is built without Verific support.\n"
|
|
|
|
"\n"
|
|
|
|
"Use Symbiotic EDA Suite if you need Yosys+Verifc.\n"
|
|
|
|
"https://www.symbioticeda.com/seda-suite\n"
|
|
|
|
"\n"
|
|
|
|
"Contact office@symbioticeda.com for free evaluation\n"
|
|
|
|
"binaries of Symbiotic EDA Suite.\n");
|
2018-06-22 13:40:22 -05:00
|
|
|
|
2017-07-26 11:00:01 -05:00
|
|
|
log_header(design, "Executing VERIFIC (loading SystemVerilog and VHDL designs using Verific).\n");
|
2014-03-09 14:40:04 -05:00
|
|
|
|
2018-08-16 04:49:17 -05:00
|
|
|
if (set_verific_global_flags)
|
|
|
|
{
|
|
|
|
Message::SetConsoleOutput(0);
|
|
|
|
Message::RegisterCallBackMsg(msg_func);
|
2019-01-02 08:33:43 -06:00
|
|
|
|
2018-08-16 04:49:17 -05:00
|
|
|
RuntimeFlags::SetVar("db_preserve_user_nets", 1);
|
|
|
|
RuntimeFlags::SetVar("db_allow_external_nets", 1);
|
2019-01-02 08:33:43 -06:00
|
|
|
RuntimeFlags::SetVar("db_infer_wide_operators", 1);
|
|
|
|
|
2018-08-16 04:49:17 -05:00
|
|
|
RuntimeFlags::SetVar("veri_extract_dualport_rams", 0);
|
|
|
|
RuntimeFlags::SetVar("veri_extract_multiport_rams", 1);
|
2019-01-02 08:33:43 -06:00
|
|
|
|
|
|
|
RuntimeFlags::SetVar("vhdl_extract_dualport_rams", 0);
|
|
|
|
RuntimeFlags::SetVar("vhdl_extract_multiport_rams", 1);
|
|
|
|
|
|
|
|
RuntimeFlags::SetVar("vhdl_support_variable_slice", 1);
|
|
|
|
RuntimeFlags::SetVar("vhdl_ignore_assertion_statements", 0);
|
2018-08-16 04:49:17 -05:00
|
|
|
|
2020-06-09 08:54:14 -05:00
|
|
|
RuntimeFlags::SetVar("veri_preserve_assignments", 1);
|
|
|
|
RuntimeFlags::SetVar("vhdl_preserve_assignments", 1);
|
|
|
|
|
2018-08-16 04:49:17 -05:00
|
|
|
// Workaround for VIPER #13851
|
|
|
|
RuntimeFlags::SetVar("veri_create_name_for_unnamed_gen_block", 1);
|
|
|
|
|
|
|
|
// WARNING: instantiating unknown module 'XYZ' (VERI-1063)
|
|
|
|
Message::SetMessageType("VERI-1063", VERIFIC_ERROR);
|
|
|
|
|
2019-05-30 03:03:54 -05:00
|
|
|
// https://github.com/YosysHQ/yosys/issues/1055
|
|
|
|
RuntimeFlags::SetVar("veri_elaborate_top_level_modules_having_interface_ports", 1) ;
|
|
|
|
|
2019-02-24 12:51:30 -06:00
|
|
|
#ifndef DB_PRESERVE_INITIAL_VALUE
|
|
|
|
# warning Verific was built without DB_PRESERVE_INITIAL_VALUE.
|
|
|
|
#endif
|
|
|
|
|
2018-08-16 04:49:17 -05:00
|
|
|
set_verific_global_flags = false;
|
|
|
|
}
|
2018-07-22 11:44:05 -05:00
|
|
|
|
2018-03-01 04:40:43 -06:00
|
|
|
verific_verbose = 0;
|
2018-09-04 13:06:10 -05:00
|
|
|
verific_sva_fsm_limit = 16;
|
2018-02-28 04:45:04 -06:00
|
|
|
|
2017-07-04 13:01:30 -05:00
|
|
|
const char *release_str = Message::ReleaseString();
|
|
|
|
time_t release_time = Message::ReleaseDate();
|
|
|
|
char *release_tmstr = ctime(&release_time);
|
|
|
|
|
|
|
|
if (release_str == nullptr)
|
|
|
|
release_str = "(no release string)";
|
|
|
|
|
|
|
|
for (char *p = release_tmstr; *p; p++)
|
|
|
|
if (*p == '\n') *p = 0;
|
|
|
|
|
|
|
|
log("Built with Verific %s, released at %s.\n", release_str, release_tmstr);
|
|
|
|
|
2017-07-22 09:16:44 -05:00
|
|
|
int argidx = 1;
|
2018-08-22 06:30:22 -05:00
|
|
|
std::string work = "work";
|
2017-07-22 09:16:44 -05:00
|
|
|
|
2018-08-16 04:49:17 -05:00
|
|
|
if (GetSize(args) > argidx && (args[argidx] == "-set-error" || args[argidx] == "-set-warning" ||
|
|
|
|
args[argidx] == "-set-info" || args[argidx] == "-set-ignore"))
|
|
|
|
{
|
|
|
|
msg_type_t new_type;
|
|
|
|
|
|
|
|
if (args[argidx] == "-set-error")
|
|
|
|
new_type = VERIFIC_ERROR;
|
|
|
|
else if (args[argidx] == "-set-warning")
|
|
|
|
new_type = VERIFIC_WARNING;
|
|
|
|
else if (args[argidx] == "-set-info")
|
|
|
|
new_type = VERIFIC_INFO;
|
|
|
|
else if (args[argidx] == "-set-ignore")
|
|
|
|
new_type = VERIFIC_IGNORE;
|
|
|
|
else
|
|
|
|
log_abort();
|
|
|
|
|
|
|
|
for (argidx++; argidx < GetSize(args); argidx++)
|
|
|
|
Message::SetMessageType(args[argidx].c_str(), new_type);
|
|
|
|
|
|
|
|
goto check_error;
|
|
|
|
}
|
|
|
|
|
2017-10-13 13:12:51 -05:00
|
|
|
if (GetSize(args) > argidx && args[argidx] == "-vlog-incdir") {
|
|
|
|
for (argidx++; argidx < GetSize(args); argidx++)
|
2018-07-16 11:46:06 -05:00
|
|
|
verific_incdirs.push_back(args[argidx]);
|
2017-10-13 13:12:51 -05:00
|
|
|
goto check_error;
|
|
|
|
}
|
|
|
|
|
2017-10-13 13:23:19 -05:00
|
|
|
if (GetSize(args) > argidx && args[argidx] == "-vlog-libdir") {
|
|
|
|
for (argidx++; argidx < GetSize(args); argidx++)
|
2018-07-16 11:46:06 -05:00
|
|
|
verific_libdirs.push_back(args[argidx]);
|
2017-10-13 13:23:19 -05:00
|
|
|
goto check_error;
|
|
|
|
}
|
|
|
|
|
2017-10-13 13:12:51 -05:00
|
|
|
if (GetSize(args) > argidx && args[argidx] == "-vlog-define") {
|
|
|
|
for (argidx++; argidx < GetSize(args); argidx++) {
|
|
|
|
string name = args[argidx];
|
|
|
|
size_t equal = name.find('=');
|
|
|
|
if (equal != std::string::npos) {
|
|
|
|
string value = name.substr(equal+1);
|
|
|
|
name = name.substr(0, equal);
|
|
|
|
veri_file::DefineCmdLineMacro(name.c_str(), value.c_str());
|
|
|
|
} else {
|
|
|
|
veri_file::DefineCmdLineMacro(name.c_str());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
goto check_error;
|
|
|
|
}
|
|
|
|
|
2018-06-28 16:43:38 -05:00
|
|
|
if (GetSize(args) > argidx && args[argidx] == "-vlog-undef") {
|
|
|
|
for (argidx++; argidx < GetSize(args); argidx++) {
|
|
|
|
string name = args[argidx];
|
|
|
|
veri_file::UndefineMacro(name.c_str());
|
|
|
|
}
|
|
|
|
goto check_error;
|
|
|
|
}
|
|
|
|
|
2019-10-24 02:14:03 -05:00
|
|
|
veri_file::RemoveAllLOptions();
|
2018-08-22 06:30:22 -05:00
|
|
|
for (; argidx < GetSize(args); argidx++)
|
|
|
|
{
|
|
|
|
if (args[argidx] == "-work" && argidx+1 < GetSize(args)) {
|
|
|
|
work = args[++argidx];
|
|
|
|
continue;
|
|
|
|
}
|
2019-10-24 02:14:03 -05:00
|
|
|
if (args[argidx] == "-L" && argidx+1 < GetSize(args)) {
|
|
|
|
veri_file::AddLOption(args[++argidx].c_str());
|
|
|
|
continue;
|
|
|
|
}
|
2018-08-22 06:30:22 -05:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2018-03-14 14:22:11 -05:00
|
|
|
if (GetSize(args) > argidx && (args[argidx] == "-vlog95" || args[argidx] == "-vlog2k" || args[argidx] == "-sv2005" ||
|
2018-06-29 03:02:27 -05:00
|
|
|
args[argidx] == "-sv2009" || args[argidx] == "-sv2012" || args[argidx] == "-sv" || args[argidx] == "-formal"))
|
2018-03-14 14:22:11 -05:00
|
|
|
{
|
|
|
|
Array file_names;
|
|
|
|
unsigned verilog_mode;
|
|
|
|
|
|
|
|
if (args[argidx] == "-vlog95")
|
|
|
|
verilog_mode = veri_file::VERILOG_95;
|
|
|
|
else if (args[argidx] == "-vlog2k")
|
|
|
|
verilog_mode = veri_file::VERILOG_2K;
|
|
|
|
else if (args[argidx] == "-sv2005")
|
|
|
|
verilog_mode = veri_file::SYSTEM_VERILOG_2005;
|
|
|
|
else if (args[argidx] == "-sv2009")
|
|
|
|
verilog_mode = veri_file::SYSTEM_VERILOG_2009;
|
2018-06-29 03:02:27 -05:00
|
|
|
else if (args[argidx] == "-sv2012" || args[argidx] == "-sv" || args[argidx] == "-formal")
|
2018-03-14 14:22:11 -05:00
|
|
|
verilog_mode = veri_file::SYSTEM_VERILOG;
|
|
|
|
else
|
|
|
|
log_abort();
|
2014-03-09 14:40:04 -05:00
|
|
|
|
2018-06-29 03:02:27 -05:00
|
|
|
veri_file::DefineMacro("VERIFIC");
|
|
|
|
veri_file::DefineMacro(args[argidx] == "-formal" ? "FORMAL" : "SYNTHESIS");
|
|
|
|
|
2019-08-07 14:20:08 -05:00
|
|
|
for (argidx++; argidx < GetSize(args) && GetSize(args[argidx]) >= 2 && args[argidx].compare(0, 2, "-D") == 0; argidx++) {
|
2018-06-28 16:58:15 -05:00
|
|
|
std::string name = args[argidx].substr(2);
|
|
|
|
if (args[argidx] == "-D") {
|
|
|
|
if (++argidx >= GetSize(args))
|
|
|
|
break;
|
|
|
|
name = args[argidx];
|
|
|
|
}
|
|
|
|
size_t equal = name.find('=');
|
|
|
|
if (equal != std::string::npos) {
|
|
|
|
string value = name.substr(equal+1);
|
|
|
|
name = name.substr(0, equal);
|
|
|
|
veri_file::DefineMacro(name.c_str(), value.c_str());
|
|
|
|
} else {
|
|
|
|
veri_file::DefineMacro(name.c_str());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-07-16 11:46:06 -05:00
|
|
|
for (auto &dir : verific_incdirs)
|
|
|
|
veri_file::AddIncludeDir(dir.c_str());
|
|
|
|
for (auto &dir : verific_libdirs)
|
|
|
|
veri_file::AddYDir(dir.c_str());
|
|
|
|
|
2018-06-28 16:58:15 -05:00
|
|
|
while (argidx < GetSize(args))
|
|
|
|
file_names.Insert(args[argidx++].c_str());
|
2014-03-09 14:40:04 -05:00
|
|
|
|
2018-08-22 06:30:22 -05:00
|
|
|
if (!veri_file::AnalyzeMultipleFiles(&file_names, verilog_mode, work.c_str(), veri_file::MFCU))
|
2018-03-14 14:22:11 -05:00
|
|
|
log_cmd_error("Reading Verilog/SystemVerilog sources failed.\n");
|
2014-03-09 14:40:04 -05:00
|
|
|
|
2018-06-20 16:45:01 -05:00
|
|
|
verific_import_pending = true;
|
2017-10-04 11:56:28 -05:00
|
|
|
goto check_error;
|
2014-03-09 14:40:04 -05:00
|
|
|
}
|
|
|
|
|
2017-07-22 09:16:44 -05:00
|
|
|
if (GetSize(args) > argidx && args[argidx] == "-vhdl87") {
|
2015-11-12 12:28:14 -06:00
|
|
|
vhdl_file::SetDefaultLibraryPath((proc_share_dirname() + "verific/vhdl_vdbs_1987").c_str());
|
2017-07-22 09:16:44 -05:00
|
|
|
for (argidx++; argidx < GetSize(args); argidx++)
|
2018-08-22 06:30:22 -05:00
|
|
|
if (!vhdl_file::Analyze(args[argidx].c_str(), work.c_str(), vhdl_file::VHDL_87))
|
2014-03-09 14:40:04 -05:00
|
|
|
log_cmd_error("Reading `%s' in VHDL_87 mode failed.\n", args[argidx].c_str());
|
2018-06-20 16:45:01 -05:00
|
|
|
verific_import_pending = true;
|
2017-10-04 11:56:28 -05:00
|
|
|
goto check_error;
|
2014-03-09 14:40:04 -05:00
|
|
|
}
|
|
|
|
|
2017-07-22 09:16:44 -05:00
|
|
|
if (GetSize(args) > argidx && args[argidx] == "-vhdl93") {
|
2014-03-13 11:34:31 -05:00
|
|
|
vhdl_file::SetDefaultLibraryPath((proc_share_dirname() + "verific/vhdl_vdbs_1993").c_str());
|
2017-07-22 09:16:44 -05:00
|
|
|
for (argidx++; argidx < GetSize(args); argidx++)
|
2018-08-22 06:30:22 -05:00
|
|
|
if (!vhdl_file::Analyze(args[argidx].c_str(), work.c_str(), vhdl_file::VHDL_93))
|
2014-03-09 14:40:04 -05:00
|
|
|
log_cmd_error("Reading `%s' in VHDL_93 mode failed.\n", args[argidx].c_str());
|
2018-06-20 16:45:01 -05:00
|
|
|
verific_import_pending = true;
|
2017-10-04 11:56:28 -05:00
|
|
|
goto check_error;
|
2014-03-09 14:40:04 -05:00
|
|
|
}
|
|
|
|
|
2017-07-22 09:16:44 -05:00
|
|
|
if (GetSize(args) > argidx && args[argidx] == "-vhdl2k") {
|
2014-03-13 11:34:31 -05:00
|
|
|
vhdl_file::SetDefaultLibraryPath((proc_share_dirname() + "verific/vhdl_vdbs_1993").c_str());
|
2017-07-22 09:16:44 -05:00
|
|
|
for (argidx++; argidx < GetSize(args); argidx++)
|
2018-08-22 06:30:22 -05:00
|
|
|
if (!vhdl_file::Analyze(args[argidx].c_str(), work.c_str(), vhdl_file::VHDL_2K))
|
2014-03-09 14:40:04 -05:00
|
|
|
log_cmd_error("Reading `%s' in VHDL_2K mode failed.\n", args[argidx].c_str());
|
2018-06-20 16:45:01 -05:00
|
|
|
verific_import_pending = true;
|
2017-10-04 11:56:28 -05:00
|
|
|
goto check_error;
|
2014-03-09 14:40:04 -05:00
|
|
|
}
|
|
|
|
|
2017-07-28 08:32:54 -05:00
|
|
|
if (GetSize(args) > argidx && (args[argidx] == "-vhdl2008" || args[argidx] == "-vhdl")) {
|
2014-03-13 11:34:31 -05:00
|
|
|
vhdl_file::SetDefaultLibraryPath((proc_share_dirname() + "verific/vhdl_vdbs_2008").c_str());
|
2017-07-22 09:16:44 -05:00
|
|
|
for (argidx++; argidx < GetSize(args); argidx++)
|
2018-08-22 06:30:22 -05:00
|
|
|
if (!vhdl_file::Analyze(args[argidx].c_str(), work.c_str(), vhdl_file::VHDL_2008))
|
2014-03-09 14:40:04 -05:00
|
|
|
log_cmd_error("Reading `%s' in VHDL_2008 mode failed.\n", args[argidx].c_str());
|
2018-06-20 16:45:01 -05:00
|
|
|
verific_import_pending = true;
|
2017-10-04 11:56:28 -05:00
|
|
|
goto check_error;
|
2014-03-09 14:40:04 -05:00
|
|
|
}
|
|
|
|
|
2017-07-22 09:16:44 -05:00
|
|
|
if (GetSize(args) > argidx && args[argidx] == "-import")
|
2014-03-09 14:40:04 -05:00
|
|
|
{
|
|
|
|
std::set<Netlist*> nl_todo, nl_done;
|
2017-07-22 09:16:44 -05:00
|
|
|
bool mode_all = false, mode_gates = false, mode_keep = false;
|
2018-03-07 12:40:34 -06:00
|
|
|
bool mode_nosva = false, mode_names = false, mode_verific = false;
|
2019-08-07 08:31:49 -05:00
|
|
|
bool mode_autocover = false, mode_fullinit = false;
|
2018-02-28 04:45:04 -06:00
|
|
|
bool flatten = false, extnets = false;
|
2017-07-24 06:57:16 -05:00
|
|
|
string dumpfile;
|
2019-03-08 19:54:01 -06:00
|
|
|
Map parameters(STRING_HASH);
|
2014-03-09 14:40:04 -05:00
|
|
|
|
2017-07-22 09:16:44 -05:00
|
|
|
for (argidx++; argidx < GetSize(args); argidx++) {
|
2014-03-14 05:46:13 -05:00
|
|
|
if (args[argidx] == "-all") {
|
|
|
|
mode_all = true;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
if (args[argidx] == "-gates") {
|
|
|
|
mode_gates = true;
|
|
|
|
continue;
|
|
|
|
}
|
2017-07-24 04:29:06 -05:00
|
|
|
if (args[argidx] == "-flatten") {
|
|
|
|
flatten = true;
|
|
|
|
continue;
|
|
|
|
}
|
2017-07-25 07:53:11 -05:00
|
|
|
if (args[argidx] == "-extnets") {
|
|
|
|
extnets = true;
|
|
|
|
continue;
|
|
|
|
}
|
2017-07-22 09:16:44 -05:00
|
|
|
if (args[argidx] == "-k") {
|
|
|
|
mode_keep = true;
|
|
|
|
continue;
|
|
|
|
}
|
2017-07-27 04:54:45 -05:00
|
|
|
if (args[argidx] == "-nosva") {
|
|
|
|
mode_nosva = true;
|
|
|
|
continue;
|
|
|
|
}
|
2018-09-04 13:06:10 -05:00
|
|
|
if (args[argidx] == "-L" && argidx+1 < GetSize(args)) {
|
|
|
|
verific_sva_fsm_limit = atoi(args[++argidx].c_str());
|
|
|
|
continue;
|
|
|
|
}
|
2017-07-27 04:54:45 -05:00
|
|
|
if (args[argidx] == "-n") {
|
|
|
|
mode_names = true;
|
|
|
|
continue;
|
|
|
|
}
|
2018-04-06 07:10:57 -05:00
|
|
|
if (args[argidx] == "-autocover") {
|
|
|
|
mode_autocover = true;
|
|
|
|
continue;
|
|
|
|
}
|
2019-08-07 08:31:49 -05:00
|
|
|
if (args[argidx] == "-fullinit") {
|
|
|
|
mode_fullinit = true;
|
|
|
|
continue;
|
|
|
|
}
|
2019-03-08 19:54:01 -06:00
|
|
|
if (args[argidx] == "-chparam" && argidx+2 < GetSize(args)) {
|
2019-03-13 14:42:18 -05:00
|
|
|
const std::string &key = args[++argidx];
|
|
|
|
const std::string &value = args[++argidx];
|
2019-03-08 19:54:01 -06:00
|
|
|
unsigned new_insertion = parameters.Insert(key.c_str(), value.c_str(),
|
|
|
|
1 /* force_overwrite */);
|
|
|
|
if (!new_insertion)
|
|
|
|
log_warning_noprefix("-chparam %s already specified: overwriting.\n", key.c_str());
|
|
|
|
continue;
|
|
|
|
}
|
2018-03-07 12:40:34 -06:00
|
|
|
if (args[argidx] == "-V") {
|
|
|
|
mode_verific = true;
|
|
|
|
continue;
|
|
|
|
}
|
2017-07-24 04:29:06 -05:00
|
|
|
if (args[argidx] == "-v") {
|
2018-03-01 04:40:43 -06:00
|
|
|
verific_verbose = 1;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
if (args[argidx] == "-vv") {
|
|
|
|
verific_verbose = 2;
|
2017-07-24 04:29:06 -05:00
|
|
|
continue;
|
|
|
|
}
|
2017-07-24 06:57:16 -05:00
|
|
|
if (args[argidx] == "-d" && argidx+1 < GetSize(args)) {
|
|
|
|
dumpfile = args[++argidx];
|
|
|
|
continue;
|
|
|
|
}
|
2014-03-14 05:46:13 -05:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2019-08-07 14:20:08 -05:00
|
|
|
if (argidx > GetSize(args) && args[argidx].compare(0, 1, "-") == 0)
|
2014-09-06 01:47:06 -05:00
|
|
|
cmd_error(args, argidx, "unknown option");
|
2014-03-14 05:46:13 -05:00
|
|
|
|
2019-11-20 05:54:10 -06:00
|
|
|
std::set<std::string> top_mod_names;
|
|
|
|
|
2014-03-14 05:46:13 -05:00
|
|
|
if (mode_all)
|
|
|
|
{
|
2018-03-08 06:26:33 -06:00
|
|
|
log("Running hier_tree::ElaborateAll().\n");
|
|
|
|
|
2018-08-22 06:30:22 -05:00
|
|
|
VhdlLibrary *vhdl_lib = vhdl_file::GetLibrary(work.c_str(), 1);
|
|
|
|
VeriLibrary *veri_lib = veri_file::GetLibrary(work.c_str(), 1);
|
2018-03-08 06:26:33 -06:00
|
|
|
|
|
|
|
Array veri_libs, vhdl_libs;
|
|
|
|
if (vhdl_lib) vhdl_libs.InsertLast(vhdl_lib);
|
|
|
|
if (veri_lib) veri_libs.InsertLast(veri_lib);
|
|
|
|
|
2019-03-08 19:54:01 -06:00
|
|
|
Array *netlists = hier_tree::ElaborateAll(&veri_libs, &vhdl_libs, ¶meters);
|
2018-03-08 06:26:33 -06:00
|
|
|
Netlist *nl;
|
|
|
|
int i;
|
|
|
|
|
|
|
|
FOREACH_ARRAY_ITEM(netlists, i, nl)
|
|
|
|
nl_todo.insert(nl);
|
|
|
|
delete netlists;
|
2014-03-14 05:46:13 -05:00
|
|
|
}
|
|
|
|
else
|
2017-07-25 06:33:25 -05:00
|
|
|
{
|
2017-07-22 09:16:44 -05:00
|
|
|
if (argidx == GetSize(args))
|
2019-11-19 15:25:38 -06:00
|
|
|
cmd_error(args, argidx, "No top module specified.\n");
|
2014-03-09 14:40:04 -05:00
|
|
|
|
2018-03-08 06:26:33 -06:00
|
|
|
Array veri_modules, vhdl_units;
|
|
|
|
for (; argidx < GetSize(args); argidx++)
|
|
|
|
{
|
|
|
|
const char *name = args[argidx].c_str();
|
2019-11-20 05:54:10 -06:00
|
|
|
top_mod_names.insert(name);
|
2019-03-13 17:40:00 -05:00
|
|
|
VeriLibrary* veri_lib = veri_file::GetLibrary(work.c_str(), 1);
|
|
|
|
|
|
|
|
if (veri_lib) {
|
|
|
|
VeriModule *veri_module = veri_lib->GetModule(name, 1);
|
|
|
|
if (veri_module) {
|
|
|
|
log("Adding Verilog module '%s' to elaboration queue.\n", name);
|
|
|
|
veri_modules.InsertLast(veri_module);
|
|
|
|
continue;
|
|
|
|
}
|
2018-03-08 06:26:33 -06:00
|
|
|
|
2019-03-13 17:40:00 -05:00
|
|
|
// Also elaborate all root modules since they may contain bind statements
|
|
|
|
MapIter mi;
|
|
|
|
FOREACH_VERILOG_MODULE_IN_LIBRARY(veri_lib, mi, veri_module) {
|
|
|
|
if (!veri_module->IsRootModule()) continue;
|
|
|
|
veri_modules.InsertLast(veri_module);
|
|
|
|
}
|
2018-03-08 06:26:33 -06:00
|
|
|
}
|
|
|
|
|
2018-08-22 06:30:22 -05:00
|
|
|
VhdlLibrary *vhdl_lib = vhdl_file::GetLibrary(work.c_str(), 1);
|
2018-03-08 06:26:33 -06:00
|
|
|
VhdlDesignUnit *vhdl_unit = vhdl_lib->GetPrimUnit(name);
|
|
|
|
if (vhdl_unit) {
|
|
|
|
log("Adding VHDL unit '%s' to elaboration queue.\n", name);
|
|
|
|
vhdl_units.InsertLast(vhdl_unit);
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
log_error("Can't find module/unit '%s'.\n", name);
|
|
|
|
}
|
|
|
|
|
|
|
|
log("Running hier_tree::Elaborate().\n");
|
2019-03-08 19:54:01 -06:00
|
|
|
Array *netlists = hier_tree::Elaborate(&veri_modules, &vhdl_units, ¶meters);
|
2018-03-08 06:26:33 -06:00
|
|
|
Netlist *nl;
|
|
|
|
int i;
|
|
|
|
|
2019-03-13 17:05:55 -05:00
|
|
|
FOREACH_ARRAY_ITEM(netlists, i, nl) {
|
|
|
|
nl->AddAtt(new Att(" \\top", NULL));
|
2018-03-08 06:26:33 -06:00
|
|
|
nl_todo.insert(nl);
|
2019-03-13 17:05:55 -05:00
|
|
|
}
|
2018-03-08 06:26:33 -06:00
|
|
|
delete netlists;
|
2014-03-09 14:40:04 -05:00
|
|
|
}
|
|
|
|
|
2018-04-06 14:23:47 -05:00
|
|
|
if (!verific_error_msg.empty())
|
|
|
|
goto check_error;
|
|
|
|
|
2017-07-24 04:29:06 -05:00
|
|
|
if (flatten) {
|
|
|
|
for (auto nl : nl_todo)
|
|
|
|
nl->Flatten();
|
|
|
|
}
|
|
|
|
|
2017-07-25 07:53:11 -05:00
|
|
|
if (extnets) {
|
|
|
|
VerificExtNets worker;
|
|
|
|
for (auto nl : nl_todo)
|
|
|
|
worker.run(nl);
|
|
|
|
}
|
2017-07-24 06:57:16 -05:00
|
|
|
|
2020-01-24 12:12:52 -06:00
|
|
|
for (auto nl : nl_todo)
|
|
|
|
nl->ChangePortBusStructures(1 /* hierarchical */);
|
|
|
|
|
2017-07-25 07:53:11 -05:00
|
|
|
if (!dumpfile.empty()) {
|
2017-07-24 06:57:16 -05:00
|
|
|
VeriWrite veri_writer;
|
2017-07-25 07:53:11 -05:00
|
|
|
veri_writer.WriteFile(dumpfile.c_str(), Netlist::PresentDesign());
|
2017-07-24 06:57:16 -05:00
|
|
|
}
|
|
|
|
|
2014-03-09 14:40:04 -05:00
|
|
|
while (!nl_todo.empty()) {
|
|
|
|
Netlist *nl = *nl_todo.begin();
|
2017-02-04 06:36:00 -06:00
|
|
|
if (nl_done.count(nl) == 0) {
|
2018-03-07 12:40:34 -06:00
|
|
|
VerificImporter importer(mode_gates, mode_keep, mode_nosva,
|
2019-08-07 08:31:49 -05:00
|
|
|
mode_names, mode_verific, mode_autocover, mode_fullinit);
|
2019-11-20 05:54:10 -06:00
|
|
|
importer.import_netlist(design, nl, nl_todo, top_mod_names.count(nl->Owner()->Name()));
|
2017-02-04 06:36:00 -06:00
|
|
|
}
|
2014-03-09 14:40:04 -05:00
|
|
|
nl_todo.erase(nl);
|
|
|
|
nl_done.insert(nl);
|
|
|
|
}
|
|
|
|
|
2017-10-13 13:12:51 -05:00
|
|
|
veri_file::Reset();
|
|
|
|
vhdl_file::Reset();
|
2014-03-09 14:40:04 -05:00
|
|
|
Libset::Reset();
|
2018-07-16 11:46:06 -05:00
|
|
|
verific_incdirs.clear();
|
|
|
|
verific_libdirs.clear();
|
2018-06-20 16:45:01 -05:00
|
|
|
verific_import_pending = false;
|
2017-10-04 11:56:28 -05:00
|
|
|
goto check_error;
|
2014-03-09 14:40:04 -05:00
|
|
|
}
|
|
|
|
|
2019-11-19 15:24:48 -06:00
|
|
|
cmd_error(args, argidx, "Missing or unsupported mode parameter.\n");
|
2017-10-04 11:56:28 -05:00
|
|
|
|
|
|
|
check_error:
|
2017-10-05 07:38:32 -05:00
|
|
|
if (!verific_error_msg.empty())
|
|
|
|
log_error("%s\n", verific_error_msg.c_str());
|
2017-10-04 11:56:28 -05:00
|
|
|
|
2014-03-09 14:40:04 -05:00
|
|
|
}
|
2014-03-13 11:34:31 -05:00
|
|
|
#else /* YOSYS_ENABLE_VERIFIC */
|
2018-07-21 01:41:18 -05:00
|
|
|
void execute(std::vector<std::string>, RTLIL::Design *) YS_OVERRIDE {
|
2019-12-18 06:06:34 -06:00
|
|
|
log_cmd_error("This version of Yosys is built without Verific support.\n"
|
|
|
|
"\n"
|
|
|
|
"Use Symbiotic EDA Suite if you need Yosys+Verifc.\n"
|
|
|
|
"https://www.symbioticeda.com/seda-suite\n"
|
|
|
|
"\n"
|
|
|
|
"Contact office@symbioticeda.com for free evaluation\n"
|
|
|
|
"binaries of Symbiotic EDA Suite.\n");
|
2014-03-09 14:40:04 -05:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
} VerificPass;
|
2015-07-02 04:14:30 -05:00
|
|
|
|
2018-06-21 09:56:55 -05:00
|
|
|
struct ReadPass : public Pass {
|
|
|
|
ReadPass() : Pass("read", "load HDL designs") { }
|
2018-07-21 01:41:18 -05:00
|
|
|
void help() YS_OVERRIDE
|
2018-06-21 09:56:55 -05:00
|
|
|
{
|
|
|
|
// |---v---|---v---|---v---|---v---|---v---|---v---|---v---|---v---|---v---|---v---|
|
|
|
|
log("\n");
|
2018-06-29 03:02:27 -05:00
|
|
|
log(" read {-vlog95|-vlog2k|-sv2005|-sv2009|-sv2012|-sv|-formal} <verilog-file>..\n");
|
2018-06-21 09:56:55 -05:00
|
|
|
log("\n");
|
|
|
|
log("Load the specified Verilog/SystemVerilog files. (Full SystemVerilog support\n");
|
|
|
|
log("is only available via Verific.)\n");
|
|
|
|
log("\n");
|
2018-06-28 16:58:15 -05:00
|
|
|
log("Additional -D<macro>[=<value>] options may be added after the option indicating\n");
|
|
|
|
log("the language version (and before file names) to set additional verilog defines.\n");
|
|
|
|
log("\n");
|
2018-06-21 09:56:55 -05:00
|
|
|
log("\n");
|
|
|
|
log(" read {-vhdl87|-vhdl93|-vhdl2k|-vhdl2008|-vhdl} <vhdl-file>..\n");
|
|
|
|
log("\n");
|
|
|
|
log("Load the specified VHDL files. (Requires Verific.)\n");
|
|
|
|
log("\n");
|
|
|
|
log("\n");
|
|
|
|
log(" read -define <macro>[=<value>]..\n");
|
|
|
|
log("\n");
|
|
|
|
log("Set global Verilog/SystemVerilog defines.\n");
|
|
|
|
log("\n");
|
2018-06-28 16:43:38 -05:00
|
|
|
log("\n");
|
|
|
|
log(" read -undef <macro>..\n");
|
|
|
|
log("\n");
|
|
|
|
log("Unset global Verilog/SystemVerilog defines.\n");
|
|
|
|
log("\n");
|
2018-07-16 08:32:26 -05:00
|
|
|
log("\n");
|
|
|
|
log(" read -incdir <directory>\n");
|
|
|
|
log("\n");
|
|
|
|
log("Add directory to global Verilog/SystemVerilog include directories.\n");
|
|
|
|
log("\n");
|
2019-03-27 08:03:35 -05:00
|
|
|
log("\n");
|
|
|
|
log(" read -verific\n");
|
|
|
|
log(" read -noverific\n");
|
|
|
|
log("\n");
|
|
|
|
log("Subsequent calls to 'read' will either use or not use Verific. Calling 'read'\n");
|
|
|
|
log("with -verific will result in an error on Yosys binaries that are built without\n");
|
|
|
|
log("Verific support. The default is to use Verific if it is available.\n");
|
|
|
|
log("\n");
|
2018-06-21 09:56:55 -05:00
|
|
|
}
|
2018-07-21 01:41:18 -05:00
|
|
|
void execute(std::vector<std::string> args, RTLIL::Design *design) YS_OVERRIDE
|
2018-06-21 09:56:55 -05:00
|
|
|
{
|
2019-03-27 08:03:35 -05:00
|
|
|
#ifdef YOSYS_ENABLE_VERIFIC
|
|
|
|
static bool verific_available = !check_noverific_env();
|
|
|
|
#else
|
|
|
|
static bool verific_available = false;
|
|
|
|
#endif
|
|
|
|
static bool use_verific = verific_available;
|
|
|
|
|
2019-02-28 22:34:42 -06:00
|
|
|
if (args.size() < 2 || args[1][0] != '-')
|
2019-11-19 15:24:48 -06:00
|
|
|
cmd_error(args, 1, "Missing mode parameter.\n");
|
2018-06-21 09:56:55 -05:00
|
|
|
|
2019-03-27 08:03:35 -05:00
|
|
|
if (args[1] == "-verific" || args[1] == "-noverific") {
|
|
|
|
if (args.size() != 2)
|
2019-11-19 15:24:48 -06:00
|
|
|
cmd_error(args, 1, "Additional arguments to -verific/-noverific.\n");
|
2019-03-27 08:03:35 -05:00
|
|
|
if (args[1] == "-verific") {
|
|
|
|
if (!verific_available)
|
2019-11-19 15:24:48 -06:00
|
|
|
cmd_error(args, 1, "This version of Yosys is built without Verific support.\n");
|
2019-03-27 08:03:35 -05:00
|
|
|
use_verific = true;
|
|
|
|
} else {
|
|
|
|
use_verific = false;
|
|
|
|
}
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2018-06-21 09:56:55 -05:00
|
|
|
if (args.size() < 3)
|
2019-11-19 15:24:48 -06:00
|
|
|
cmd_error(args, 3, "Missing file name parameter.\n");
|
2018-06-21 09:56:55 -05:00
|
|
|
|
2018-06-22 13:40:22 -05:00
|
|
|
if (args[1] == "-vlog95" || args[1] == "-vlog2k") {
|
|
|
|
if (use_verific) {
|
|
|
|
args[0] = "verific";
|
|
|
|
} else {
|
|
|
|
args[0] = "read_verilog";
|
2019-07-29 03:29:36 -05:00
|
|
|
args[1] = "-defer";
|
2018-06-22 13:40:22 -05:00
|
|
|
}
|
2018-06-21 09:56:55 -05:00
|
|
|
Pass::call(design, args);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2018-06-29 03:02:27 -05:00
|
|
|
if (args[1] == "-sv2005" || args[1] == "-sv2009" || args[1] == "-sv2012" || args[1] == "-sv" || args[1] == "-formal") {
|
2018-06-22 13:40:22 -05:00
|
|
|
if (use_verific) {
|
|
|
|
args[0] = "verific";
|
|
|
|
} else {
|
|
|
|
args[0] = "read_verilog";
|
2018-06-29 03:02:27 -05:00
|
|
|
if (args[1] == "-formal")
|
|
|
|
args.insert(args.begin()+1, std::string());
|
2018-06-22 13:40:22 -05:00
|
|
|
args[1] = "-sv";
|
2019-07-29 03:29:36 -05:00
|
|
|
args.insert(args.begin()+1, "-defer");
|
2018-06-22 13:40:22 -05:00
|
|
|
}
|
2018-06-21 09:56:55 -05:00
|
|
|
Pass::call(design, args);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (args[1] == "-vhdl87" || args[1] == "-vhdl93" || args[1] == "-vhdl2k" || args[1] == "-vhdl2008" || args[1] == "-vhdl") {
|
2018-06-22 13:40:22 -05:00
|
|
|
if (use_verific) {
|
|
|
|
args[0] = "verific";
|
|
|
|
Pass::call(design, args);
|
|
|
|
} else {
|
2019-11-19 15:24:48 -06:00
|
|
|
cmd_error(args, 1, "This version of Yosys is built without Verific support.\n");
|
2018-06-22 13:40:22 -05:00
|
|
|
}
|
2018-06-21 09:56:55 -05:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (args[1] == "-define") {
|
2018-06-22 13:40:22 -05:00
|
|
|
if (use_verific) {
|
|
|
|
args[0] = "verific";
|
|
|
|
args[1] = "-vlog-define";
|
|
|
|
Pass::call(design, args);
|
|
|
|
}
|
2018-06-21 09:56:55 -05:00
|
|
|
args[0] = "verilog_defines";
|
|
|
|
args.erase(args.begin()+1, args.begin()+2);
|
|
|
|
for (int i = 1; i < GetSize(args); i++)
|
|
|
|
args[i] = "-D" + args[i];
|
|
|
|
Pass::call(design, args);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2018-06-28 16:43:38 -05:00
|
|
|
if (args[1] == "-undef") {
|
|
|
|
if (use_verific) {
|
|
|
|
args[0] = "verific";
|
|
|
|
args[1] = "-vlog-undef";
|
|
|
|
Pass::call(design, args);
|
|
|
|
}
|
|
|
|
args[0] = "verilog_defines";
|
|
|
|
args.erase(args.begin()+1, args.begin()+2);
|
|
|
|
for (int i = 1; i < GetSize(args); i++)
|
|
|
|
args[i] = "-U" + args[i];
|
|
|
|
Pass::call(design, args);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2018-07-16 08:32:26 -05:00
|
|
|
if (args[1] == "-incdir") {
|
|
|
|
if (use_verific) {
|
|
|
|
args[0] = "verific";
|
|
|
|
args[1] = "-vlog-incdir";
|
|
|
|
Pass::call(design, args);
|
|
|
|
}
|
|
|
|
args[0] = "verilog_defaults";
|
|
|
|
args[1] = "-add";
|
2018-07-16 09:48:09 -05:00
|
|
|
for (int i = 2; i < GetSize(args); i++)
|
2018-07-16 08:32:26 -05:00
|
|
|
args[i] = "-I" + args[i];
|
|
|
|
Pass::call(design, args);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2019-11-19 15:24:48 -06:00
|
|
|
cmd_error(args, 1, "Missing or unsupported mode parameter.\n");
|
2018-06-21 09:56:55 -05:00
|
|
|
}
|
|
|
|
} ReadPass;
|
|
|
|
|
2017-02-04 06:36:00 -06:00
|
|
|
PRIVATE_NAMESPACE_END
|