learn-fpga-amaranth icon indicating copy to clipboard operation
learn-fpga-amaranth copied to clipboard

16_store isn't transitioning to LOAD state

Open wdevore opened this issue 2 years ago • 1 comments

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!

wdevore avatar Oct 31 '23 01:10 wdevore

LOL. I see that it is correct in #17.

wdevore avatar Oct 31 '23 01:10 wdevore

@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.

bl0x avatar Jul 04 '24 20:07 bl0x