learn-fpga-amaranth
learn-fpga-amaranth copied to clipboard
16_store isn't transitioning to 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:
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!
LOL. I see that it is correct in #17.
@wdevore Thank you for reporting this. I must have stumbled over this in the next section and corrected it along the way. It is fixed now.