diff --git a/crlcore/src/ccore/alliance/vst/VhdlEntity.cpp b/crlcore/src/ccore/alliance/vst/VhdlEntity.cpp index 1d8fb6c2..d0684de1 100644 --- a/crlcore/src/ccore/alliance/vst/VhdlEntity.cpp +++ b/crlcore/src/ccore/alliance/vst/VhdlEntity.cpp @@ -105,6 +105,7 @@ namespace Vhdl { , _globals() , _flags (flags) { + if (flags & VstNoLowerCase) _ns.setNoLowerCase( true ); if (not _offset) { //_offset = offsetof(EntityProperty,_entity); _offset = (ptrdiff_t)this - (ptrdiff_t)property; @@ -133,7 +134,7 @@ namespace Vhdl { signal->addNet( index, net ); _signals.insert( signal ); } else { - ScalarSignal* signal = new ScalarSignal(net); + ScalarSignal* signal = new ScalarSignal(stem,net); _signals.insert( signal ); if (net->isGlobal()) _globals.insert( signal ); @@ -229,7 +230,7 @@ namespace Vhdl { signal->addNet( index, net ); _signals.insert( signal ); } else { - _signals.insert( new ScalarSignal(net) ); + _signals.insert( new ScalarSignal(stem,net) ); } } } @@ -324,6 +325,12 @@ namespace Vhdl { out << "-- Coriolis Structural VHDL Driver\n"; out << "-- Generated on " << stamp << "\n"; out << "-- \n"; + if (_flags & OptionMask) { + out << "-- Genarated with options:\n"; + if (_flags & VstUseConcat) out << "-- * VstUseConcat: Use concat (&) in port map.\n"; + if (_flags & VstNoLowerCase) out << "-- * VstNoLowerCase: Identifiers are *not* put in lowercase.\n"; + out << "-- \n"; + } if (isIeeeMode()) { out << "-- VHDL IEEE compliant.\n"; } else { diff --git a/crlcore/src/ccore/alliance/vst/VhdlSignal.cpp b/crlcore/src/ccore/alliance/vst/VhdlSignal.cpp index e7bed529..f154e764 100644 --- a/crlcore/src/ccore/alliance/vst/VhdlSignal.cpp +++ b/crlcore/src/ccore/alliance/vst/VhdlSignal.cpp @@ -96,8 +96,8 @@ namespace Vhdl { // Class : "Vhdl::ScalarSignal". - ScalarSignal::ScalarSignal ( Net* net ) - : Signal(getString(net->getName())) + ScalarSignal::ScalarSignal ( string vhdlName, Net* net ) + : Signal(vhdlName) , _bit (BitExtension::create(net,this)) { } diff --git a/crlcore/src/ccore/alliance/vst/VstDriver.cpp b/crlcore/src/ccore/alliance/vst/VstDriver.cpp index 8fb670ff..c8190034 100644 --- a/crlcore/src/ccore/alliance/vst/VstDriver.cpp +++ b/crlcore/src/ccore/alliance/vst/VstDriver.cpp @@ -15,6 +15,7 @@ #include +#include #include "hurricane/Warning.h" #include "hurricane/Cell.h" #include "hurricane/Net.h" @@ -39,16 +40,36 @@ namespace CRL { void vstDriver ( const string cellPath, Cell *cell, unsigned int& saveState ) { 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; //NamingScheme::toVhdl( cell, NamingScheme::FromVerilog ); Vhdl::Entity* vhdlEntity = Vhdl::EntityExtension::create( cell, entityFlags ); - string celltest = cellPath; - ofstream ccelltest ( celltest.c_str() ); - vhdlEntity->toEntity( ccelltest ); - ccelltest << endl; - ccelltest.close(); + string celltest = cellPath; + if (not (saveState & Catalog::State::VstNoLowerCase)) { + size_t slash = cellPath.find_last_of( "/" ); + size_t dot = cellPath.find_last_of( "." ); + string path = ""; + string file = ""; + string ext = cellPath.substr( dot+1 ); + if (slash != string::npos) { + path = cellPath.substr( 0, slash ); + file = cellPath.substr( slash+1, dot-slash-1 ); + } else { + file = cellPath; + } + NamingScheme ns (NamingScheme::FromVerilog); + file = getString( ns.convert(file) ); + celltest = path + '/' + file + '.' + ext; + + if (cellPath != celltest) remove( cellPath.c_str() ); + } + ofstream cellStream ( celltest.c_str() ); + + vhdlEntity->toEntity( cellStream ); + cellStream << endl; + cellStream.close(); Vhdl::EntityExtension::destroy( cell ); } diff --git a/crlcore/src/ccore/alliance/vst/VstParserScanner.ll b/crlcore/src/ccore/alliance/vst/VstParserScanner.ll index 3c5fd864..3131d56d 100644 --- a/crlcore/src/ccore/alliance/vst/VstParserScanner.ll +++ b/crlcore/src/ccore/alliance/vst/VstParserScanner.ll @@ -229,7 +229,10 @@ base_specifier (B|b|O|o|X|x) \/ { return Slash; } {letter}(_?{letter_or_digit})* { - VHDLKeywords::iterator it = vhdlKeywords.find( lower(yytext) ); + char keyword[512]; + strncpy( keyword, yytext, 511 ); + lower( keyword ); + VHDLKeywords::iterator it = vhdlKeywords.find( keyword ); if (it != vhdlKeywords.end()) { return it->second; } VSTlval._text = Vst::states->addLexIdentifier( yytext ); return Identifier; diff --git a/crlcore/src/ccore/blif/BlifParser.cpp b/crlcore/src/ccore/blif/BlifParser.cpp index c8a495c1..4f9504f3 100644 --- a/crlcore/src/ccore/blif/BlifParser.cpp +++ b/crlcore/src/ccore/blif/BlifParser.cpp @@ -431,7 +431,9 @@ namespace { { for ( Model* model : _blifOrder ) CRL::NamingScheme::toVhdl( model->getCell() - , CRL::NamingScheme::Recursive|CRL::NamingScheme::FromVerilog ); + , CRL::NamingScheme::Recursive + | CRL::NamingScheme::FromVerilog + | CRL::NamingScheme::NoLowerCase ); } diff --git a/crlcore/src/ccore/crlcore/Catalog.h b/crlcore/src/ccore/crlcore/Catalog.h index 747e1dc1..18fbcbae 100644 --- a/crlcore/src/ccore/crlcore/Catalog.h +++ b/crlcore/src/ccore/crlcore/Catalog.h @@ -87,6 +87,7 @@ namespace CRL { , InMemory = 1 << 7 , Foreign = 1 << 8 , VstUseConcat = 1 << 9 + , VstNoLowerCase = 1 << 10 , Views = Physical|Logical }; // Constructors. diff --git a/crlcore/src/ccore/crlcore/ToolBox.h b/crlcore/src/ccore/crlcore/ToolBox.h index 961097e9..d3172396 100644 --- a/crlcore/src/ccore/crlcore/ToolBox.h +++ b/crlcore/src/ccore/crlcore/ToolBox.h @@ -65,19 +65,29 @@ namespace CRL { enum Flag { NoFlags = 0x0000 , Recursive = 0x0001 , FromVerilog = 0x0002 + , NoLowerCase = 0x0004 }; public: - typedef std::function< Name(const Name&) > converter_t; + typedef std::function< Name(const Name&,uint32_t) > converter_t; public: - static Name vlogToVhdl ( const Name& vlogName ); - static void toVhdl ( Cell* topCell, unsigned int flags ); - NamingScheme ( unsigned int flags ); - Name convert ( const Name& ) const; + static Name vlogToVhdl ( const Name& vlogName, uint32_t flags ); + static void toVhdl ( Cell* topCell, uint32_t flags ); + NamingScheme ( uint32_t flags ); + inline void setNoLowerCase ( bool state ); + Name convert ( const Name& ) const; private: + uint32_t _flags; converter_t _converter; }; + inline void NamingScheme::setNoLowerCase ( bool state ) + { + if (state) _flags |= NoLowerCase; + else _flags &= ~NoLowerCase; + } + + } // CRL namespace. #endif // CRL_TOOLBOX_H diff --git a/crlcore/src/ccore/crlcore/VhdlEntity.h b/crlcore/src/ccore/crlcore/VhdlEntity.h index a5da68a6..991e92ae 100644 --- a/crlcore/src/ccore/crlcore/VhdlEntity.h +++ b/crlcore/src/ccore/crlcore/VhdlEntity.h @@ -58,15 +58,17 @@ namespace Vhdl { class Entity { public: - enum Flag { NoFlags = 0x0000 - , EntityMode = 0x0001 - , IeeeMode = 0x0002 - , ComponentMode = 0x0004 - , AsPortSignal = 0x0008 - , AsInnerSignal = 0x0010 - , VstUseConcat = 0x0020 + enum Flag { NoFlags = 0x0000 + , EntityMode = 0x0001 + , IeeeMode = 0x0002 + , ComponentMode = 0x0004 + , AsPortSignal = 0x0008 + , AsInnerSignal = 0x0010 + , VstUseConcat = 0x0020 + , VstNoLowerCase = 0x0040 + , OptionMask = VstUseConcat|VstNoLowerCase }; - const unsigned int ModeMask = VstUseConcat; + const unsigned int ModeMask = VstUseConcat|VstNoLowerCase; public: static std::vector& getAllEntities (); diff --git a/crlcore/src/ccore/crlcore/VhdlSignal.h b/crlcore/src/ccore/crlcore/VhdlSignal.h index b22fa60f..b78ef112 100644 --- a/crlcore/src/ccore/crlcore/VhdlSignal.h +++ b/crlcore/src/ccore/crlcore/VhdlSignal.h @@ -74,7 +74,7 @@ namespace Vhdl { class ScalarSignal : public Signal { public: - ScalarSignal ( Net* ); + ScalarSignal ( std::string vhdlName, Net* ); virtual ~ScalarSignal (); virtual bool isScalar () const; virtual bool isVector () const; diff --git a/crlcore/src/ccore/toolbox/NamingScheme.cpp b/crlcore/src/ccore/toolbox/NamingScheme.cpp index 0c904bf6..e14c317e 100644 --- a/crlcore/src/ccore/toolbox/NamingScheme.cpp +++ b/crlcore/src/ccore/toolbox/NamingScheme.cpp @@ -29,17 +29,10 @@ namespace CRL { using Hurricane::Instance; - Name NamingScheme::vlogToVhdl ( const Name& vlogName ) + Name NamingScheme::vlogToVhdl ( const Name& vlogName, uint32_t flags ) { string vhdlName; - - // VHDL reserved keywords (scalar). - if (vlogName == Name("in" )) return "in_v"; - if (vlogName == Name("out" )) return "out_v"; - if (vlogName == Name("inout")) return "inout_v"; - if (vlogName == Name("true" )) return "bool_true"; - if (vlogName == Name("false")) return "bool_false"; - if (vlogName == Name("undef")) return "bool_undef"; + string loweredName; size_t parCount = 0; size_t posLeftPar = 0; @@ -49,6 +42,7 @@ namespace CRL { if (vlogName[i] == '[') { ++parCount; posLeftPar=i; } if (vlogName[i] == ')') { posRightPar=i; } if (vlogName[i] == ']') { posRightPar=i; } + loweredName.push_back( tolower(vlogName[i]) ); } char leftPar = (parCount > 1) ? '_' : '('; char rightPar = (parCount > 1) ? '_' : ')'; @@ -62,8 +56,17 @@ namespace CRL { } } - for ( size_t i=0 ; isetName( converter(topCell->getName()) ); + topCell->setName( converter(topCell->getName(),flags) ); vector nets; for ( Net* net : topCell->getNets() ) nets.push_back( net ); - for ( auto net : nets ) net->setName( converter( net->getName() ) ); + for ( auto net : nets ) net->setName( converter( net->getName(), flags ) ); vector instances; set models; @@ -119,7 +122,7 @@ namespace CRL { instances.push_back( inst ); models.insert( inst->getMasterCell() ); } - for ( auto inst : instances ) inst->setName( converter( inst->getName() ) ); + for ( auto inst : instances ) inst->setName( converter( inst->getName(), flags ) ); if (flags & Recursive) for ( auto model : models ) { @@ -128,17 +131,18 @@ namespace CRL { } - NamingScheme::NamingScheme ( unsigned int flags ) - : _converter(nullptr) + NamingScheme::NamingScheme ( uint32_t flags ) + : _flags (flags) + , _converter(nullptr) { - if (flags & FromVerilog) _converter = vlogToVhdl; + if (_flags & FromVerilog) _converter = vlogToVhdl; } Name NamingScheme::convert ( const Name& name ) const { if (_converter == nullptr) return name; - return _converter(name); + return _converter(name,_flags); } diff --git a/crlcore/src/pyCRL/PyCatalog.cpp b/crlcore/src/pyCRL/PyCatalog.cpp index 9db1d02e..e0c73384 100644 --- a/crlcore/src/pyCRL/PyCatalog.cpp +++ b/crlcore/src/pyCRL/PyCatalog.cpp @@ -2,25 +2,17 @@ // -*- C++ -*- // // This file is part of the Coriolis Software. -// Copyright (c) UPMC/LIP6 2010-2010, All Rights Reserved +// Copyright (c) SU/LIP6 2010-2020, All Rights Reserved // -// =================================================================== -// -// $Id$ -// -// x-----------------------------------------------------------------x -// | | +// +-----------------------------------------------------------------+ // | C O R I O L I S | // | Alliance / Hurricane Interface | // | | // | Author : Jean-Paul CHAPUT | -// | E-mail : Jean-Paul.Chaput@asim.lip6.fr | +// | E-mail : Jean-Paul.Chaput@lip6.fr | // | =============================================================== | // | C++ Module : "./PyCatalog.cpp" | -// | *************************************************************** | -// | U p d a t e s | -// | | -// x-----------------------------------------------------------------x +// +-----------------------------------------------------------------+ #include "hurricane/isobar/PyCell.h" diff --git a/crlcore/src/pyCRL/PyCatalogState.cpp b/crlcore/src/pyCRL/PyCatalogState.cpp index 47d24a26..402fe73c 100644 --- a/crlcore/src/pyCRL/PyCatalogState.cpp +++ b/crlcore/src/pyCRL/PyCatalogState.cpp @@ -1,14 +1,14 @@ // -*- C++ -*- // // This file is part of the Coriolis Software. -// Copyright (c) UPMC 2010-2018, All Rights Reserved +// Copyright (c) UPMC 2010-2020, All Rights Reserved // // +-----------------------------------------------------------------+ // | C O R I O L I S | // | Alliance / Hurricane Interface | // | | // | Author : Jean-Paul CHAPUT | -// | E-mail : Jean-Paul.Chaput@asim.lip6.fr | +// | E-mail : Jean-Paul.Chaput@lip6.fr | // | =============================================================== | // | C++ Module : "./PyCatalogState.cpp" | // +-----------------------------------------------------------------+ @@ -146,6 +146,7 @@ extern "C" { LoadObjectConstant(PyTypeCatalogState.tp_dict,Catalog::State::InMemory ,"InMemory"); LoadObjectConstant(PyTypeCatalogState.tp_dict,Catalog::State::Foreign ,"Foreign"); LoadObjectConstant(PyTypeCatalogState.tp_dict,Catalog::State::VstUseConcat ,"VstUseConcat"); + LoadObjectConstant(PyTypeCatalogState.tp_dict,Catalog::State::VstNoLowerCase ,"VstNoLowerCase"); LoadObjectConstant(PyTypeCatalogState.tp_dict,Catalog::State::Views ,"Views"); } diff --git a/cumulus/src/plugins/rsave.py b/cumulus/src/plugins/rsave.py index 7deba8b2..0199d379 100644 --- a/cumulus/src/plugins/rsave.py +++ b/cumulus/src/plugins/rsave.py @@ -48,7 +48,10 @@ def rsave ( cell, views=CRL.Catalog.State.Physical, depth=0 ): sviews += 'netlist' if views & CRL.Catalog.State.VstUseConcat: if sviews: sviews += ',' - sviews += 'VST uses &' + sviews += ' uses &' + if views & CRL.Catalog.State.VstNoLowerCase: + if sviews: sviews += ', no lowercase' + sviews += '' if views & CRL.Catalog.State.Physical: if sviews: sviews += ',' sviews += 'layout' diff --git a/unicorn/src/UnicornGui.cpp b/unicorn/src/UnicornGui.cpp index 9b44ecd1..64237a40 100644 --- a/unicorn/src/UnicornGui.cpp +++ b/unicorn/src/UnicornGui.cpp @@ -98,7 +98,7 @@ namespace Unicorn { _importCell.setDialog( _importDialog ); _importCell.addImporter ( "JSON (experimental)" , std::bind( &Cell::fromJson , placeholders::_1 ) ); - _importCell.addImporter ( "BLIF (Yosys/ABC)" , std::bind( &Blif::load , placeholders::_1, true ) ); + _importCell.addImporter ( "BLIF (Yosys/ABC)" , std::bind( &Blif::load , placeholders::_1, false ) ); _importCell.addImporter ( "ACM/SIGDA (aka MCNC, .bench)", std::bind( &AcmSigda::load , placeholders::_1 ) ); /* Disabled because this is never the one you want _importCell.addImporter ( "ISPD'04 (Bookshelf)" , std::bind( &Ispd04::load , placeholders::_1 ) );