DRVH instruction causes DIRx issues
ozpropdev
Posts: 2,792
in Propeller 2
Hi Chip
The last few days I've been trying to hunt down a weird program issue and discovered an issue with the DRVH instruction.
On their own DRVH seem to work Ok but any instructions that access the releveant DIRx register goes weird.
Here's some code snippets that demonstrate the issue.
Sorry to get you back to Quartus
The last few days I've been trying to hunt down a weird program issue and discovered an issue with the DRVH instruction.
On their own DRVH seem to work Ok but any instructions that access the releveant DIRx register goes weird.
Here's some code snippets that demonstrate the issue.
'code_a & code_e are the only code snippets that work as expected. dat org jmp #code_a code_a drvh #32 drvh #33 drvh #34 drvh #35 'all leds on as expected jmp #$ code_b drvh #32 drvh #33 drvh #34 drvh #35 bitl dirb,#1 'turns all leds off ???????? jmp #$ code_c drvh #32 drvh #33 drvh #34 drvh #35 or dirb,#0 'turns all leds off ???????? jmp #$ code_d drvh #32 drvh #33 drvh #34 drvh #35 or dirb,#%110000 'turns all leds off ???????? or outb,#%100000 'turns led #5 on as expected jmp #$ code_e bmask dirb,#3 bmask outb,#3 or dirb,#%110000 'all leds remain on as expected or outb,#%100000 'turns led #5 on Ok jmp #$ code_f drvh #32 drvh #33 drvh #34 drvh #35 bitl dirb,#33 'turns all leds off ???????? jmp #$I went back to V16 and the issue is still there if that helps.
Sorry to get you back to Quartus
Comments
You're attempting to use instructions to turn off bits. You should be using instead.
Or'ing a bit with zero doesn't change it.
EDIT: I tried the following code, and all the LEDs are lit. This is consistent with the theory that drvh/flth doesn't set the shadow ram, and that the shadow ram is accessed on reads.
Nicely spotted.
Could this not be fixed, so reads do not access shadow ram, but the real value instead ?
This is due to the DIRA/DIRB values not being data-forwarded in the pipeline during DRVx/FLTx instructions, though OUTA/OUTB values ARE forwarded. In other words, if you want to do an operation on DIRA/DIRB after a DRVx/FLTx instruction, do some other instruction in-between. This will overcome the need for the missing data-forwarding.
Hope you are having a pleasant and productive time in China!
I tried putting some spacer instructions in and still get the same result.
Something to think about when you get back. No rush.
I just realized why this fails:
For ALU-type interactions with DIRA/DIRB (BITL, in this case), the DIRA/DIRB shadow RAM registers are used as the data source, not the actual DIRA/DIRB register bits. DRVH just affects the register bits and doesn't update the shadow RAM register that BITL depends upon. What an oversight on my part! Okay, so this is fixable by making mux's to pull in the register data for D and S, and ignore the shadow register. This is not a big deal, but it does generate more logic.
https://drive.google.com/file/d/0B9NbgkdrupkHcEpydFkxZFRtNTg/view?usp=sharing