yosys-master
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
AST Namespace Reference

Data Structures

struct  AstNode
 
struct  AstModule
 

Enumerations

enum  AstNodeType {
  AST_NONE, AST_DESIGN, AST_MODULE, AST_TASK,
  AST_FUNCTION, AST_DPI_FUNCTION, AST_WIRE, AST_MEMORY,
  AST_AUTOWIRE, AST_PARAMETER, AST_LOCALPARAM, AST_DEFPARAM,
  AST_PARASET, AST_ARGUMENT, AST_RANGE, AST_MULTIRANGE,
  AST_CONSTANT, AST_REALVALUE, AST_CELLTYPE, AST_IDENTIFIER,
  AST_PREFIX, AST_ASSERT, AST_FCALL, AST_TO_BITS,
  AST_TO_SIGNED, AST_TO_UNSIGNED, AST_CONCAT, AST_REPLICATE,
  AST_BIT_NOT, AST_BIT_AND, AST_BIT_OR, AST_BIT_XOR,
  AST_BIT_XNOR, AST_REDUCE_AND, AST_REDUCE_OR, AST_REDUCE_XOR,
  AST_REDUCE_XNOR, AST_REDUCE_BOOL, AST_SHIFT_LEFT, AST_SHIFT_RIGHT,
  AST_SHIFT_SLEFT, AST_SHIFT_SRIGHT, AST_LT, AST_LE,
  AST_EQ, AST_NE, AST_EQX, AST_NEX,
  AST_GE, AST_GT, AST_ADD, AST_SUB,
  AST_MUL, AST_DIV, AST_MOD, AST_POW,
  AST_POS, AST_NEG, AST_LOGIC_AND, AST_LOGIC_OR,
  AST_LOGIC_NOT, AST_TERNARY, AST_MEMRD, AST_MEMWR,
  AST_TCALL, AST_ASSIGN, AST_CELL, AST_PRIMITIVE,
  AST_CELLARRAY, AST_ALWAYS, AST_INITIAL, AST_BLOCK,
  AST_ASSIGN_EQ, AST_ASSIGN_LE, AST_CASE, AST_COND,
  AST_DEFAULT, AST_FOR, AST_WHILE, AST_REPEAT,
  AST_GENVAR, AST_GENFOR, AST_GENIF, AST_GENCASE,
  AST_GENBLOCK, AST_POSEDGE, AST_NEGEDGE, AST_EDGE
}
 

Functions

std::string type2str (AstNodeType type)
 
void process (RTLIL::Design *design, AstNode *ast, bool dump_ast1, bool dump_ast2, bool dump_vlog, bool nolatches, bool nomem2reg, bool mem2reg, bool lib, bool noopt, bool icells, bool ignore_redef, bool defer, bool autowire)
 
void use_internal_line_num ()
 
AstNodedpi_call (const std::string &rtype, const std::string &fname, const std::vector< std::string > &argtypes, const std::vector< AstNode * > &args)
 

Variables

std::string current_filename
 
void(* set_line_num )(int) = NULL
 
int(* get_line_num )() = NULL
 

Enumeration Type Documentation

Enumerator
AST_NONE 
AST_DESIGN 
AST_MODULE 
AST_TASK 
AST_FUNCTION 
AST_DPI_FUNCTION 
AST_WIRE 
AST_MEMORY 
AST_AUTOWIRE 
AST_PARAMETER 
AST_LOCALPARAM 
AST_DEFPARAM 
AST_PARASET 
AST_ARGUMENT 
AST_RANGE 
AST_MULTIRANGE 
AST_CONSTANT 
AST_REALVALUE 
AST_CELLTYPE 
AST_IDENTIFIER 
AST_PREFIX 
AST_ASSERT 
AST_FCALL 
AST_TO_BITS 
AST_TO_SIGNED 
AST_TO_UNSIGNED 
AST_CONCAT 
AST_REPLICATE 
AST_BIT_NOT 
AST_BIT_AND 
AST_BIT_OR 
AST_BIT_XOR 
AST_BIT_XNOR 
AST_REDUCE_AND 
AST_REDUCE_OR 
AST_REDUCE_XOR 
AST_REDUCE_XNOR 
AST_REDUCE_BOOL 
AST_SHIFT_LEFT 
AST_SHIFT_RIGHT 
AST_SHIFT_SLEFT 
AST_SHIFT_SRIGHT 
AST_LT 
AST_LE 
AST_EQ 
AST_NE 
AST_EQX 
AST_NEX 
AST_GE 
AST_GT 
AST_ADD 
AST_SUB 
AST_MUL 
AST_DIV 
AST_MOD 
AST_POW 
AST_POS 
AST_NEG 
AST_LOGIC_AND 
AST_LOGIC_OR 
AST_LOGIC_NOT 
AST_TERNARY 
AST_MEMRD 
AST_MEMWR 
AST_TCALL 
AST_ASSIGN 
AST_CELL 
AST_PRIMITIVE 
AST_CELLARRAY 
AST_ALWAYS 
AST_INITIAL 
AST_BLOCK 
AST_ASSIGN_EQ 
AST_ASSIGN_LE 
AST_CASE 
AST_COND 
AST_DEFAULT 
AST_FOR 
AST_WHILE 
AST_REPEAT 
AST_GENVAR 
AST_GENFOR 
AST_GENIF 
AST_GENCASE 
AST_GENBLOCK 
AST_POSEDGE 
AST_NEGEDGE 
AST_EDGE 

Definition at line 42 of file ast.h.

43  {
44  AST_NONE,
45  AST_DESIGN,
46  AST_MODULE,
47  AST_TASK,
50 
51  AST_WIRE,
52  AST_MEMORY,
59  AST_RANGE,
65  AST_PREFIX,
66  AST_ASSERT,
67 
68  AST_FCALL,
72  AST_CONCAT,
76  AST_BIT_OR,
88  AST_LT,
89  AST_LE,
90  AST_EQ,
91  AST_NE,
92  AST_EQX,
93  AST_NEX,
94  AST_GE,
95  AST_GT,
96  AST_ADD,
97  AST_SUB,
98  AST_MUL,
99  AST_DIV,
100  AST_MOD,
101  AST_POW,
102  AST_POS,
103  AST_NEG,
105  AST_LOGIC_OR,
107  AST_TERNARY,
108  AST_MEMRD,
109  AST_MEMWR,
110 
111  AST_TCALL,
112  AST_ASSIGN,
113  AST_CELL,
116  AST_ALWAYS,
117  AST_INITIAL,
118  AST_BLOCK,
121  AST_CASE,
122  AST_COND,
123  AST_DEFAULT,
124  AST_FOR,
125  AST_WHILE,
126  AST_REPEAT,
127 
128  AST_GENVAR,
129  AST_GENFOR,
130  AST_GENIF,
131  AST_GENCASE,
132  AST_GENBLOCK,
133 
134  AST_POSEDGE,
135  AST_NEGEDGE,
136  AST_EDGE
137  };

Function Documentation

YOSYS_NAMESPACE_BEGIN AST::AstNode * AST::dpi_call ( const std::string &  rtype,
const std::string &  fname,
const std::vector< std::string > &  argtypes,
const std::vector< AstNode * > &  args 
)

Definition at line 140 of file dpicall.cc.

141 {
142  log_error("Can't call DPI function `%s': this version of yosys is built without plugin support\n", fname.c_str());
143 }
void log_error(const char *format,...)
Definition: log.cc:204

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void AST::process ( RTLIL::Design design,
AstNode ast,
bool  dump_ast1,
bool  dump_ast2,
bool  dump_vlog,
bool  nolatches,
bool  nomem2reg,
bool  mem2reg,
bool  lib,
bool  noopt,
bool  icells,
bool  ignore_redef,
bool  defer,
bool  autowire 
)

Definition at line 967 of file ast.cc.

968 {
969  current_ast = ast;
970  flag_dump_ast1 = dump_ast1;
971  flag_dump_ast2 = dump_ast2;
972  flag_dump_vlog = dump_vlog;
973  flag_nolatches = nolatches;
974  flag_nomem2reg = nomem2reg;
975  flag_mem2reg = mem2reg;
976  flag_lib = lib;
977  flag_noopt = noopt;
978  flag_icells = icells;
979  flag_autowire = autowire;
980 
981  std::vector<AstNode*> global_decls;
982 
984  for (auto it = current_ast->children.begin(); it != current_ast->children.end(); it++)
985  {
986  if ((*it)->type == AST_MODULE)
987  {
988  for (auto n : global_decls)
989  (*it)->children.push_back(n->clone());
990 
991  if (flag_icells && (*it)->str.substr(0, 2) == "\\$")
992  (*it)->str = (*it)->str.substr(1);
993 
994  if (defer)
995  (*it)->str = "$abstract" + (*it)->str;
996 
997  if (design->has((*it)->str)) {
998  if (!ignore_redef)
999  log_error("Re-definition of module `%s' at %s:%d!\n",
1000  (*it)->str.c_str(), (*it)->filename.c_str(), (*it)->linenum);
1001  log("Ignoring re-definition of module `%s' at %s:%d!\n",
1002  (*it)->str.c_str(), (*it)->filename.c_str(), (*it)->linenum);
1003  continue;
1004  }
1005 
1006  design->add(process_module(*it, defer));
1007  }
1008  else
1009  global_decls.push_back(*it);
1010  }
1011 }
bool flag_lib
Definition: ast.cc:56
static AstModule * process_module(AstNode *ast, bool defer)
Definition: ast.cc:873
void add(RTLIL::Module *module)
Definition: rtlil.cc:259
bool flag_dump_ast1
Definition: ast.cc:56
void log_error(const char *format,...)
Definition: log.cc:204
AstNode * current_ast
Definition: ast.cc:57
tuple n
Definition: fsm/generate.py:59
bool flag_autowire
Definition: ast.cc:56
#define log_assert(_assert_expr_)
Definition: log.h:85
bool flag_dump_ast2
Definition: ast.cc:56
bool flag_noopt
Definition: ast.cc:56
AstNodeType type
Definition: ast.h:146
bool has(RTLIL::IdString id) const
Definition: rtlil.h:519
void log(const char *format,...)
Definition: log.cc:180
std::vector< AstNode * > children
Definition: ast.h:149
bool flag_nolatches
Definition: ast.cc:56
bool flag_mem2reg
Definition: ast.cc:56
bool flag_icells
Definition: ast.cc:56
bool flag_nomem2reg
Definition: ast.cc:56
bool flag_dump_vlog
Definition: ast.cc:56

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

std::string AST::type2str ( AstNodeType  type)

Definition at line 66 of file ast.cc.

67 {
68  switch (type)
69  {
70 #define X(_item) case _item: return #_item;
71  X(AST_NONE)
72  X(AST_DESIGN)
73  X(AST_MODULE)
74  X(AST_TASK)
77  X(AST_WIRE)
78  X(AST_MEMORY)
83  X(AST_PARASET)
85  X(AST_RANGE)
91  X(AST_PREFIX)
92  X(AST_ASSERT)
93  X(AST_FCALL)
94  X(AST_TO_BITS)
97  X(AST_CONCAT)
99  X(AST_BIT_NOT)
100  X(AST_BIT_AND)
101  X(AST_BIT_OR)
102  X(AST_BIT_XOR)
103  X(AST_BIT_XNOR)
113  X(AST_LT)
114  X(AST_LE)
115  X(AST_EQ)
116  X(AST_NE)
117  X(AST_EQX)
118  X(AST_NEX)
119  X(AST_GE)
120  X(AST_GT)
121  X(AST_ADD)
122  X(AST_SUB)
123  X(AST_MUL)
124  X(AST_DIV)
125  X(AST_MOD)
126  X(AST_POW)
127  X(AST_POS)
128  X(AST_NEG)
130  X(AST_LOGIC_OR)
132  X(AST_TERNARY)
133  X(AST_MEMRD)
134  X(AST_MEMWR)
135  X(AST_TCALL)
136  X(AST_ASSIGN)
137  X(AST_CELL)
140  X(AST_ALWAYS)
141  X(AST_INITIAL)
142  X(AST_BLOCK)
145  X(AST_CASE)
146  X(AST_COND)
147  X(AST_DEFAULT)
148  X(AST_FOR)
149  X(AST_WHILE)
150  X(AST_REPEAT)
151  X(AST_GENVAR)
152  X(AST_GENFOR)
153  X(AST_GENIF)
154  X(AST_GENCASE)
155  X(AST_GENBLOCK)
156  X(AST_POSEDGE)
157  X(AST_NEGEDGE)
158  X(AST_EDGE)
159 #undef X
160  default:
161  log_abort();
162  }
163 }
#define X(_item)
#define log_abort()
Definition: log.h:84

+ Here is the caller graph for this function:

void AST::use_internal_line_num ( )

Definition at line 1123 of file ast.cc.

1124 {
1125  set_line_num = &internal_set_line_num;
1126  get_line_num = &internal_get_line_num;
1127 }
void(* set_line_num)(int)
Definition: ast.cc:50
int(* get_line_num)()
Definition: ast.cc:51

+ Here is the caller graph for this function:

Variable Documentation

std::string AST::current_filename

Definition at line 49 of file ast.cc.

int(* AST::get_line_num)() = NULL

Definition at line 51 of file ast.cc.

void(* AST::set_line_num)(int) = NULL

Definition at line 50 of file ast.cc.