SH4 Superscalar

If you have any questions on programming, this is the place to ask them, whether you're a newbie or an experienced programmer. Discussion on programming in general is also welcome. We will help you with programming homework, but we will not do your work for you! Any porting requests must be made in Developmental Ideas.
Post Reply
Olivier
DCEmu Newbie
DCEmu Newbie
Posts: 7
Joined: Thu Jul 29, 2021 8:26 am
Location: Aix-en-Provence, France
Has liked: 4 times
Been liked: 0

SH4 Superscalar

Post by Olivier » Thu Jul 29, 2021 8:47 am

Hello to you all, this is my first post here ^^
I've done my share of coding on Genesis and 32X, and am now getting into Dreamcast (I love Hitachi SuperH!).
As you know, one of the main differences between SH2 and SH4 is the latter being superscalar.
This means that, for certain instructions, two can run in parallel. eg :

Code: Select all

ADD R2,R1    ; EX
MOV.L @R4,R5    ; LS
But here's the thing I don't get : how is an instruction assigned to a pipeline?
For example, in

Code: Select all

SHAD R0,R1    ; EX
ADD R2,R3    ; EX
MOV.L @R4,R5    ; LS
, the instructions

Code: Select all

SHAD R0,R1    ; EX
ADD R2,R3    ; EX
can not be run in parallel since both are EX group, and two EX-group instructions can not be run in parallel (SH4 /SH7750 Hardware Manual, section 8, p164)
From what I get with figure 8.3 case "a", the "SHAD" instruction will be issued first and alone, THEN the "ADD" and "MOV" instructions will be run in parallel.

Let me picture the situation the way I get it:

Code: Select all

SHAD	R0,R1	I D X N S
ADD	R2,R3   I -
Here, the processor realizes it can not run these two instructions in parallel, so only the "SHAD" instruction will be issued,the second pipeline is "stalled", then ...

Code: Select all

ADD	R2,R3   I - D X N S
MOV.L	@R4,R5    I D X N S
... the ADD instruction is "moved" to the next pipeline entry, combined with the next "MOV.L" instruction.
Then, the pipeline keeps on going:

Code: Select all

next		    I D X
next		    I D X
next		      I D
next		      I D
Is my understanding correct, or am I missing something?
TapamN
DCEmu Freak
DCEmu Freak
Posts: 62
Joined: Sun Oct 04, 2009 11:13 am
Has liked: 0
Been liked: 16 times

Re: SH4 Superscalar

Post by TapamN » Fri Jul 30, 2021 2:07 am

If two instructions can't be executed in parallel, it runs the first instruction this cycle, then the next cycle it tries to run the second and third instructions in parallel.
These users liked the author TapamN for the post:
Olivier
Olivier
DCEmu Newbie
DCEmu Newbie
Posts: 7
Joined: Thu Jul 29, 2021 8:26 am
Location: Aix-en-Provence, France
Has liked: 4 times
Been liked: 0

Re: SH4 Superscalar

Post by Olivier » Fri Jul 30, 2021 7:34 am

TapamN wrote:
Fri Jul 30, 2021 2:07 am
If two instructions can't be executed in parallel, it runs the first instruction this cycle, then the next cycle it tries to run the second and third instructions in parallel.
OK, now I get it. Thank you very much for your answer ^^
Post Reply