Shop OBEX P1 Docs P2 Docs Learn Events
Self modifying code spacer instruction requirement (SETS/SETD) - Page 2 — Parallax Forums

Self modifying code spacer instruction requirement (SETS/SETD)

2»

Comments

  • Yes Andy, ALTS works nicely too!
    It will be a little strange using two different instructions depending on how far away the destination is.
  • Dave HeinDave Hein Posts: 6,347
    edited 2015-11-17 00:31
    ozpropdev wrote: »
    Thinking some more....
    If the pipeline is 2 stage? then surely one space instruction is enough.
    The results from the P123-A7 (Cyclone V) were ~95% correct with one spacer.
    I feel their may still be something else going on here.
    Perhaps Chip can shine some light on this.
    Chip used to have a timing diagram in his earlier instructions.txt files that showed when the instructions are fetched, and when the results are written. I can't find the timing diagram right now, but I believe that the instruction is being written at the same time it is being fetched when there is only one NOP. If so, this would require a mux that would use the value being written for the fetched instruction when the cog addresses match. If this mux doesn't exist then the value that is fetched would depend on the characteristics of the RAM in the FPGA. Maybe one version of the FPGA chip works without the mux, and the other version doesn't.
  • ElectrodudeElectrodude Posts: 1,653
    edited 2015-11-17 00:52
    Dave Hein wrote: »
    ozpropdev wrote: »
    Thinking some more....
    If the pipeline is 2 stage? then surely one space instruction is enough.
    The results from the P123-A7 (Cyclone V) were ~95% correct with one spacer.
    I feel their may still be something else going on here.
    Perhaps Chip can shine some light on this.
    Chip used to have a timing diagram in his earlier instructions.txt files that showed when the instructions are fetched, and when the results are written. I can't find the timing diagram right now, but I believe that the instruction is being written at the same time it is being fetched when there is only one NOP. If so, this would require a mux that would use the value being written for the fetched instruction when the cog addresses match. If this mux doesn't exist then the value that is fetched would depend on the characteristics of the RAM in the FPGA. Maybe one version of the FPGA chip works without the mux, and the other version doesn't.
    I have a copy:
    clk
    ------------____________------------____________------------____________------------____________------------____________------------____________-
    
    |                       |                       |                       |                       |                       |                       |
    |-------+               |              rdRAM Ic |-------+               |              rdRAM Id |-------+               |              rdRAM Ie |
    |       |               |                       |       |               |                       |       |               |                       |
    |---+   +----> rdRAM Db |------------> latch Db |---+   +----> rdRAM Dc |------------> latch Dc |---+   +----> rdRAM Dd |------------> latch Dd |
    |---+   +----> rdRAM Sb |------------> latch Sb |---+   +----> rdRAM Sc |------------> latch Sc |---+   +----> rdRAM Sd |------------> latch Sd |
    |---+   +----> latch Ib |------------> latch Ib |---+   +----> latch Ic |------------> latch Ic |---+   +----> latch Id |------------> latch Id |
    |   |                   |                       |   |                   |                       |   |                   |                       |
    |   +------------------ALU-----------> wrRAM Ra |   +------------------ALU-----------> wrRAM Rb |   +------------------ALU-----------> wrRAM Rc |
    |                       |                       |                       |                       |                       |                       |
    |                       |     stall = 'gox'     |                       |     stall = 'gox'     |                       |     stall = 'gox'     |
    |         'get'         |      done = 'go'      |         'get'         |      done = 'go'      |         'get'         |      done = 'go'      |
    

    Sorry if it's too wide for your screen. Zoom out or copy and paste it somewhere else.

    The result of an instruction is written at the same time the second instruction after it is fetched.
  • Electrodude, thanks for posting the diagram. In the diagram, Ic is being read during the same cycle that Ra is written. So in the code
    		sets	.get_pixels,asx
    		nop
    .get_pixels	mov	pixels,0-0
    
    the result from the SETS is written in the same cycle that the MOV instruction is being fetched. This either requires that the RAM passes through the value as it is being written or there has to be a mux that will pass the value through when the read and write addresses match.
  • It seems like this issue may have fallen between the cracks. So when modifying an instruction, are two spacer instructions required, or is one supposed to be sufficient?
  • cgraceycgracey Posts: 14,134
    Ariba wrote: »
    You can use ALTS here:
    		alts	asx,#0		
    .get_pixels	mov	pixels,0-0
    
    Perhaps ALTI can be renamed to ALTNEXT or ALTNXT, so it does not suggest a specific field.

    Regarding differencies for Cyclone 4 and 5:
    Maybe the dual ported RAM behaves differently on read while write. Some FPGAs read the new value written and some return the old value when the same address is written and read.

    Andy

    That's the only place where a difference could exist, read during write.

    Does the DE2-115 always work with one spacer instruction?
  • cgraceycgracey Posts: 14,134
    I had set the read-during-write behavior to 'don't care' on the Cyclone V builds. I can set it to read=write, but I really need to find out what the OnSemi RAMs will do.
Sign In or Register to comment.