mirror of
https://github.com/YosysHQ/yosys
synced 2025-09-13 05:01:29 +00:00
Use well-known constants in ID macro and make the constant values known at compile time
This commit is contained in:
parent
3d14108a96
commit
23af52c3c8
5 changed files with 294 additions and 172 deletions
|
@ -206,13 +206,13 @@ namespace RTLIL {
|
|||
struct Module;
|
||||
struct Design;
|
||||
struct Monitor;
|
||||
struct Selection;
|
||||
struct Selection;
|
||||
struct SigChunk;
|
||||
enum State : unsigned char;
|
||||
|
||||
typedef std::pair<SigSpec, SigSpec> SigSig;
|
||||
|
||||
namespace ID {}
|
||||
namespace ID {}
|
||||
}
|
||||
|
||||
namespace AST {
|
||||
|
@ -277,16 +277,6 @@ RTLIL::IdString new_id_suffix(std::string file, int line, std::string func, std:
|
|||
#define NEW_ID_SUFFIX(suffix) \
|
||||
YOSYS_NAMESPACE_PREFIX new_id_suffix(__FILE__, __LINE__, __FUNCTION__, suffix)
|
||||
|
||||
// Create a statically allocated IdString object, using for example ID::A or ID($add).
|
||||
//
|
||||
// Recipe for Converting old code that is using conversion of strings like ID::A and
|
||||
// "$add" for creating IdStrings: Run below SED command on the .cc file and then use for
|
||||
// example "meld foo.cc foo.cc.orig" to manually compile errors, if necessary.
|
||||
//
|
||||
// sed -i.orig -r 's/"\\\\([a-zA-Z0-9_]+)"/ID(\1)/g; s/"(\$[a-zA-Z0-9_]+)"/ID(\1)/g;' <filename>
|
||||
//
|
||||
#define ID(_id) ([]() -> const RTLIL::IdString & { const char *p = "\\" #_id, *q = p[1] == '$' ? p+1 : p; \
|
||||
static const YOSYS_NAMESPACE_PREFIX RTLIL::IdString id(q); return id; })()
|
||||
namespace ID = RTLIL::ID;
|
||||
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue