Bug fixes in the VST/VHDL driver coupled with BlifParser.

* Change: In Hurricane::NetAlias, store additional data in NetAliasName,
    the external status of the former Net. When a Net::merge() is
    performed, we must keep track of whether the merged (destroyed)
    one was external and keep that information.
      Add NetAliasHook::isExternal() & NetAliasHook::setExternal()
    virtual methods.
* Change: In Net::getNet() add a new optional argument to allow the
    search of the net name in *internal* aliases. Otherwise only the
    aliases tagged as *external* will be searched.
      It was a bug that, when looking for a Plug master net by name
    we got an homonymous internal net. In that case we must only
    look for net that are (or where) part of the interface.
* New: In Vhdl::VectorSignal, when a vector contains only one bit,
    unvectorize it, like when it is non-contiguous (we use the
    isCountiguous() method to carry that information).
* New: In Vhdl::VhdlEntity, Catalog::State and NamingScheme, added
    a flag UniquifyUpperCase to uniquify the names in uppercases.
    In case of a clash with the same name in lowercase.
      Prepend 'u' before all previously uppercased letter. For
    example 'VexRiscV' becomes 'uvexuriscuv' (urgh!).
      The Catalog flags is exported to Python for use by the blif2vst
    script.
* Change: In BlifParser, Model::newOne() and Model::newZero(), return
    a new gate each time it is called instead of making just one for
    each Model. This way, if two outside nets are connected to one
    or zero they do not get merged (should work, but will be less
    clear).
* Bug: In BlifParser, Model::connectSubckts(), when looking for the
    master net in the instances models (by name), limit the search
    to the *external* aliases names.
* Change: In NamingScheme::vlogTovhdl(), reactivate the removal of
    two consecutive '_'.
* Change: In cumulus/bin/blif2vst.py, prefix the master cells
    (i.e. components) with 'cmpt_' to avoid clash names with signals
    in VHDL.
This commit is contained in:
Jean-Paul Chaput 2021-04-05 23:53:44 +02:00
parent 08d1db5dd6
commit ec3c22547a
20 changed files with 208 additions and 152 deletions

View File

@ -105,7 +105,8 @@ namespace Vhdl {
, _globals() , _globals()
, _flags (flags) , _flags (flags)
{ {
if (flags & VstNoLowerCase) _ns.setNoLowerCase( true ); if (flags & VstNoLowerCase) _ns.setNoLowerCase( true );
if (flags & VstUniquifyUpperCase) _ns.setUniquifyUpperCase( true );
if (not _offset) { if (not _offset) {
//_offset = offsetof(EntityProperty,_entity); //_offset = offsetof(EntityProperty,_entity);
_offset = (ptrdiff_t)this - (ptrdiff_t)property; _offset = (ptrdiff_t)this - (ptrdiff_t)property;
@ -331,8 +332,12 @@ namespace Vhdl {
out << "-- \n"; out << "-- \n";
if (_flags & OptionMask) { if (_flags & OptionMask) {
out << "-- Genarated with options:\n"; out << "-- Genarated with options:\n";
if (_flags & VstUseConcat) out << "-- * VstUseConcat: Use concat (&) in port map.\n"; if (_flags & VstUseConcat) out << "-- * VstUseConcat: Use concat (&) in port map.\n";
if (_flags & VstNoLowerCase) out << "-- * VstNoLowerCase: Identifiers are *not* put in lowercase.\n"; if (_flags & VstNoLowerCase) out << "-- * VstNoLowerCase: Identifiers are *not* put in lowercase.\n";
if (_flags & VstUniquifyUpperCase) {
out << "-- * VstUniquifyUpperCase: Upper case identifiers are uniquified.\n";
out << "-- (one 'u' before each lowered letter)\n";
}
out << "-- \n"; out << "-- \n";
} }
if (isIeeeMode()) { if (isIeeeMode()) {

View File

@ -111,6 +111,7 @@ namespace Vhdl {
bool ScalarSignal::isVector () const { return false; } bool ScalarSignal::isVector () const { return false; }
bool ScalarSignal::isExternal () const { return _bit->isExternal(); } bool ScalarSignal::isExternal () const { return _bit->isExternal(); }
bool ScalarSignal::isContiguous () const { return false; } bool ScalarSignal::isContiguous () const { return false; }
size_t ScalarSignal::getSize () const { return 1; }
const Bit* ScalarSignal::getBit () const { return _bit; } const Bit* ScalarSignal::getBit () const { return _bit; }
const Bit* ScalarSignal::getBit ( size_t ) const { return _bit; } const Bit* ScalarSignal::getBit ( size_t ) const { return _bit; }
const Net* ScalarSignal::getNet () const { return _bit->getNet(); } const Net* ScalarSignal::getNet () const { return _bit->getNet(); }
@ -158,6 +159,7 @@ namespace Vhdl {
bool VectorSignal::isScalar () const { return false; } bool VectorSignal::isScalar () const { return false; }
bool VectorSignal::isVector () const { return true; } bool VectorSignal::isVector () const { return true; }
size_t VectorSignal::getSize () const { return _bits.size(); }
bool VectorSignal::isExternal () const { return (*_bits. begin())->isExternal(); } bool VectorSignal::isExternal () const { return (*_bits. begin())->isExternal(); }
size_t VectorSignal::getMin () const { return (*_bits.rbegin())->getIndex(); } size_t VectorSignal::getMin () const { return (*_bits.rbegin())->getIndex(); }
size_t VectorSignal::getMax () const { return (*_bits. begin())->getIndex(); } size_t VectorSignal::getMax () const { return (*_bits. begin())->getIndex(); }
@ -194,13 +196,13 @@ namespace Vhdl {
bool VectorSignal::isContiguous () const bool VectorSignal::isContiguous () const
{ {
if (_bits.size() < 2) return false;
auto inet1 = _bits.rbegin(); auto inet1 = _bits.rbegin();
auto inet2 = inet1; auto inet2 = inet1;
for ( ++inet1; inet1!=_bits.rend() ; ++inet1, ++inet2 ) { for ( ++inet1; inet1!=_bits.rend() ; ++inet1, ++inet2 ) {
if ((*inet1)->getIndex() != (*inet2)->getIndex()+1) return false; if ((*inet1)->getIndex() != (*inet2)->getIndex()+1) return false;
} }
return true; return true;
} }
@ -211,7 +213,6 @@ namespace Vhdl {
string range = "(" + getString(getMax()) + " downto " + getString(getMin()) + ")"; string range = "(" + getString(getMax()) + " downto " + getString(getMin()) + ")";
_toVhdlPort( out, width, flags, getName(), range, getDirection() ); _toVhdlPort( out, width, flags, getName(), range, getDirection() );
} else { } else {
bool first = true; bool first = true;
for ( auto bit : _bits ) { for ( auto bit : _bits ) {
string name = getName() + "_" + getString(bit->getIndex()); string name = getName() + "_" + getString(bit->getIndex());

View File

@ -40,9 +40,10 @@ namespace CRL {
void vstDriver ( const string cellPath, Cell *cell, unsigned int& saveState ) void vstDriver ( const string cellPath, Cell *cell, unsigned int& saveState )
{ {
unsigned int entityFlags = Vhdl::Entity::EntityMode /* | Vhdl::Entity::IeeeMode */; unsigned int entityFlags = Vhdl::Entity::EntityMode /* | Vhdl::Entity::IeeeMode */;
if (saveState & Catalog::State::VstUseConcat ) entityFlags |= Vhdl::Entity::VstUseConcat; if (saveState & Catalog::State::VstUseConcat ) entityFlags |= Vhdl::Entity::VstUseConcat;
if (saveState & Catalog::State::VstNoLowerCase) entityFlags |= Vhdl::Entity::VstNoLowerCase; if (saveState & Catalog::State::VstNoLowerCase ) entityFlags |= Vhdl::Entity::VstNoLowerCase;
if (saveState & Catalog::State::VstNoLinkage ) entityFlags |= Vhdl::Entity::VstNoLinkage; if (saveState & Catalog::State::VstUniquifyUpperCase) entityFlags |= Vhdl::Entity::VstUniquifyUpperCase;
if (saveState & Catalog::State::VstNoLinkage ) entityFlags |= Vhdl::Entity::VstNoLinkage;
//NamingScheme::toVhdl( cell, NamingScheme::FromVerilog ); //NamingScheme::toVhdl( cell, NamingScheme::FromVerilog );
Vhdl::Entity* vhdlEntity = Vhdl::EntityExtension::create( cell, entityFlags ); Vhdl::Entity* vhdlEntity = Vhdl::EntityExtension::create( cell, entityFlags );

View File

@ -515,14 +515,11 @@ namespace {
Net* Model::newOne () Net* Model::newOne ()
{ {
if (not _masterNetOne) return NULL; if (not _masterNetOne) return NULL;
if (_oneInstance) return _oneInstance->getPlug( _masterNetOne )->getNet(); // if (_oneInstance) return _oneInstance->getPlug( _masterNetOne )->getNet();
ostringstream name; name << "one_" << _supplyCount++; ostringstream name; name << "one_" << _supplyCount++;
_oneInstance = Instance::create( _cell, name.str(), _oneCell ); _oneInstance = Instance::create( _cell, name.str(), _oneCell );
Net* one = Net::create( _cell, name.str() ); Net* one = Net::create( _cell, name.str() );
_oneInstance->getPlug( _masterNetOne )->setNet( one ); _oneInstance->getPlug( _masterNetOne )->setNet( one );
return one; return one;
} }
@ -530,14 +527,11 @@ namespace {
Net* Model::newZero () Net* Model::newZero ()
{ {
if (not _masterNetZero) return NULL; if (not _masterNetZero) return NULL;
if (_zeroInstance) return _zeroInstance->getPlug( _masterNetZero )->getNet(); // if (_zeroInstance) return _zeroInstance->getPlug( _masterNetZero )->getNet();
ostringstream name; name << "zero_" << _supplyCount++; ostringstream name; name << "zero_" << _supplyCount++;
_zeroInstance = Instance::create( _cell, name.str(), _zeroCell ); _zeroInstance = Instance::create( _cell, name.str(), _zeroCell );
Net* zero = Net::create( _cell, name.str() ); Net* zero = Net::create( _cell, name.str() );
_zeroInstance->getPlug( _masterNetZero )->setNet( zero ); _zeroInstance->getPlug( _masterNetZero )->setNet( zero );
return zero; return zero;
} }
@ -553,8 +547,8 @@ namespace {
net->setDirection( (Net::Direction::Code)direction ); net->setDirection( (Net::Direction::Code)direction );
if (isClock) net->setType( Net::Type::CLOCK ); if (isClock) net->setType( Net::Type::CLOCK );
// if (_cell->getName() == "ALU_dec19") // if (_cell->getName() == "alu_div0")
// cerr << "ALU_dec19 net create:" << direction << " " << net << endl; // cerr << "alu_div0 net create:" << direction << " " << net << endl;
} else { } else {
net->addAlias( name ); net->addAlias( name );
if (isExternal) net->setExternal( true ); if (isExternal) net->setExternal( true );
@ -563,8 +557,8 @@ namespace {
net->setDirection( (Net::Direction::Code)direction ); net->setDirection( (Net::Direction::Code)direction );
if (isClock) net->setType( Net::Type::CLOCK ); if (isClock) net->setType( Net::Type::CLOCK );
// if (_cell->getName() == "ALU_dec19") // if (_cell->getName() == "alu_div0")
// cerr << "ALU_dec19 net merge:" << direction << " " << net << endl; // cerr << "alu_div0 net merge:" << direction << " " << net << endl;
} }
return net; return net;
} }
@ -607,13 +601,16 @@ namespace {
if (not message.str().empty()) cerr << Warning( message.str() ) << endl; if (not message.str().empty()) cerr << Warning( message.str() ) << endl;
return net2; return net2;
} }
if ( (not net1->isExternal() and net2->isExternal()) if ( (not net1->isExternal() and net2->isExternal())
or ( net1->isExternal() and net2->isExternal() and (net1->getId() > net2->getId()) ) ) { or ( net1->isExternal() and net2->isExternal() and (net1->getId() > net2->getId()) ) ) {
std::swap( net1 , net2 ); std::swap( net1 , net2 );
std::swap( name1, name2 ); std::swap( name1, name2 );
} }
// if (_cell->getName() == "alu_div0")
// cerr << "alu_div0 alias net merge:" << net2 << " -> " << net1 << endl;
net1->merge( net2 ); return net1; net1->merge( net2 ); return net1;
} }
@ -625,6 +622,9 @@ namespace {
if (not net1) { if (not net1) {
net1 = Net::create( _cell, name1 ); net1 = Net::create( _cell, name1 );
net1->setExternal ( false ); net1->setExternal ( false );
// if (_cell->getName() == "alu_div0")
// cerr << "alu_div0 alias net create:" << net1 << endl;
} }
net1->addAlias( name2 ); net1->addAlias( name2 );
@ -683,7 +683,7 @@ namespace {
// << "external: <" << netName << ">." // << "external: <" << netName << ">."
// << endl; // << endl;
Net* net = _cell->getNet( netName ); Net* net = _cell->getNet( netName );
Net* masterNet = instance->getMasterCell()->getNet(masterNetName); Net* masterNet = instance->getMasterCell()->getNet(masterNetName,false);
if(not masterNet) { if(not masterNet) {
Name vlogMasterNetName = NamingScheme::vlogToVhdl( masterNetName, NamingScheme::NoLowerCase ); Name vlogMasterNetName = NamingScheme::vlogToVhdl( masterNetName, NamingScheme::NoLowerCase );
masterNet = instance->getMasterCell()->getNet(vlogMasterNetName); masterNet = instance->getMasterCell()->getNet(vlogMasterNetName);
@ -721,13 +721,15 @@ namespace {
plugNet->addAlias( netName ); plugNet->addAlias( netName );
} }
else if (plugNet != net){ // Plus already connected to another net else if (plugNet != net){ // Plus already connected to another net
if (not plugNet->isExternal()) net->merge( plugNet ); if (not plugNet->isExternal()) {
net->merge( plugNet );
}
else plugNet->merge( net ); else plugNet->merge( net );
} }
if (subckt->getModel()->getCell()->getName() == "sm0") { // if (subckt->getModel()->getCell()->getName() == "sm0") {
cerr << "sm0 plug:" << plug->getMasterNet()->getName() << " => net:" << net->getName() << endl; // cerr << "sm0 plug:" << plug->getMasterNet()->getName() << " => net:" << net->getName() << endl;
} // }
if (plugNet->isSupply() and not plug->getMasterNet()->isSupply()) { if (plugNet->isSupply() and not plug->getMasterNet()->isSupply()) {
ostringstream message; ostringstream message;

View File

@ -14,9 +14,7 @@
// +-----------------------------------------------------------------+ // +-----------------------------------------------------------------+
#ifndef CRL_CATALOG_H #pragma once
#define CRL_CATALOG_H
#include <string> #include <string>
#include <map> #include <map>
#include "hurricane/Name.h" #include "hurricane/Name.h"
@ -77,19 +75,20 @@ namespace CRL {
class State { class State {
public: public:
// Flags Constants. // Flags Constants.
enum Flags { TerminalNetlist = 1 << 0 enum Flags { TerminalNetlist = 1 << 0
, Feed = 1 << 1 , Feed = 1 << 1
, Pad = 1 << 2 , Pad = 1 << 2
, GDS = 1 << 3 , GDS = 1 << 3
, Delete = 1 << 4 , Delete = 1 << 4
, Logical = 1 << 5 , Logical = 1 << 5
, Physical = 1 << 6 , Physical = 1 << 6
, InMemory = 1 << 7 , InMemory = 1 << 7
, Foreign = 1 << 8 , Foreign = 1 << 8
, VstUseConcat = 1 << 9 , VstUseConcat = 1 << 9
, VstNoLowerCase = 1 << 10 , VstNoLowerCase = 1 << 10
, VstNoLinkage = 1 << 11 , VstUniquifyUpperCase = 1 << 11
, Views = Physical|Logical , VstNoLinkage = 1 << 12
, Views = Physical|Logical
}; };
// Constructors. // Constructors.
inline State (); inline State ();
@ -436,6 +435,3 @@ inline std::string getPrint ( const CRL::Catalog &CATAL ) { return CATAL._getPr
INSPECTOR_P_SUPPORT(CRL::Catalog); INSPECTOR_P_SUPPORT(CRL::Catalog);
INSPECTOR_P_SUPPORT(CRL::Catalog::State); INSPECTOR_P_SUPPORT(CRL::Catalog::State);
#endif // CRL_CATALOG_H

View File

@ -65,19 +65,21 @@ namespace CRL {
class NamingScheme { class NamingScheme {
public: public:
enum Flag { NoFlags = 0x0000 enum Flag { NoFlags = 0x0000
, Recursive = 0x0001 , Recursive = 0x0001
, FromVerilog = 0x0002 , FromVerilog = 0x0002
, NoLowerCase = 0x0004 , NoLowerCase = 0x0004
, UniquifyUpperCase = 0x0008
}; };
public: public:
typedef std::function< Name(const Name&,uint32_t) > converter_t; typedef std::function< Name(const Name&,uint32_t) > converter_t;
public: public:
static Name vlogToVhdl ( const Name& vlogName, uint32_t flags ); static Name vlogToVhdl ( const Name& vlogName, uint32_t flags );
static void toVhdl ( Cell* topCell, uint32_t flags ); static void toVhdl ( Cell* topCell, uint32_t flags );
NamingScheme ( uint32_t flags ); NamingScheme ( uint32_t flags );
inline void setNoLowerCase ( bool state ); inline void setNoLowerCase ( bool state );
Name convert ( const Name& ) const; inline void setUniquifyUpperCase ( bool state );
Name convert ( const Name& ) const;
private: private:
uint32_t _flags; uint32_t _flags;
converter_t _converter; converter_t _converter;
@ -91,6 +93,13 @@ namespace CRL {
} }
inline void NamingScheme::setUniquifyUpperCase ( bool state )
{
if (state) _flags |= UniquifyUpperCase;
else _flags &= ~UniquifyUpperCase;
}
// ------------------------------------------------------------------- // -------------------------------------------------------------------
// Class : "CRL::SubNetNames". // Class : "CRL::SubNetNames".

View File

@ -14,9 +14,7 @@
// +-----------------------------------------------------------------+ // +-----------------------------------------------------------------+
#ifndef VHDL_BIT_H #pragma once
#define VHDL_BIT_H
#include <cstddef> #include <cstddef>
#include <string> #include <string>
#include "hurricane/Name.h" #include "hurricane/Name.h"
@ -159,6 +157,3 @@ namespace Vhdl {
INSPECTOR_P_SUPPORT(Vhdl::Bit); INSPECTOR_P_SUPPORT(Vhdl::Bit);
#endif // VHDL_BIT_H

View File

@ -58,18 +58,19 @@ namespace Vhdl {
class Entity { class Entity {
public: public:
enum Flag { NoFlags = 0x0000 enum Flag { NoFlags = 0x0000
, EntityMode = 0x0001 , EntityMode = 0x0001
, IeeeMode = 0x0002 , IeeeMode = 0x0002
, ComponentMode = 0x0004 , ComponentMode = 0x0004
, AsPortSignal = 0x0008 , AsPortSignal = 0x0008
, AsInnerSignal = 0x0010 , AsInnerSignal = 0x0010
, VstUseConcat = 0x0020 , VstUseConcat = 0x0020
, VstNoLowerCase = 0x0040 , VstNoLowerCase = 0x0040
, VstNoLinkage = 0x0080 , VstUniquifyUpperCase = 0x0080
, OptionMask = VstUseConcat|VstNoLowerCase|VstNoLinkage , VstNoLinkage = 0x0100
, OptionMask = VstUseConcat|VstNoLowerCase|VstUniquifyUpperCase|VstNoLinkage
}; };
const unsigned int ModeMask = VstUseConcat|VstNoLowerCase|VstNoLinkage; const unsigned int ModeMask = VstUseConcat|VstNoLowerCase|VstUniquifyUpperCase|VstNoLinkage;
public: public:
static std::vector<Entity*>& static std::vector<Entity*>&
getAllEntities (); getAllEntities ();

View File

@ -14,9 +14,7 @@
// +-----------------------------------------------------------------+ // +-----------------------------------------------------------------+
#ifndef VHDL_SIGNAL_H #pragma once
#define VHDL_SIGNAL_H
#include <set> #include <set>
#include "hurricane/Net.h" #include "hurricane/Net.h"
#include "crlcore/VhdlBit.h" #include "crlcore/VhdlBit.h"
@ -40,6 +38,7 @@ namespace Vhdl {
virtual bool isVector () const = 0; virtual bool isVector () const = 0;
virtual bool isExternal () const = 0; virtual bool isExternal () const = 0;
virtual bool isContiguous () const = 0; virtual bool isContiguous () const = 0;
virtual size_t getSize () const = 0;
inline std::string getName () const; inline std::string getName () const;
virtual const Bit* getBit () const = 0; virtual const Bit* getBit () const = 0;
virtual const Bit* getBit ( size_t ) const = 0; virtual const Bit* getBit ( size_t ) const = 0;
@ -80,6 +79,7 @@ namespace Vhdl {
virtual bool isVector () const; virtual bool isVector () const;
virtual bool isExternal () const; virtual bool isExternal () const;
virtual bool isContiguous () const; virtual bool isContiguous () const;
virtual size_t getSize () const;
virtual const Bit* getBit () const; virtual const Bit* getBit () const;
virtual const Bit* getBit ( size_t ) const; virtual const Bit* getBit ( size_t ) const;
virtual const Net* getNet () const; virtual const Net* getNet () const;
@ -106,6 +106,7 @@ namespace Vhdl {
virtual bool isVector () const; virtual bool isVector () const;
virtual bool isExternal () const; virtual bool isExternal () const;
virtual bool isContiguous () const; virtual bool isContiguous () const;
virtual size_t getSize () const;
virtual const Bit* getBit () const; virtual const Bit* getBit () const;
virtual const Bit* getBit ( size_t ) const; virtual const Bit* getBit ( size_t ) const;
virtual const Net* getNet () const; virtual const Net* getNet () const;
@ -135,5 +136,3 @@ namespace Vhdl {
INSPECTOR_P_SUPPORT(Vhdl::Signal); INSPECTOR_P_SUPPORT(Vhdl::Signal);
INSPECTOR_P_SUPPORT(Vhdl::ScalarSignal); INSPECTOR_P_SUPPORT(Vhdl::ScalarSignal);
INSPECTOR_P_SUPPORT(Vhdl::VectorSignal); INSPECTOR_P_SUPPORT(Vhdl::VectorSignal);
#endif // VHDL_SIGNAL_H

View File

@ -43,6 +43,8 @@ namespace CRL {
if (vlogName[i] == ')') { posRightPar=i; } if (vlogName[i] == ')') { posRightPar=i; }
if (vlogName[i] == ']') { posRightPar=i; } if (vlogName[i] == ']') { posRightPar=i; }
loweredName.push_back( tolower(vlogName[i]) ); loweredName.push_back( tolower(vlogName[i]) );
if ( (flags & UniquifyUpperCase) and (vlogName[i] != tolower(vlogName[i])) )
loweredName.push_back( 'u' );
} }
char leftPar = (parCount > 1) ? '_' : '('; char leftPar = (parCount > 1) ? '_' : '(';
char rightPar = (parCount > 1) ? '_' : ')'; char rightPar = (parCount > 1) ? '_' : ')';
@ -84,7 +86,7 @@ namespace CRL {
if (translated == '_') { if (translated == '_') {
if (vhdlName.empty() ) continue; if (vhdlName.empty() ) continue;
if (i == refName.size()-1) break; if (i == refName.size()-1) break;
//if (vhdlName.back() == '_') continue; if (vhdlName.back() == '_') continue;
} }
vhdlName += translated; vhdlName += translated;

View File

@ -137,18 +137,19 @@ extern "C" {
{ {
PyObject* constant; PyObject* constant;
LoadObjectConstant(PyTypeCatalogState.tp_dict,Catalog::State::TerminalNetlist ,"TerminalNetlist"); LoadObjectConstant(PyTypeCatalogState.tp_dict,Catalog::State::TerminalNetlist ,"TerminalNetlist");
LoadObjectConstant(PyTypeCatalogState.tp_dict,Catalog::State::Feed ,"Feed"); LoadObjectConstant(PyTypeCatalogState.tp_dict,Catalog::State::Feed ,"Feed");
LoadObjectConstant(PyTypeCatalogState.tp_dict,Catalog::State::GDS ,"GDS"); LoadObjectConstant(PyTypeCatalogState.tp_dict,Catalog::State::GDS ,"GDS");
LoadObjectConstant(PyTypeCatalogState.tp_dict,Catalog::State::Delete ,"Delete"); LoadObjectConstant(PyTypeCatalogState.tp_dict,Catalog::State::Delete ,"Delete");
LoadObjectConstant(PyTypeCatalogState.tp_dict,Catalog::State::Logical ,"Logical"); LoadObjectConstant(PyTypeCatalogState.tp_dict,Catalog::State::Logical ,"Logical");
LoadObjectConstant(PyTypeCatalogState.tp_dict,Catalog::State::Physical ,"Physical"); LoadObjectConstant(PyTypeCatalogState.tp_dict,Catalog::State::Physical ,"Physical");
LoadObjectConstant(PyTypeCatalogState.tp_dict,Catalog::State::InMemory ,"InMemory"); LoadObjectConstant(PyTypeCatalogState.tp_dict,Catalog::State::InMemory ,"InMemory");
LoadObjectConstant(PyTypeCatalogState.tp_dict,Catalog::State::Foreign ,"Foreign"); LoadObjectConstant(PyTypeCatalogState.tp_dict,Catalog::State::Foreign ,"Foreign");
LoadObjectConstant(PyTypeCatalogState.tp_dict,Catalog::State::VstUseConcat ,"VstUseConcat"); LoadObjectConstant(PyTypeCatalogState.tp_dict,Catalog::State::VstUseConcat ,"VstUseConcat");
LoadObjectConstant(PyTypeCatalogState.tp_dict,Catalog::State::VstNoLowerCase ,"VstNoLowerCase"); LoadObjectConstant(PyTypeCatalogState.tp_dict,Catalog::State::VstNoLowerCase ,"VstNoLowerCase");
LoadObjectConstant(PyTypeCatalogState.tp_dict,Catalog::State::VstNoLinkage ,"VstNoLinkage"); LoadObjectConstant(PyTypeCatalogState.tp_dict,Catalog::State::VstUniquifyUpperCase,"VstUniquifyUpperCase");
LoadObjectConstant(PyTypeCatalogState.tp_dict,Catalog::State::Views ,"Views"); LoadObjectConstant(PyTypeCatalogState.tp_dict,Catalog::State::VstNoLinkage ,"VstNoLinkage");
LoadObjectConstant(PyTypeCatalogState.tp_dict,Catalog::State::Views ,"Views");
} }

View File

@ -51,6 +51,8 @@ def rsave ( cell, views=CRL.Catalog.State.Physical, depth=0 ):
sviews += ' uses &' sviews += ' uses &'
if views & CRL.Catalog.State.VstNoLowerCase: if views & CRL.Catalog.State.VstNoLowerCase:
if sviews: sviews += ', no lowercase' if sviews: sviews += ', no lowercase'
if views & CRL.Catalog.State.VstUniquifyUpperCase:
if sviews: sviews += ', uniquify uppercase'
if views & CRL.Catalog.State.VstNoLinkage: if views & CRL.Catalog.State.VstNoLinkage:
if sviews: sviews += ', no linkage' if sviews: sviews += ', no linkage'
sviews += '' sviews += ''

View File

@ -1,10 +1,11 @@
#!/usr/bin/env python #!/usr/bin/env python
from __future__ import print_function
import sys
import traceback
import os.path
import optparse
try: try:
import sys
import traceback
import os.path
import optparse
import helpers import helpers
from helpers import showPythonTrace from helpers import showPythonTrace
from helpers.io import ErrorMessage, catch from helpers.io import ErrorMessage, catch
@ -24,34 +25,37 @@ except Exception, e:
framework = CRL.AllianceFramework.get() framework = CRL.AllianceFramework.get()
def renameNMigen( occurrence ):
masterCell = occurrence.getEntity().getMasterCell()
origName = masterCell.getName()
replName = origName.replace( '$$', '_unm' )
if not masterCell.isTerminalNetlist() and not replName.startswith('cmpt_'):
replName = 'cmpt_' + replName
#for letter in 'ABCDEFGHIJKLMNOPQRSTUVWXYZ':
# replName = replName.replace(letter, '{}u'.format(letter))
if origName != replName:
print( ' - "{}" => "{}"'.format(origName,replName) )
masterCell.setName( replName )
def renameNMigenUniquify ( topCell ): def renameNMigenUniquify ( topCell ):
for occurrence in topCell.getTerminalNetlistInstanceOccurrences(): for occurrence in topCell.getTerminalNetlistInstanceOccurrences():
masterCell = occurrence.getEntity().getMasterCell() renameNMigen(occurrence)
origName = masterCell.getName()
replName = origName.replace( '$$', '_unm' )
if origName != replName:
print ' - "%s" => "%s"' % (origName,replName)
masterCell.setName( replName )
for occurrence in topCell.getNonTerminalNetlistInstanceOccurrences(): for occurrence in topCell.getNonTerminalNetlistInstanceOccurrences():
masterCell = occurrence.getEntity().getMasterCell() renameNMigen(occurrence)
origName = masterCell.getName()
replName = origName.replace( '$$', '_unm' )
if origName != replName:
print ' - "%s" => "%s"' % (origName,replName)
masterCell.setName( replName )
return return
if __name__ == '__main__': if __name__ == '__main__':
parser = optparse.OptionParser() parser = optparse.OptionParser()
parser.add_option( '-c', '--cell' , type='string' , dest='cellName' , help='The name of the BLIF to convert, without extension.') parser.add_option( '-c', '--cell' , type='string' , dest='cellName' , help='The name of the BLIF to convert, without extension.')
parser.add_option( '-v', '--verbose' , action='store_true', dest='verbose' , help='First level of verbosity.') parser.add_option( '-v', '--verbose' , action='store_true', dest='verbose' , help='First level of verbosity.')
parser.add_option( '-V', '--very-verbose' , action='store_true', dest='veryVerbose' , help='Second level of verbosity.') parser.add_option( '-V', '--very-verbose' , action='store_true', dest='veryVerbose' , help='Second level of verbosity.')
parser.add_option( '--vst-use-concat' , action='store_true', dest='vstUseConcat' , help='The VST driver will use "&" (concat) in PORT MAP.') parser.add_option( '--vst-use-concat' , action='store_true', dest='vstUseConcat' , help='The VST driver will use "&" (concat) in PORT MAP.')
parser.add_option( '--vst-no-lowercase', action='store_true', dest='vstNoLowerCase', help='The VST will keep the case of all identifiers.') parser.add_option( '--vst-no-lowercase' , action='store_true', dest='vstNoLowerCase' , help='The VST will keep the case of all identifiers.')
parser.add_option( '--vst-no-linkage' , action='store_true', dest='vstNoLinkage' , help='Undefined direction will be set to "in" instead of "linkage".') parser.add_option( '--vst-uniquify-uppercase', action='store_true', dest='vstUniquifyUpperCase', help='The uppercase identifiers will be uniquified.')
parser.add_option( '--vst-no-linkage' , action='store_true', dest='vstNoLinkage' , help='Undefined direction will be set to "in" instead of "linkage".')
(options, args) = parser.parse_args() (options, args) = parser.parse_args()
views = CRL.Catalog.State.Logical views = CRL.Catalog.State.Logical
@ -60,13 +64,14 @@ if __name__ == '__main__':
if options.veryVerbose: if options.veryVerbose:
Cfg.getParamBool('misc.verboseLevel1').setBool(True) Cfg.getParamBool('misc.verboseLevel1').setBool(True)
Cfg.getParamBool('misc.verboseLevel2').setBool(True) Cfg.getParamBool('misc.verboseLevel2').setBool(True)
if options.vstUseConcat: views |= CRL.Catalog.State.VstUseConcat if options.vstUseConcat: views |= CRL.Catalog.State.VstUseConcat
if options.vstNoLowerCase: views |= CRL.Catalog.State.VstNoLowerCase if options.vstNoLowerCase: views |= CRL.Catalog.State.VstNoLowerCase
if options.vstNoLinkage: views |= CRL.Catalog.State.VstNoLinkage if options.vstUniquifyUpperCase: views |= CRL.Catalog.State.VstUniquifyUpperCase
if options.vstNoLinkage: views |= CRL.Catalog.State.VstNoLinkage
cell = CRL.Blif.load( options.cellName ) cell = CRL.Blif.load( options.cellName )
if cell.getName() == 'top': if cell.getName() == 'top':
print ' o Renaming RTLIL anonymous top cell "top" into "%s".' % options.cellName print( ' o Renaming RTLIL anonymous top cell "top" into "{}".'.format(options.cellName) )
cell.setName( options.cellName ) cell.setName( options.cellName )
renameNMigenUniquify( cell ) renameNMigenUniquify( cell )
CRL.restoreNetsDirection( cell, Cell.Flags_TerminalNetlist ) CRL.restoreNetsDirection( cell, Cell.Flags_TerminalNetlist )

View File

@ -66,6 +66,7 @@ class Yosys ( object ):
'yosys hierarchy -top %(designTop)s\n' 'yosys hierarchy -top %(designTop)s\n'
tclScript += 'yosys dfflibmap -liberty %(libertyFile)s\n' \ tclScript += 'yosys dfflibmap -liberty %(libertyFile)s\n' \
'yosys memorydff\n' \
'yosys abc -liberty %(libertyFile)s\n' \ 'yosys abc -liberty %(libertyFile)s\n' \
'yosys clean\n' \ 'yosys clean\n' \
'yosys write_blif %(designName)s.blif\n' 'yosys write_blif %(designName)s.blif\n'

View File

@ -727,16 +727,19 @@ Entity* Cell::getEntity(const Signature& signature) const
return NULL; return NULL;
} }
Net* Cell::getNet ( const Name& name ) const Net* Cell::getNet ( const Name& name, bool useAlias ) const
//****************************************** //*********************************************************
{ {
Net* net = _netMap.getElement(name); Net* net = _netMap.getElement(name);
if (net) return net; if (net) return net;
NetAliasName key(name); NetAliasName key(name);
AliasNameSet::iterator ialias = _netAliasSet.find( &key ); AliasNameSet::iterator ialias = _netAliasSet.find( &key );
if (ialias != _netAliasSet.end()) if (ialias != _netAliasSet.end()) {
if (not (useAlias or (*ialias)->isExternal()))
return NULL;
return (*ialias)->getNet(); return (*ialias)->getNet();
}
return NULL; return NULL;
} }

View File

@ -526,10 +526,24 @@ bool Net::hasAlias(const Name& name) const
return false; return false;
} }
bool Net::addAlias(const Name& name) NetAliasHook* Net::getAlias(const Name& name) const
// ********************************* // ************************************************
{ {
if (hasAlias(name)) return true; if (name == _name) return dynamic_cast<NetAliasHook*>( const_cast<NetMainName*>( &_mainName ));
for ( NetAliasHook* alias : getAliases() ) {
if (alias->getName() == name) return alias;
}
return NULL;
}
bool Net::addAlias(const Name& name, bool isExternal )
// ***************************************************
{
NetAliasHook* alias = getAlias( name );
if (alias) {
if (isExternal) alias->setExternal( true );
return true;
}
if (getCell()->getNet(name)) { if (getCell()->getNet(name)) {
cerr << Warning( "Net::addAlias(): Cannot add alias %s to net %s, already taken." cerr << Warning( "Net::addAlias(): Cannot add alias %s to net %s, already taken."
@ -539,7 +553,7 @@ bool Net::addAlias(const Name& name)
return false; return false;
} }
NetAliasName* slave = new NetAliasName ( name ); NetAliasName* slave = new NetAliasName ( name, isExternal );
_mainName.attach( slave ); _mainName.attach( slave );
getCell()->_addNetAlias( slave ); getCell()->_addNetAlias( slave );
@ -677,19 +691,22 @@ void Net::merge(Net* net)
} }
} }
Name mergedName = net->getName(); bool mergedExternal = net->isExternal();
Name mergedName = net->getName();
NetAliasName* slaves = NULL; NetAliasName* slaves = NULL;
if (net->_mainName.isAttached()) { if (net->_mainName.isAttached()) {
slaves = dynamic_cast<NetAliasName*>( net->_mainName.getNext() ); slaves = dynamic_cast<NetAliasName*>( net->_mainName.getNext() );
net->_mainName.detach(); net->_mainName.detach();
} }
if (net->isExternal() and not isExternal()) if (mergedExternal and not isExternal()) {
setExternal( true ); setExternal( true );
}
net->destroy(); net->destroy();
if (slaves) _mainName.attach( slaves ); if (slaves) _mainName.attach( slaves );
addAlias( mergedName ); addAlias( mergedName, mergedExternal );
} }
void Net::_postCreate() void Net::_postCreate()
@ -711,6 +728,8 @@ void Net::_preDestroy()
// ******************* // *******************
{ {
cdebug_log(18,1) << "entering Net::_preDestroy: " << this << endl; cdebug_log(18,1) << "entering Net::_preDestroy: " << this << endl;
if (getName() == "pipe_middle_0_rb[0]")
cerr << "entering Net::_preDestroy: " << this << endl;
Inherit::_preDestroy(); Inherit::_preDestroy();

View File

@ -158,19 +158,22 @@ namespace Hurricane {
} }
bool NetMainName::isMaster () const { return true; } bool NetMainName::isMaster () const { return true; }
bool NetMainName::isSlave () const { return false; } bool NetMainName::isSlave () const { return false; }
Name NetMainName::getName () const { return getNet()->getName(); } bool NetMainName::isExternal () const { return getNet()->isExternal(); }
Net* NetMainName::getNet () const { return (Net*)((ptrdiff_t)this - _offset); } Name NetMainName::getName () const { return getNet()->getName(); }
string NetMainName::_getString () const { return "<NetMainName " + getString(getName()) + ">"; } Net* NetMainName::getNet () const { return (Net*)((ptrdiff_t)this - _offset); }
string NetMainName::_getString () const { return "<NetMainName " + getString(getName()) + ">"; }
void NetMainName::setExternal ( bool state ) { getNet()->setExternal(state); }
// ------------------------------------------------------------------- // -------------------------------------------------------------------
// Class : "Hurricane::NetAliasName". // Class : "Hurricane::NetAliasName".
NetAliasName::NetAliasName ( Name name ) NetAliasName::NetAliasName ( Name name, bool isExternal )
: NetAliasHook() : NetAliasHook()
, _name (name) , _name (name)
, _isExternal (isExternal)
{ } { }
@ -182,9 +185,11 @@ namespace Hurricane {
} }
bool NetAliasName::isMaster () const { return false; } bool NetAliasName::isMaster () const { return false; }
bool NetAliasName::isSlave () const { return true; } bool NetAliasName::isSlave () const { return true; }
Name NetAliasName::getName () const { return _name; } bool NetAliasName::isExternal () const { return _isExternal; }
Name NetAliasName::getName () const { return _name; }
void NetAliasName::setExternal ( bool state ) { _isExternal=state; }
Net* NetAliasName::getNet () const Net* NetAliasName::getNet () const
@ -206,7 +211,8 @@ namespace Hurricane {
{ {
Record* record = NetAliasHook::_getRecord(); Record* record = NetAliasHook::_getRecord();
if (record) { if (record) {
record->add ( getSlot("_name", &_name) ); record->add ( getSlot("_name" , &_name ) );
record->add ( getSlot("_isExternal", &_isExternal) );
} }
return record; return record;
} }

View File

@ -431,7 +431,7 @@ class Cell : public Entity {
public: Instances getTerminalNetlistInstancesUnder(const Box& area) const; public: Instances getTerminalNetlistInstancesUnder(const Box& area) const;
public: Instances getNonTerminalNetlistInstances() const; public: Instances getNonTerminalNetlistInstances() const;
public: Instances getNonTerminalNetlistInstancesUnder(const Box& area) const; public: Instances getNonTerminalNetlistInstancesUnder(const Box& area) const;
public: Net* getNet(const Name& name) const; public: Net* getNet(const Name& name, bool useAlias=true) const;
public: DeepNet* getDeepNet( Path, const Net* ) const; public: DeepNet* getDeepNet( Path, const Net* ) const;
public: Nets getNets() const {return _netMap.getElements();}; public: Nets getNets() const {return _netMap.getElements();};
public: Nets getGlobalNets() const; public: Nets getGlobalNets() const;

View File

@ -210,18 +210,19 @@ class Net : public Entity {
// Predicates // Predicates
// ********** // **********
public: virtual bool isDeepNet () const {return false;}; public: virtual bool isDeepNet () const {return false;};
public: bool isGlobal () const {return _isGlobal;}; public: bool isGlobal () const {return _isGlobal;};
public: bool isExternal () const {return _isExternal;}; public: bool isExternal () const {return _isExternal;};
public: bool isAutomatic() const {return _isAutomatic;}; public: bool isAutomatic() const {return _isAutomatic;};
public: bool isBlockage () const {return (_type == Type::BLOCKAGE);}; public: bool isBlockage () const {return (_type == Type::BLOCKAGE);};
public: bool isFused () const {return (_type == Type::FUSED);}; public: bool isFused () const {return (_type == Type::FUSED);};
public: bool isLogical () const {return (_type == Type::LOGICAL);}; public: bool isLogical () const {return (_type == Type::LOGICAL);};
public: bool isClock () const {return (_type == Type::CLOCK);}; public: bool isClock () const {return (_type == Type::CLOCK);};
public: bool isPower () const {return (_type == Type::POWER);}; public: bool isPower () const {return (_type == Type::POWER);};
public: bool isGround () const {return (_type == Type::GROUND);}; public: bool isGround () const {return (_type == Type::GROUND);};
public: bool isSupply () const {return (isPower() || isGround());}; public: bool isSupply () const {return (isPower() || isGround());};
public: bool hasAlias (const Name& name) const; public: bool hasAlias (const Name& ) const;
public: NetAliasHook* getAlias (const Name& ) const;
// Updators // Updators
// ******** // ********
@ -237,7 +238,7 @@ class Net : public Entity {
public: void setRoutingState(uint32_t state); public: void setRoutingState(uint32_t state);
public: void materialize(); public: void materialize();
public: void unmaterialize(); public: void unmaterialize();
public: bool addAlias(const Name& name); public: bool addAlias(const Name& name, bool isExternal=false);
public: bool removeAlias(const Name& name); public: bool removeAlias(const Name& name);
public: void merge(Net* net); public: void merge(Net* net);
public: Net* getClone(Cell* cloneCell); public: Net* getClone(Cell* cloneCell);

View File

@ -52,6 +52,7 @@ namespace Hurricane {
bool isAttached () const; bool isAttached () const;
virtual bool isMaster () const = 0; virtual bool isMaster () const = 0;
virtual bool isSlave () const = 0; virtual bool isSlave () const = 0;
virtual bool isExternal () const = 0;
virtual Name getName () const = 0; virtual Name getName () const = 0;
virtual Net* getNet () const = 0; virtual Net* getNet () const = 0;
NetAliasHook* getNext () const; NetAliasHook* getNext () const;
@ -60,6 +61,7 @@ namespace Hurricane {
void attach ( NetAliasHook* ); void attach ( NetAliasHook* );
void detach (); void detach ();
void detachAll (); void detachAll ();
virtual void setExternal ( bool ) = 0;
inline void toJson ( JsonWriter* ) const; inline void toJson ( JsonWriter* ) const;
virtual std::string _getString () const = 0; virtual std::string _getString () const = 0;
virtual Record* _getRecord () const; virtual Record* _getRecord () const;
@ -81,9 +83,11 @@ namespace Hurricane {
public: public:
virtual bool isMaster () const; virtual bool isMaster () const;
virtual bool isSlave () const; virtual bool isSlave () const;
virtual bool isExternal () const;
virtual Name getName () const; virtual Name getName () const;
virtual Net* getNet () const; virtual Net* getNet () const;
virtual std::string _getString () const; virtual std::string _getString () const;
virtual void setExternal ( bool state );
void clear (); void clear ();
public: public:
NetMainName ( Net* ); NetMainName ( Net* );
@ -108,19 +112,22 @@ namespace Hurricane {
public: public:
virtual bool isMaster () const; virtual bool isMaster () const;
virtual bool isSlave () const; virtual bool isSlave () const;
virtual bool isExternal () const;
virtual Name getName () const; virtual Name getName () const;
virtual Net* getNet () const; virtual Net* getNet () const;
virtual void toJson ( JsonWriter* ) const; virtual void toJson ( JsonWriter* ) const;
virtual void setExternal ( bool );
virtual std::string _getString () const; virtual std::string _getString () const;
virtual Record* _getRecord () const; virtual Record* _getRecord () const;
public: public:
NetAliasName ( Name ); NetAliasName ( Name, bool isExternal=false );
virtual ~NetAliasName (); virtual ~NetAliasName ();
private: private:
NetAliasName ( const NetAliasName& ); NetAliasName ( const NetAliasName& );
NetAliasName& operator= ( const NetAliasName& ); NetAliasName& operator= ( const NetAliasName& );
private: private:
Name _name; Name _name;
bool _isExternal;
}; };