#include <celltypes.h>
|
static RTLIL::Const | eval_not (RTLIL::Const v) |
|
static RTLIL::Const | eval (RTLIL::IdString type, const RTLIL::Const &arg1, const RTLIL::Const &arg2, bool signed1, bool signed2, int result_len) |
|
static RTLIL::Const | eval (RTLIL::Cell *cell, const RTLIL::Const &arg1, const RTLIL::Const &arg2) |
|
static RTLIL::Const | eval (RTLIL::Cell *cell, const RTLIL::Const &arg1, const RTLIL::Const &arg2, const RTLIL::Const &arg3) |
|
static RTLIL::Const | eval (RTLIL::Cell *cell, const RTLIL::Const &arg1, const RTLIL::Const &arg2, const RTLIL::Const &arg3, const RTLIL::Const &arg4) |
|
Definition at line 34 of file celltypes.h.
Definition at line 42 of file celltypes.h.
void setup(RTLIL::Design *design=NULL)
Definition at line 205 of file celltypes.h.
208 return it !=
cell_types.end() && it->second.is_evaluable;
std::map< RTLIL::IdString, CellType > cell_types
Definition at line 199 of file celltypes.h.
202 return it !=
cell_types.end() && it->second.inputs.count(port) != 0;
std::map< RTLIL::IdString, CellType > cell_types
Definition at line 188 of file celltypes.h.
std::map< RTLIL::IdString, CellType > cell_types
Definition at line 193 of file celltypes.h.
196 return it !=
cell_types.end() && it->second.outputs.count(port) != 0;
std::map< RTLIL::IdString, CellType > cell_types
void CellTypes::clear |
( |
| ) |
|
|
inline |
Definition at line 183 of file celltypes.h.
std::map< RTLIL::IdString, CellType > cell_types
Definition at line 219 of file celltypes.h.
221 if (type ==
"$sshr" && !signed1)
223 if (type ==
"$sshl" && !signed1)
226 if (type !=
"$sshr" && type !=
"$sshl" && type !=
"$shr" && type !=
"$shl" && type !=
"$shift" && type !=
"$shiftx" &&
227 type !=
"$pos" && type !=
"$neg" && type !=
"$not") {
228 if (!signed1 || !signed2)
229 signed1 =
false, signed2 =
false;
232 #define HANDLE_CELL_TYPE(_t) if (type == "$" #_t) return const_ ## _t(arg1, arg2, signed1, signed2, result_len);
268 #undef HANDLE_CELL_TYPE
270 if (type ==
"$_BUF_")
272 if (type ==
"$_NOT_")
274 if (type ==
"$_AND_")
275 return const_and(arg1, arg2,
false,
false, 1);
276 if (type ==
"$_NAND_")
279 return const_or(arg1, arg2,
false,
false, 1);
280 if (type ==
"$_NOR_")
282 if (type ==
"$_XOR_")
283 return const_xor(arg1, arg2,
false,
false, 1);
284 if (type ==
"$_XNOR_")
285 return const_xnor(arg1, arg2,
false,
false, 1);
#define HANDLE_CELL_TYPE(_t)
RTLIL::Const const_xor(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_and(const RTLIL::Const &arg1, const RTLIL::Const &arg2, bool signed1, bool signed2, int result_len)
static RTLIL::Const eval_not(RTLIL::Const v)
RTLIL::Const const_xnor(const RTLIL::Const &arg1, const RTLIL::Const &arg2, bool signed1, bool signed2, int result_len)
static RTLIL::State logic_or(RTLIL::State a, RTLIL::State b)
static RTLIL::State logic_and(RTLIL::State a, RTLIL::State b)
Definition at line 290 of file celltypes.h.
292 if (cell->
type ==
"$slice") {
294 int width = cell->
parameters.at(
"\\Y_WIDTH").as_int();
295 int offset = cell->
parameters.at(
"\\OFFSET").as_int();
296 ret.
bits.insert(ret.
bits.end(), arg1.
bits.begin()+offset, arg1.
bits.begin()+offset+width);
300 if (cell->
type ==
"$concat") {
306 if (cell->
type ==
"$lut")
308 int width = cell->
parameters.at(
"\\WIDTH").as_int();
310 std::vector<RTLIL::State> t = cell->
parameters.at(
"\\LUT").bits;
311 while (
GetSize(t) < (1 << width))
313 t.resize(1 << width);
315 for (
int i = width-1; i >= 0; i--) {
317 std::vector<RTLIL::State> new_t;
319 new_t = std::vector<RTLIL::State>(t.begin(), t.begin() +
GetSize(t)/2);
321 new_t = std::vector<RTLIL::State>(t.begin() +
GetSize(t)/2, t.end());
323 for (
int j = 0; j <
GetSize(t)/2; j++)
332 bool signed_a = cell->
parameters.count(
"\\A_SIGNED") > 0 && cell->
parameters[
"\\A_SIGNED"].as_bool();
333 bool signed_b = cell->
parameters.count(
"\\B_SIGNED") > 0 && cell->
parameters[
"\\B_SIGNED"].as_bool();
334 int result_len = cell->
parameters.count(
"\\Y_WIDTH") > 0 ? cell->
parameters[
"\\Y_WIDTH"].as_int() : -1;
335 return eval(cell->
type, arg1, arg2, signed_a, signed_b, result_len);
std::map< RTLIL::IdString, RTLIL::Const > parameters
int GetSize(RTLIL::Wire *wire)
static RTLIL::Const eval(RTLIL::IdString type, const RTLIL::Const &arg1, const RTLIL::Const &arg2, bool signed1, bool signed2, int result_len)
#define log_assert(_assert_expr_)
std::vector< RTLIL::State > bits
Definition at line 338 of file celltypes.h.
340 if (cell->
type.
in(
"$mux",
"$pmux",
"$_MUX_")) {
342 for (
size_t i = 0; i < arg3.
bits.size(); i++)
344 std::vector<RTLIL::State> bits(arg2.
bits.begin() + i*arg1.
bits.size(), arg2.
bits.begin() + (i+1)*arg1.
bits.size());
350 if (cell->
type ==
"$_AOI3_")
352 if (cell->
type ==
"$_OAI3_")
356 return eval(cell, arg1, arg2);
RTLIL::Const const_or(const RTLIL::Const &arg1, const RTLIL::Const &arg2, bool signed1, bool signed2, int result_len)
bool in(T first, Args...rest)
RTLIL::Const const_and(const RTLIL::Const &arg1, const RTLIL::Const &arg2, bool signed1, bool signed2, int result_len)
static RTLIL::Const eval_not(RTLIL::Const v)
static RTLIL::Const eval(RTLIL::IdString type, const RTLIL::Const &arg1, const RTLIL::Const &arg2, bool signed1, bool signed2, int result_len)
#define log_assert(_assert_expr_)
std::vector< RTLIL::State > bits
Definition at line 359 of file celltypes.h.
361 if (cell->
type ==
"$_AOI4_")
362 return eval_not(
const_or(
const_and(arg1, arg2,
false,
false, 1),
const_and(arg3, arg4,
false,
false, 1),
false,
false, 1));
363 if (cell->
type ==
"$_OAI4_")
364 return eval_not(
const_and(
const_or(arg1, arg2,
false,
false, 1),
const_and(arg3, arg4,
false,
false, 1),
false,
false, 1));
367 return eval(cell, arg1, arg2, arg3);
RTLIL::Const const_or(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)
static RTLIL::Const eval_not(RTLIL::Const v)
static RTLIL::Const eval(RTLIL::IdString type, const RTLIL::Const &arg1, const RTLIL::Const &arg2, bool signed1, bool signed2, int result_len)
#define log_assert(_assert_expr_)
std::vector< RTLIL::State > bits
Definition at line 211 of file celltypes.h.
213 for (
auto &bit : v.
bits)
std::vector< RTLIL::State > bits
Definition at line 47 of file celltypes.h.
void setup_internals_mem()
void setup_design(RTLIL::Design *design)
void setup_stdcells_mem()
Definition at line 77 of file celltypes.h.
void setup_module(RTLIL::Module *module)
RTLIL::ObjRange< RTLIL::Module * > modules()
void CellTypes::setup_internals |
( |
| ) |
|
|
inline |
Definition at line 83 of file celltypes.h.
85 std::vector<RTLIL::IdString> unary_ops = {
86 "$not",
"$pos",
"$neg",
87 "$reduce_and",
"$reduce_or",
"$reduce_xor",
"$reduce_xnor",
"$reduce_bool",
88 "$logic_not",
"$slice",
"$lut"
91 std::vector<RTLIL::IdString> binary_ops = {
92 "$and",
"$or",
"$xor",
"$xnor",
93 "$shl",
"$shr",
"$sshl",
"$sshr",
"$shift",
"$shiftx",
94 "$lt",
"$le",
"$eq",
"$ne",
"$eqx",
"$nex",
"$ge",
"$gt",
95 "$add",
"$sub",
"$mul",
"$div",
"$mod",
"$pow",
96 "$logic_and",
"$logic_or",
"$concat",
"$macc"
99 for (
auto type : unary_ops)
102 for (
auto type : binary_ops)
103 setup_type(type, {
"\\A",
"\\B"}, {
"\\Y"},
true);
105 for (
auto type : std::vector<RTLIL::IdString>({
"$mux",
"$pmux"}))
106 setup_type(type, {
"\\A",
"\\B",
"\\S"}, {
"\\Y"},
true);
108 setup_type(
"$lcu", {
"\\P",
"\\G",
"\\CI"}, {
"\\CO"},
true);
109 setup_type(
"$alu", {
"\\A",
"\\B",
"\\CI",
"\\BI"}, {
"\\X",
"\\Y",
"\\CO"},
true);
110 setup_type(
"$fa", {
"\\A",
"\\B",
"\\C"}, {
"\\X",
"\\Y"},
true);
112 setup_type(
"$assert", {
"\\A",
"\\EN"}, std::set<RTLIL::IdString>(),
true);
void setup_type(RTLIL::IdString type, const std::set< RTLIL::IdString > &inputs, const std::set< RTLIL::IdString > &outputs, bool is_evaluable=false)
void CellTypes::setup_internals_mem |
( |
| ) |
|
|
inline |
Definition at line 115 of file celltypes.h.
117 setup_type(
"$sr", {
"\\SET",
"\\CLR"}, {
"\\Q"});
118 setup_type(
"$dff", {
"\\CLK",
"\\D"}, {
"\\Q"});
119 setup_type(
"$dffe", {
"\\CLK",
"\\EN",
"\\D"}, {
"\\Q"});
120 setup_type(
"$dffsr", {
"\\CLK",
"\\SET",
"\\CLR",
"\\D"}, {
"\\Q"});
121 setup_type(
"$adff", {
"\\CLK",
"\\ARST",
"\\D"}, {
"\\Q"});
122 setup_type(
"$dlatch", {
"\\EN",
"\\D"}, {
"\\Q"});
123 setup_type(
"$dlatchsr", {
"\\EN",
"\\SET",
"\\CLR",
"\\D"}, {
"\\Q"});
125 setup_type(
"$memrd", {
"\\CLK",
"\\ADDR"}, {
"\\DATA"});
126 setup_type(
"$memwr", {
"\\CLK",
"\\EN",
"\\ADDR",
"\\DATA"}, std::set<RTLIL::IdString>());
127 setup_type(
"$mem", {
"\\RD_CLK",
"\\RD_ADDR",
"\\WR_CLK",
"\\WR_EN",
"\\WR_ADDR",
"\\WR_DATA"}, {
"\\RD_DATA"});
129 setup_type(
"$fsm", {
"\\CLK",
"\\ARST",
"\\CTRL_IN"}, {
"\\CTRL_OUT"});
void setup_type(RTLIL::IdString type, const std::set< RTLIL::IdString > &inputs, const std::set< RTLIL::IdString > &outputs, bool is_evaluable=false)
Definition at line 64 of file celltypes.h.
66 std::set<RTLIL::IdString> inputs, outputs;
70 inputs.insert(wire->
name);
72 outputs.insert(wire->
name);
RTLIL::Wire * wire(RTLIL::IdString id)
std::vector< RTLIL::IdString > ports
void setup_type(RTLIL::IdString type, const std::set< RTLIL::IdString > &inputs, const std::set< RTLIL::IdString > &outputs, bool is_evaluable=false)
void CellTypes::setup_stdcells |
( |
| ) |
|
|
inline |
Definition at line 132 of file celltypes.h.
136 setup_type(
"$_AND_", {
"\\A",
"\\B"}, {
"\\Y"},
true);
137 setup_type(
"$_NAND_", {
"\\A",
"\\B"}, {
"\\Y"},
true);
138 setup_type(
"$_OR_", {
"\\A",
"\\B"}, {
"\\Y"},
true);
139 setup_type(
"$_NOR_", {
"\\A",
"\\B"}, {
"\\Y"},
true);
140 setup_type(
"$_XOR_", {
"\\A",
"\\B"}, {
"\\Y"},
true);
141 setup_type(
"$_XNOR_", {
"\\A",
"\\B"}, {
"\\Y"},
true);
142 setup_type(
"$_MUX_", {
"\\A",
"\\B",
"\\S"}, {
"\\Y"},
true);
143 setup_type(
"$_AOI3_", {
"\\A",
"\\B",
"\\C"}, {
"\\Y"},
true);
144 setup_type(
"$_OAI3_", {
"\\A",
"\\B",
"\\C"}, {
"\\Y"},
true);
145 setup_type(
"$_AOI4_", {
"\\A",
"\\B",
"\\C",
"\\D"}, {
"\\Y"},
true);
146 setup_type(
"$_OAI4_", {
"\\A",
"\\B",
"\\C",
"\\D"}, {
"\\Y"},
true);
void setup_type(RTLIL::IdString type, const std::set< RTLIL::IdString > &inputs, const std::set< RTLIL::IdString > &outputs, bool is_evaluable=false)
void CellTypes::setup_stdcells_mem |
( |
| ) |
|
|
inline |
Definition at line 149 of file celltypes.h.
151 std::vector<char> list_np = {
'N',
'P'}, list_01 = {
'0',
'1'};
153 for (
auto c1 : list_np)
154 for (
auto c2 : list_np)
157 for (
auto c1 : list_np)
160 for (
auto c1 : list_np)
161 for (
auto c2 : list_np)
164 for (
auto c1 : list_np)
165 for (
auto c2 : list_np)
166 for (
auto c3 : list_01)
167 setup_type(
stringf(
"$_DFF_%c%c%c_", c1, c2, c3), {
"\\C",
"\\R",
"\\D"}, {
"\\Q"});
169 for (
auto c1 : list_np)
170 for (
auto c2 : list_np)
171 for (
auto c3 : list_np)
172 setup_type(
stringf(
"$_DFFSR_%c%c%c_", c1, c2, c3), {
"\\C",
"\\S",
"\\R",
"\\D"}, {
"\\Q"});
174 for (
auto c1 : list_np)
177 for (
auto c1 : list_np)
178 for (
auto c2 : list_np)
179 for (
auto c3 : list_np)
180 setup_type(
stringf(
"$_DLATCHSR_%c%c%c_", c1, c2, c3), {
"\\E",
"\\S",
"\\R",
"\\D"}, {
"\\Q"});
std::string stringf(const char *fmt,...)
void setup_type(RTLIL::IdString type, const std::set< RTLIL::IdString > &inputs, const std::set< RTLIL::IdString > &outputs, bool is_evaluable=false)
Definition at line 58 of file celltypes.h.
60 CellType ct = {type, inputs, outputs, is_evaluable};
std::map< RTLIL::IdString, CellType > cell_types
The documentation for this struct was generated from the following file: