Bug 358

Summary: new MCU-ALU test picked up RC / OE / CR handling issue
Product: Libre-SOC's first SoC Reporter: Luke Kenneth Casson Leighton <lkcl>
Component: Source CodeAssignee: Michael Nolan <mtnolan2640>
Status: RESOLVED FIXED    
Severity: enhancement CC: libre-soc-bugs
Priority: ---    
Version: unspecified   
Hardware: PC   
OS: Linux   
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:
Bug Depends on:    
Bug Blocks: 305    

Description Luke Kenneth Casson Leighton 2020-05-30 20:47:48 BST
yippee!  a new unit test (test_alu_compunit.py) just picked up that
we are using rc from Decode2ExecuteType in the wrong way.  as RC and
OE are both of type "Data", the test needs to be on "rc_ok" enabled.

i think.

the symptoms: test_alu_compunit.py fails because CR0 is not being
outputted on OP_CMP.  as in: cr0.ok is not being set.

it's not being set because in CommonOutputStage:
        comb += self.o.cr0.data.eq(cr0)
        comb += self.o.cr0.ok.eq(op.rc.rc & op.rc.rc_ok) # CR0 to be set

op.rc.rc & op.rc.rc_ok is *zero*, and yet the test in test_output_caller.py
(and test_alu_compunit.py) is this:

    def check_extra_alu_outputs(self, alu, dec2, sim, code):
        rc = yield dec2.e.rc.data
        if rc:
             ....
Comment 1 Luke Kenneth Casson Leighton 2020-05-30 20:48:10 BST
michael, any clues?
Comment 2 Luke Kenneth Casson Leighton 2020-05-30 21:39:40 BST
ah.  just as in the unit tests which check if OP_CMP* is enabled, this was missing in CommonOutputStage.

however this highlights something else: the destination for CR output needs to be implicitly set to CR0 when RC is enabled, otherwise the output stage has ni idea where to put the result.
Comment 3 Luke Kenneth Casson Leighton 2020-05-30 22:22:51 BST
(In reply to Luke Kenneth Casson Leighton from comment #2)

> however this highlights something else: the destination for CR output needs
> to be implicitly set to CR0 when RC is enabled, otherwise the output stage
> has no idea where to put the result.

... which is in decode2.cr_out bitfield.
so the unit tests need to be modified to check if cr out ok is set, rather than use RC or the OP_CMP* test.