Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[wawk] using 2-digit number in sliced_symbol leads to error #1

Closed
eyck opened this issue Jun 11, 2022 · 2 comments · Fixed by #5
Closed

[wawk] using 2-digit number in sliced_symbol leads to error #1

eyck opened this issue Jun 11, 2022 · 2 comments · Fixed by #5

Comments

@eyck
Copy link

eyck commented Jun 11, 2022

When I try to access a sliced part of a 32bit signal (e.g. inst[11:7]) I get the following error:

Traceback (most recent call last):
  File "/home/eyck/tmp/wal/.wal/bin/wawk", line 33, in <module>
    sys.exit(load_entry_point('wal-lang', 'console_scripts', 'wawk')())
  File "/home/eyck/git/wal/wawk/wawk.py", line 70, in run
    wal.eval(statement.action)
  File "/home/eyck/git/wal/wal/core.py", line 43, in eval
    return self.eval_context.eval(sexpr)
  File "/home/eyck/git/wal/wal/eval.py", line 93, in eval
    res = self.eval_dispatch(head, tail)
  File "/home/eyck/git/wal/wal/eval.py", line 44, in eval_dispatch
    return self.dispatch.get(oprtr.value, lambda a, b: NotImplementedError())(self, args)
  File "/home/eyck/git/wal/wal/implementation/core.py", line 290, in op_do
    return seval.eval_args(args)[-1]
  File "/home/eyck/git/wal/wal/eval.py", line 40, in eval_args
    return list(map(self.eval, args))
  File "/home/eyck/git/wal/wal/eval.py", line 93, in eval
    res = self.eval_dispatch(head, tail)
  File "/home/eyck/git/wal/wal/eval.py", line 44, in eval_dispatch
    return self.dispatch.get(oprtr.value, lambda a, b: NotImplementedError())(self, args)
  File "/home/eyck/git/wal/wal/implementation/core.py", line 239, in op_if
    return seval.eval(args[1])
  File "/home/eyck/git/wal/wal/eval.py", line 93, in eval
    res = self.eval_dispatch(head, tail)
  File "/home/eyck/git/wal/wal/eval.py", line 44, in eval_dispatch
    return self.dispatch.get(oprtr.value, lambda a, b: NotImplementedError())(self, args)
  File "/home/eyck/git/wal/wal/implementation/core.py", line 290, in op_do
    return seval.eval_args(args)[-1]
  File "/home/eyck/git/wal/wal/eval.py", line 40, in eval_args
    return list(map(self.eval, args))
  File "/home/eyck/git/wal/wal/eval.py", line 93, in eval
    res = self.eval_dispatch(head, tail)
  File "/home/eyck/git/wal/wal/eval.py", line 44, in eval_dispatch
    return self.dispatch.get(oprtr.value, lambda a, b: NotImplementedError())(self, args)
  File "/home/eyck/git/wal/wal/implementation/core.py", line 194, in op_set
    res = seval.eval(arg[1])
  File "/home/eyck/git/wal/wal/eval.py", line 93, in eval
    res = self.eval_dispatch(head, tail)
  File "/home/eyck/git/wal/wal/eval.py", line 44, in eval_dispatch
    return self.dispatch.get(oprtr.value, lambda a, b: NotImplementedError())(self, args)
  File "/home/eyck/git/wal/wal/implementation/core.py", line 91, in op_neq
    evaluated = seval.eval_args(args)
  File "/home/eyck/git/wal/wal/eval.py", line 40, in eval_args
    return list(map(self.eval, args))
  File "/home/eyck/git/wal/wal/eval.py", line 93, in eval
    res = self.eval_dispatch(head, tail)
  File "/home/eyck/git/wal/wal/eval.py", line 44, in eval_dispatch
    return self.dispatch.get(oprtr.value, lambda a, b: NotImplementedError())(self, args)
  File "/home/eyck/git/wal/wal/implementation/core.py", line 609, in op_slice
    return (evaluated[0] & (((1 << (upper - lower + 1)) - 1) << lower)) >> lower
ValueError: negative shift count
@eyck eyck changed the title [wawk] using 2-digit number in sliced_symbol leads to error message [wawk] using 2-digit number in sliced_symbol leads to error Jun 11, 2022
@eyck
Copy link
Author

eyck commented Jun 11, 2022

When shifting so that single digit can be used:

	shifted = instr/128;
	store = shifted[4:0]!=0 ;

it works

@FRoith
Copy link
Contributor

FRoith commented Jul 11, 2022

Found the bug in the wawk parser and fixed it in #5

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants