I noticed that the LOAD state wasn't being reached even though isLoad was active. Looking at Bruno's code it is using ternary operator to select state which, for Amaranth, I believe you can either use Mux or m.Elif. So, I changed the Execute state from:
with m.If(~isSystem):
m.d.sync += pc.eq(nextPc)
with m.If(isLoad):
m.next = "LOAD"
with m.If(isStore):
m.next = "STORE"
with m.Else(): <-- this overrides because isStore isn't active
m.next = "FETCH_INSTR"
to:
with m.If(~isSystem):
m.d.sync += pc.eq(nextPc)
with m.If(isLoad):
m.next = "LOAD"
with m.Elif(isStore): <---- change is here
m.next = "STORE"
with m.Else():
m.next = "FETCH_INSTR"
which makes it work correctly. However, my mind says that m.If should also work. However, the problem is with the m.Else part. This is being triggered because isStore isn't active which overrides the LOAD state!
I noticed that the LOAD state wasn't being reached even though isLoad was active. Looking at Bruno's code it is using ternary operator to select state which, for Amaranth, I believe you can either use Mux or m.Elif. So, I changed the Execute state from:
to:
which makes it work correctly. However, my mind says that m.If should also work. However, the problem is with the m.Else part. This is being triggered because isStore isn't active which overrides the LOAD state!