2018-07-21 01:41:18 -05:00
|
|
|
/* -*- c++ -*-
|
2013-01-05 04:13:26 -06:00
|
|
|
* yosys -- Yosys Open SYnthesis Suite
|
|
|
|
*
|
|
|
|
* Copyright (C) 2012 Clifford Wolf <clifford@clifford.at>
|
2015-07-02 04:14:30 -05:00
|
|
|
*
|
2013-01-05 04:13:26 -06: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
|
|
|
*
|
2013-01-05 04:13:26 -06: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-30 07:10:15 -05:00
|
|
|
#include "kernel/yosys.h"
|
|
|
|
|
2013-01-05 04:13:26 -06:00
|
|
|
#ifndef RTLIL_H
|
|
|
|
#define RTLIL_H
|
|
|
|
|
2014-07-31 06:19:47 -05:00
|
|
|
YOSYS_NAMESPACE_BEGIN
|
|
|
|
|
2013-01-05 04:13:26 -06:00
|
|
|
namespace RTLIL
|
|
|
|
{
|
2014-07-26 19:00:04 -05:00
|
|
|
enum State : unsigned char {
|
2013-01-05 04:13:26 -06:00
|
|
|
S0 = 0,
|
|
|
|
S1 = 1,
|
|
|
|
Sx = 2, // undefined value or conflict
|
|
|
|
Sz = 3, // high-impedance / not-connected
|
|
|
|
Sa = 4, // don't care (used only in cases)
|
|
|
|
Sm = 5 // marker (used internally by some passes)
|
|
|
|
};
|
2013-12-04 07:14:05 -06:00
|
|
|
|
2014-07-26 19:00:04 -05:00
|
|
|
enum SyncType : unsigned char {
|
2013-01-05 04:13:26 -06:00
|
|
|
ST0 = 0, // level sensitive: 0
|
|
|
|
ST1 = 1, // level sensitive: 1
|
|
|
|
STp = 2, // edge sensitive: posedge
|
|
|
|
STn = 3, // edge sensitive: negedge
|
|
|
|
STe = 4, // edge sensitive: both edges
|
2013-11-21 06:49:00 -06:00
|
|
|
STa = 5, // always active
|
2016-10-14 05:33:56 -05:00
|
|
|
STg = 6, // global clock
|
|
|
|
STi = 7 // init
|
2013-01-05 04:13:26 -06:00
|
|
|
};
|
|
|
|
|
2014-07-26 19:00:04 -05:00
|
|
|
enum ConstFlags : unsigned char {
|
2013-12-04 07:14:05 -06:00
|
|
|
CONST_FLAG_NONE = 0,
|
|
|
|
CONST_FLAG_STRING = 1,
|
2013-12-04 07:24:44 -06:00
|
|
|
CONST_FLAG_SIGNED = 2, // only used for parameters
|
2019-05-04 01:46:24 -05:00
|
|
|
CONST_FLAG_REAL = 4 // only used for parameters
|
2013-12-04 07:14:05 -06:00
|
|
|
};
|
|
|
|
|
2013-01-05 04:13:26 -06:00
|
|
|
struct Const;
|
2015-04-24 15:04:05 -05:00
|
|
|
struct AttrObject;
|
2013-01-05 04:13:26 -06:00
|
|
|
struct Selection;
|
2014-07-31 07:34:12 -05:00
|
|
|
struct Monitor;
|
2013-01-05 04:13:26 -06:00
|
|
|
struct Design;
|
|
|
|
struct Module;
|
|
|
|
struct Wire;
|
|
|
|
struct Memory;
|
|
|
|
struct Cell;
|
|
|
|
struct SigChunk;
|
2013-11-21 21:07:13 -06:00
|
|
|
struct SigBit;
|
2014-07-22 16:49:26 -05:00
|
|
|
struct SigSpecIterator;
|
2014-07-27 07:47:23 -05:00
|
|
|
struct SigSpecConstIterator;
|
2013-01-05 04:13:26 -06:00
|
|
|
struct SigSpec;
|
|
|
|
struct CaseRule;
|
|
|
|
struct SwitchRule;
|
|
|
|
struct SyncRule;
|
|
|
|
struct Process;
|
|
|
|
|
|
|
|
typedef std::pair<SigSpec, SigSpec> SigSig;
|
|
|
|
|
2014-08-02 06:11:01 -05:00
|
|
|
struct IdString
|
|
|
|
{
|
2019-03-11 14:12:28 -05:00
|
|
|
#undef YOSYS_XTRACE_GET_PUT
|
|
|
|
#undef YOSYS_SORT_ID_FREE_LIST
|
|
|
|
|
2014-08-02 08:52:21 -05:00
|
|
|
// the global id string cache
|
2014-08-02 08:11:35 -05:00
|
|
|
|
2014-12-11 14:46:36 -06:00
|
|
|
static struct destruct_guard_t {
|
2014-12-16 03:38:25 -06:00
|
|
|
bool ok; // POD, will be initialized to zero
|
2014-12-11 14:46:36 -06:00
|
|
|
destruct_guard_t() { ok = true; }
|
|
|
|
~destruct_guard_t() { ok = false; }
|
|
|
|
} destruct_guard;
|
|
|
|
|
2014-08-02 08:11:35 -05:00
|
|
|
static std::vector<int> global_refcount_storage_;
|
2014-08-02 08:44:10 -05:00
|
|
|
static std::vector<char*> global_id_storage_;
|
2014-12-26 14:59:41 -06:00
|
|
|
static dict<char*, int, hash_cstr_ops> global_id_index_;
|
2014-08-02 08:11:35 -05:00
|
|
|
static std::vector<int> global_free_idx_list_;
|
|
|
|
|
2019-03-11 14:12:28 -05:00
|
|
|
static int last_created_idx_ptr_;
|
|
|
|
static int last_created_idx_[8];
|
|
|
|
|
|
|
|
static inline void xtrace_db_dump()
|
|
|
|
{
|
|
|
|
#ifdef YOSYS_XTRACE_GET_PUT
|
|
|
|
for (int idx = 0; idx < GetSize(global_id_storage_); idx++)
|
|
|
|
{
|
|
|
|
if (global_id_storage_.at(idx) == nullptr)
|
|
|
|
log("#X# DB-DUMP index %d: FREE\n", idx);
|
|
|
|
else
|
|
|
|
log("#X# DB-DUMP index %d: '%s' (ref %d)\n", idx, global_id_storage_.at(idx), global_refcount_storage_.at(idx));
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline void checkpoint()
|
|
|
|
{
|
|
|
|
last_created_idx_ptr_ = 0;
|
|
|
|
for (int i = 0; i < 8; i++) {
|
|
|
|
if (last_created_idx_[i])
|
|
|
|
put_reference(last_created_idx_[i]);
|
|
|
|
last_created_idx_[i] = 0;
|
|
|
|
}
|
|
|
|
#ifdef YOSYS_SORT_ID_FREE_LIST
|
|
|
|
std::sort(global_free_idx_list_.begin(), global_free_idx_list_.end(), std::greater<int>());
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2014-08-02 08:11:35 -05:00
|
|
|
static inline int get_reference(int idx)
|
|
|
|
{
|
|
|
|
global_refcount_storage_.at(idx)++;
|
2019-03-11 14:12:28 -05:00
|
|
|
#ifdef YOSYS_XTRACE_GET_PUT
|
|
|
|
if (yosys_xtrace) {
|
|
|
|
log("#X# GET-BY-INDEX '%s' (index %d, refcount %d)\n", global_id_storage_.at(idx), idx, global_refcount_storage_.at(idx));
|
|
|
|
}
|
|
|
|
#endif
|
2014-08-02 08:11:35 -05:00
|
|
|
return idx;
|
|
|
|
}
|
|
|
|
|
2014-08-02 08:44:10 -05:00
|
|
|
static inline int get_reference(const char *p)
|
2014-08-02 08:11:35 -05:00
|
|
|
{
|
2014-12-11 14:46:36 -06:00
|
|
|
log_assert(destruct_guard.ok);
|
|
|
|
|
2014-08-02 08:44:10 -05:00
|
|
|
if (p[0]) {
|
|
|
|
log_assert(p[1] != 0);
|
|
|
|
log_assert(p[0] == '$' || p[0] == '\\');
|
2014-08-02 08:11:35 -05:00
|
|
|
}
|
|
|
|
|
2014-08-02 08:44:10 -05:00
|
|
|
auto it = global_id_index_.find((char*)p);
|
2014-08-02 08:11:35 -05:00
|
|
|
if (it != global_id_index_.end()) {
|
|
|
|
global_refcount_storage_.at(it->second)++;
|
2019-03-11 14:12:28 -05:00
|
|
|
#ifdef YOSYS_XTRACE_GET_PUT
|
|
|
|
if (yosys_xtrace) {
|
|
|
|
log("#X# GET-BY-NAME '%s' (index %d, refcount %d)\n", global_id_storage_.at(it->second), it->second, global_refcount_storage_.at(it->second));
|
|
|
|
}
|
|
|
|
#endif
|
2014-08-02 08:11:35 -05:00
|
|
|
return it->second;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (global_free_idx_list_.empty()) {
|
|
|
|
log_assert(global_id_storage_.size() < 0x40000000);
|
|
|
|
global_free_idx_list_.push_back(global_id_storage_.size());
|
2014-08-02 08:44:10 -05:00
|
|
|
global_id_storage_.push_back(nullptr);
|
2014-08-02 08:11:35 -05:00
|
|
|
global_refcount_storage_.push_back(0);
|
|
|
|
}
|
|
|
|
|
|
|
|
int idx = global_free_idx_list_.back();
|
|
|
|
global_free_idx_list_.pop_back();
|
2014-08-02 08:44:10 -05:00
|
|
|
global_id_storage_.at(idx) = strdup(p);
|
2014-08-02 08:11:35 -05:00
|
|
|
global_id_index_[global_id_storage_.at(idx)] = idx;
|
|
|
|
global_refcount_storage_.at(idx)++;
|
2014-12-29 06:33:33 -06:00
|
|
|
|
2014-12-30 20:56:09 -06:00
|
|
|
// Avoid Create->Delete->Create pattern
|
2019-03-11 14:12:28 -05:00
|
|
|
if (last_created_idx_[last_created_idx_ptr_])
|
|
|
|
put_reference(last_created_idx_[last_created_idx_ptr_]);
|
|
|
|
last_created_idx_[last_created_idx_ptr_] = idx;
|
|
|
|
get_reference(last_created_idx_[last_created_idx_ptr_]);
|
|
|
|
last_created_idx_ptr_ = (last_created_idx_ptr_ + 1) & 7;
|
2014-12-30 20:56:09 -06:00
|
|
|
|
2014-12-29 06:33:33 -06:00
|
|
|
if (yosys_xtrace) {
|
|
|
|
log("#X# New IdString '%s' with index %d.\n", p, idx);
|
|
|
|
log_backtrace("-X- ", yosys_xtrace-1);
|
|
|
|
}
|
|
|
|
|
2019-03-11 14:12:28 -05:00
|
|
|
#ifdef YOSYS_XTRACE_GET_PUT
|
|
|
|
if (yosys_xtrace) {
|
|
|
|
log("#X# GET-BY-NAME '%s' (index %d, refcount %d)\n", global_id_storage_.at(idx), idx, global_refcount_storage_.at(idx));
|
|
|
|
}
|
|
|
|
#endif
|
2014-08-02 08:11:35 -05:00
|
|
|
return idx;
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline void put_reference(int idx)
|
|
|
|
{
|
2014-12-11 14:46:36 -06:00
|
|
|
// put_reference() may be called from destructors after the destructor of
|
|
|
|
// global_refcount_storage_ has been run. in this case we simply do nothing.
|
|
|
|
if (!destruct_guard.ok)
|
|
|
|
return;
|
|
|
|
|
2019-03-11 14:12:28 -05:00
|
|
|
#ifdef YOSYS_XTRACE_GET_PUT
|
|
|
|
if (yosys_xtrace) {
|
|
|
|
log("#X# PUT '%s' (index %d, refcount %d)\n", global_id_storage_.at(idx), idx, global_refcount_storage_.at(idx));
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2014-08-02 09:03:18 -05:00
|
|
|
log_assert(global_refcount_storage_.at(idx) > 0);
|
|
|
|
|
2014-08-02 08:11:35 -05:00
|
|
|
if (--global_refcount_storage_.at(idx) != 0)
|
|
|
|
return;
|
|
|
|
|
2014-12-29 06:33:33 -06:00
|
|
|
if (yosys_xtrace) {
|
|
|
|
log("#X# Removed IdString '%s' with index %d.\n", global_id_storage_.at(idx), idx);
|
|
|
|
log_backtrace("-X- ", yosys_xtrace-1);
|
|
|
|
}
|
|
|
|
|
2014-08-02 08:11:35 -05:00
|
|
|
global_id_index_.erase(global_id_storage_.at(idx));
|
2014-08-02 08:44:10 -05:00
|
|
|
free(global_id_storage_.at(idx));
|
2014-08-02 09:03:18 -05:00
|
|
|
global_id_storage_.at(idx) = nullptr;
|
2014-08-02 08:11:35 -05:00
|
|
|
global_free_idx_list_.push_back(idx);
|
|
|
|
}
|
|
|
|
|
2014-08-02 08:52:21 -05:00
|
|
|
// the actual IdString object is just is a single int
|
2014-08-02 08:11:35 -05:00
|
|
|
|
|
|
|
int index_;
|
|
|
|
|
|
|
|
IdString() : index_(get_reference("")) { }
|
|
|
|
IdString(const char *str) : index_(get_reference(str)) { }
|
|
|
|
IdString(const IdString &str) : index_(get_reference(str.index_)) { }
|
2014-08-02 08:44:10 -05:00
|
|
|
IdString(const std::string &str) : index_(get_reference(str.c_str())) { }
|
2014-08-02 08:11:35 -05:00
|
|
|
~IdString() { put_reference(index_); }
|
|
|
|
|
|
|
|
void operator=(const IdString &rhs) {
|
|
|
|
put_reference(index_);
|
|
|
|
index_ = get_reference(rhs.index_);
|
|
|
|
}
|
|
|
|
|
|
|
|
void operator=(const char *rhs) {
|
|
|
|
IdString id(rhs);
|
|
|
|
*this = id;
|
|
|
|
}
|
|
|
|
|
|
|
|
void operator=(const std::string &rhs) {
|
|
|
|
IdString id(rhs);
|
|
|
|
*this = id;
|
|
|
|
}
|
|
|
|
|
2014-08-02 11:58:40 -05:00
|
|
|
const char *c_str() const {
|
2014-08-02 08:11:35 -05:00
|
|
|
return global_id_storage_.at(index_);
|
|
|
|
}
|
|
|
|
|
2014-08-02 08:44:10 -05:00
|
|
|
std::string str() const {
|
|
|
|
return std::string(global_id_storage_.at(index_));
|
|
|
|
}
|
|
|
|
|
2016-01-30 00:40:17 -06:00
|
|
|
bool operator<(const IdString &rhs) const {
|
2014-08-02 08:11:35 -05:00
|
|
|
return index_ < rhs.index_;
|
|
|
|
}
|
2014-08-02 06:11:01 -05:00
|
|
|
|
2016-01-30 00:40:17 -06:00
|
|
|
bool operator==(const IdString &rhs) const { return index_ == rhs.index_; }
|
|
|
|
bool operator!=(const IdString &rhs) const { return index_ != rhs.index_; }
|
2014-08-02 06:11:01 -05:00
|
|
|
|
2015-08-14 03:56:05 -05:00
|
|
|
// The methods below are just convenience functions for better compatibility with std::string.
|
2014-08-02 06:11:01 -05:00
|
|
|
|
2014-08-02 08:11:35 -05:00
|
|
|
bool operator==(const std::string &rhs) const { return str() == rhs; }
|
|
|
|
bool operator!=(const std::string &rhs) const { return str() != rhs; }
|
|
|
|
|
2014-08-04 08:08:35 -05:00
|
|
|
bool operator==(const char *rhs) const { return strcmp(c_str(), rhs) == 0; }
|
|
|
|
bool operator!=(const char *rhs) const { return strcmp(c_str(), rhs) != 0; }
|
2014-08-02 06:11:01 -05:00
|
|
|
|
2014-08-02 11:58:40 -05:00
|
|
|
char operator[](size_t i) const {
|
2014-08-02 12:08:02 -05:00
|
|
|
const char *p = c_str();
|
2015-07-02 04:14:30 -05:00
|
|
|
for (; i != 0; i--, p++)
|
2014-08-02 12:08:02 -05:00
|
|
|
log_assert(*p != 0);
|
|
|
|
return *p;
|
2014-08-02 11:58:40 -05:00
|
|
|
}
|
|
|
|
|
2014-08-02 08:44:10 -05:00
|
|
|
std::string substr(size_t pos = 0, size_t len = std::string::npos) const {
|
2014-08-02 09:03:18 -05:00
|
|
|
if (len == std::string::npos || len >= strlen(c_str() + pos))
|
2014-08-02 08:44:10 -05:00
|
|
|
return std::string(c_str() + pos);
|
|
|
|
else
|
|
|
|
return std::string(c_str() + pos, len);
|
|
|
|
}
|
|
|
|
|
2019-02-26 14:04:16 -06:00
|
|
|
bool ends_with(const char* suffix) const {
|
|
|
|
size_t len = strlen(suffix);
|
|
|
|
if (size() < len) return false;
|
|
|
|
return substr(size()-len) == suffix;
|
|
|
|
}
|
|
|
|
|
2014-08-02 08:44:10 -05:00
|
|
|
size_t size() const {
|
|
|
|
return str().size();
|
|
|
|
}
|
|
|
|
|
|
|
|
bool empty() const {
|
|
|
|
return c_str()[0] == 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
void clear() {
|
|
|
|
*this = IdString();
|
|
|
|
}
|
2014-08-02 09:03:18 -05:00
|
|
|
|
2014-12-26 14:35:22 -06:00
|
|
|
unsigned int hash() const {
|
|
|
|
return index_;
|
|
|
|
}
|
|
|
|
|
2014-12-28 19:01:42 -06:00
|
|
|
// The following is a helper key_compare class. Instead of for example std::set<Cell*>
|
|
|
|
// use std::set<Cell*, IdString::compare_ptr_by_name<Cell>> if the order of cells in the
|
2014-08-02 09:03:18 -05:00
|
|
|
// set has an influence on the algorithm.
|
|
|
|
|
|
|
|
template<typename T> struct compare_ptr_by_name {
|
2014-11-07 08:21:03 -06:00
|
|
|
bool operator()(const T *a, const T *b) const {
|
2014-08-02 09:03:18 -05:00
|
|
|
return (a == nullptr || b == nullptr) ? (a < b) : (a->name < b->name);
|
|
|
|
}
|
|
|
|
};
|
2014-08-04 08:08:35 -05:00
|
|
|
|
|
|
|
// often one needs to check if a given IdString is part of a list (for example a list
|
|
|
|
// of cell types). the following functions helps with that.
|
|
|
|
|
|
|
|
template<typename T, typename... Args>
|
2014-12-31 15:50:08 -06:00
|
|
|
bool in(T first, Args... rest) const {
|
2014-08-04 08:08:35 -05:00
|
|
|
return in(first) || in(rest...);
|
|
|
|
}
|
|
|
|
|
2014-12-31 15:50:08 -06:00
|
|
|
bool in(IdString rhs) const { return *this == rhs; }
|
|
|
|
bool in(const char *rhs) const { return *this == rhs; }
|
|
|
|
bool in(const std::string &rhs) const { return *this == rhs; }
|
|
|
|
bool in(const pool<IdString> &rhs) const { return rhs.count(*this) != 0; }
|
2014-08-01 17:45:25 -05:00
|
|
|
};
|
2013-01-05 04:13:26 -06:00
|
|
|
|
2014-08-01 17:45:25 -05:00
|
|
|
static inline std::string escape_id(std::string str) {
|
2013-01-05 04:13:26 -06:00
|
|
|
if (str.size() > 0 && str[0] != '\\' && str[0] != '$')
|
|
|
|
return "\\" + str;
|
|
|
|
return str;
|
|
|
|
}
|
|
|
|
|
2014-08-01 17:45:25 -05:00
|
|
|
static inline std::string unescape_id(std::string str) {
|
2015-01-30 15:51:16 -06:00
|
|
|
if (str.size() < 2)
|
|
|
|
return str;
|
|
|
|
if (str[0] != '\\')
|
|
|
|
return str;
|
|
|
|
if (str[1] == '$' || str[1] == '\\')
|
|
|
|
return str;
|
|
|
|
if (str[1] >= '0' && str[1] <= '9')
|
|
|
|
return str;
|
|
|
|
return str.substr(1);
|
2013-01-05 04:13:26 -06:00
|
|
|
}
|
|
|
|
|
2014-08-01 17:45:25 -05:00
|
|
|
static inline std::string unescape_id(RTLIL::IdString str) {
|
|
|
|
return unescape_id(str.str());
|
|
|
|
}
|
|
|
|
|
2014-08-02 06:34:07 -05:00
|
|
|
static inline const char *id2cstr(const RTLIL::IdString &str) {
|
2014-08-02 09:03:18 -05:00
|
|
|
return log_id(str);
|
2014-08-01 17:45:25 -05:00
|
|
|
}
|
|
|
|
|
2014-08-14 19:40:46 -05:00
|
|
|
template <typename T> struct sort_by_name_id {
|
2013-08-09 05:42:32 -05:00
|
|
|
bool operator()(T *a, T *b) const {
|
|
|
|
return a->name < b->name;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2014-08-14 19:40:46 -05:00
|
|
|
template <typename T> struct sort_by_name_str {
|
|
|
|
bool operator()(T *a, T *b) const {
|
|
|
|
return strcmp(a->name.c_str(), b->name.c_str()) < 0;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
struct sort_by_id_str {
|
|
|
|
bool operator()(RTLIL::IdString a, RTLIL::IdString b) const {
|
|
|
|
return strcmp(a.c_str(), b.c_str()) < 0;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2013-01-05 04:13:26 -06:00
|
|
|
// see calc.cc for the implementation of this functions
|
|
|
|
RTLIL::Const const_not (const RTLIL::Const &arg1, const RTLIL::Const &arg2, bool signed1, bool signed2, int result_len);
|
|
|
|
RTLIL::Const const_and (const RTLIL::Const &arg1, const RTLIL::Const &arg2, bool signed1, bool signed2, int result_len);
|
|
|
|
RTLIL::Const const_or (const RTLIL::Const &arg1, const RTLIL::Const &arg2, bool signed1, bool signed2, int result_len);
|
|
|
|
RTLIL::Const const_xor (const RTLIL::Const &arg1, const RTLIL::Const &arg2, bool signed1, bool signed2, int result_len);
|
|
|
|
RTLIL::Const const_xnor (const RTLIL::Const &arg1, const RTLIL::Const &arg2, bool signed1, bool signed2, int result_len);
|
|
|
|
|
|
|
|
RTLIL::Const const_reduce_and (const RTLIL::Const &arg1, const RTLIL::Const &arg2, bool signed1, bool signed2, int result_len);
|
|
|
|
RTLIL::Const const_reduce_or (const RTLIL::Const &arg1, const RTLIL::Const &arg2, bool signed1, bool signed2, int result_len);
|
|
|
|
RTLIL::Const const_reduce_xor (const RTLIL::Const &arg1, const RTLIL::Const &arg2, bool signed1, bool signed2, int result_len);
|
|
|
|
RTLIL::Const const_reduce_xnor (const RTLIL::Const &arg1, const RTLIL::Const &arg2, bool signed1, bool signed2, int result_len);
|
|
|
|
RTLIL::Const const_reduce_bool (const RTLIL::Const &arg1, const RTLIL::Const &arg2, bool signed1, bool signed2, int result_len);
|
|
|
|
|
|
|
|
RTLIL::Const const_logic_not (const RTLIL::Const &arg1, const RTLIL::Const &arg2, bool signed1, bool signed2, int result_len);
|
|
|
|
RTLIL::Const const_logic_and (const RTLIL::Const &arg1, const RTLIL::Const &arg2, bool signed1, bool signed2, int result_len);
|
|
|
|
RTLIL::Const const_logic_or (const RTLIL::Const &arg1, const RTLIL::Const &arg2, bool signed1, bool signed2, int result_len);
|
|
|
|
|
|
|
|
RTLIL::Const const_shl (const RTLIL::Const &arg1, const RTLIL::Const &arg2, bool signed1, bool signed2, int result_len);
|
|
|
|
RTLIL::Const const_shr (const RTLIL::Const &arg1, const RTLIL::Const &arg2, bool signed1, bool signed2, int result_len);
|
|
|
|
RTLIL::Const const_sshl (const RTLIL::Const &arg1, const RTLIL::Const &arg2, bool signed1, bool signed2, int result_len);
|
|
|
|
RTLIL::Const const_sshr (const RTLIL::Const &arg1, const RTLIL::Const &arg2, bool signed1, bool signed2, int result_len);
|
2014-07-29 07:42:33 -05:00
|
|
|
RTLIL::Const const_shift (const RTLIL::Const &arg1, const RTLIL::Const &arg2, bool signed1, bool signed2, int result_len);
|
|
|
|
RTLIL::Const const_shiftx (const RTLIL::Const &arg1, const RTLIL::Const &arg2, bool signed1, bool signed2, int result_len);
|
2013-01-05 04:13:26 -06:00
|
|
|
|
|
|
|
RTLIL::Const const_lt (const RTLIL::Const &arg1, const RTLIL::Const &arg2, bool signed1, bool signed2, int result_len);
|
|
|
|
RTLIL::Const const_le (const RTLIL::Const &arg1, const RTLIL::Const &arg2, bool signed1, bool signed2, int result_len);
|
|
|
|
RTLIL::Const const_eq (const RTLIL::Const &arg1, const RTLIL::Const &arg2, bool signed1, bool signed2, int result_len);
|
|
|
|
RTLIL::Const const_ne (const RTLIL::Const &arg1, const RTLIL::Const &arg2, bool signed1, bool signed2, int result_len);
|
2013-12-27 06:50:08 -06:00
|
|
|
RTLIL::Const const_eqx (const RTLIL::Const &arg1, const RTLIL::Const &arg2, bool signed1, bool signed2, int result_len);
|
|
|
|
RTLIL::Const const_nex (const RTLIL::Const &arg1, const RTLIL::Const &arg2, bool signed1, bool signed2, int result_len);
|
2013-01-05 04:13:26 -06:00
|
|
|
RTLIL::Const const_ge (const RTLIL::Const &arg1, const RTLIL::Const &arg2, bool signed1, bool signed2, int result_len);
|
|
|
|
RTLIL::Const const_gt (const RTLIL::Const &arg1, const RTLIL::Const &arg2, bool signed1, bool signed2, int result_len);
|
|
|
|
|
|
|
|
RTLIL::Const const_add (const RTLIL::Const &arg1, const RTLIL::Const &arg2, bool signed1, bool signed2, int result_len);
|
|
|
|
RTLIL::Const const_sub (const RTLIL::Const &arg1, const RTLIL::Const &arg2, bool signed1, bool signed2, int result_len);
|
|
|
|
RTLIL::Const const_mul (const RTLIL::Const &arg1, const RTLIL::Const &arg2, bool signed1, bool signed2, int result_len);
|
|
|
|
RTLIL::Const const_div (const RTLIL::Const &arg1, const RTLIL::Const &arg2, bool signed1, bool signed2, int result_len);
|
|
|
|
RTLIL::Const const_mod (const RTLIL::Const &arg1, const RTLIL::Const &arg2, bool signed1, bool signed2, int result_len);
|
|
|
|
RTLIL::Const const_pow (const RTLIL::Const &arg1, const RTLIL::Const &arg2, bool signed1, bool signed2, int result_len);
|
|
|
|
|
|
|
|
RTLIL::Const const_pos (const RTLIL::Const &arg1, const RTLIL::Const &arg2, bool signed1, bool signed2, int result_len);
|
|
|
|
RTLIL::Const const_neg (const RTLIL::Const &arg1, const RTLIL::Const &arg2, bool signed1, bool signed2, int result_len);
|
2014-07-27 03:13:22 -05:00
|
|
|
|
|
|
|
|
|
|
|
// This iterator-range-pair is used for Design::modules(), Module::wires() and Module::cells().
|
|
|
|
// It maintains a reference counter that is used to make sure that the container is not modified while being iterated over.
|
|
|
|
|
|
|
|
template<typename T>
|
|
|
|
struct ObjIterator
|
|
|
|
{
|
2014-12-26 03:53:21 -06:00
|
|
|
typename dict<RTLIL::IdString, T>::iterator it;
|
|
|
|
dict<RTLIL::IdString, T> *list_p;
|
2014-07-27 03:13:22 -05:00
|
|
|
int *refcount_p;
|
|
|
|
|
|
|
|
ObjIterator() : list_p(nullptr), refcount_p(nullptr) {
|
|
|
|
}
|
|
|
|
|
|
|
|
ObjIterator(decltype(list_p) list_p, int *refcount_p) : list_p(list_p), refcount_p(refcount_p) {
|
|
|
|
if (list_p->empty()) {
|
|
|
|
this->list_p = nullptr;
|
|
|
|
this->refcount_p = nullptr;
|
|
|
|
} else {
|
|
|
|
it = list_p->begin();
|
|
|
|
(*refcount_p)++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
ObjIterator(const RTLIL::ObjIterator<T> &other) {
|
|
|
|
it = other.it;
|
|
|
|
list_p = other.list_p;
|
|
|
|
refcount_p = other.refcount_p;
|
|
|
|
if (refcount_p)
|
|
|
|
(*refcount_p)++;
|
|
|
|
}
|
|
|
|
|
|
|
|
ObjIterator &operator=(const RTLIL::ObjIterator<T> &other) {
|
|
|
|
if (refcount_p)
|
|
|
|
(*refcount_p)--;
|
|
|
|
it = other.it;
|
|
|
|
list_p = other.list_p;
|
|
|
|
refcount_p = other.refcount_p;
|
|
|
|
if (refcount_p)
|
|
|
|
(*refcount_p)++;
|
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
|
|
|
|
~ObjIterator() {
|
|
|
|
if (refcount_p)
|
|
|
|
(*refcount_p)--;
|
|
|
|
}
|
|
|
|
|
|
|
|
inline T operator*() const {
|
2014-07-28 04:08:55 -05:00
|
|
|
log_assert(list_p != nullptr);
|
2014-07-27 03:13:22 -05:00
|
|
|
return it->second;
|
|
|
|
}
|
|
|
|
|
|
|
|
inline bool operator!=(const RTLIL::ObjIterator<T> &other) const {
|
|
|
|
if (list_p == nullptr || other.list_p == nullptr)
|
|
|
|
return list_p != other.list_p;
|
|
|
|
return it != other.it;
|
|
|
|
}
|
|
|
|
|
|
|
|
inline void operator++() {
|
2014-07-28 04:08:55 -05:00
|
|
|
log_assert(list_p != nullptr);
|
2014-07-27 03:13:22 -05:00
|
|
|
if (++it == list_p->end()) {
|
|
|
|
(*refcount_p)--;
|
|
|
|
list_p = nullptr;
|
|
|
|
refcount_p = nullptr;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
template<typename T>
|
|
|
|
struct ObjRange
|
|
|
|
{
|
2014-12-26 03:53:21 -06:00
|
|
|
dict<RTLIL::IdString, T> *list_p;
|
2014-07-27 03:13:22 -05:00
|
|
|
int *refcount_p;
|
|
|
|
|
|
|
|
ObjRange(decltype(list_p) list_p, int *refcount_p) : list_p(list_p), refcount_p(refcount_p) { }
|
|
|
|
RTLIL::ObjIterator<T> begin() { return RTLIL::ObjIterator<T>(list_p, refcount_p); }
|
|
|
|
RTLIL::ObjIterator<T> end() { return RTLIL::ObjIterator<T>(); }
|
2014-07-27 03:41:06 -05:00
|
|
|
|
2014-07-31 07:11:39 -05:00
|
|
|
size_t size() const {
|
|
|
|
return list_p->size();
|
|
|
|
}
|
|
|
|
|
2014-12-26 14:59:41 -06:00
|
|
|
operator pool<T>() const {
|
|
|
|
pool<T> result;
|
2014-07-27 03:41:06 -05:00
|
|
|
for (auto &it : *list_p)
|
|
|
|
result.insert(it.second);
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
|
|
|
operator std::vector<T>() const {
|
|
|
|
std::vector<T> result;
|
|
|
|
result.reserve(list_p->size());
|
|
|
|
for (auto &it : *list_p)
|
|
|
|
result.push_back(it.second);
|
|
|
|
return result;
|
|
|
|
}
|
2014-07-30 15:04:30 -05:00
|
|
|
|
2015-01-19 06:59:08 -06:00
|
|
|
pool<T> to_pool() const { return *this; }
|
2014-07-30 15:04:30 -05:00
|
|
|
std::vector<T> to_vector() const { return *this; }
|
2014-07-27 03:13:22 -05:00
|
|
|
};
|
2013-01-05 04:13:26 -06:00
|
|
|
};
|
|
|
|
|
2014-07-26 19:00:04 -05:00
|
|
|
struct RTLIL::Const
|
|
|
|
{
|
2013-12-04 07:14:05 -06:00
|
|
|
int flags;
|
2013-01-05 04:13:26 -06:00
|
|
|
std::vector<RTLIL::State> bits;
|
2014-07-26 19:00:04 -05:00
|
|
|
|
2013-12-04 07:14:05 -06:00
|
|
|
Const();
|
|
|
|
Const(std::string str);
|
2013-01-05 04:13:26 -06:00
|
|
|
Const(int val, int width = 32);
|
|
|
|
Const(RTLIL::State bit, int width = 1);
|
2015-11-26 11:11:34 -06:00
|
|
|
Const(const std::vector<RTLIL::State> &bits) : bits(bits) { flags = CONST_FLAG_NONE; }
|
2014-09-19 08:50:55 -05:00
|
|
|
Const(const std::vector<bool> &bits);
|
2018-08-13 08:18:46 -05:00
|
|
|
Const(const RTLIL::Const &c);
|
2019-05-05 03:00:27 -05:00
|
|
|
RTLIL::Const &operator =(const RTLIL::Const &other) = default;
|
2014-07-26 19:00:04 -05:00
|
|
|
|
2013-01-05 04:13:26 -06:00
|
|
|
bool operator <(const RTLIL::Const &other) const;
|
|
|
|
bool operator ==(const RTLIL::Const &other) const;
|
|
|
|
bool operator !=(const RTLIL::Const &other) const;
|
2014-07-26 19:00:04 -05:00
|
|
|
|
2013-01-05 04:13:26 -06:00
|
|
|
bool as_bool() const;
|
2014-08-24 08:14:00 -05:00
|
|
|
int as_int(bool is_signed = false) const;
|
2013-01-05 04:13:26 -06:00
|
|
|
std::string as_string() const;
|
2015-01-31 05:08:20 -06:00
|
|
|
static Const from_string(std::string str);
|
2014-07-26 19:00:04 -05:00
|
|
|
|
2013-12-04 07:14:05 -06:00
|
|
|
std::string decode_string() const;
|
2014-08-31 11:07:48 -05:00
|
|
|
|
|
|
|
inline int size() const { return bits.size(); }
|
2015-04-06 10:06:15 -05:00
|
|
|
inline RTLIL::State &operator[](int index) { return bits.at(index); }
|
2015-11-26 11:11:34 -06:00
|
|
|
inline const RTLIL::State &operator[](int index) const { return bits.at(index); }
|
2015-04-06 10:06:15 -05:00
|
|
|
|
2017-08-18 04:40:08 -05:00
|
|
|
bool is_fully_zero() const;
|
2017-12-13 19:06:39 -06:00
|
|
|
bool is_fully_ones() const;
|
2017-08-18 04:40:08 -05:00
|
|
|
bool is_fully_def() const;
|
|
|
|
bool is_fully_undef() const;
|
|
|
|
|
2015-04-06 10:06:15 -05:00
|
|
|
inline RTLIL::Const extract(int offset, int len = 1, RTLIL::State padding = RTLIL::State::S0) const {
|
|
|
|
RTLIL::Const ret;
|
|
|
|
ret.bits.reserve(len);
|
|
|
|
for (int i = offset; i < offset + len; i++)
|
|
|
|
ret.bits.push_back(i < GetSize(bits) ? bits[i] : padding);
|
|
|
|
return ret;
|
|
|
|
}
|
2014-12-28 19:01:42 -06:00
|
|
|
|
2019-03-23 08:38:48 -05:00
|
|
|
void extu(int width) {
|
|
|
|
bits.resize(width, RTLIL::State::S0);
|
|
|
|
}
|
|
|
|
|
|
|
|
void exts(int width) {
|
|
|
|
bits.resize(width, bits.empty() ? RTLIL::State::Sx : bits.back());
|
|
|
|
}
|
|
|
|
|
2014-12-28 19:01:42 -06:00
|
|
|
inline unsigned int hash() const {
|
2014-12-30 11:51:24 -06:00
|
|
|
unsigned int h = mkhash_init;
|
2014-12-28 19:01:42 -06:00
|
|
|
for (auto b : bits)
|
|
|
|
mkhash(h, b);
|
|
|
|
return h;
|
|
|
|
}
|
2013-01-05 04:13:26 -06:00
|
|
|
};
|
|
|
|
|
2015-04-24 15:04:05 -05:00
|
|
|
struct RTLIL::AttrObject
|
|
|
|
{
|
|
|
|
dict<RTLIL::IdString, RTLIL::Const> attributes;
|
|
|
|
|
2019-04-20 04:04:46 -05:00
|
|
|
void set_bool_attribute(RTLIL::IdString id, bool value=true);
|
2015-04-24 15:04:05 -05:00
|
|
|
bool get_bool_attribute(RTLIL::IdString id) const;
|
2017-08-30 04:39:11 -05:00
|
|
|
|
2019-04-18 12:19:45 -05:00
|
|
|
bool get_blackbox_attribute(bool ignore_wb=false) const {
|
|
|
|
return get_bool_attribute("\\blackbox") || (!ignore_wb && get_bool_attribute("\\whitebox"));
|
2019-04-18 10:42:12 -05:00
|
|
|
}
|
|
|
|
|
2015-04-24 15:04:05 -05:00
|
|
|
void set_strpool_attribute(RTLIL::IdString id, const pool<string> &data);
|
|
|
|
void add_strpool_attribute(RTLIL::IdString id, const pool<string> &data);
|
|
|
|
pool<string> get_strpool_attribute(RTLIL::IdString id) const;
|
2017-08-30 04:39:11 -05:00
|
|
|
|
|
|
|
void set_src_attribute(const std::string &src);
|
|
|
|
std::string get_src_attribute() const;
|
2015-04-24 15:04:05 -05:00
|
|
|
};
|
|
|
|
|
2014-12-26 03:53:21 -06:00
|
|
|
struct RTLIL::SigChunk
|
|
|
|
{
|
|
|
|
RTLIL::Wire *wire;
|
|
|
|
std::vector<RTLIL::State> data; // only used if wire == NULL, LSB at index 0
|
|
|
|
int width, offset;
|
|
|
|
|
|
|
|
SigChunk();
|
|
|
|
SigChunk(const RTLIL::Const &value);
|
|
|
|
SigChunk(RTLIL::Wire *wire);
|
|
|
|
SigChunk(RTLIL::Wire *wire, int offset, int width = 1);
|
|
|
|
SigChunk(const std::string &str);
|
|
|
|
SigChunk(int val, int width = 32);
|
|
|
|
SigChunk(RTLIL::State bit, int width = 1);
|
|
|
|
SigChunk(RTLIL::SigBit bit);
|
2018-08-13 08:18:46 -05:00
|
|
|
SigChunk(const RTLIL::SigChunk &sigchunk);
|
2019-05-05 03:00:27 -05:00
|
|
|
RTLIL::SigChunk &operator =(const RTLIL::SigChunk &other) = default;
|
2014-12-26 03:53:21 -06:00
|
|
|
|
|
|
|
RTLIL::SigChunk extract(int offset, int length) const;
|
|
|
|
|
|
|
|
bool operator <(const RTLIL::SigChunk &other) const;
|
|
|
|
bool operator ==(const RTLIL::SigChunk &other) const;
|
|
|
|
bool operator !=(const RTLIL::SigChunk &other) const;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct RTLIL::SigBit
|
|
|
|
{
|
|
|
|
RTLIL::Wire *wire;
|
|
|
|
union {
|
|
|
|
RTLIL::State data; // used if wire == NULL
|
|
|
|
int offset; // used if wire != NULL
|
|
|
|
};
|
|
|
|
|
|
|
|
SigBit();
|
|
|
|
SigBit(RTLIL::State bit);
|
|
|
|
SigBit(bool bit);
|
|
|
|
SigBit(RTLIL::Wire *wire);
|
|
|
|
SigBit(RTLIL::Wire *wire, int offset);
|
|
|
|
SigBit(const RTLIL::SigChunk &chunk);
|
|
|
|
SigBit(const RTLIL::SigChunk &chunk, int index);
|
|
|
|
SigBit(const RTLIL::SigSpec &sig);
|
2018-08-13 08:18:46 -05:00
|
|
|
SigBit(const RTLIL::SigBit &sigbit);
|
2019-05-05 03:00:27 -05:00
|
|
|
RTLIL::SigBit &operator =(const RTLIL::SigBit &other) = default;
|
2014-12-26 03:53:21 -06:00
|
|
|
|
|
|
|
bool operator <(const RTLIL::SigBit &other) const;
|
|
|
|
bool operator ==(const RTLIL::SigBit &other) const;
|
|
|
|
bool operator !=(const RTLIL::SigBit &other) const;
|
2014-12-26 14:35:22 -06:00
|
|
|
unsigned int hash() const;
|
2014-12-26 03:53:21 -06:00
|
|
|
};
|
|
|
|
|
|
|
|
struct RTLIL::SigSpecIterator : public std::iterator<std::input_iterator_tag, RTLIL::SigSpec>
|
|
|
|
{
|
|
|
|
RTLIL::SigSpec *sig_p;
|
|
|
|
int index;
|
|
|
|
|
|
|
|
inline RTLIL::SigBit &operator*() const;
|
|
|
|
inline bool operator!=(const RTLIL::SigSpecIterator &other) const { return index != other.index; }
|
|
|
|
inline bool operator==(const RTLIL::SigSpecIterator &other) const { return index == other.index; }
|
|
|
|
inline void operator++() { index++; }
|
|
|
|
};
|
|
|
|
|
|
|
|
struct RTLIL::SigSpecConstIterator : public std::iterator<std::input_iterator_tag, RTLIL::SigSpec>
|
|
|
|
{
|
|
|
|
const RTLIL::SigSpec *sig_p;
|
|
|
|
int index;
|
|
|
|
|
|
|
|
inline const RTLIL::SigBit &operator*() const;
|
|
|
|
inline bool operator!=(const RTLIL::SigSpecConstIterator &other) const { return index != other.index; }
|
|
|
|
inline bool operator==(const RTLIL::SigSpecIterator &other) const { return index == other.index; }
|
|
|
|
inline void operator++() { index++; }
|
|
|
|
};
|
|
|
|
|
|
|
|
struct RTLIL::SigSpec
|
|
|
|
{
|
|
|
|
private:
|
|
|
|
int width_;
|
|
|
|
unsigned long hash_;
|
|
|
|
std::vector<RTLIL::SigChunk> chunks_; // LSB at index 0
|
|
|
|
std::vector<RTLIL::SigBit> bits_; // LSB at index 0
|
|
|
|
|
|
|
|
void pack() const;
|
|
|
|
void unpack() const;
|
2014-12-26 14:35:22 -06:00
|
|
|
void updhash() const;
|
2014-12-26 03:53:21 -06:00
|
|
|
|
|
|
|
inline bool packed() const {
|
|
|
|
return bits_.empty();
|
|
|
|
}
|
|
|
|
|
|
|
|
inline void inline_unpack() const {
|
|
|
|
if (!chunks_.empty())
|
|
|
|
unpack();
|
|
|
|
}
|
|
|
|
|
|
|
|
public:
|
|
|
|
SigSpec();
|
|
|
|
SigSpec(const RTLIL::SigSpec &other);
|
|
|
|
SigSpec(std::initializer_list<RTLIL::SigSpec> parts);
|
|
|
|
const RTLIL::SigSpec &operator=(const RTLIL::SigSpec &other);
|
|
|
|
|
|
|
|
SigSpec(const RTLIL::Const &value);
|
|
|
|
SigSpec(const RTLIL::SigChunk &chunk);
|
|
|
|
SigSpec(RTLIL::Wire *wire);
|
|
|
|
SigSpec(RTLIL::Wire *wire, int offset, int width = 1);
|
|
|
|
SigSpec(const std::string &str);
|
|
|
|
SigSpec(int val, int width = 32);
|
|
|
|
SigSpec(RTLIL::State bit, int width = 1);
|
|
|
|
SigSpec(RTLIL::SigBit bit, int width = 1);
|
|
|
|
SigSpec(std::vector<RTLIL::SigChunk> chunks);
|
|
|
|
SigSpec(std::vector<RTLIL::SigBit> bits);
|
2014-12-26 14:59:41 -06:00
|
|
|
SigSpec(pool<RTLIL::SigBit> bits);
|
2014-12-26 03:53:21 -06:00
|
|
|
SigSpec(std::set<RTLIL::SigBit> bits);
|
|
|
|
SigSpec(bool bit);
|
|
|
|
|
|
|
|
SigSpec(RTLIL::SigSpec &&other) {
|
|
|
|
width_ = other.width_;
|
|
|
|
hash_ = other.hash_;
|
|
|
|
chunks_ = std::move(other.chunks_);
|
|
|
|
bits_ = std::move(other.bits_);
|
|
|
|
}
|
|
|
|
|
|
|
|
const RTLIL::SigSpec &operator=(RTLIL::SigSpec &&other) {
|
|
|
|
width_ = other.width_;
|
|
|
|
hash_ = other.hash_;
|
|
|
|
chunks_ = std::move(other.chunks_);
|
|
|
|
bits_ = std::move(other.bits_);
|
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
|
|
|
|
size_t get_hash() const {
|
|
|
|
if (!hash_) hash();
|
|
|
|
return hash_;
|
|
|
|
}
|
|
|
|
|
|
|
|
inline const std::vector<RTLIL::SigChunk> &chunks() const { pack(); return chunks_; }
|
|
|
|
inline const std::vector<RTLIL::SigBit> &bits() const { inline_unpack(); return bits_; }
|
|
|
|
|
|
|
|
inline int size() const { return width_; }
|
|
|
|
inline bool empty() const { return width_ == 0; }
|
|
|
|
|
|
|
|
inline RTLIL::SigBit &operator[](int index) { inline_unpack(); return bits_.at(index); }
|
|
|
|
inline const RTLIL::SigBit &operator[](int index) const { inline_unpack(); return bits_.at(index); }
|
|
|
|
|
|
|
|
inline RTLIL::SigSpecIterator begin() { RTLIL::SigSpecIterator it; it.sig_p = this; it.index = 0; return it; }
|
|
|
|
inline RTLIL::SigSpecIterator end() { RTLIL::SigSpecIterator it; it.sig_p = this; it.index = width_; return it; }
|
|
|
|
|
|
|
|
inline RTLIL::SigSpecConstIterator begin() const { RTLIL::SigSpecConstIterator it; it.sig_p = this; it.index = 0; return it; }
|
|
|
|
inline RTLIL::SigSpecConstIterator end() const { RTLIL::SigSpecConstIterator it; it.sig_p = this; it.index = width_; return it; }
|
|
|
|
|
|
|
|
void sort();
|
|
|
|
void sort_and_unify();
|
|
|
|
|
|
|
|
void replace(const RTLIL::SigSpec &pattern, const RTLIL::SigSpec &with);
|
|
|
|
void replace(const RTLIL::SigSpec &pattern, const RTLIL::SigSpec &with, RTLIL::SigSpec *other) const;
|
|
|
|
|
|
|
|
void replace(const dict<RTLIL::SigBit, RTLIL::SigBit> &rules);
|
|
|
|
void replace(const dict<RTLIL::SigBit, RTLIL::SigBit> &rules, RTLIL::SigSpec *other) const;
|
|
|
|
|
|
|
|
void replace(const std::map<RTLIL::SigBit, RTLIL::SigBit> &rules);
|
|
|
|
void replace(const std::map<RTLIL::SigBit, RTLIL::SigBit> &rules, RTLIL::SigSpec *other) const;
|
|
|
|
|
|
|
|
void replace(int offset, const RTLIL::SigSpec &with);
|
|
|
|
|
|
|
|
void remove(const RTLIL::SigSpec &pattern);
|
|
|
|
void remove(const RTLIL::SigSpec &pattern, RTLIL::SigSpec *other) const;
|
|
|
|
void remove2(const RTLIL::SigSpec &pattern, RTLIL::SigSpec *other);
|
|
|
|
|
2014-12-26 14:59:41 -06:00
|
|
|
void remove(const pool<RTLIL::SigBit> &pattern);
|
|
|
|
void remove(const pool<RTLIL::SigBit> &pattern, RTLIL::SigSpec *other) const;
|
|
|
|
void remove2(const pool<RTLIL::SigBit> &pattern, RTLIL::SigSpec *other);
|
2016-01-30 00:03:12 -06:00
|
|
|
void remove2(const std::set<RTLIL::SigBit> &pattern, RTLIL::SigSpec *other);
|
|
|
|
|
2014-12-26 03:53:21 -06:00
|
|
|
void remove(int offset, int length = 1);
|
|
|
|
void remove_const();
|
|
|
|
|
|
|
|
RTLIL::SigSpec extract(const RTLIL::SigSpec &pattern, const RTLIL::SigSpec *other = NULL) const;
|
2014-12-26 14:59:41 -06:00
|
|
|
RTLIL::SigSpec extract(const pool<RTLIL::SigBit> &pattern, const RTLIL::SigSpec *other = NULL) const;
|
2014-12-26 03:53:21 -06:00
|
|
|
RTLIL::SigSpec extract(int offset, int length = 1) const;
|
|
|
|
|
|
|
|
void append(const RTLIL::SigSpec &signal);
|
|
|
|
void append_bit(const RTLIL::SigBit &bit);
|
|
|
|
|
|
|
|
void extend_u0(int width, bool is_signed = false);
|
|
|
|
|
|
|
|
RTLIL::SigSpec repeat(int num) const;
|
|
|
|
|
|
|
|
bool operator <(const RTLIL::SigSpec &other) const;
|
|
|
|
bool operator ==(const RTLIL::SigSpec &other) const;
|
|
|
|
inline bool operator !=(const RTLIL::SigSpec &other) const { return !(*this == other); }
|
|
|
|
|
|
|
|
bool is_wire() const;
|
|
|
|
bool is_chunk() const;
|
2015-10-24 15:56:40 -05:00
|
|
|
inline bool is_bit() const { return width_ == 1; }
|
2014-12-26 03:53:21 -06:00
|
|
|
|
|
|
|
bool is_fully_const() const;
|
2015-04-29 00:28:15 -05:00
|
|
|
bool is_fully_zero() const;
|
2017-12-12 14:48:31 -06:00
|
|
|
bool is_fully_ones() const;
|
2014-12-26 03:53:21 -06:00
|
|
|
bool is_fully_def() const;
|
|
|
|
bool is_fully_undef() const;
|
2015-02-07 17:01:51 -06:00
|
|
|
bool has_const() const;
|
2014-12-26 03:53:21 -06:00
|
|
|
bool has_marked_bits() const;
|
|
|
|
|
|
|
|
bool as_bool() const;
|
|
|
|
int as_int(bool is_signed = false) const;
|
|
|
|
std::string as_string() const;
|
|
|
|
RTLIL::Const as_const() const;
|
|
|
|
RTLIL::Wire *as_wire() const;
|
|
|
|
RTLIL::SigChunk as_chunk() const;
|
2015-10-24 15:56:40 -05:00
|
|
|
RTLIL::SigBit as_bit() const;
|
2014-12-26 03:53:21 -06:00
|
|
|
|
|
|
|
bool match(std::string pattern) const;
|
|
|
|
|
|
|
|
std::set<RTLIL::SigBit> to_sigbit_set() const;
|
2014-12-27 05:02:57 -06:00
|
|
|
pool<RTLIL::SigBit> to_sigbit_pool() const;
|
2014-12-26 03:53:21 -06:00
|
|
|
std::vector<RTLIL::SigBit> to_sigbit_vector() const;
|
|
|
|
std::map<RTLIL::SigBit, RTLIL::SigBit> to_sigbit_map(const RTLIL::SigSpec &other) const;
|
|
|
|
dict<RTLIL::SigBit, RTLIL::SigBit> to_sigbit_dict(const RTLIL::SigSpec &other) const;
|
|
|
|
|
|
|
|
static bool parse(RTLIL::SigSpec &sig, RTLIL::Module *module, std::string str);
|
|
|
|
static bool parse_sel(RTLIL::SigSpec &sig, RTLIL::Design *design, RTLIL::Module *module, std::string str);
|
|
|
|
static bool parse_rhs(const RTLIL::SigSpec &lhs, RTLIL::SigSpec &sig, RTLIL::Module *module, std::string str);
|
|
|
|
|
|
|
|
operator std::vector<RTLIL::SigChunk>() const { return chunks(); }
|
|
|
|
operator std::vector<RTLIL::SigBit>() const { return bits(); }
|
|
|
|
|
2014-12-26 14:35:22 -06:00
|
|
|
unsigned int hash() const { if (!hash_) updhash(); return hash_; };
|
|
|
|
|
2014-12-26 03:53:21 -06:00
|
|
|
#ifndef NDEBUG
|
|
|
|
void check() const;
|
|
|
|
#else
|
|
|
|
void check() const { }
|
|
|
|
#endif
|
|
|
|
};
|
|
|
|
|
2014-07-26 19:00:04 -05:00
|
|
|
struct RTLIL::Selection
|
|
|
|
{
|
2013-01-05 04:13:26 -06:00
|
|
|
bool full_selection;
|
2014-12-26 14:59:41 -06:00
|
|
|
pool<RTLIL::IdString> selected_modules;
|
|
|
|
dict<RTLIL::IdString, pool<RTLIL::IdString>> selected_members;
|
2014-07-26 19:00:04 -05:00
|
|
|
|
2013-01-05 04:13:26 -06:00
|
|
|
Selection(bool full = true) : full_selection(full) { }
|
2014-07-26 19:00:04 -05:00
|
|
|
|
2013-06-02 10:53:30 -05:00
|
|
|
bool selected_module(RTLIL::IdString mod_name) const;
|
|
|
|
bool selected_whole_module(RTLIL::IdString mod_name) const;
|
|
|
|
bool selected_member(RTLIL::IdString mod_name, RTLIL::IdString memb_name) const;
|
2013-01-05 04:13:26 -06:00
|
|
|
void optimize(RTLIL::Design *design);
|
2014-07-26 19:00:04 -05:00
|
|
|
|
2013-11-23 08:58:06 -06:00
|
|
|
template<typename T1> void select(T1 *module) {
|
|
|
|
if (!full_selection && selected_modules.count(module->name) == 0) {
|
|
|
|
selected_modules.insert(module->name);
|
|
|
|
selected_members.erase(module->name);
|
|
|
|
}
|
|
|
|
}
|
2014-07-26 19:00:04 -05:00
|
|
|
|
2013-08-09 08:20:22 -05:00
|
|
|
template<typename T1, typename T2> void select(T1 *module, T2 *member) {
|
|
|
|
if (!full_selection && selected_modules.count(module->name) == 0)
|
|
|
|
selected_members[module->name].insert(member->name);
|
|
|
|
}
|
2014-07-26 19:00:04 -05:00
|
|
|
|
2014-01-17 09:34:50 -06:00
|
|
|
bool empty() const {
|
|
|
|
return !full_selection && selected_modules.empty() && selected_members.empty();
|
|
|
|
}
|
2013-01-05 04:13:26 -06:00
|
|
|
};
|
|
|
|
|
2014-07-31 07:34:12 -05:00
|
|
|
struct RTLIL::Monitor
|
|
|
|
{
|
2014-12-28 10:51:16 -06:00
|
|
|
unsigned int hashidx_;
|
|
|
|
unsigned int hash() const { return hashidx_; }
|
|
|
|
|
|
|
|
Monitor() {
|
2014-12-28 17:12:36 -06:00
|
|
|
static unsigned int hashidx_count = 123456789;
|
|
|
|
hashidx_count = mkhash_xorshift(hashidx_count);
|
|
|
|
hashidx_ = hashidx_count;
|
2014-12-28 10:51:16 -06:00
|
|
|
}
|
|
|
|
|
2014-07-31 09:38:54 -05:00
|
|
|
virtual ~Monitor() { }
|
2014-07-31 07:34:12 -05:00
|
|
|
virtual void notify_module_add(RTLIL::Module*) { }
|
|
|
|
virtual void notify_module_del(RTLIL::Module*) { }
|
2014-08-01 09:53:15 -05:00
|
|
|
virtual void notify_connect(RTLIL::Cell*, const RTLIL::IdString&, const RTLIL::SigSpec&, RTLIL::SigSpec&) { }
|
2014-07-31 07:34:12 -05:00
|
|
|
virtual void notify_connect(RTLIL::Module*, const RTLIL::SigSig&) { }
|
2014-08-01 09:53:15 -05:00
|
|
|
virtual void notify_connect(RTLIL::Module*, const std::vector<RTLIL::SigSig>&) { }
|
2014-07-31 07:34:12 -05:00
|
|
|
virtual void notify_blackout(RTLIL::Module*) { }
|
|
|
|
};
|
|
|
|
|
2014-07-26 19:00:04 -05:00
|
|
|
struct RTLIL::Design
|
|
|
|
{
|
2014-12-28 10:51:16 -06:00
|
|
|
unsigned int hashidx_;
|
|
|
|
unsigned int hash() const { return hashidx_; }
|
|
|
|
|
|
|
|
pool<RTLIL::Monitor*> monitors;
|
2014-12-26 03:53:21 -06:00
|
|
|
dict<std::string, std::string> scratchpad;
|
2014-07-31 07:34:12 -05:00
|
|
|
|
2014-07-27 03:40:31 -05:00
|
|
|
int refcount_modules_;
|
2014-12-26 03:53:21 -06:00
|
|
|
dict<RTLIL::IdString, RTLIL::Module*> modules_;
|
2016-11-15 05:42:43 -06:00
|
|
|
std::vector<AST::AstNode*> verilog_packages, verilog_globals;
|
|
|
|
dict<std::string, std::pair<std::string, bool>> verilog_defines;
|
2014-07-26 19:00:04 -05:00
|
|
|
|
2013-01-05 04:13:26 -06:00
|
|
|
std::vector<RTLIL::Selection> selection_stack;
|
2014-12-26 03:53:21 -06:00
|
|
|
dict<RTLIL::IdString, RTLIL::Selection> selection_vars;
|
2013-01-05 04:13:26 -06:00
|
|
|
std::string selected_active_module;
|
2014-07-26 19:00:04 -05:00
|
|
|
|
2014-07-29 09:06:27 -05:00
|
|
|
Design();
|
2013-01-05 04:13:26 -06:00
|
|
|
~Design();
|
2014-07-26 19:00:04 -05:00
|
|
|
|
2014-07-27 14:12:09 -05:00
|
|
|
RTLIL::ObjRange<RTLIL::Module*> modules();
|
|
|
|
RTLIL::Module *module(RTLIL::IdString name);
|
2015-06-17 02:38:56 -05:00
|
|
|
RTLIL::Module *top_module();
|
2014-07-27 14:12:09 -05:00
|
|
|
|
2014-07-29 09:06:27 -05:00
|
|
|
bool has(RTLIL::IdString id) const {
|
|
|
|
return modules_.count(id) != 0;
|
|
|
|
}
|
|
|
|
|
2014-07-27 14:12:09 -05:00
|
|
|
void add(RTLIL::Module *module);
|
|
|
|
RTLIL::Module *addModule(RTLIL::IdString name);
|
|
|
|
void remove(RTLIL::Module *module);
|
2015-06-29 18:37:59 -05:00
|
|
|
void rename(RTLIL::Module *module, RTLIL::IdString new_name);
|
2014-07-27 03:40:31 -05:00
|
|
|
|
2014-08-30 12:37:12 -05:00
|
|
|
void scratchpad_unset(std::string varname);
|
|
|
|
|
|
|
|
void scratchpad_set_int(std::string varname, int value);
|
|
|
|
void scratchpad_set_bool(std::string varname, bool value);
|
|
|
|
void scratchpad_set_string(std::string varname, std::string value);
|
|
|
|
|
|
|
|
int scratchpad_get_int(std::string varname, int default_value = 0) const;
|
|
|
|
bool scratchpad_get_bool(std::string varname, bool default_value = false) const;
|
|
|
|
std::string scratchpad_get_string(std::string varname, std::string default_value = std::string()) const;
|
|
|
|
|
2015-01-23 17:13:27 -06:00
|
|
|
void sort();
|
2013-01-05 04:13:26 -06:00
|
|
|
void check();
|
|
|
|
void optimize();
|
2014-07-26 19:00:04 -05:00
|
|
|
|
2013-06-02 10:53:30 -05:00
|
|
|
bool selected_module(RTLIL::IdString mod_name) const;
|
|
|
|
bool selected_whole_module(RTLIL::IdString mod_name) const;
|
|
|
|
bool selected_member(RTLIL::IdString mod_name, RTLIL::IdString memb_name) const;
|
2014-07-26 19:00:04 -05:00
|
|
|
|
2014-07-27 04:03:56 -05:00
|
|
|
bool selected_module(RTLIL::Module *mod) const;
|
|
|
|
bool selected_whole_module(RTLIL::Module *mod) const;
|
|
|
|
|
2015-02-24 15:31:30 -06:00
|
|
|
RTLIL::Selection &selection() {
|
|
|
|
return selection_stack.back();
|
|
|
|
}
|
|
|
|
|
|
|
|
const RTLIL::Selection &selection() const {
|
|
|
|
return selection_stack.back();
|
|
|
|
}
|
|
|
|
|
2013-10-27 03:30:58 -05:00
|
|
|
bool full_selection() const {
|
|
|
|
return selection_stack.back().full_selection;
|
|
|
|
}
|
2014-07-26 19:00:04 -05:00
|
|
|
|
2013-06-02 10:53:30 -05:00
|
|
|
template<typename T1> bool selected(T1 *module) const {
|
2013-01-05 04:13:26 -06:00
|
|
|
return selected_module(module->name);
|
|
|
|
}
|
2014-07-26 19:00:04 -05:00
|
|
|
|
2013-06-02 10:53:30 -05:00
|
|
|
template<typename T1, typename T2> bool selected(T1 *module, T2 *member) const {
|
2013-01-05 04:13:26 -06:00
|
|
|
return selected_member(module->name, member->name);
|
|
|
|
}
|
2014-07-26 19:00:04 -05:00
|
|
|
|
2013-03-03 13:53:24 -06:00
|
|
|
template<typename T1, typename T2> void select(T1 *module, T2 *member) {
|
|
|
|
if (selection_stack.size() > 0) {
|
|
|
|
RTLIL::Selection &sel = selection_stack.back();
|
2013-08-09 08:20:22 -05:00
|
|
|
sel.select(module, member);
|
2013-03-03 13:53:24 -06:00
|
|
|
}
|
|
|
|
}
|
2014-07-31 07:11:39 -05:00
|
|
|
|
2018-07-09 08:48:06 -05:00
|
|
|
|
2014-07-31 07:11:39 -05:00
|
|
|
std::vector<RTLIL::Module*> selected_modules() const;
|
|
|
|
std::vector<RTLIL::Module*> selected_whole_modules() const;
|
|
|
|
std::vector<RTLIL::Module*> selected_whole_modules_warn() const;
|
2018-08-13 08:18:46 -05:00
|
|
|
#ifdef WITH_PYTHON
|
|
|
|
static std::map<unsigned int, RTLIL::Design*> *get_all_designs(void);
|
|
|
|
#endif
|
2013-01-05 04:13:26 -06:00
|
|
|
};
|
|
|
|
|
2015-04-24 15:04:05 -05:00
|
|
|
struct RTLIL::Module : public RTLIL::AttrObject
|
2014-07-25 08:05:18 -05:00
|
|
|
{
|
2014-12-28 10:51:16 -06:00
|
|
|
unsigned int hashidx_;
|
|
|
|
unsigned int hash() const { return hashidx_; }
|
|
|
|
|
2014-07-26 14:16:05 -05:00
|
|
|
protected:
|
|
|
|
void add(RTLIL::Wire *wire);
|
|
|
|
void add(RTLIL::Cell *cell);
|
|
|
|
|
|
|
|
public:
|
2014-07-31 07:11:39 -05:00
|
|
|
RTLIL::Design *design;
|
2014-12-28 10:51:16 -06:00
|
|
|
pool<RTLIL::Monitor*> monitors;
|
2014-07-31 07:34:12 -05:00
|
|
|
|
2014-07-27 03:13:22 -05:00
|
|
|
int refcount_wires_;
|
|
|
|
int refcount_cells_;
|
|
|
|
|
2014-12-26 03:53:21 -06:00
|
|
|
dict<RTLIL::IdString, RTLIL::Wire*> wires_;
|
|
|
|
dict<RTLIL::IdString, RTLIL::Cell*> cells_;
|
2014-07-26 19:00:04 -05:00
|
|
|
std::vector<RTLIL::SigSig> connections_;
|
|
|
|
|
2013-01-05 04:13:26 -06:00
|
|
|
RTLIL::IdString name;
|
2014-12-26 14:59:41 -06:00
|
|
|
pool<RTLIL::IdString> avail_parameters;
|
2014-12-26 03:53:21 -06:00
|
|
|
dict<RTLIL::IdString, RTLIL::Memory*> memories;
|
|
|
|
dict<RTLIL::IdString, RTLIL::Process*> processes;
|
2014-07-26 04:58:03 -05:00
|
|
|
|
2014-07-27 03:13:22 -05:00
|
|
|
Module();
|
2013-01-05 04:13:26 -06:00
|
|
|
virtual ~Module();
|
2018-01-05 06:28:45 -06:00
|
|
|
virtual RTLIL::IdString derive(RTLIL::Design *design, dict<RTLIL::IdString, RTLIL::Const> parameters, bool mayfail = false);
|
2018-10-12 13:58:37 -05:00
|
|
|
virtual RTLIL::IdString derive(RTLIL::Design *design, dict<RTLIL::IdString, RTLIL::Const> parameters, dict<RTLIL::IdString, RTLIL::Module*> interfaces, dict<RTLIL::IdString, RTLIL::IdString> modports, bool mayfail = false);
|
2013-01-05 04:13:26 -06:00
|
|
|
virtual size_t count_id(RTLIL::IdString id);
|
2018-10-11 16:33:31 -05:00
|
|
|
virtual void reprocess_module(RTLIL::Design *design, dict<RTLIL::IdString, RTLIL::Module *> local_interfaces);
|
2015-01-23 17:13:27 -06:00
|
|
|
|
|
|
|
virtual void sort();
|
2013-01-05 04:13:26 -06:00
|
|
|
virtual void check();
|
|
|
|
virtual void optimize();
|
2019-04-05 10:31:49 -05:00
|
|
|
virtual void makeblackbox();
|
2014-07-26 04:58:03 -05:00
|
|
|
|
2014-07-26 07:31:47 -05:00
|
|
|
void connect(const RTLIL::SigSig &conn);
|
2014-07-26 04:58:03 -05:00
|
|
|
void connect(const RTLIL::SigSpec &lhs, const RTLIL::SigSpec &rhs);
|
2014-07-31 07:34:12 -05:00
|
|
|
void new_connections(const std::vector<RTLIL::SigSig> &new_conn);
|
2014-07-26 08:57:27 -05:00
|
|
|
const std::vector<RTLIL::SigSig> &connections() const;
|
2014-08-14 09:13:42 -05:00
|
|
|
|
|
|
|
std::vector<RTLIL::IdString> ports;
|
2013-06-18 10:11:13 -05:00
|
|
|
void fixup_ports();
|
|
|
|
|
2017-05-28 04:59:05 -05:00
|
|
|
template<typename T> void rewrite_sigspecs(T &functor);
|
2019-05-15 09:01:00 -05:00
|
|
|
template<typename T> void rewrite_sigspecs2(T &functor);
|
2013-07-27 07:27:51 -05:00
|
|
|
void cloneInto(RTLIL::Module *new_mod) const;
|
|
|
|
virtual RTLIL::Module *clone() const;
|
2013-10-24 03:59:27 -05:00
|
|
|
|
2014-07-31 07:11:39 -05:00
|
|
|
bool has_memories() const;
|
|
|
|
bool has_processes() const;
|
|
|
|
|
|
|
|
bool has_memories_warn() const;
|
|
|
|
bool has_processes_warn() const;
|
|
|
|
|
|
|
|
std::vector<RTLIL::Wire*> selected_wires() const;
|
|
|
|
std::vector<RTLIL::Cell*> selected_cells() const;
|
|
|
|
|
2014-08-05 07:47:03 -05:00
|
|
|
template<typename T> bool selected(T *member) const {
|
|
|
|
return design->selected_member(name, member->name);
|
|
|
|
}
|
|
|
|
|
2014-07-27 04:03:56 -05:00
|
|
|
RTLIL::Wire* wire(RTLIL::IdString id) { return wires_.count(id) ? wires_.at(id) : nullptr; }
|
|
|
|
RTLIL::Cell* cell(RTLIL::IdString id) { return cells_.count(id) ? cells_.at(id) : nullptr; }
|
|
|
|
|
2014-07-27 03:13:22 -05:00
|
|
|
RTLIL::ObjRange<RTLIL::Wire*> wires() { return RTLIL::ObjRange<RTLIL::Wire*>(&wires_, &refcount_wires_); }
|
|
|
|
RTLIL::ObjRange<RTLIL::Cell*> cells() { return RTLIL::ObjRange<RTLIL::Cell*>(&cells_, &refcount_cells_); }
|
|
|
|
|
2014-07-26 13:12:50 -05:00
|
|
|
// Removing wires is expensive. If you have to remove wires, remove them all at once.
|
2014-12-28 10:51:16 -06:00
|
|
|
void remove(const pool<RTLIL::Wire*> &wires);
|
2014-07-21 05:35:06 -05:00
|
|
|
void remove(RTLIL::Cell *cell);
|
|
|
|
|
2014-07-25 08:05:18 -05:00
|
|
|
void rename(RTLIL::Wire *wire, RTLIL::IdString new_name);
|
|
|
|
void rename(RTLIL::Cell *cell, RTLIL::IdString new_name);
|
|
|
|
void rename(RTLIL::IdString old_name, RTLIL::IdString new_name);
|
|
|
|
|
2014-08-05 07:47:03 -05:00
|
|
|
void swap_names(RTLIL::Wire *w1, RTLIL::Wire *w2);
|
|
|
|
void swap_names(RTLIL::Cell *c1, RTLIL::Cell *c2);
|
|
|
|
|
2014-08-16 16:50:36 -05:00
|
|
|
RTLIL::IdString uniquify(RTLIL::IdString name);
|
|
|
|
RTLIL::IdString uniquify(RTLIL::IdString name, int &index);
|
|
|
|
|
2014-07-21 05:02:55 -05:00
|
|
|
RTLIL::Wire *addWire(RTLIL::IdString name, int width = 1);
|
2014-07-26 14:16:05 -05:00
|
|
|
RTLIL::Wire *addWire(RTLIL::IdString name, const RTLIL::Wire *other);
|
|
|
|
|
2014-07-21 05:02:55 -05:00
|
|
|
RTLIL::Cell *addCell(RTLIL::IdString name, RTLIL::IdString type);
|
2014-07-25 17:38:44 -05:00
|
|
|
RTLIL::Cell *addCell(RTLIL::IdString name, const RTLIL::Cell *other);
|
2014-07-21 05:02:55 -05:00
|
|
|
|
2014-07-18 03:27:06 -05:00
|
|
|
// The add* methods create a cell and return the created cell. All signals must exist in advance.
|
|
|
|
|
2017-09-09 03:16:48 -05:00
|
|
|
RTLIL::Cell* addNot (RTLIL::IdString name, RTLIL::SigSpec sig_a, RTLIL::SigSpec sig_y, bool is_signed = false, const std::string &src = "");
|
|
|
|
RTLIL::Cell* addPos (RTLIL::IdString name, RTLIL::SigSpec sig_a, RTLIL::SigSpec sig_y, bool is_signed = false, const std::string &src = "");
|
|
|
|
RTLIL::Cell* addNeg (RTLIL::IdString name, RTLIL::SigSpec sig_a, RTLIL::SigSpec sig_y, bool is_signed = false, const std::string &src = "");
|
|
|
|
|
|
|
|
RTLIL::Cell* addAnd (RTLIL::IdString name, RTLIL::SigSpec sig_a, RTLIL::SigSpec sig_b, RTLIL::SigSpec sig_y, bool is_signed = false, const std::string &src = "");
|
|
|
|
RTLIL::Cell* addOr (RTLIL::IdString name, RTLIL::SigSpec sig_a, RTLIL::SigSpec sig_b, RTLIL::SigSpec sig_y, bool is_signed = false, const std::string &src = "");
|
|
|
|
RTLIL::Cell* addXor (RTLIL::IdString name, RTLIL::SigSpec sig_a, RTLIL::SigSpec sig_b, RTLIL::SigSpec sig_y, bool is_signed = false, const std::string &src = "");
|
|
|
|
RTLIL::Cell* addXnor (RTLIL::IdString name, RTLIL::SigSpec sig_a, RTLIL::SigSpec sig_b, RTLIL::SigSpec sig_y, bool is_signed = false, const std::string &src = "");
|
|
|
|
|
|
|
|
RTLIL::Cell* addReduceAnd (RTLIL::IdString name, RTLIL::SigSpec sig_a, RTLIL::SigSpec sig_y, bool is_signed = false, const std::string &src = "");
|
|
|
|
RTLIL::Cell* addReduceOr (RTLIL::IdString name, RTLIL::SigSpec sig_a, RTLIL::SigSpec sig_y, bool is_signed = false, const std::string &src = "");
|
|
|
|
RTLIL::Cell* addReduceXor (RTLIL::IdString name, RTLIL::SigSpec sig_a, RTLIL::SigSpec sig_y, bool is_signed = false, const std::string &src = "");
|
|
|
|
RTLIL::Cell* addReduceXnor (RTLIL::IdString name, RTLIL::SigSpec sig_a, RTLIL::SigSpec sig_y, bool is_signed = false, const std::string &src = "");
|
|
|
|
RTLIL::Cell* addReduceBool (RTLIL::IdString name, RTLIL::SigSpec sig_a, RTLIL::SigSpec sig_y, bool is_signed = false, const std::string &src = "");
|
|
|
|
|
|
|
|
RTLIL::Cell* addShl (RTLIL::IdString name, RTLIL::SigSpec sig_a, RTLIL::SigSpec sig_b, RTLIL::SigSpec sig_y, bool is_signed = false, const std::string &src = "");
|
|
|
|
RTLIL::Cell* addShr (RTLIL::IdString name, RTLIL::SigSpec sig_a, RTLIL::SigSpec sig_b, RTLIL::SigSpec sig_y, bool is_signed = false, const std::string &src = "");
|
|
|
|
RTLIL::Cell* addSshl (RTLIL::IdString name, RTLIL::SigSpec sig_a, RTLIL::SigSpec sig_b, RTLIL::SigSpec sig_y, bool is_signed = false, const std::string &src = "");
|
|
|
|
RTLIL::Cell* addSshr (RTLIL::IdString name, RTLIL::SigSpec sig_a, RTLIL::SigSpec sig_b, RTLIL::SigSpec sig_y, bool is_signed = false, const std::string &src = "");
|
|
|
|
RTLIL::Cell* addShift (RTLIL::IdString name, RTLIL::SigSpec sig_a, RTLIL::SigSpec sig_b, RTLIL::SigSpec sig_y, bool is_signed = false, const std::string &src = "");
|
|
|
|
RTLIL::Cell* addShiftx (RTLIL::IdString name, RTLIL::SigSpec sig_a, RTLIL::SigSpec sig_b, RTLIL::SigSpec sig_y, bool is_signed = false, const std::string &src = "");
|
|
|
|
|
|
|
|
RTLIL::Cell* addLt (RTLIL::IdString name, RTLIL::SigSpec sig_a, RTLIL::SigSpec sig_b, RTLIL::SigSpec sig_y, bool is_signed = false, const std::string &src = "");
|
|
|
|
RTLIL::Cell* addLe (RTLIL::IdString name, RTLIL::SigSpec sig_a, RTLIL::SigSpec sig_b, RTLIL::SigSpec sig_y, bool is_signed = false, const std::string &src = "");
|
|
|
|
RTLIL::Cell* addEq (RTLIL::IdString name, RTLIL::SigSpec sig_a, RTLIL::SigSpec sig_b, RTLIL::SigSpec sig_y, bool is_signed = false, const std::string &src = "");
|
|
|
|
RTLIL::Cell* addNe (RTLIL::IdString name, RTLIL::SigSpec sig_a, RTLIL::SigSpec sig_b, RTLIL::SigSpec sig_y, bool is_signed = false, const std::string &src = "");
|
|
|
|
RTLIL::Cell* addEqx (RTLIL::IdString name, RTLIL::SigSpec sig_a, RTLIL::SigSpec sig_b, RTLIL::SigSpec sig_y, bool is_signed = false, const std::string &src = "");
|
|
|
|
RTLIL::Cell* addNex (RTLIL::IdString name, RTLIL::SigSpec sig_a, RTLIL::SigSpec sig_b, RTLIL::SigSpec sig_y, bool is_signed = false, const std::string &src = "");
|
|
|
|
RTLIL::Cell* addGe (RTLIL::IdString name, RTLIL::SigSpec sig_a, RTLIL::SigSpec sig_b, RTLIL::SigSpec sig_y, bool is_signed = false, const std::string &src = "");
|
|
|
|
RTLIL::Cell* addGt (RTLIL::IdString name, RTLIL::SigSpec sig_a, RTLIL::SigSpec sig_b, RTLIL::SigSpec sig_y, bool is_signed = false, const std::string &src = "");
|
|
|
|
|
|
|
|
RTLIL::Cell* addAdd (RTLIL::IdString name, RTLIL::SigSpec sig_a, RTLIL::SigSpec sig_b, RTLIL::SigSpec sig_y, bool is_signed = false, const std::string &src = "");
|
|
|
|
RTLIL::Cell* addSub (RTLIL::IdString name, RTLIL::SigSpec sig_a, RTLIL::SigSpec sig_b, RTLIL::SigSpec sig_y, bool is_signed = false, const std::string &src = "");
|
|
|
|
RTLIL::Cell* addMul (RTLIL::IdString name, RTLIL::SigSpec sig_a, RTLIL::SigSpec sig_b, RTLIL::SigSpec sig_y, bool is_signed = false, const std::string &src = "");
|
|
|
|
RTLIL::Cell* addDiv (RTLIL::IdString name, RTLIL::SigSpec sig_a, RTLIL::SigSpec sig_b, RTLIL::SigSpec sig_y, bool is_signed = false, const std::string &src = "");
|
|
|
|
RTLIL::Cell* addMod (RTLIL::IdString name, RTLIL::SigSpec sig_a, RTLIL::SigSpec sig_b, RTLIL::SigSpec sig_y, bool is_signed = false, const std::string &src = "");
|
|
|
|
RTLIL::Cell* addPow (RTLIL::IdString name, RTLIL::SigSpec sig_a, RTLIL::SigSpec sig_b, RTLIL::SigSpec sig_y, bool a_signed = false, bool b_signed = false, const std::string &src = "");
|
|
|
|
|
|
|
|
RTLIL::Cell* addLogicNot (RTLIL::IdString name, RTLIL::SigSpec sig_a, RTLIL::SigSpec sig_y, bool is_signed = false, const std::string &src = "");
|
|
|
|
RTLIL::Cell* addLogicAnd (RTLIL::IdString name, RTLIL::SigSpec sig_a, RTLIL::SigSpec sig_b, RTLIL::SigSpec sig_y, bool is_signed = false, const std::string &src = "");
|
|
|
|
RTLIL::Cell* addLogicOr (RTLIL::IdString name, RTLIL::SigSpec sig_a, RTLIL::SigSpec sig_b, RTLIL::SigSpec sig_y, bool is_signed = false, const std::string &src = "");
|
|
|
|
|
|
|
|
RTLIL::Cell* addMux (RTLIL::IdString name, RTLIL::SigSpec sig_a, RTLIL::SigSpec sig_b, RTLIL::SigSpec sig_s, RTLIL::SigSpec sig_y, const std::string &src = "");
|
|
|
|
RTLIL::Cell* addPmux (RTLIL::IdString name, RTLIL::SigSpec sig_a, RTLIL::SigSpec sig_b, RTLIL::SigSpec sig_s, RTLIL::SigSpec sig_y, const std::string &src = "");
|
|
|
|
|
|
|
|
RTLIL::Cell* addSlice (RTLIL::IdString name, RTLIL::SigSpec sig_a, RTLIL::SigSpec sig_y, RTLIL::Const offset, const std::string &src = "");
|
|
|
|
RTLIL::Cell* addConcat (RTLIL::IdString name, RTLIL::SigSpec sig_a, RTLIL::SigSpec sig_b, RTLIL::SigSpec sig_y, const std::string &src = "");
|
|
|
|
RTLIL::Cell* addLut (RTLIL::IdString name, RTLIL::SigSpec sig_a, RTLIL::SigSpec sig_y, RTLIL::Const lut, const std::string &src = "");
|
|
|
|
RTLIL::Cell* addTribuf (RTLIL::IdString name, RTLIL::SigSpec sig_a, RTLIL::SigSpec sig_en, RTLIL::SigSpec sig_y, const std::string &src = "");
|
|
|
|
RTLIL::Cell* addAssert (RTLIL::IdString name, RTLIL::SigSpec sig_a, RTLIL::SigSpec sig_en, const std::string &src = "");
|
|
|
|
RTLIL::Cell* addAssume (RTLIL::IdString name, RTLIL::SigSpec sig_a, RTLIL::SigSpec sig_en, const std::string &src = "");
|
|
|
|
RTLIL::Cell* addLive (RTLIL::IdString name, RTLIL::SigSpec sig_a, RTLIL::SigSpec sig_en, const std::string &src = "");
|
|
|
|
RTLIL::Cell* addFair (RTLIL::IdString name, RTLIL::SigSpec sig_a, RTLIL::SigSpec sig_en, const std::string &src = "");
|
|
|
|
RTLIL::Cell* addCover (RTLIL::IdString name, RTLIL::SigSpec sig_a, RTLIL::SigSpec sig_en, const std::string &src = "");
|
|
|
|
RTLIL::Cell* addEquiv (RTLIL::IdString name, RTLIL::SigSpec sig_a, RTLIL::SigSpec sig_b, RTLIL::SigSpec sig_y, const std::string &src = "");
|
|
|
|
|
|
|
|
RTLIL::Cell* addSr (RTLIL::IdString name, RTLIL::SigSpec sig_set, RTLIL::SigSpec sig_clr, RTLIL::SigSpec sig_q, bool set_polarity = true, bool clr_polarity = true, const std::string &src = "");
|
|
|
|
RTLIL::Cell* addFf (RTLIL::IdString name, RTLIL::SigSpec sig_d, RTLIL::SigSpec sig_q, const std::string &src = "");
|
|
|
|
RTLIL::Cell* addDff (RTLIL::IdString name, RTLIL::SigSpec sig_clk, RTLIL::SigSpec sig_d, RTLIL::SigSpec sig_q, bool clk_polarity = true, const std::string &src = "");
|
|
|
|
RTLIL::Cell* addDffe (RTLIL::IdString name, RTLIL::SigSpec sig_clk, RTLIL::SigSpec sig_en, RTLIL::SigSpec sig_d, RTLIL::SigSpec sig_q, bool clk_polarity = true, bool en_polarity = true, const std::string &src = "");
|
2014-03-09 21:02:27 -05:00
|
|
|
RTLIL::Cell* addDffsr (RTLIL::IdString name, RTLIL::SigSpec sig_clk, RTLIL::SigSpec sig_set, RTLIL::SigSpec sig_clr,
|
2017-09-09 03:16:48 -05:00
|
|
|
RTLIL::SigSpec sig_d, RTLIL::SigSpec sig_q, bool clk_polarity = true, bool set_polarity = true, bool clr_polarity = true, const std::string &src = "");
|
2014-03-09 21:02:27 -05:00
|
|
|
RTLIL::Cell* addAdff (RTLIL::IdString name, RTLIL::SigSpec sig_clk, RTLIL::SigSpec sig_arst, RTLIL::SigSpec sig_d, RTLIL::SigSpec sig_q,
|
2017-09-09 03:16:48 -05:00
|
|
|
RTLIL::Const arst_value, bool clk_polarity = true, bool arst_polarity = true, const std::string &src = "");
|
|
|
|
RTLIL::Cell* addDlatch (RTLIL::IdString name, RTLIL::SigSpec sig_en, RTLIL::SigSpec sig_d, RTLIL::SigSpec sig_q, bool en_polarity = true, const std::string &src = "");
|
2014-03-31 07:14:40 -05:00
|
|
|
RTLIL::Cell* addDlatchsr (RTLIL::IdString name, RTLIL::SigSpec sig_en, RTLIL::SigSpec sig_set, RTLIL::SigSpec sig_clr,
|
2017-09-09 03:16:48 -05:00
|
|
|
RTLIL::SigSpec sig_d, RTLIL::SigSpec sig_q, bool en_polarity = true, bool set_polarity = true, bool clr_polarity = true, const std::string &src = "");
|
|
|
|
|
|
|
|
RTLIL::Cell* addBufGate (RTLIL::IdString name, RTLIL::SigBit sig_a, RTLIL::SigBit sig_y, const std::string &src = "");
|
|
|
|
RTLIL::Cell* addNotGate (RTLIL::IdString name, RTLIL::SigBit sig_a, RTLIL::SigBit sig_y, const std::string &src = "");
|
|
|
|
RTLIL::Cell* addAndGate (RTLIL::IdString name, RTLIL::SigBit sig_a, RTLIL::SigBit sig_b, RTLIL::SigBit sig_y, const std::string &src = "");
|
|
|
|
RTLIL::Cell* addNandGate (RTLIL::IdString name, RTLIL::SigBit sig_a, RTLIL::SigBit sig_b, RTLIL::SigBit sig_y, const std::string &src = "");
|
|
|
|
RTLIL::Cell* addOrGate (RTLIL::IdString name, RTLIL::SigBit sig_a, RTLIL::SigBit sig_b, RTLIL::SigBit sig_y, const std::string &src = "");
|
|
|
|
RTLIL::Cell* addNorGate (RTLIL::IdString name, RTLIL::SigBit sig_a, RTLIL::SigBit sig_b, RTLIL::SigBit sig_y, const std::string &src = "");
|
|
|
|
RTLIL::Cell* addXorGate (RTLIL::IdString name, RTLIL::SigBit sig_a, RTLIL::SigBit sig_b, RTLIL::SigBit sig_y, const std::string &src = "");
|
|
|
|
RTLIL::Cell* addXnorGate (RTLIL::IdString name, RTLIL::SigBit sig_a, RTLIL::SigBit sig_b, RTLIL::SigBit sig_y, const std::string &src = "");
|
|
|
|
RTLIL::Cell* addAndnotGate (RTLIL::IdString name, RTLIL::SigBit sig_a, RTLIL::SigBit sig_b, RTLIL::SigBit sig_y, const std::string &src = "");
|
|
|
|
RTLIL::Cell* addOrnotGate (RTLIL::IdString name, RTLIL::SigBit sig_a, RTLIL::SigBit sig_b, RTLIL::SigBit sig_y, const std::string &src = "");
|
|
|
|
RTLIL::Cell* addMuxGate (RTLIL::IdString name, RTLIL::SigBit sig_a, RTLIL::SigBit sig_b, RTLIL::SigBit sig_s, RTLIL::SigBit sig_y, const std::string &src = "");
|
|
|
|
RTLIL::Cell* addAoi3Gate (RTLIL::IdString name, RTLIL::SigBit sig_a, RTLIL::SigBit sig_b, RTLIL::SigBit sig_c, RTLIL::SigBit sig_y, const std::string &src = "");
|
|
|
|
RTLIL::Cell* addOai3Gate (RTLIL::IdString name, RTLIL::SigBit sig_a, RTLIL::SigBit sig_b, RTLIL::SigBit sig_c, RTLIL::SigBit sig_y, const std::string &src = "");
|
|
|
|
RTLIL::Cell* addAoi4Gate (RTLIL::IdString name, RTLIL::SigBit sig_a, RTLIL::SigBit sig_b, RTLIL::SigBit sig_c, RTLIL::SigBit sig_d, RTLIL::SigBit sig_y, const std::string &src = "");
|
|
|
|
RTLIL::Cell* addOai4Gate (RTLIL::IdString name, RTLIL::SigBit sig_a, RTLIL::SigBit sig_b, RTLIL::SigBit sig_c, RTLIL::SigBit sig_d, RTLIL::SigBit sig_y, const std::string &src = "");
|
|
|
|
|
|
|
|
RTLIL::Cell* addFfGate (RTLIL::IdString name, RTLIL::SigSpec sig_d, RTLIL::SigSpec sig_q, const std::string &src = "");
|
|
|
|
RTLIL::Cell* addDffGate (RTLIL::IdString name, RTLIL::SigSpec sig_clk, RTLIL::SigSpec sig_d, RTLIL::SigSpec sig_q, bool clk_polarity = true, const std::string &src = "");
|
|
|
|
RTLIL::Cell* addDffeGate (RTLIL::IdString name, RTLIL::SigSpec sig_clk, RTLIL::SigSpec sig_en, RTLIL::SigSpec sig_d, RTLIL::SigSpec sig_q, bool clk_polarity = true, bool en_polarity = true, const std::string &src = "");
|
2014-03-15 08:35:29 -05:00
|
|
|
RTLIL::Cell* addDffsrGate (RTLIL::IdString name, RTLIL::SigSpec sig_clk, RTLIL::SigSpec sig_set, RTLIL::SigSpec sig_clr,
|
2017-09-09 03:16:48 -05:00
|
|
|
RTLIL::SigSpec sig_d, RTLIL::SigSpec sig_q, bool clk_polarity = true, bool set_polarity = true, bool clr_polarity = true, const std::string &src = "");
|
2014-03-15 08:35:29 -05:00
|
|
|
RTLIL::Cell* addAdffGate (RTLIL::IdString name, RTLIL::SigSpec sig_clk, RTLIL::SigSpec sig_arst, RTLIL::SigSpec sig_d, RTLIL::SigSpec sig_q,
|
2017-09-09 03:16:48 -05:00
|
|
|
bool arst_value = false, bool clk_polarity = true, bool arst_polarity = true, const std::string &src = "");
|
|
|
|
RTLIL::Cell* addDlatchGate (RTLIL::IdString name, RTLIL::SigSpec sig_en, RTLIL::SigSpec sig_d, RTLIL::SigSpec sig_q, bool en_polarity = true, const std::string &src = "");
|
2014-03-31 07:14:40 -05:00
|
|
|
RTLIL::Cell* addDlatchsrGate (RTLIL::IdString name, RTLIL::SigSpec sig_en, RTLIL::SigSpec sig_set, RTLIL::SigSpec sig_clr,
|
2017-09-09 03:16:48 -05:00
|
|
|
RTLIL::SigSpec sig_d, RTLIL::SigSpec sig_q, bool en_polarity = true, bool set_polarity = true, bool clr_polarity = true, const std::string &src = "");
|
2014-07-18 03:27:06 -05:00
|
|
|
|
|
|
|
// The methods without the add* prefix create a cell and an output signal. They return the newly created output signal.
|
|
|
|
|
2017-09-09 03:16:48 -05:00
|
|
|
RTLIL::SigSpec Not (RTLIL::IdString name, RTLIL::SigSpec sig_a, bool is_signed = false, const std::string &src = "");
|
|
|
|
RTLIL::SigSpec Pos (RTLIL::IdString name, RTLIL::SigSpec sig_a, bool is_signed = false, const std::string &src = "");
|
|
|
|
RTLIL::SigSpec Bu0 (RTLIL::IdString name, RTLIL::SigSpec sig_a, bool is_signed = false, const std::string &src = "");
|
|
|
|
RTLIL::SigSpec Neg (RTLIL::IdString name, RTLIL::SigSpec sig_a, bool is_signed = false, const std::string &src = "");
|
|
|
|
|
|
|
|
RTLIL::SigSpec And (RTLIL::IdString name, RTLIL::SigSpec sig_a, RTLIL::SigSpec sig_b, bool is_signed = false, const std::string &src = "");
|
|
|
|
RTLIL::SigSpec Or (RTLIL::IdString name, RTLIL::SigSpec sig_a, RTLIL::SigSpec sig_b, bool is_signed = false, const std::string &src = "");
|
|
|
|
RTLIL::SigSpec Xor (RTLIL::IdString name, RTLIL::SigSpec sig_a, RTLIL::SigSpec sig_b, bool is_signed = false, const std::string &src = "");
|
|
|
|
RTLIL::SigSpec Xnor (RTLIL::IdString name, RTLIL::SigSpec sig_a, RTLIL::SigSpec sig_b, bool is_signed = false, const std::string &src = "");
|
|
|
|
|
|
|
|
RTLIL::SigSpec ReduceAnd (RTLIL::IdString name, RTLIL::SigSpec sig_a, bool is_signed = false, const std::string &src = "");
|
|
|
|
RTLIL::SigSpec ReduceOr (RTLIL::IdString name, RTLIL::SigSpec sig_a, bool is_signed = false, const std::string &src = "");
|
|
|
|
RTLIL::SigSpec ReduceXor (RTLIL::IdString name, RTLIL::SigSpec sig_a, bool is_signed = false, const std::string &src = "");
|
|
|
|
RTLIL::SigSpec ReduceXnor (RTLIL::IdString name, RTLIL::SigSpec sig_a, bool is_signed = false, const std::string &src = "");
|
|
|
|
RTLIL::SigSpec ReduceBool (RTLIL::IdString name, RTLIL::SigSpec sig_a, bool is_signed = false, const std::string &src = "");
|
|
|
|
|
|
|
|
RTLIL::SigSpec Shl (RTLIL::IdString name, RTLIL::SigSpec sig_a, RTLIL::SigSpec sig_b, bool is_signed = false, const std::string &src = "");
|
|
|
|
RTLIL::SigSpec Shr (RTLIL::IdString name, RTLIL::SigSpec sig_a, RTLIL::SigSpec sig_b, bool is_signed = false, const std::string &src = "");
|
|
|
|
RTLIL::SigSpec Sshl (RTLIL::IdString name, RTLIL::SigSpec sig_a, RTLIL::SigSpec sig_b, bool is_signed = false, const std::string &src = "");
|
|
|
|
RTLIL::SigSpec Sshr (RTLIL::IdString name, RTLIL::SigSpec sig_a, RTLIL::SigSpec sig_b, bool is_signed = false, const std::string &src = "");
|
|
|
|
RTLIL::SigSpec Shift (RTLIL::IdString name, RTLIL::SigSpec sig_a, RTLIL::SigSpec sig_b, bool is_signed = false, const std::string &src = "");
|
|
|
|
RTLIL::SigSpec Shiftx (RTLIL::IdString name, RTLIL::SigSpec sig_a, RTLIL::SigSpec sig_b, bool is_signed = false, const std::string &src = "");
|
|
|
|
|
|
|
|
RTLIL::SigSpec Lt (RTLIL::IdString name, RTLIL::SigSpec sig_a, RTLIL::SigSpec sig_b, bool is_signed = false, const std::string &src = "");
|
|
|
|
RTLIL::SigSpec Le (RTLIL::IdString name, RTLIL::SigSpec sig_a, RTLIL::SigSpec sig_b, bool is_signed = false, const std::string &src = "");
|
|
|
|
RTLIL::SigSpec Eq (RTLIL::IdString name, RTLIL::SigSpec sig_a, RTLIL::SigSpec sig_b, bool is_signed = false, const std::string &src = "");
|
|
|
|
RTLIL::SigSpec Ne (RTLIL::IdString name, RTLIL::SigSpec sig_a, RTLIL::SigSpec sig_b, bool is_signed = false, const std::string &src = "");
|
|
|
|
RTLIL::SigSpec Eqx (RTLIL::IdString name, RTLIL::SigSpec sig_a, RTLIL::SigSpec sig_b, bool is_signed = false, const std::string &src = "");
|
|
|
|
RTLIL::SigSpec Nex (RTLIL::IdString name, RTLIL::SigSpec sig_a, RTLIL::SigSpec sig_b, bool is_signed = false, const std::string &src = "");
|
|
|
|
RTLIL::SigSpec Ge (RTLIL::IdString name, RTLIL::SigSpec sig_a, RTLIL::SigSpec sig_b, bool is_signed = false, const std::string &src = "");
|
|
|
|
RTLIL::SigSpec Gt (RTLIL::IdString name, RTLIL::SigSpec sig_a, RTLIL::SigSpec sig_b, bool is_signed = false, const std::string &src = "");
|
|
|
|
|
|
|
|
RTLIL::SigSpec Add (RTLIL::IdString name, RTLIL::SigSpec sig_a, RTLIL::SigSpec sig_b, bool is_signed = false, const std::string &src = "");
|
|
|
|
RTLIL::SigSpec Sub (RTLIL::IdString name, RTLIL::SigSpec sig_a, RTLIL::SigSpec sig_b, bool is_signed = false, const std::string &src = "");
|
|
|
|
RTLIL::SigSpec Mul (RTLIL::IdString name, RTLIL::SigSpec sig_a, RTLIL::SigSpec sig_b, bool is_signed = false, const std::string &src = "");
|
|
|
|
RTLIL::SigSpec Div (RTLIL::IdString name, RTLIL::SigSpec sig_a, RTLIL::SigSpec sig_b, bool is_signed = false, const std::string &src = "");
|
|
|
|
RTLIL::SigSpec Mod (RTLIL::IdString name, RTLIL::SigSpec sig_a, RTLIL::SigSpec sig_b, bool is_signed = false, const std::string &src = "");
|
|
|
|
RTLIL::SigSpec Pow (RTLIL::IdString name, RTLIL::SigSpec sig_a, RTLIL::SigSpec sig_b, bool a_signed = false, bool b_signed = false, const std::string &src = "");
|
|
|
|
|
|
|
|
RTLIL::SigSpec LogicNot (RTLIL::IdString name, RTLIL::SigSpec sig_a, bool is_signed = false, const std::string &src = "");
|
|
|
|
RTLIL::SigSpec LogicAnd (RTLIL::IdString name, RTLIL::SigSpec sig_a, RTLIL::SigSpec sig_b, bool is_signed = false, const std::string &src = "");
|
|
|
|
RTLIL::SigSpec LogicOr (RTLIL::IdString name, RTLIL::SigSpec sig_a, RTLIL::SigSpec sig_b, bool is_signed = false, const std::string &src = "");
|
|
|
|
|
|
|
|
RTLIL::SigSpec Mux (RTLIL::IdString name, RTLIL::SigSpec sig_a, RTLIL::SigSpec sig_b, RTLIL::SigSpec sig_s, const std::string &src = "");
|
|
|
|
RTLIL::SigSpec Pmux (RTLIL::IdString name, RTLIL::SigSpec sig_a, RTLIL::SigSpec sig_b, RTLIL::SigSpec sig_s, const std::string &src = "");
|
|
|
|
|
|
|
|
RTLIL::SigBit BufGate (RTLIL::IdString name, RTLIL::SigBit sig_a, const std::string &src = "");
|
|
|
|
RTLIL::SigBit NotGate (RTLIL::IdString name, RTLIL::SigBit sig_a, const std::string &src = "");
|
|
|
|
RTLIL::SigBit AndGate (RTLIL::IdString name, RTLIL::SigBit sig_a, RTLIL::SigBit sig_b, const std::string &src = "");
|
|
|
|
RTLIL::SigBit NandGate (RTLIL::IdString name, RTLIL::SigBit sig_a, RTLIL::SigBit sig_b, const std::string &src = "");
|
|
|
|
RTLIL::SigBit OrGate (RTLIL::IdString name, RTLIL::SigBit sig_a, RTLIL::SigBit sig_b, const std::string &src = "");
|
|
|
|
RTLIL::SigBit NorGate (RTLIL::IdString name, RTLIL::SigBit sig_a, RTLIL::SigBit sig_b, const std::string &src = "");
|
|
|
|
RTLIL::SigBit XorGate (RTLIL::IdString name, RTLIL::SigBit sig_a, RTLIL::SigBit sig_b, const std::string &src = "");
|
|
|
|
RTLIL::SigBit XnorGate (RTLIL::IdString name, RTLIL::SigBit sig_a, RTLIL::SigBit sig_b, const std::string &src = "");
|
|
|
|
RTLIL::SigBit AndnotGate (RTLIL::IdString name, RTLIL::SigBit sig_a, RTLIL::SigBit sig_b, const std::string &src = "");
|
|
|
|
RTLIL::SigBit OrnotGate (RTLIL::IdString name, RTLIL::SigBit sig_a, RTLIL::SigBit sig_b, const std::string &src = "");
|
|
|
|
RTLIL::SigBit MuxGate (RTLIL::IdString name, RTLIL::SigBit sig_a, RTLIL::SigBit sig_b, RTLIL::SigBit sig_s, const std::string &src = "");
|
|
|
|
RTLIL::SigBit Aoi3Gate (RTLIL::IdString name, RTLIL::SigBit sig_a, RTLIL::SigBit sig_b, RTLIL::SigBit sig_c, const std::string &src = "");
|
|
|
|
RTLIL::SigBit Oai3Gate (RTLIL::IdString name, RTLIL::SigBit sig_a, RTLIL::SigBit sig_b, RTLIL::SigBit sig_c, const std::string &src = "");
|
|
|
|
RTLIL::SigBit Aoi4Gate (RTLIL::IdString name, RTLIL::SigBit sig_a, RTLIL::SigBit sig_b, RTLIL::SigBit sig_c, RTLIL::SigBit sig_d, const std::string &src = "");
|
|
|
|
RTLIL::SigBit Oai4Gate (RTLIL::IdString name, RTLIL::SigBit sig_a, RTLIL::SigBit sig_b, RTLIL::SigBit sig_c, RTLIL::SigBit sig_d, const std::string &src = "");
|
|
|
|
|
|
|
|
RTLIL::SigSpec Anyconst (RTLIL::IdString name, int width = 1, const std::string &src = "");
|
|
|
|
RTLIL::SigSpec Anyseq (RTLIL::IdString name, int width = 1, const std::string &src = "");
|
2018-02-23 06:14:47 -06:00
|
|
|
RTLIL::SigSpec Allconst (RTLIL::IdString name, int width = 1, const std::string &src = "");
|
|
|
|
RTLIL::SigSpec Allseq (RTLIL::IdString name, int width = 1, const std::string &src = "");
|
2017-09-09 03:16:48 -05:00
|
|
|
RTLIL::SigSpec Initstate (RTLIL::IdString name, const std::string &src = "");
|
2018-07-09 08:48:06 -05:00
|
|
|
|
|
|
|
#ifdef WITH_PYTHON
|
|
|
|
static std::map<unsigned int, RTLIL::Module*> *get_all_modules(void);
|
|
|
|
#endif
|
2013-01-05 04:13:26 -06:00
|
|
|
};
|
|
|
|
|
2015-04-24 15:04:05 -05:00
|
|
|
struct RTLIL::Wire : public RTLIL::AttrObject
|
2014-07-26 04:58:03 -05:00
|
|
|
{
|
2014-12-28 10:51:16 -06:00
|
|
|
unsigned int hashidx_;
|
|
|
|
unsigned int hash() const { return hashidx_; }
|
|
|
|
|
2014-07-26 14:16:05 -05:00
|
|
|
protected:
|
2014-07-26 04:58:03 -05:00
|
|
|
// use module->addWire() and module->remove() to create or destroy wires
|
|
|
|
friend struct RTLIL::Module;
|
|
|
|
Wire();
|
2018-07-10 01:52:36 -05:00
|
|
|
~Wire();
|
2014-07-26 04:58:03 -05:00
|
|
|
|
|
|
|
public:
|
|
|
|
// do not simply copy wires
|
2014-07-26 14:16:05 -05:00
|
|
|
Wire(RTLIL::Wire &other) = delete;
|
|
|
|
void operator=(RTLIL::Wire &other) = delete;
|
2014-07-26 04:58:03 -05:00
|
|
|
|
2014-07-31 07:11:39 -05:00
|
|
|
RTLIL::Module *module;
|
2013-01-05 04:13:26 -06:00
|
|
|
RTLIL::IdString name;
|
|
|
|
int width, start_offset, port_id;
|
2014-07-28 05:12:13 -05:00
|
|
|
bool port_input, port_output, upto;
|
2018-07-09 08:48:06 -05:00
|
|
|
|
|
|
|
#ifdef WITH_PYTHON
|
|
|
|
static std::map<unsigned int, RTLIL::Wire*> *get_all_wires(void);
|
|
|
|
#endif
|
2013-01-05 04:13:26 -06:00
|
|
|
};
|
|
|
|
|
2015-04-24 15:04:05 -05:00
|
|
|
struct RTLIL::Memory : public RTLIL::AttrObject
|
2014-07-26 04:58:03 -05:00
|
|
|
{
|
2014-12-28 10:51:16 -06:00
|
|
|
unsigned int hashidx_;
|
|
|
|
unsigned int hash() const { return hashidx_; }
|
|
|
|
|
2014-07-26 04:58:03 -05:00
|
|
|
Memory();
|
|
|
|
|
2013-01-05 04:13:26 -06:00
|
|
|
RTLIL::IdString name;
|
|
|
|
int width, start_offset, size;
|
2018-08-13 08:18:46 -05:00
|
|
|
#ifdef WITH_PYTHON
|
|
|
|
~Memory();
|
|
|
|
static std::map<unsigned int, RTLIL::Memory*> *get_all_memorys(void);
|
|
|
|
#endif
|
2013-01-05 04:13:26 -06:00
|
|
|
};
|
|
|
|
|
2015-04-24 15:04:05 -05:00
|
|
|
struct RTLIL::Cell : public RTLIL::AttrObject
|
2014-07-25 08:05:18 -05:00
|
|
|
{
|
2014-12-28 10:51:16 -06:00
|
|
|
unsigned int hashidx_;
|
|
|
|
unsigned int hash() const { return hashidx_; }
|
|
|
|
|
2014-07-25 08:05:18 -05:00
|
|
|
protected:
|
2014-07-26 04:58:03 -05:00
|
|
|
// use module->addCell() and module->remove() to create or destroy cells
|
2014-07-25 08:05:18 -05:00
|
|
|
friend struct RTLIL::Module;
|
2014-08-22 09:09:13 -05:00
|
|
|
Cell();
|
2018-07-10 01:52:36 -05:00
|
|
|
~Cell();
|
2014-07-25 08:05:18 -05:00
|
|
|
|
|
|
|
public:
|
2014-07-26 04:58:03 -05:00
|
|
|
// do not simply copy cells
|
2014-07-25 08:05:18 -05:00
|
|
|
Cell(RTLIL::Cell &other) = delete;
|
|
|
|
void operator=(RTLIL::Cell &other) = delete;
|
|
|
|
|
2014-07-31 07:11:39 -05:00
|
|
|
RTLIL::Module *module;
|
2013-01-05 04:13:26 -06:00
|
|
|
RTLIL::IdString name;
|
|
|
|
RTLIL::IdString type;
|
2014-12-26 03:53:21 -06:00
|
|
|
dict<RTLIL::IdString, RTLIL::SigSpec> connections_;
|
|
|
|
dict<RTLIL::IdString, RTLIL::Const> parameters;
|
2014-07-26 05:22:58 -05:00
|
|
|
|
|
|
|
// access cell ports
|
2014-07-31 09:38:54 -05:00
|
|
|
bool hasPort(RTLIL::IdString portname) const;
|
|
|
|
void unsetPort(RTLIL::IdString portname);
|
|
|
|
void setPort(RTLIL::IdString portname, RTLIL::SigSpec signal);
|
|
|
|
const RTLIL::SigSpec &getPort(RTLIL::IdString portname) const;
|
2014-12-26 03:53:21 -06:00
|
|
|
const dict<RTLIL::IdString, RTLIL::SigSpec> &connections() const;
|
2014-07-26 05:22:58 -05:00
|
|
|
|
2015-02-07 04:40:19 -06:00
|
|
|
// information about cell ports
|
|
|
|
bool known() const;
|
|
|
|
bool input(RTLIL::IdString portname) const;
|
|
|
|
bool output(RTLIL::IdString portname) const;
|
|
|
|
|
2014-07-31 09:38:54 -05:00
|
|
|
// access cell parameters
|
2014-08-31 10:07:07 -05:00
|
|
|
bool hasParam(RTLIL::IdString paramname) const;
|
|
|
|
void unsetParam(RTLIL::IdString paramname);
|
|
|
|
void setParam(RTLIL::IdString paramname, RTLIL::Const value);
|
|
|
|
const RTLIL::Const &getParam(RTLIL::IdString paramname) const;
|
2014-07-31 09:38:54 -05:00
|
|
|
|
2015-01-23 17:13:27 -06:00
|
|
|
void sort();
|
2014-07-21 05:02:55 -05:00
|
|
|
void check();
|
2014-07-26 05:22:58 -05:00
|
|
|
void fixup_parameters(bool set_a_signed = false, bool set_b_signed = false);
|
2013-06-18 10:11:13 -05:00
|
|
|
|
2014-09-29 05:51:54 -05:00
|
|
|
bool has_keep_attr() const {
|
|
|
|
return get_bool_attribute("\\keep") || (module && module->design && module->design->module(type) &&
|
|
|
|
module->design->module(type)->get_bool_attribute("\\keep"));
|
|
|
|
}
|
|
|
|
|
2017-05-28 04:59:05 -05:00
|
|
|
template<typename T> void rewrite_sigspecs(T &functor);
|
2019-05-15 09:01:00 -05:00
|
|
|
template<typename T> void rewrite_sigspecs2(T &functor);
|
2018-07-09 08:48:06 -05:00
|
|
|
|
|
|
|
#ifdef WITH_PYTHON
|
|
|
|
static std::map<unsigned int, RTLIL::Cell*> *get_all_cells(void);
|
|
|
|
#endif
|
2013-01-05 04:13:26 -06:00
|
|
|
};
|
|
|
|
|
2014-07-26 19:00:04 -05:00
|
|
|
struct RTLIL::CaseRule
|
|
|
|
{
|
2013-01-05 04:13:26 -06:00
|
|
|
std::vector<RTLIL::SigSpec> compare;
|
|
|
|
std::vector<RTLIL::SigSig> actions;
|
|
|
|
std::vector<RTLIL::SwitchRule*> switches;
|
2014-07-26 19:00:04 -05:00
|
|
|
|
2013-01-05 04:13:26 -06:00
|
|
|
~CaseRule();
|
|
|
|
void optimize();
|
2013-06-18 10:11:13 -05:00
|
|
|
|
2018-12-23 03:04:23 -06:00
|
|
|
bool empty() const;
|
|
|
|
|
2017-05-28 04:59:05 -05:00
|
|
|
template<typename T> void rewrite_sigspecs(T &functor);
|
2019-05-15 09:01:00 -05:00
|
|
|
template<typename T> void rewrite_sigspecs2(T &functor);
|
2013-07-27 07:27:51 -05:00
|
|
|
RTLIL::CaseRule *clone() const;
|
2013-01-05 04:13:26 -06:00
|
|
|
};
|
|
|
|
|
2015-04-24 15:04:05 -05:00
|
|
|
struct RTLIL::SwitchRule : public RTLIL::AttrObject
|
2014-07-26 19:00:04 -05:00
|
|
|
{
|
2013-01-05 04:13:26 -06:00
|
|
|
RTLIL::SigSpec signal;
|
|
|
|
std::vector<RTLIL::CaseRule*> cases;
|
2014-07-26 19:00:04 -05:00
|
|
|
|
2013-01-05 04:13:26 -06:00
|
|
|
~SwitchRule();
|
2013-06-18 10:11:13 -05:00
|
|
|
|
2018-12-23 03:04:23 -06:00
|
|
|
bool empty() const;
|
|
|
|
|
2017-05-28 04:59:05 -05:00
|
|
|
template<typename T> void rewrite_sigspecs(T &functor);
|
2019-05-15 09:01:00 -05:00
|
|
|
template<typename T> void rewrite_sigspecs2(T &functor);
|
2013-07-27 07:27:51 -05:00
|
|
|
RTLIL::SwitchRule *clone() const;
|
2013-01-05 04:13:26 -06:00
|
|
|
};
|
|
|
|
|
2014-07-26 19:00:04 -05:00
|
|
|
struct RTLIL::SyncRule
|
|
|
|
{
|
2013-01-05 04:13:26 -06:00
|
|
|
RTLIL::SyncType type;
|
|
|
|
RTLIL::SigSpec signal;
|
|
|
|
std::vector<RTLIL::SigSig> actions;
|
2013-06-18 10:11:13 -05:00
|
|
|
|
2017-05-28 04:59:05 -05:00
|
|
|
template<typename T> void rewrite_sigspecs(T &functor);
|
2019-05-15 09:01:00 -05:00
|
|
|
template<typename T> void rewrite_sigspecs2(T &functor);
|
2013-07-27 07:27:51 -05:00
|
|
|
RTLIL::SyncRule *clone() const;
|
2013-01-05 04:13:26 -06:00
|
|
|
};
|
|
|
|
|
2015-04-24 15:04:05 -05:00
|
|
|
struct RTLIL::Process : public RTLIL::AttrObject
|
2014-07-26 19:00:04 -05:00
|
|
|
{
|
2013-01-05 04:13:26 -06:00
|
|
|
RTLIL::IdString name;
|
|
|
|
RTLIL::CaseRule root_case;
|
|
|
|
std::vector<RTLIL::SyncRule*> syncs;
|
2014-07-26 19:00:04 -05:00
|
|
|
|
2013-01-05 04:13:26 -06:00
|
|
|
~Process();
|
2013-06-18 10:11:13 -05:00
|
|
|
|
2017-05-28 04:59:05 -05:00
|
|
|
template<typename T> void rewrite_sigspecs(T &functor);
|
2019-05-15 09:01:00 -05:00
|
|
|
template<typename T> void rewrite_sigspecs2(T &functor);
|
2013-07-27 07:27:51 -05:00
|
|
|
RTLIL::Process *clone() const;
|
2013-01-05 04:13:26 -06:00
|
|
|
};
|
|
|
|
|
2014-12-26 03:53:21 -06:00
|
|
|
|
|
|
|
inline RTLIL::SigBit::SigBit() : wire(NULL), data(RTLIL::State::S0) { }
|
|
|
|
inline RTLIL::SigBit::SigBit(RTLIL::State bit) : wire(NULL), data(bit) { }
|
|
|
|
inline RTLIL::SigBit::SigBit(bool bit) : wire(NULL), data(bit ? RTLIL::S1 : RTLIL::S0) { }
|
|
|
|
inline RTLIL::SigBit::SigBit(RTLIL::Wire *wire) : wire(wire), offset(0) { log_assert(wire && wire->width == 1); }
|
|
|
|
inline RTLIL::SigBit::SigBit(RTLIL::Wire *wire, int offset) : wire(wire), offset(offset) { log_assert(wire != nullptr); }
|
|
|
|
inline RTLIL::SigBit::SigBit(const RTLIL::SigChunk &chunk) : wire(chunk.wire) { log_assert(chunk.width == 1); if (wire) offset = chunk.offset; else data = chunk.data[0]; }
|
|
|
|
inline RTLIL::SigBit::SigBit(const RTLIL::SigChunk &chunk, int index) : wire(chunk.wire) { if (wire) offset = chunk.offset + index; else data = chunk.data[index]; }
|
2018-08-13 08:18:46 -05:00
|
|
|
inline RTLIL::SigBit::SigBit(const RTLIL::SigBit &sigbit) : wire(sigbit.wire), data(sigbit.data){if(wire) offset = sigbit.offset;}
|
2014-12-26 03:53:21 -06:00
|
|
|
|
|
|
|
inline bool RTLIL::SigBit::operator<(const RTLIL::SigBit &other) const {
|
|
|
|
if (wire == other.wire)
|
|
|
|
return wire ? (offset < other.offset) : (data < other.data);
|
|
|
|
if (wire != nullptr && other.wire != nullptr)
|
|
|
|
return wire->name < other.wire->name;
|
2019-03-11 14:12:28 -05:00
|
|
|
return (wire != nullptr) < (other.wire != nullptr);
|
2014-12-26 03:53:21 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
inline bool RTLIL::SigBit::operator==(const RTLIL::SigBit &other) const {
|
|
|
|
return (wire == other.wire) && (wire ? (offset == other.offset) : (data == other.data));
|
|
|
|
}
|
|
|
|
|
|
|
|
inline bool RTLIL::SigBit::operator!=(const RTLIL::SigBit &other) const {
|
|
|
|
return (wire != other.wire) || (wire ? (offset != other.offset) : (data != other.data));
|
|
|
|
}
|
|
|
|
|
2014-12-26 14:35:22 -06:00
|
|
|
inline unsigned int RTLIL::SigBit::hash() const {
|
|
|
|
if (wire)
|
2014-12-27 05:02:57 -06:00
|
|
|
return mkhash_add(wire->name.hash(), offset);
|
2014-12-26 14:35:22 -06:00
|
|
|
return data;
|
|
|
|
}
|
|
|
|
|
2014-12-26 03:53:21 -06:00
|
|
|
inline RTLIL::SigBit &RTLIL::SigSpecIterator::operator*() const {
|
|
|
|
return (*sig_p)[index];
|
|
|
|
}
|
|
|
|
|
|
|
|
inline const RTLIL::SigBit &RTLIL::SigSpecConstIterator::operator*() const {
|
|
|
|
return (*sig_p)[index];
|
|
|
|
}
|
|
|
|
|
|
|
|
inline RTLIL::SigBit::SigBit(const RTLIL::SigSpec &sig) {
|
|
|
|
log_assert(sig.size() == 1 && sig.chunks().size() == 1);
|
|
|
|
*this = SigBit(sig.chunks().front());
|
|
|
|
}
|
|
|
|
|
2013-06-18 12:54:33 -05:00
|
|
|
template<typename T>
|
2017-05-28 04:59:05 -05:00
|
|
|
void RTLIL::Module::rewrite_sigspecs(T &functor)
|
2013-06-18 12:54:33 -05:00
|
|
|
{
|
2014-07-26 18:51:45 -05:00
|
|
|
for (auto &it : cells_)
|
2013-06-18 12:54:33 -05:00
|
|
|
it.second->rewrite_sigspecs(functor);
|
|
|
|
for (auto &it : processes)
|
|
|
|
it.second->rewrite_sigspecs(functor);
|
2014-07-26 04:58:03 -05:00
|
|
|
for (auto &it : connections_) {
|
2013-06-18 12:54:33 -05:00
|
|
|
functor(it.first);
|
|
|
|
functor(it.second);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-05-15 09:01:00 -05:00
|
|
|
template<typename T>
|
|
|
|
void RTLIL::Module::rewrite_sigspecs2(T &functor)
|
|
|
|
{
|
|
|
|
for (auto &it : cells_)
|
|
|
|
it.second->rewrite_sigspecs2(functor);
|
|
|
|
for (auto &it : processes)
|
|
|
|
it.second->rewrite_sigspecs2(functor);
|
|
|
|
for (auto &it : connections_) {
|
|
|
|
functor(it.first, it.second);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-06-18 12:54:33 -05:00
|
|
|
template<typename T>
|
2017-05-28 04:59:05 -05:00
|
|
|
void RTLIL::Cell::rewrite_sigspecs(T &functor) {
|
2014-07-26 04:58:03 -05:00
|
|
|
for (auto &it : connections_)
|
2013-06-18 12:54:33 -05:00
|
|
|
functor(it.second);
|
|
|
|
}
|
|
|
|
|
2019-05-15 09:01:00 -05:00
|
|
|
template<typename T>
|
|
|
|
void RTLIL::Cell::rewrite_sigspecs2(T &functor) {
|
|
|
|
for (auto &it : connections_)
|
|
|
|
functor(it.second);
|
|
|
|
}
|
|
|
|
|
2013-06-18 12:54:33 -05:00
|
|
|
template<typename T>
|
2017-05-28 04:59:05 -05:00
|
|
|
void RTLIL::CaseRule::rewrite_sigspecs(T &functor) {
|
2013-06-18 12:54:33 -05:00
|
|
|
for (auto &it : compare)
|
|
|
|
functor(it);
|
|
|
|
for (auto &it : actions) {
|
|
|
|
functor(it.first);
|
|
|
|
functor(it.second);
|
|
|
|
}
|
|
|
|
for (auto it : switches)
|
|
|
|
it->rewrite_sigspecs(functor);
|
|
|
|
}
|
|
|
|
|
2019-05-15 09:01:00 -05:00
|
|
|
template<typename T>
|
|
|
|
void RTLIL::CaseRule::rewrite_sigspecs2(T &functor) {
|
|
|
|
for (auto &it : compare)
|
|
|
|
functor(it);
|
|
|
|
for (auto &it : actions) {
|
|
|
|
functor(it.first, it.second);
|
|
|
|
}
|
|
|
|
for (auto it : switches)
|
|
|
|
it->rewrite_sigspecs2(functor);
|
|
|
|
}
|
|
|
|
|
2013-06-18 12:54:33 -05:00
|
|
|
template<typename T>
|
2017-05-28 04:59:05 -05:00
|
|
|
void RTLIL::SwitchRule::rewrite_sigspecs(T &functor)
|
2013-06-18 12:54:33 -05:00
|
|
|
{
|
|
|
|
functor(signal);
|
|
|
|
for (auto it : cases)
|
|
|
|
it->rewrite_sigspecs(functor);
|
|
|
|
}
|
|
|
|
|
2019-05-15 09:01:00 -05:00
|
|
|
template<typename T>
|
|
|
|
void RTLIL::SwitchRule::rewrite_sigspecs2(T &functor)
|
|
|
|
{
|
|
|
|
functor(signal);
|
|
|
|
for (auto it : cases)
|
|
|
|
it->rewrite_sigspecs2(functor);
|
|
|
|
}
|
|
|
|
|
2013-06-18 12:54:33 -05:00
|
|
|
template<typename T>
|
2017-05-28 04:59:05 -05:00
|
|
|
void RTLIL::SyncRule::rewrite_sigspecs(T &functor)
|
2013-06-18 12:54:33 -05:00
|
|
|
{
|
|
|
|
functor(signal);
|
|
|
|
for (auto &it : actions) {
|
|
|
|
functor(it.first);
|
|
|
|
functor(it.second);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-05-15 09:01:00 -05:00
|
|
|
template<typename T>
|
|
|
|
void RTLIL::SyncRule::rewrite_sigspecs2(T &functor)
|
|
|
|
{
|
|
|
|
functor(signal);
|
|
|
|
for (auto &it : actions) {
|
|
|
|
functor(it.first, it.second);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-06-18 12:54:33 -05:00
|
|
|
template<typename T>
|
2017-05-28 04:59:05 -05:00
|
|
|
void RTLIL::Process::rewrite_sigspecs(T &functor)
|
2013-06-18 12:54:33 -05:00
|
|
|
{
|
|
|
|
root_case.rewrite_sigspecs(functor);
|
|
|
|
for (auto it : syncs)
|
|
|
|
it->rewrite_sigspecs(functor);
|
|
|
|
}
|
|
|
|
|
2019-05-15 09:01:00 -05:00
|
|
|
template<typename T>
|
|
|
|
void RTLIL::Process::rewrite_sigspecs2(T &functor)
|
|
|
|
{
|
|
|
|
root_case.rewrite_sigspecs2(functor);
|
|
|
|
for (auto it : syncs)
|
|
|
|
it->rewrite_sigspecs2(functor);
|
|
|
|
}
|
|
|
|
|
2014-07-31 06:19:47 -05:00
|
|
|
YOSYS_NAMESPACE_END
|
|
|
|
|
2013-01-05 04:13:26 -06:00
|
|
|
#endif
|