You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi, I am getting the following error while creating a circuit in jupyter using circuitgraph. My file is a halfadder program
" module halfadder
(
input a,
input b,
output sum,
output carry
);
xor x1(sum, a, b) ;
and a1(carry, a, b) ;
endmodule"
##Error I got for the code "c = cg.from_file('C:/Users/jenil/Downloads/halfadder.v')"
File ~\AppData\Local\Programs\Python\Python311\Lib\site-packages\lark\parsers\lalr_parser.py:193, in _Parser.parse_from_state(self, state, last_token)
191 except NameError:
192 pass
--> 193 raise e
194 except Exception as e:
195 if self.debug:
File ~\AppData\Local\Programs\Python\Python311\Lib\site-packages\lark\parsers\lalr_parser.py:183, in _Parser.parse_from_state(self, state, last_token)
181 try:
182 token = last_token
--> 183 for token in state.lexer.lex(state):
184 state.feed_token(token)
186 end_token = Token.new_borrow_pos('$END', '', token) if token else Token('$END', '', 0, 1, 1)
File ~\AppData\Local\Programs\Python\Python311\Lib\site-packages\lark\lexer.py:657, in ContextualLexer.lex(self, lexer_state, parser_state)
655 last_token = lexer_state.last_token # Save last_token. Calling root_lexer.next_token will change this to the wrong token
656 token = self.root_lexer.next_token(lexer_state, parser_state)
--> 657 raise UnexpectedToken(token, e.allowed, state=parser_state, token_history=[last_token], terminals_by_name=self.root_lexer.terminals_by_name)
658 except UnexpectedCharacters:
659 raise e
UnexpectedToken: Unexpected token Token('IDENTIFIER', 'a') at line 3, column 8.
Expected one of:
* RPAR
* COMMA
Previous tokens: [Token('IDENTIFIER', 'input')]. PI give a guidance.
The text was updated successfully, but these errors were encountered:
Hi, I am getting the following error while creating a circuit in jupyter using circuitgraph. My file is a halfadder program
" module halfadder
(
input a,
input b,
output sum,
output carry
);
xor x1(sum, a, b) ;
and a1(carry, a, b) ;
endmodule"
##Error I got for the code "c = cg.from_file('C:/Users/jenil/Downloads/halfadder.v')"
UnexpectedCharacters Traceback (most recent call last)
File ~\AppData\Local\Programs\Python\Python311\Lib\site-packages\lark\lexer.py:648, in ContextualLexer.lex(self, lexer_state, parser_state)
647 lexer = self.lexers[parser_state.position]
--> 648 yield lexer.next_token(lexer_state, parser_state)
649 except EOFError:
File ~\AppData\Local\Programs\Python\Python311\Lib\site-packages\lark\lexer.py:581, in BasicLexer.next_token(self, lex_state, parser_state)
580 allowed = {""}
--> 581 raise UnexpectedCharacters(lex_state.text, line_ctr.char_pos, line_ctr.line, line_ctr.column,
582 allowed=allowed, token_history=lex_state.last_token and [lex_state.last_token],
583 state=parser_state, terminals_by_name=self.terminals_by_name)
585 value, type_ = res
UnexpectedCharacters: No terminal matches 'a' in the current parser context, at line 3 col 8
Expected one of:
* RPAR
* COMMA
Previous tokens: Token('IDENTIFIER', 'input')
During handling of the above exception, another exception occurred:
UnexpectedToken Traceback (most recent call last)
Cell In[15], line 2
1 from circuitgraph import Circuit
----> 2 c = cg.from_file('C:/Users/jenil/Downloads/halfadder.v')
File ~\AppData\Local\Programs\Python\Python311\Lib\site-packages\circuitgraph\io.py:75, in from_file(path, name, fmt, blackboxes, warnings, error_on_warning, fast)
73 netlist = f.read()
74 if fmt == "verilog" or path.suffix == ".v":
---> 75 return verilog_to_circuit(
76 netlist,
77 name,
78 infer_module_name,
79 blackboxes,
80 warnings,
81 error_on_warning,
82 fast,
83 )
84 if fmt == "bench" or path.suffix == ".bench":
85 return bench_to_circuit(netlist, name)
File ~\AppData\Local\Programs\Python\Python311\Lib\site-packages\circuitgraph\io.py:238, in verilog_to_circuit(netlist, name, infer_module_name, blackboxes, warnings, error_on_warning, fast)
235 else:
236 raise ValueError(f"Could not read netlist: {name} module not found") from e1
--> 238 return parse_verilog_netlist(module, blackboxes, warnings, error_on_warning)
File ~\AppData\Local\Programs\Python\Python311\Lib\site-packages\circuitgraph\parsing\verilog.py:374, in parse_verilog_netlist(netlist, blackboxes, warnings, error_on_warning)
372 with open(Path(file).parent.absolute() / "verilog.lark") as f:
373 parser = Lark(f, parser="lalr", transformer=transformer)
--> 374 [c] = parser.parse(netlist)
375 return c
File ~\AppData\Local\Programs\Python\Python311\Lib\site-packages\lark\lark.py:652, in Lark.parse(self, text, start, on_error)
634 def parse(self, text: str, start: Optional[str]=None, on_error: 'Optional[Callable[[UnexpectedInput], bool]]'=None) -> 'ParseTree':
635 """Parse the given text, according to the options provided.
636
637 Parameters:
(...)
650
651 """
--> 652 return self.parser.parse(text, start=start, on_error=on_error)
File ~\AppData\Local\Programs\Python\Python311\Lib\site-packages\lark\parser_frontends.py:101, in ParsingFrontend.parse(self, text, start, on_error)
99 kw = {} if on_error is None else {'on_error': on_error}
100 stream = self._make_lexer_thread(text)
--> 101 return self.parser.parse(stream, chosen_start, **kw)
File ~\AppData\Local\Programs\Python\Python311\Lib\site-packages\lark\parsers\lalr_parser.py:41, in LALR_Parser.parse(self, lexer, start, on_error)
39 def parse(self, lexer, start, on_error=None):
40 try:
---> 41 return self.parser.parse(lexer, start)
42 except UnexpectedInput as e:
43 if on_error is None:
File ~\AppData\Local\Programs\Python\Python311\Lib\site-packages\lark\parsers\lalr_parser.py:171, in _Parser.parse(self, lexer, start, value_stack, state_stack, start_interactive)
169 if start_interactive:
170 return InteractiveParser(self, parser_state, parser_state.lexer)
--> 171 return self.parse_from_state(parser_state)
File ~\AppData\Local\Programs\Python\Python311\Lib\site-packages\lark\parsers\lalr_parser.py:193, in _Parser.parse_from_state(self, state, last_token)
191 except NameError:
192 pass
--> 193 raise e
194 except Exception as e:
195 if self.debug:
File ~\AppData\Local\Programs\Python\Python311\Lib\site-packages\lark\parsers\lalr_parser.py:183, in _Parser.parse_from_state(self, state, last_token)
181 try:
182 token = last_token
--> 183 for token in state.lexer.lex(state):
184 state.feed_token(token)
186 end_token = Token.new_borrow_pos('$END', '', token) if token else Token('$END', '', 0, 1, 1)
File ~\AppData\Local\Programs\Python\Python311\Lib\site-packages\lark\lexer.py:657, in ContextualLexer.lex(self, lexer_state, parser_state)
655 last_token = lexer_state.last_token # Save last_token. Calling root_lexer.next_token will change this to the wrong token
656 token = self.root_lexer.next_token(lexer_state, parser_state)
--> 657 raise UnexpectedToken(token, e.allowed, state=parser_state, token_history=[last_token], terminals_by_name=self.root_lexer.terminals_by_name)
658 except UnexpectedCharacters:
659 raise e
UnexpectedToken: Unexpected token Token('IDENTIFIER', 'a') at line 3, column 8.
Expected one of:
* RPAR
* COMMA
Previous tokens: [Token('IDENTIFIER', 'input')]. PI give a guidance.
The text was updated successfully, but these errors were encountered: