Bug 607 - unnecessary code added related to MMU in PowerDecoder2
Summary: unnecessary code added related to MMU in PowerDecoder2
Status: CONFIRMED
Alias: None
Product: Libre-SOC's first SoC
Classification: Unclassified
Component: Source Code (show other bugs)
Version: unspecified
Hardware: Other Linux
: --- enhancement
Assignee: Tobias Platen
URL:
Depends on:
Blocks:
 
Reported: 2021-02-27 23:58 GMT by Luke Kenneth Casson Leighton
Modified: 2021-03-02 18:10 GMT (History)
1 user (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 Luke Kenneth Casson Leighton 2021-02-27 23:58:05 GMT
https://git.libre-soc.org/?p=soc.git;a=blob;f=src/soc/decoder/power_decoder2.py;h=0662284351b588a659ebd96a663dc72df94cc34f;hb=HEAD#l920

this is unnecessary because mmu0 internal_op is 100% guaranteed to be identical to self.internal_op.

all of those lines shall be deleted and replaced with

929   comb += self.do_copy("insn_type", self.op_get("internal_op"))
Comment 1 Luke Kenneth Casson Leighton 2021-02-28 11:45:08 GMT
thanks Tobias.
Comment 2 Luke Kenneth Casson Leighton 2021-02-28 11:46:19 GMT
remember to git push :)
Comment 3 Tobias Platen 2021-02-28 11:48:28 GMT
I pushed the last change.
It is a weird thing, for a different project I use subversion, which does not have a push.
Comment 4 Tobias Platen 2021-03-01 18:51:10 GMT
In src/soc/simple/core.py I added this line:           self.decoders["mmu0"].mmu0_spr_dec = self.decoders["spr0"] 
after having found out using GTKWave that the insn_type for mmu0 is OP_INVALID in my unit test where is use "mtspr 18, 1". The correct insn_type for DSISR DAR SVSRR0 and PIDR is passed to the wrong function unit instead.
Comment 5 Luke Kenneth Casson Leighton 2021-03-01 19:41:14 GMT
(In reply to Tobias Platen from comment #4)
> In src/soc/simple/core.py I added this line:          
> self.decoders["mmu0"].mmu0_spr_dec = self.decoders["spr0"] 

ok that will need a comment, cross-reference this bugreport as well
special-case hacks like that we need to pay attention to.  then also
cross-reference it in PowerDecoderSubset as well, that mmu_spr_dec
is set up in simple/core.py

what we don't need is surprises when people go "where does mmu0_spr_dec
come from, it's not in the constructor, wtf??"


> after having found out using GTKWave that the insn_type for mmu0 is
> OP_INVALID in my unit test where is use "mtspr 18, 1". The correct insn_type
> for DSISR DAR SVSRR0 and PIDR is passed to the wrong function unit instead.

yyeah this is because of the subset decoding. there may be more that needs
doing, here.

note i've just pushed this:

commit f5549bf43d740610a5980b5930241ff37641bdd6 (HEAD -> master, origin/master)
Author: Luke Kenneth Casson Leighton <lkcl@lkcl.net>
Date:   Mon Mar 1 19:35:31 2021 +0000

    Revert "fix Bug 607 - unnecessary code added related to MMU in PowerDecoder2"
Comment 6 Luke Kenneth Casson Leighton 2021-03-01 21:10:10 GMT
https://git.libre-soc.org/?p=soc.git;a=blob;f=src/soc/decoder/power_decoder2.py;h=6b3530813943dd37a07bc68d42c4c4cbaf7deac2;hb=HEAD#l774

rright.  ok.  what this is doing is asking BOTH the SPR *AND* the MMU pipelines to process the MTMSR operation.

clearly this is disastrous because there will be two FUs fighting for the register file amongst other things.

try moving it to PowerDecoder2, removong mmu_spr_dec and simply "overriding" the fn_unit etc.

with m.If((fn_unit == Function.SPR) &
           OP_MTMSR & DSR etc etc))

     comb += self.do_copy("fn_unit", Function.MMU)

this *really* should be enough to get the operation redirected to the correct FU Decoder.

ohh i know what needs to be done.  there is a filter which selects the rows of CSV files.  because the CSV file says "this is for SPR pipe" it is getting filtered out.

let me find the location.
Comment 7 Luke Kenneth Casson Leighton 2021-03-01 21:15:23 GMT
https://git.libre-soc.org/?p=soc.git;a=blob;f=src/soc/decoder/power_decoder2.py;h=6b3530813943dd37a07bc68d42c4c4cbaf7deac2;hb=HEAD#l715

found it.

urr this is a nuisance.

i think the solution here is to modify the CSV files or perhaps even add special sub-processing entries for the SPR field.

have to think
Comment 8 Luke Kenneth Casson Leighton 2021-03-02 18:10:57 GMT
ok there are a few things going on here.  the CSV File always directs to the SPR FU.   i've added a filter which allows the CSV entry to get through to the MMU FU.

then stopped non-MMU SPR requests from getting to the SPR FU and only allowed them to get to the MMU FU.

then also i had to fix the MMU FSM to get it to store in the SPR regfile.

also, the unit test was wrong.  you can't give a FU things that it is incapable of processing.  the MMU FSM cannot cope with SPRs numbered 720 for example.