'K_MOD_EQ', 'K_AND_EQ', 'K_OR_EQ'),
('right', 'K_XOR_EQ', 'K_LS_EQ', 'K_RS_EQ', 'K_RSS_EQ'),
('right', '?', ':', 'K_inside'),
'K_MOD_EQ', 'K_AND_EQ', 'K_OR_EQ'),
('right', 'K_XOR_EQ', 'K_LS_EQ', 'K_RS_EQ', 'K_RSS_EQ'),
('right', '?', ':', 'K_inside'),
- ('left', 'K_LOR'),
- ('left', 'K_LAND'),
- ('left', '|'),
- ('left', '^', 'K_NXOR', 'K_NOR'),
- ('left', '&', 'K_NAND'),
- ('left', 'K_EQ', 'K_NE', 'K_CEQ', 'K_CNE', 'K_WEQ', 'K_WNE'),
- ('left', 'K_GE', 'K_LE', '<', '>'),
- ('left', 'K_LS', 'K_RS', 'K_RSS'),
- ('left', '+', '-'),
- ('left', '*', '/', '%'),
- ('left', 'K_POW'),
- ('left', 'UNARY_PREC'),
- ('nonassoc', 'less_than_K_else'),
- ('nonassoc', 'K_else'),
- ('nonassoc', '('),
- ('nonassoc', 'K_exclude'),
- ('nonassoc', 'no_timeunits_declaration'),
- ('nonassoc', 'one_timeunits_declaration'),
+ ('left', 'K_LOR'),
+ ('left', 'K_LAND'),
+ ('left', '|'),
+ ('left', '^', 'K_NXOR', 'K_NOR'),
+ ('left', '&', 'K_NAND'),
+ ('left', 'K_EQ', 'K_NE', 'K_CEQ', 'K_CNE', 'K_WEQ', 'K_WNE'),
+ ('left', 'K_GE', 'K_LE', '<', '>'),
+ ('left', 'K_LS', 'K_RS', 'K_RSS'),
+ ('left', '+', '-'),
+ ('left', '*', '/', '%'),
+ ('left', 'K_POW'),
+ ('left', 'UNARY_PREC'),
+ ('nonassoc', 'less_than_K_else'),
+ ('nonassoc', 'K_else'),
+ ('nonassoc', '('),
+ ('nonassoc', 'K_exclude'),
+ ('nonassoc', 'no_timeunits_declaration'),
+ ('nonassoc', 'one_timeunits_declaration'),
+
+
+IVL_VT_NO_TYPE = 'VT_NO_TYPE'
+IVL_VT_BOOL = 'VT_BOOL'
+IVL_VT_LOGIC = 'VT_LOGIC'
+"""
+ IVL_VT_VOID = 0, /* Not used */
+ IVL_VT_NO_TYPE = 1, /* Place holder for missing/unknown type. */
+ IVL_VT_REAL = 2,
+ IVL_VT_BOOL = 3,
+ IVL_VT_LOGIC = 4,
+ IVL_VT_STRING = 5,
+ IVL_VT_DARRAY = 6, /* Array (esp. dynamic array) */
+ IVL_VT_CLASS = 7, /* SystemVerilog class instances */
+ IVL_VT_QUEUE = 8, /* SystemVerilog queue instances */
+ IVL_VT_VECTOR = IVL_VT_LOGIC /* For compatibility */
+"""
+
+NN_NONE = 'NONE'
+NN_IMPLICIT = 'IMPLICIT'
+NN_IMPLICIT_REG = 'IMPLICIT_REG'
+NN_INTEGER = 'INTEGER'
+NN_WIRE = 'WIRE'
+NN_TRI = 'TRI'
+NN_TRI1 = 'TRI1'
+NN_SUPPLY0 = 'SUPPLY0'
+NN_SUPPLY1 = 'SUPPLY1'
+NN_WAND = 'WAND'
+NN_TRIAND = 'TRIAND'
+NN_TRI0 = 'TRI0'
+NN_WOR = 'WOR'
+NN_TRIOR = 'TRIOR'
+NN_REG = 'REG'
+NN_UNRESOLVED_WIRE = 'UNRESOLVED_WIRE'
+
+NP_NOT_A_PORT = 'NOT_A_PORT'
+NP_PIMPLICIT = 'PIMPLICIT'
+NP_PINPUT = 'PINPUT'
+NP_POUTPUT = 'POUTPUT'
+NP_PINOUT = 'PINOUT'
+NP_PREF = 'PREF'
+
+def indent(s, i=4):
+ st = ''
+ for x in s:
+ st += str(x)
+ res = []
+ for p in st.split('\n'):
+ res.append(' ' * i + p)
+ return '\n'.join(res)
+
+
+class DataType:
+ def __init__(self, typ, signed):
+ self.typ = typ
+ self.signed = signed
+
+def port_decl(comment, dt, name):
+ if dt.dims is None:
+ width = '' # width: 1
+ else:
+ width = dt.dims
+ # XXX TODO, better checking, should be using data structure... *sigh*
+ width = width[1:-1] # strip brackets
+ width = width.split(':')
+ assert width[0] == '0'
+ width = width[1]
+ return 'self.%s = Signal(%s) # %s' % (name, width, comment)
+
'''inside_expression : expression K_inside '{' open_range_list '}' '''
print('inside_expression_1', list(p))
# { yyerror(@2, "sorry: \"inside\" expressions not supported yet.");
'''inside_expression : expression K_inside '{' open_range_list '}' '''
print('inside_expression_1', list(p))
# { yyerror(@2, "sorry: \"inside\" expressions not supported yet.");
# PForStatement*tmp_for = new PForStatement(tmp_ident, $6, $8, $10, $13);
# FILE_NAME(tmp_for, @1);
# PForStatement*tmp_for = new PForStatement(tmp_ident, $6, $8, $10, $13);
# FILE_NAME(tmp_for, @1);
'''loop_statement : K_foreach '(' IDENTIFIER '[' loop_variables ']' ')' _embed1_loop_statement statement_or_null '''
print('loop_statement_7', list(p))
# { PForeach*tmp_for = pform_make_foreach(@1, $3, $5, $9);
'''loop_statement : K_foreach '(' IDENTIFIER '[' loop_variables ']' ')' _embed1_loop_statement statement_or_null '''
print('loop_statement_7', list(p))
# { PForeach*tmp_for = pform_make_foreach(@1, $3, $5, $9);
# yyerror(@1, "error: Error in for loop step assignment.");
# }
()
def p_loop_statement_9(p):
'''loop_statement : K_for '(' lpvalue '=' expression ';' error ';' for_step ')' statement_or_null '''
print('loop_statement_9', list(p))
# yyerror(@1, "error: Error in for loop step assignment.");
# }
()
def p_loop_statement_9(p):
'''loop_statement : K_for '(' lpvalue '=' expression ';' error ';' for_step ')' statement_or_null '''
print('loop_statement_9', list(p))
# yyerror(@1, "error: Error in for loop condition expression.");
# }
()
def p_loop_statement_10(p):
'''loop_statement : K_for '(' error ')' statement_or_null '''
print('loop_statement_10', list(p))
# yyerror(@1, "error: Error in for loop condition expression.");
# }
()
def p_loop_statement_10(p):
'''loop_statement : K_for '(' error ')' statement_or_null '''
print('loop_statement_10', list(p))
# yyerror(@1, "error: Incomprehensible for loop.");
# }
()
def p_loop_statement_11(p):
'''loop_statement : K_while '(' error ')' statement_or_null '''
print('loop_statement_11', list(p))
# yyerror(@1, "error: Incomprehensible for loop.");
# }
()
def p_loop_statement_11(p):
'''loop_statement : K_while '(' error ')' statement_or_null '''
print('loop_statement_11', list(p))
# yyerror(@1, "error: Error in while loop condition.");
# }
()
def p_loop_statement_12(p):
'''loop_statement : K_do statement_or_null K_while '(' error ')' ';' '''
print('loop_statement_12', list(p))
# yyerror(@1, "error: Error in while loop condition.");
# }
()
def p_loop_statement_12(p):
'''loop_statement : K_do statement_or_null K_while '(' error ')' ';' '''
print('loop_statement_12', list(p))
# yyerror(@1, "error: Error in do/while loop condition.");
# }
()
def p_loop_statement_13(p):
'''loop_statement : K_foreach '(' IDENTIFIER '[' error ']' ')' statement_or_null '''
print('loop_statement_13', list(p))
# yyerror(@1, "error: Error in do/while loop condition.");
# }
()
def p_loop_statement_13(p):
'''loop_statement : K_foreach '(' IDENTIFIER '[' error ']' ')' statement_or_null '''
print('loop_statement_13', list(p))
'''procedural_assertion_statement : K_assert '(' expression ')' statement %prec less_than_K_else '''
print('procedural_assertion_statement_1', list(p))
# { yyerror(@1, "sorry: Simple immediate assertion statements not implemented.");
'''procedural_assertion_statement : K_assert '(' expression ')' statement %prec less_than_K_else '''
print('procedural_assertion_statement_1', list(p))
# { yyerror(@1, "sorry: Simple immediate assertion statements not implemented.");
# }
()
def p_procedural_assertion_statement_2(p):
'''procedural_assertion_statement : K_assert '(' expression ')' K_else statement '''
print('procedural_assertion_statement_2', list(p))
# { yyerror(@1, "sorry: Simple immediate assertion statements not implemented.");
# }
()
def p_procedural_assertion_statement_2(p):
'''procedural_assertion_statement : K_assert '(' expression ')' K_else statement '''
print('procedural_assertion_statement_2', list(p))
# { yyerror(@1, "sorry: Simple immediate assertion statements not implemented.");
# }
()
def p_procedural_assertion_statement_3(p):
'''procedural_assertion_statement : K_assert '(' expression ')' statement K_else statement '''
print('procedural_assertion_statement_3', list(p))
# { yyerror(@1, "sorry: Simple immediate assertion statements not implemented.");
# }
()
def p_procedural_assertion_statement_3(p):
'''procedural_assertion_statement : K_assert '(' expression ')' statement K_else statement '''
print('procedural_assertion_statement_3', list(p))
# { yyerror(@1, "sorry: Simple immediate assertion statements not implemented.");
# { perm_string name = lex_strings.make($3.text);
# if (pform_test_type_identifier_local(name)) {
# yyerror(@3, "error: Typedef identifier \"%s\" is already a type name.", $3.text);
# { perm_string name = lex_strings.make($3.text);
# if (pform_test_type_identifier_local(name)) {
# yyerror(@3, "error: Typedef identifier \"%s\" is already a type name.", $3.text);
def p_list_of_port_declarations_2(p):
'''list_of_port_declarations : list_of_port_declarations ',' port_declaration '''
print('list_of_port_declarations_2', list(p))
def p_list_of_port_declarations_2(p):
'''list_of_port_declarations : list_of_port_declarations ',' port_declaration '''
print('list_of_port_declarations_2', list(p))
clsname = [Leaf(token.NAME, 'class'),
Leaf(token.NAME, p[4], prefix=' '),
Leaf(token.COLON, ':')]
clsname = [Leaf(token.NAME, 'class'),
Leaf(token.NAME, p[4], prefix=' '),
Leaf(token.COLON, ':')]
- stmt = Node(syms.pass_stmt, [Leaf(token.NAME, "pass"),])
- stmts = Node(syms.small_stmt, [stmt, Leaf(token.NEWLINE, '\n')])
- stmts = Node(syms.stmt, [stmts])
+ pass_stmt = Node(syms.pass_stmt, [Leaf(token.NAME, "pass"),])
+ if params:
+ params = [Leaf(token.LPAR, '(')] + params + [Leaf(token.RPAR, ')')]
+ fn = [Leaf(token.NAME, 'def'),
+ Leaf(token.NAME, '__init__', prefix=' '),
+ Node(syms.parameters, params),
+ Leaf(token.COLON, ':')]
+ fndef = Node(syms.funcdef, fn)
+ stmts = Node(syms.stmt, [fndef])
+ else:
+ stmts = Node(syms.small_stmt, [pass_stmt, Leaf(token.NEWLINE, '\n')])
+ stmts = Node(syms.stmt, [stmts])
+
+ # XXX TODO ports as py nodes
+ ports = p[8]
+ stmts.children.append(Leaf(token.STRING, '\n' + indent(ports, 8)))
()
def p_module_port_list_opt_4(p):
'''module_port_list_opt : '(' error ')' '''
print('module_port_list_opt_4', list(p))
# { yyerror(@2, "Errors in port declarations.");
# yyerrok;
()
def p_module_port_list_opt_4(p):
'''module_port_list_opt : '(' error ')' '''
print('module_port_list_opt_4', list(p))
# { yyerror(@2, "Errors in port declarations.");
# yyerrok;
def p_module_parameter_port_list_3(p):
'''module_parameter_port_list : module_parameter_port_list ',' K_parameter param_type parameter_assign '''
print('module_parameter_port_list_3', list(p))
def p_module_parameter_port_list_3(p):
'''module_parameter_port_list : module_parameter_port_list ',' K_parameter param_type parameter_assign '''
print('module_parameter_port_list_3', list(p))