2018-07-21 01:41:18 -05:00
|
|
|
/* -*- c++ -*-
|
2014-07-30 07:10:15 -05:00
|
|
|
* yosys -- Yosys Open SYnthesis Suite
|
|
|
|
*
|
2021-06-07 17:39:36 -05:00
|
|
|
* Copyright (C) 2012 Claire Xenia Wolf <claire@yosyshq.com>
|
2015-07-02 04:14:30 -05:00
|
|
|
*
|
2014-07-30 07:10:15 -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-07-30 07:10:15 -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.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
// *** NOTE TO THE READER ***
|
|
|
|
//
|
|
|
|
// Maybe you have just opened this file in the hope to learn more about the
|
|
|
|
// Yosys API. Let me congratulate you on this great decision! ;)
|
|
|
|
//
|
|
|
|
// If you want to know how the design is represented by Yosys in the memory,
|
|
|
|
// you should read "kernel/rtlil.h".
|
|
|
|
//
|
|
|
|
// If you want to know how to register a command with Yosys, you could read
|
|
|
|
// "kernel/register.h", but it would be easier to just look at a simple
|
|
|
|
// example instead. A simple one would be "passes/cmds/log.cc".
|
2014-07-31 06:19:47 -05:00
|
|
|
//
|
|
|
|
// This header is very boring. It just defines some general things that
|
|
|
|
// belong nowhere else and includes the interesting headers.
|
2014-09-16 04:26:44 -05:00
|
|
|
//
|
2021-03-22 13:16:25 -05:00
|
|
|
// Find more information in the "guidelines/GettingStarted" file.
|
2014-07-30 07:10:15 -05:00
|
|
|
|
|
|
|
|
|
|
|
#ifndef YOSYS_H
|
|
|
|
#define YOSYS_H
|
|
|
|
|
|
|
|
#include <map>
|
|
|
|
#include <set>
|
2015-10-25 13:30:49 -05:00
|
|
|
#include <tuple>
|
2014-07-30 07:10:15 -05:00
|
|
|
#include <vector>
|
|
|
|
#include <string>
|
2014-07-31 06:19:47 -05:00
|
|
|
#include <algorithm>
|
2014-08-16 17:56:47 -05:00
|
|
|
#include <functional>
|
2014-12-26 03:53:21 -06:00
|
|
|
#include <unordered_map>
|
|
|
|
#include <unordered_set>
|
2014-07-30 07:10:15 -05:00
|
|
|
#include <initializer_list>
|
2014-12-28 19:46:59 -06:00
|
|
|
#include <stdexcept>
|
2015-02-21 05:15:41 -06:00
|
|
|
#include <memory>
|
2016-05-08 03:50:39 -05:00
|
|
|
#include <cmath>
|
2019-07-24 06:33:07 -05:00
|
|
|
#include <cstddef>
|
2014-08-02 08:44:10 -05:00
|
|
|
|
2014-08-23 06:54:21 -05:00
|
|
|
#include <sstream>
|
|
|
|
#include <fstream>
|
2014-08-23 08:03:55 -05:00
|
|
|
#include <istream>
|
2014-08-23 06:54:21 -05:00
|
|
|
#include <ostream>
|
|
|
|
#include <iostream>
|
|
|
|
|
2014-08-01 12:43:28 -05:00
|
|
|
#include <stdarg.h>
|
2014-08-02 08:44:10 -05:00
|
|
|
#include <stdlib.h>
|
|
|
|
#include <string.h>
|
2014-10-17 07:01:47 -05:00
|
|
|
#include <stdint.h>
|
2014-08-02 08:44:10 -05:00
|
|
|
#include <stdio.h>
|
2016-10-11 05:12:09 -05:00
|
|
|
#include <limits.h>
|
2014-07-30 07:10:15 -05:00
|
|
|
|
2018-08-20 09:04:43 -05:00
|
|
|
#ifdef WITH_PYTHON
|
2018-08-16 09:00:11 -05:00
|
|
|
#include <Python.h>
|
2018-08-20 09:04:43 -05:00
|
|
|
#endif
|
2018-08-16 09:00:11 -05:00
|
|
|
|
2014-10-14 18:18:31 -05:00
|
|
|
#ifndef _YOSYS_
|
2014-10-17 08:51:33 -05:00
|
|
|
# error It looks like you are trying to build Yosys without the config defines set. \
|
2014-10-14 18:18:31 -05:00
|
|
|
When building Yosys with a custom make system, make sure you set all the \
|
2014-10-17 08:51:33 -05:00
|
|
|
defines the Yosys Makefile would set for your build configuration.
|
2014-10-14 18:18:31 -05:00
|
|
|
#endif
|
|
|
|
|
2014-10-12 05:18:38 -05:00
|
|
|
#ifdef YOSYS_ENABLE_TCL
|
|
|
|
# include <tcl.h>
|
2017-05-17 13:46:22 -05:00
|
|
|
# ifdef YOSYS_MXE_HACKS
|
|
|
|
extern Tcl_Command Tcl_CreateCommand(Tcl_Interp *interp, const char *cmdName, Tcl_CmdProc *proc, ClientData clientData, Tcl_CmdDeleteProc *deleteProc);
|
|
|
|
extern Tcl_Interp *Tcl_CreateInterp(void);
|
|
|
|
extern void Tcl_DeleteInterp(Tcl_Interp *interp);
|
|
|
|
extern int Tcl_Eval(Tcl_Interp *interp, const char *script);
|
|
|
|
extern int Tcl_EvalFile(Tcl_Interp *interp, const char *fileName);
|
|
|
|
extern void Tcl_Finalize(void);
|
|
|
|
extern int Tcl_GetCommandInfo(Tcl_Interp *interp, const char *cmdName, Tcl_CmdInfo *infoPtr);
|
|
|
|
extern const char *Tcl_GetStringResult(Tcl_Interp *interp);
|
2019-07-31 10:30:48 -05:00
|
|
|
extern Tcl_Obj *Tcl_NewStringObj(const char *bytes, int length);
|
|
|
|
extern Tcl_Obj *Tcl_NewIntObj(int intValue);
|
|
|
|
extern Tcl_Obj *Tcl_NewListObj(int objc, Tcl_Obj *const objv[]);
|
|
|
|
extern Tcl_Obj *Tcl_ObjSetVar2(Tcl_Interp *interp, Tcl_Obj *part1Ptr, Tcl_Obj *part2Ptr, Tcl_Obj *newValuePtr, int flags);
|
2017-05-17 13:46:22 -05:00
|
|
|
# endif
|
2020-12-21 15:17:33 -06:00
|
|
|
# undef CONST
|
|
|
|
# undef INLINE
|
2014-10-12 05:18:38 -05:00
|
|
|
#endif
|
|
|
|
|
2014-10-16 11:06:54 -05:00
|
|
|
#ifdef _WIN32
|
2014-10-17 07:01:47 -05:00
|
|
|
# undef NOMINMAX
|
|
|
|
# define NOMINMAX 1
|
|
|
|
# undef YY_NO_UNISTD_H
|
|
|
|
# define YY_NO_UNISTD_H 1
|
|
|
|
|
2014-10-17 05:04:40 -05:00
|
|
|
# include <windows.h>
|
2014-10-16 11:06:54 -05:00
|
|
|
# include <io.h>
|
|
|
|
# include <direct.h>
|
|
|
|
|
|
|
|
# define strtok_r strtok_s
|
|
|
|
# define strdup _strdup
|
|
|
|
# define snprintf _snprintf
|
|
|
|
# define getcwd _getcwd
|
|
|
|
# define mkdir _mkdir
|
|
|
|
# define popen _popen
|
|
|
|
# define pclose _pclose
|
2014-10-17 08:51:33 -05:00
|
|
|
|
|
|
|
# ifndef __MINGW32__
|
2016-05-07 03:53:18 -05:00
|
|
|
# define PATH_MAX MAX_PATH
|
2014-10-17 08:51:33 -05:00
|
|
|
# define isatty _isatty
|
|
|
|
# define fileno _fileno
|
|
|
|
# endif
|
2020-06-17 08:08:55 -05:00
|
|
|
|
2020-12-26 16:21:30 -06:00
|
|
|
// The following defines conflict with our identifiers:
|
|
|
|
# undef CONST
|
|
|
|
// `wingdi.h` defines a TRANSPARENT macro that conflicts with X(TRANSPARENT) entry in kernel/constids.inc
|
2020-06-17 08:08:55 -05:00
|
|
|
# undef TRANSPARENT
|
2014-10-16 11:06:54 -05:00
|
|
|
#endif
|
|
|
|
|
2016-10-11 05:12:09 -05:00
|
|
|
#ifndef PATH_MAX
|
|
|
|
# define PATH_MAX 4096
|
|
|
|
#endif
|
|
|
|
|
2019-04-03 05:21:21 -05:00
|
|
|
#define YOSYS_NAMESPACE Yosys
|
2014-07-31 08:02:16 -05:00
|
|
|
#define PRIVATE_NAMESPACE_BEGIN namespace {
|
|
|
|
#define PRIVATE_NAMESPACE_END }
|
2014-09-27 09:17:53 -05:00
|
|
|
#define YOSYS_NAMESPACE_BEGIN namespace Yosys {
|
|
|
|
#define YOSYS_NAMESPACE_END }
|
|
|
|
#define YOSYS_NAMESPACE_PREFIX Yosys::
|
|
|
|
#define USING_YOSYS_NAMESPACE using namespace Yosys;
|
2014-07-30 07:10:15 -05:00
|
|
|
|
2014-11-09 03:55:04 -06:00
|
|
|
#if defined(__GNUC__) || defined(__clang__)
|
|
|
|
# define YS_ATTRIBUTE(...) __attribute__((__VA_ARGS__))
|
|
|
|
#elif defined(_MSC_VER)
|
|
|
|
# define YS_ATTRIBUTE(...)
|
2014-10-16 11:06:54 -05:00
|
|
|
#else
|
2014-11-09 03:55:04 -06:00
|
|
|
# define YS_ATTRIBUTE(...)
|
2014-10-14 17:56:04 -05:00
|
|
|
#endif
|
|
|
|
|
2021-11-05 04:51:58 -05:00
|
|
|
#if defined(__GNUC__) || defined(__clang__)
|
2020-06-19 10:45:52 -05:00
|
|
|
# define YS_MAYBE_UNUSED __attribute__((__unused__))
|
|
|
|
#else
|
|
|
|
# define YS_MAYBE_UNUSED
|
|
|
|
#endif
|
|
|
|
|
2020-05-04 14:12:30 -05:00
|
|
|
#if __cplusplus >= 201703L
|
|
|
|
# define YS_FALLTHROUGH [[fallthrough]];
|
|
|
|
#elif defined(__clang__)
|
|
|
|
# define YS_FALLTHROUGH [[clang::fallthrough]];
|
2020-05-08 03:13:39 -05:00
|
|
|
#elif defined(__GNUC__)
|
|
|
|
# define YS_FALLTHROUGH [[gnu::fallthrough]];
|
2020-05-04 14:12:30 -05:00
|
|
|
#else
|
|
|
|
# define YS_FALLTHROUGH
|
|
|
|
#endif
|
|
|
|
|
2014-07-30 07:10:15 -05:00
|
|
|
YOSYS_NAMESPACE_BEGIN
|
|
|
|
|
2014-12-28 19:46:59 -06:00
|
|
|
// Note: All headers included in hashlib.h must be included
|
|
|
|
// outside of YOSYS_NAMESPACE before this or bad things will happen.
|
2014-12-28 14:43:14 -06:00
|
|
|
#ifdef HASHLIB_H
|
|
|
|
# undef HASHLIB_H
|
|
|
|
# include "kernel/hashlib.h"
|
|
|
|
#else
|
|
|
|
# include "kernel/hashlib.h"
|
|
|
|
# undef HASHLIB_H
|
|
|
|
#endif
|
|
|
|
|
2014-12-26 04:05:23 -06:00
|
|
|
using std::vector;
|
2014-12-28 10:51:16 -06:00
|
|
|
using std::string;
|
2015-10-25 13:30:49 -05:00
|
|
|
using std::tuple;
|
2014-12-31 15:50:08 -06:00
|
|
|
using std::pair;
|
|
|
|
|
2015-10-25 13:30:49 -05:00
|
|
|
using std::make_tuple;
|
|
|
|
using std::make_pair;
|
2017-07-25 07:52:34 -05:00
|
|
|
using std::get;
|
2015-10-25 13:30:49 -05:00
|
|
|
using std::min;
|
|
|
|
using std::max;
|
|
|
|
|
2015-06-11 06:39:49 -05:00
|
|
|
// A primitive shared string implementation that does not
|
|
|
|
// move its .c_str() when the object is copied or moved.
|
|
|
|
struct shared_str {
|
|
|
|
std::shared_ptr<string> content;
|
|
|
|
shared_str() { }
|
|
|
|
shared_str(string s) { content = std::shared_ptr<string>(new string(s)); }
|
|
|
|
shared_str(const char *s) { content = std::shared_ptr<string>(new string(s)); }
|
2015-06-14 17:46:27 -05:00
|
|
|
const char *c_str() const { return content->c_str(); }
|
|
|
|
const string &str() const { return *content; }
|
|
|
|
bool operator==(const shared_str &other) const { return *content == *other.content; }
|
|
|
|
unsigned int hash() const { return hashlib::hash_ops<std::string>::hash(*content); }
|
2015-06-11 06:39:49 -05:00
|
|
|
};
|
|
|
|
|
2014-12-28 10:51:16 -06:00
|
|
|
using hashlib::mkhash;
|
2014-12-30 11:51:24 -06:00
|
|
|
using hashlib::mkhash_init;
|
2014-12-28 10:51:16 -06:00
|
|
|
using hashlib::mkhash_add;
|
2014-12-28 17:12:36 -06:00
|
|
|
using hashlib::mkhash_xorshift;
|
2014-12-28 10:51:16 -06:00
|
|
|
using hashlib::hash_ops;
|
|
|
|
using hashlib::hash_cstr_ops;
|
|
|
|
using hashlib::hash_ptr_ops;
|
|
|
|
using hashlib::hash_obj_ops;
|
|
|
|
using hashlib::dict;
|
2015-01-18 05:12:33 -06:00
|
|
|
using hashlib::idict;
|
2014-12-28 10:51:16 -06:00
|
|
|
using hashlib::pool;
|
2015-10-27 09:04:47 -05:00
|
|
|
using hashlib::mfp;
|
2014-12-26 03:53:21 -06:00
|
|
|
|
2014-08-01 09:53:15 -05:00
|
|
|
namespace RTLIL {
|
2014-08-01 17:45:25 -05:00
|
|
|
struct IdString;
|
2014-12-28 10:51:16 -06:00
|
|
|
struct Const;
|
2014-12-26 03:53:21 -06:00
|
|
|
struct SigBit;
|
2014-08-01 09:53:15 -05:00
|
|
|
struct SigSpec;
|
|
|
|
struct Wire;
|
|
|
|
struct Cell;
|
2019-11-30 19:51:16 -06:00
|
|
|
struct Memory;
|
2021-07-11 16:57:53 -05:00
|
|
|
struct Process;
|
2014-12-28 10:51:16 -06:00
|
|
|
struct Module;
|
|
|
|
struct Design;
|
|
|
|
struct Monitor;
|
2019-10-02 19:49:07 -05:00
|
|
|
enum State : unsigned char;
|
2014-08-01 09:53:15 -05:00
|
|
|
}
|
|
|
|
|
2014-12-28 20:11:50 -06:00
|
|
|
namespace AST {
|
|
|
|
struct AstNode;
|
|
|
|
}
|
|
|
|
|
2014-12-28 10:51:16 -06:00
|
|
|
using RTLIL::IdString;
|
|
|
|
using RTLIL::Const;
|
|
|
|
using RTLIL::SigBit;
|
|
|
|
using RTLIL::SigSpec;
|
|
|
|
using RTLIL::Wire;
|
|
|
|
using RTLIL::Cell;
|
|
|
|
using RTLIL::Module;
|
|
|
|
using RTLIL::Design;
|
|
|
|
|
2014-12-28 19:46:59 -06:00
|
|
|
namespace hashlib {
|
|
|
|
template<> struct hash_ops<RTLIL::Wire*> : hash_obj_ops {};
|
|
|
|
template<> struct hash_ops<RTLIL::Cell*> : hash_obj_ops {};
|
2019-11-30 19:51:16 -06:00
|
|
|
template<> struct hash_ops<RTLIL::Memory*> : hash_obj_ops {};
|
2021-07-11 16:57:53 -05:00
|
|
|
template<> struct hash_ops<RTLIL::Process*> : hash_obj_ops {};
|
2014-12-28 19:46:59 -06:00
|
|
|
template<> struct hash_ops<RTLIL::Module*> : hash_obj_ops {};
|
|
|
|
template<> struct hash_ops<RTLIL::Design*> : hash_obj_ops {};
|
|
|
|
template<> struct hash_ops<RTLIL::Monitor*> : hash_obj_ops {};
|
2014-12-28 20:11:50 -06:00
|
|
|
template<> struct hash_ops<AST::AstNode*> : hash_obj_ops {};
|
2014-12-28 19:46:59 -06:00
|
|
|
|
|
|
|
template<> struct hash_ops<const RTLIL::Wire*> : hash_obj_ops {};
|
|
|
|
template<> struct hash_ops<const RTLIL::Cell*> : hash_obj_ops {};
|
2019-11-30 19:51:16 -06:00
|
|
|
template<> struct hash_ops<const RTLIL::Memory*> : hash_obj_ops {};
|
2021-07-11 16:57:53 -05:00
|
|
|
template<> struct hash_ops<const RTLIL::Process*> : hash_obj_ops {};
|
2014-12-28 19:46:59 -06:00
|
|
|
template<> struct hash_ops<const RTLIL::Module*> : hash_obj_ops {};
|
|
|
|
template<> struct hash_ops<const RTLIL::Design*> : hash_obj_ops {};
|
|
|
|
template<> struct hash_ops<const RTLIL::Monitor*> : hash_obj_ops {};
|
2014-12-28 20:11:50 -06:00
|
|
|
template<> struct hash_ops<const AST::AstNode*> : hash_obj_ops {};
|
2014-12-28 19:46:59 -06:00
|
|
|
}
|
2014-12-28 10:51:16 -06:00
|
|
|
|
2014-12-28 14:27:51 -06:00
|
|
|
void memhasher_on();
|
|
|
|
void memhasher_off();
|
|
|
|
void memhasher_do();
|
|
|
|
|
|
|
|
extern bool memhasher_active;
|
|
|
|
inline void memhasher() { if (memhasher_active) memhasher_do(); }
|
|
|
|
|
2015-01-31 17:39:59 -06:00
|
|
|
void yosys_banner();
|
2019-05-06 18:33:56 -05:00
|
|
|
int ceil_log2(int x) YS_ATTRIBUTE(const);
|
2014-11-09 03:55:04 -06:00
|
|
|
std::string stringf(const char *fmt, ...) YS_ATTRIBUTE(format(printf, 1, 2));
|
2014-08-01 12:43:28 -05:00
|
|
|
std::string vstringf(const char *fmt, va_list ap);
|
2014-10-23 03:47:21 -05:00
|
|
|
int readsome(std::istream &f, char *s, int n);
|
2015-04-08 05:14:34 -05:00
|
|
|
std::string next_token(std::string &text, const char *sep = " \t\r\n", bool long_strings = false);
|
2015-04-24 15:04:05 -05:00
|
|
|
std::vector<std::string> split_tokens(const std::string &text, const char *sep = " \t\r\n");
|
2014-10-10 11:19:00 -05:00
|
|
|
bool patmatch(const char *pattern, const char *string);
|
2019-11-11 03:23:06 -06:00
|
|
|
#if !defined(YOSYS_DISABLE_SPAWN)
|
2014-10-12 03:57:15 -05:00
|
|
|
int run_command(const std::string &command, std::function<void(const std::string&)> process_line = std::function<void(const std::string&)>());
|
2019-11-11 03:23:06 -06:00
|
|
|
#endif
|
2022-05-23 15:21:45 -05:00
|
|
|
std::string get_base_tmpdir();
|
|
|
|
std::string make_temp_file(std::string template_str = get_base_tmpdir() + "/yosys_XXXXXX");
|
|
|
|
std::string make_temp_dir(std::string template_str = get_base_tmpdir() + "/yosys_XXXXXX");
|
2014-10-17 07:01:47 -05:00
|
|
|
bool check_file_exists(std::string filename, bool is_exec = false);
|
2015-03-22 05:03:56 -05:00
|
|
|
bool is_absolute_path(std::string filename);
|
2014-10-12 05:11:57 -05:00
|
|
|
void remove_directory(std::string dirname);
|
2019-04-29 05:20:33 -05:00
|
|
|
std::string escape_filename_spaces(const std::string& filename);
|
2014-10-10 11:19:00 -05:00
|
|
|
|
2014-10-10 09:59:44 -05:00
|
|
|
template<typename T> int GetSize(const T &obj) { return obj.size(); }
|
2022-07-27 09:15:11 -05:00
|
|
|
inline int GetSize(RTLIL::Wire *wire);
|
2014-07-30 07:10:15 -05:00
|
|
|
|
2014-12-26 20:04:50 -06:00
|
|
|
extern int autoidx;
|
2014-12-29 06:33:33 -06:00
|
|
|
extern int yosys_xtrace;
|
2014-12-26 20:04:50 -06:00
|
|
|
|
2014-07-30 07:10:15 -05:00
|
|
|
YOSYS_NAMESPACE_END
|
|
|
|
|
|
|
|
#include "kernel/log.h"
|
|
|
|
#include "kernel/rtlil.h"
|
|
|
|
#include "kernel/register.h"
|
|
|
|
|
|
|
|
YOSYS_NAMESPACE_BEGIN
|
|
|
|
|
2014-12-31 15:50:08 -06:00
|
|
|
using RTLIL::State;
|
2015-10-25 08:35:40 -05:00
|
|
|
using RTLIL::SigChunk;
|
|
|
|
using RTLIL::SigSig;
|
2014-12-31 15:50:08 -06:00
|
|
|
|
2014-12-30 16:45:43 -06:00
|
|
|
namespace hashlib {
|
|
|
|
template<> struct hash_ops<RTLIL::State> : hash_ops<int> {};
|
|
|
|
}
|
|
|
|
|
2014-07-31 06:19:47 -05:00
|
|
|
void yosys_setup();
|
2018-08-20 07:44:03 -05:00
|
|
|
|
|
|
|
#ifdef WITH_PYTHON
|
|
|
|
bool yosys_already_setup();
|
|
|
|
#endif
|
|
|
|
|
2014-07-31 06:19:47 -05:00
|
|
|
void yosys_shutdown();
|
|
|
|
|
2014-07-30 07:10:15 -05:00
|
|
|
#ifdef YOSYS_ENABLE_TCL
|
2014-07-31 06:19:47 -05:00
|
|
|
Tcl_Interp *yosys_get_tcl_interp();
|
2014-07-30 07:10:15 -05:00
|
|
|
#endif
|
|
|
|
|
2014-07-31 06:19:47 -05:00
|
|
|
extern RTLIL::Design *yosys_design;
|
|
|
|
|
|
|
|
RTLIL::IdString new_id(std::string file, int line, std::string func);
|
2021-03-02 17:28:56 -06:00
|
|
|
RTLIL::IdString new_id_suffix(std::string file, int line, std::string func, std::string suffix);
|
2014-07-31 06:19:47 -05:00
|
|
|
|
|
|
|
#define NEW_ID \
|
|
|
|
YOSYS_NAMESPACE_PREFIX new_id(__FILE__, __LINE__, __FUNCTION__)
|
2021-03-02 17:28:56 -06:00
|
|
|
#define NEW_ID_SUFFIX(suffix) \
|
|
|
|
YOSYS_NAMESPACE_PREFIX new_id_suffix(__FILE__, __LINE__, __FUNCTION__, suffix)
|
2014-07-31 06:19:47 -05:00
|
|
|
|
2020-04-02 11:51:32 -05:00
|
|
|
// Create a statically allocated IdString object, using for example ID::A or ID($add).
|
2019-08-09 11:54:03 -05:00
|
|
|
//
|
2020-04-02 11:51:32 -05:00
|
|
|
// Recipe for Converting old code that is using conversion of strings like ID::A and
|
2019-08-09 11:54:03 -05:00
|
|
|
// "$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 char *p = "\\" #_id, *q = p[1] == '$' ? p+1 : p; \
|
|
|
|
static const YOSYS_NAMESPACE_PREFIX RTLIL::IdString id(q); return id; })()
|
2019-08-16 14:37:11 -05:00
|
|
|
namespace ID = RTLIL::ID;
|
2014-08-03 07:59:13 -05:00
|
|
|
|
2014-07-31 06:19:47 -05:00
|
|
|
RTLIL::Design *yosys_get_design();
|
|
|
|
std::string proc_self_dirname();
|
|
|
|
std::string proc_share_dirname();
|
2020-04-10 03:38:40 -05:00
|
|
|
std::string proc_program_prefix();
|
2014-07-31 06:19:47 -05:00
|
|
|
const char *create_prompt(RTLIL::Design *design, int recursion_counter);
|
2016-08-22 08:05:57 -05:00
|
|
|
std::vector<std::string> glob_filename(const std::string &filename_pattern);
|
2015-04-08 05:14:34 -05:00
|
|
|
void rewrite_filename(std::string &filename);
|
2014-07-31 06:19:47 -05:00
|
|
|
|
2015-02-01 06:38:46 -06:00
|
|
|
void run_pass(std::string command, RTLIL::Design *design = nullptr);
|
2021-12-09 15:24:58 -06:00
|
|
|
bool run_frontend(std::string filename, std::string command, RTLIL::Design *design = nullptr, std::string *from_to_label = nullptr);
|
2015-02-01 06:38:46 -06:00
|
|
|
void run_backend(std::string filename, std::string command, RTLIL::Design *design = nullptr);
|
2014-07-31 06:19:47 -05:00
|
|
|
void shell(RTLIL::Design *design);
|
|
|
|
|
2018-01-07 09:36:13 -06:00
|
|
|
// journal of all input and output files read (for "yosys -E")
|
|
|
|
extern std::set<std::string> yosys_input_files, yosys_output_files;
|
|
|
|
|
2014-07-30 07:10:15 -05:00
|
|
|
// from kernel/version_*.o (cc source generated from Makefile)
|
|
|
|
extern const char *yosys_version_str;
|
|
|
|
|
|
|
|
// from passes/cmds/design.cc
|
|
|
|
extern std::map<std::string, RTLIL::Design*> saved_designs;
|
|
|
|
extern std::vector<RTLIL::Design*> pushed_designs;
|
|
|
|
|
2014-08-22 06:58:36 -05:00
|
|
|
// from passes/cmds/pluginc.cc
|
|
|
|
extern std::map<std::string, void*> loaded_plugins;
|
2018-08-16 09:00:11 -05:00
|
|
|
#ifdef WITH_PYTHON
|
|
|
|
extern std::map<std::string, void*> loaded_python_plugins;
|
|
|
|
#endif
|
2014-08-22 06:58:36 -05:00
|
|
|
extern std::map<std::string, std::string> loaded_plugin_aliases;
|
|
|
|
void load_plugin(std::string filename, std::vector<std::string> aliases);
|
|
|
|
|
2020-11-06 07:17:15 -06:00
|
|
|
extern std::string yosys_share_dirname;
|
|
|
|
extern std::string yosys_abc_executable;
|
|
|
|
|
2014-07-30 07:10:15 -05:00
|
|
|
YOSYS_NAMESPACE_END
|
|
|
|
|
|
|
|
#endif
|