Bug 436 - isa simulator appears to calculate wrong result for test_divwuo_regression_1
Summary: isa simulator appears to calculate wrong result for test_divwuo_regression_1
Status: RESOLVED FIXED
Alias: None
Product: Libre-SOC's first SoC
Classification: Unclassified
Component: Source Code (show other bugs)
Version: unspecified
Hardware: PC Linux
: --- normal
Assignee: Luke Kenneth Casson Leighton
URL:
Depends on:
Blocks: 325
  Show dependency treegraph
 
Reported: 2020-07-23 03:42 BST by Jacob Lifshay
Modified: 2020-07-24 13:24 BST (History)
3 users (show)

See Also:
NLnet milestone: ---
total budget (EUR) for completion of task and all subtasks: 0
budget (EUR) for this task, excluding subtasks' budget: 0
parent task for budget allocation:
child tasks for budget allocation:
The table of payments (in EUR) for this task; TOML format:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Jacob Lifshay 2020-07-23 03:42:02 BST
when dividing 0xC4E32B68 by 0x32867D69, the ISA simulator appears to give 0xFFFFFFFF as the result -- the correct result is 0x3
Comment 1 Jacob Lifshay 2020-07-23 03:45:52 BST
see comment on mailing list: http://lists.libre-riscv.org/pipermail/libre-riscv-dev/2020-July/008637.html
Comment 2 Luke Kenneth Casson Leighton 2020-07-24 13:19:40 BST
yep, that's down to changing of a "hack" function which is now
no longer appropriate

diff --git a/src/soc/decoder/pseudo/parser.py b/src/soc/decoder/pseudo/parser.py
index 346e3f98..3d75fbb0 100644
--- a/src/soc/decoder/pseudo/parser.py
+++ b/src/soc/decoder/pseudo/parser.py
@@ -615,7 +615,8 @@ class PowerParser:
                 l, r = p[1], p[3]
                 # actual call will be "dividend / divisor" - just check
                 # LHS name
-                if isinstance(l, ast.Name) and l.id == 'dividend':
+                # XXX DISABLE BAD HACK (False)
+                if False and isinstance(l, ast.Name) and l.id == 'dividend':
                     if p[2] == '/':
                         fn = 'trunc_divs'
                     else:
Comment 3 Luke Kenneth Casson Leighton 2020-07-24 13:24:47 BST
this is related to that helper function that you wrote (which is great btw).
it turns out that it's a signed (only) floor_div function, and that
calling "standard" (python3) floordiv is appropriate in unsigned cases
(such as divwuo)

i had messed up the parser and called the wrong function since changing
the pseudo-code to actually *explicitly* call DIVS:

http://lists.mailinglist.openpowerfoundation.org/pipermail/openpower-hdl-cores/2020-July/000078.html