REP blocks and branching issue.
ozpropdev
Posts: 2,792
in Propeller 2
I started a new thread to isolate the REP issues "evanh" found from the FPGA files thread.
Here's my current test code demonstrating the Jxxx instruction issue.
And here's the results from my debugger.
Version1 & 3 work correctly, but version2 with the "JATN" instruction restarts the cancelled REP block again.
Version1 results
PA = $7788 shows correct REP block cancel.
Version2 results
Version3 results
So a "rel9" branch works OK.
I'll keep digging......
FYI: These test were done on FPGA becuase sadly I fried my P2 silicon this morning.
Here's my current test code demonstrating the Jxxx instruction issue.
test_code mov pa,#0 mov pb,#0 cogid cog decod cog { 'In version1 the ATN flag is polled and a branch cancels the REP loop if C=1. This works corretly. } { version1 rep @rep_end,#0 incmod pb,#7 wz if_z cogatn cog add pa,#1 add pa,#$10 pollatn wc if_c jmp #escape add pa,#$100 add pa,_1000 rep_end } { In version 2 a JATN is used. This cancels the REP block but then restarts the REP block again. } { version2 rep @rep_end,#0 incmod pb,#7 wz if_z cogatn cog add pa,#1 add pa,#$10 jatn #escape add pa,#$100 add pa,_1000 rep_end } { To check relative (rel9) branches work, this version uses a TJZ instruction. It cancels correctly too. } '{ version3 rep @rep_end,#0 incmod pb,#7 wz add pa,#1 add pa,#$10 tjz pb,#escape add pa,#$100 add pa,_1000 rep_end '} escape jmp #$ _1000 long $1000 cog long 0
And here's the results from my debugger.
Version1 & 3 work correctly, but version2 with the "JATN" instruction restarts the cancelled REP block again.
Version1 results
<LOG>>step ~~~~~~~~~~~~~~~~~~~ Propeller 2 Debugger 3.3 File: demo3.obj ~~~~~~~~~~~~~~~~~~~ TOS: 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 Cog #1 FLAGS: nc nz BRK:00 001: F607EE00 MOV PB,#test_code <LOG>(step) > ~~~~~~~~~~~~~~~~~~~ Propeller 2 Debugger 3.3 File: demo3.obj ~~~~~~~~~~~~~~~~~~~ TOS: 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 Cog #1 FLAGS: nc nz BRK:00 002: FD601E01 COGID cog <LOG>(step) > ~~~~~~~~~~~~~~~~~~~ Propeller 2 Debugger 3.3 File: demo3.obj ~~~~~~~~~~~~~~~~~~~ TOS: 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 Cog #1 FLAGS: nc nz BRK:00 003: F9C01E0F DECOD cog <LOG>(step) > ~~~~~~~~~~~~~~~~~~~ Propeller 2 Debugger 3.3 File: demo3.obj ~~~~~~~~~~~~~~~~~~~ TOS: 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 Cog #1 FLAGS: nc nz BRK:00 004: FCDC1000 version1 REP #$8,#test_code 005: F70FEE07 INCMOD PB,#$7 WZ 006: AD601E3F IF_z COGATN cog 007: F107EC01 ADD PA,#$1 008: F107EC10 ADD PA,#$10 009: FD701C24 POLLATN WC 00A: CD900008 IF_c JMP #rep_end 00B: F107ED00 ADD PA,#$100 00C: F103EC0E ADD PA,_1000 <LOG>(step) > ~~~~~~~~~~~~~~~~~~~ Propeller 2 Debugger 3.3 File: demo3.obj ~~~~~~~~~~~~~~~~~~~ TOS: 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 Cog #1 FLAGS: C Z BRK:00 00D: FD9FFFFC rep_end JMP #rep_end <LOG>(step) >pa pa COG $1F6: $00007788 %0000_0000000_000_000111011_110001000 30600 <LOG>>logoff
PA = $7788 shows correct REP block cancel.
Version2 results
<LOG>>step ~~~~~~~~~~~~~~~~~~~ Propeller 2 Debugger 3.3 File: demo3.obj ~~~~~~~~~~~~~~~~~~~ TOS: 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 Cog #1 FLAGS: nc nz BRK:00 001: F607EE00 MOV PB,#test_code <LOG>(step) > ~~~~~~~~~~~~~~~~~~~ Propeller 2 Debugger 3.3 File: demo3.obj ~~~~~~~~~~~~~~~~~~~ TOS: 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 Cog #1 FLAGS: nc nz BRK:00 002: FD601C01 COGID cog <LOG>(step) > ~~~~~~~~~~~~~~~~~~~ Propeller 2 Debugger 3.3 File: demo3.obj ~~~~~~~~~~~~~~~~~~~ TOS: 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 Cog #1 FLAGS: nc nz BRK:00 003: F9C01C0E DECOD cog <LOG>(step) > ~~~~~~~~~~~~~~~~~~~ Propeller 2 Debugger 3.3 File: demo3.obj ~~~~~~~~~~~~~~~~~~~ TOS: 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 Cog #1 FLAGS: nc nz BRK:00 004: FCDC0E00 version2 REP #$7,#test_code 005: F70FEE07 INCMOD PB,#$7 WZ 006: AD601C3F IF_z COGATN cog 007: F107EC01 ADD PA,#$1 008: F107EC10 ADD PA,#$10 009: FBCC1C02 JATN ,#$2 (+2) 00A: F107ED00 ADD PA,#$100 00B: F103EC0D ADD PA,_1000 <LOG>(step) > ~~~~~~~~~~~~~~~~~~~ Propeller 2 Debugger 3.3 File: demo3.obj ~~~~~~~~~~~~~~~~~~~ TOS: 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 Cog #1 FLAGS: nc Z BRK:00 004: FCDC0E00 version2 REP #$7,#test_code 005: F70FEE07 INCMOD PB,#$7 WZ 006: AD601C3F IF_z COGATN cog 007: F107EC01 ADD PA,#$1 008: F107EC10 ADD PA,#$10 009: FBCC1C02 JATN ,#$2 (+2) 00A: F107ED00 ADD PA,#$100 00B: F103EC0D ADD PA,_1000 <LOG>(step) >pa pa COG $1F6: $00007788 %0000_0000000_000_000111011_110001000 30600 <LOG>>step ~~~~~~~~~~~~~~~~~~~ Propeller 2 Debugger 3.3 File: demo3.obj ~~~~~~~~~~~~~~~~~~~ TOS: 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 Cog #1 FLAGS: nc Z BRK:00 004: FCDC0E00 version2 REP #$7,#test_code 005: F70FEE07 INCMOD PB,#$7 WZ 006: AD601C3F IF_z COGATN cog 007: F107EC01 ADD PA,#$1 008: F107EC10 ADD PA,#$10 009: FBCC1C02 JATN ,#$2 (+2) 00A: F107ED00 ADD PA,#$100 00B: F103EC0D ADD PA,_1000 <LOG>(step) >pa pa COG $1F6: $0000EF10 %0000_0000000_000_001110111_100010000 61200 <LOG>>logoffNote that the REP cancels correctly with PA = $7788, but then restarts the REP block again.
Version3 results
<LOG>>step ~~~~~~~~~~~~~~~~~~~ Propeller 2 Debugger 3.3 File: demo3.obj ~~~~~~~~~~~~~~~~~~~ TOS: 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 Cog #1 FLAGS: nc nz BRK:00 001: F607EE00 MOV PB,#test_code <LOG>(step) > ~~~~~~~~~~~~~~~~~~~ Propeller 2 Debugger 3.3 File: demo3.obj ~~~~~~~~~~~~~~~~~~~ TOS: 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 Cog #1 FLAGS: nc nz BRK:00 002: FD601A01 COGID cog <LOG>(step) > ~~~~~~~~~~~~~~~~~~~ Propeller 2 Debugger 3.3 File: demo3.obj ~~~~~~~~~~~~~~~~~~~ TOS: 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 Cog #1 FLAGS: nc nz BRK:00 003: F9C01A0D DECOD cog <LOG>(step) > ~~~~~~~~~~~~~~~~~~~ Propeller 2 Debugger 3.3 File: demo3.obj ~~~~~~~~~~~~~~~~~~~ TOS: 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 Cog #1 FLAGS: nc nz BRK:00 004: FCDC0C00 version3 REP #$6,#test_code 005: F70FEE07 INCMOD PB,#$7 WZ 006: F107EC01 ADD PA,#$1 007: F107EC10 ADD PA,#$10 008: FB97EE02 TJZ PB,#$2 (+2) 009: F107ED00 ADD PA,#$100 00A: F103EC0C ADD PA,_1000 <LOG>(step) > ~~~~~~~~~~~~~~~~~~~ Propeller 2 Debugger 3.3 File: demo3.obj ~~~~~~~~~~~~~~~~~~~ TOS: 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 Cog #1 FLAGS: nc Z BRK:00 00B: FD9FFFFC rep_end JMP #rep_end <LOG>(step) >pa pa COG $1F6: $00007788 %0000_0000000_000_000111011_110001000 30600 <LOG>>logoffREP block cancels correctly woth PA = $7788.
So a "rel9" branch works OK.
I'll keep digging......
FYI: These test were done on FPGA becuase sadly I fried my P2 silicon this morning.
Comments
Oh no! How did that happen?
Starting grieving process now.
I mourn for you, too. We could send you another glob-top prototype for soldering onto a P2D2.
Update: Fixed my one. Turned out to just be IC sockets. Wriggled the chips and perfect readings again. The soldering is actually good for single sided boards. It has been reworked but maybe that's a good sign.
Version4 has a relative jump. (Does extra loop)
Version5 has a absolute branch. Works Ok
Version6 is a relative branch with NOP padding to show PC+relative issue.
Version4 results
PA = $9999 (1extra loop)
Version5 results With absolute brach PA = $8888 which is the correct result.
Version6 result Note that the NOP padding "fudges" the relative branch to hit the right address.
I think yes, evanh reports erratic exiting, which is a separate issue....
Yes. Version two in Brian's opening post is a branch-on-event. It intermittently fails by falling out the bottom of the "forever" REP block instead of taking the branch. And happens no matter where in the REP block it sits.
It's all good Chip. The smoke is on the way up to you
Other instructions that don't manipulate the program counter seem to execute as if nothing is wrong.
The conditional criteria for event jumps can possibly change within the instruction cycle, causing a bifurcated reaction in the REP/jump circuits. This shouldn't be allowed.
I'm going to fix this and make new FPGA files. This bug should go away, then.
Wendy's holding the door for us on this. I hope a few of you will be able to confirm that, indeed, this bug is gone, after I get the new FPGA images out.
Thanks for doggedly hammering on this. And the LUT problem. They should both be fixed here, shortly.
Cooking up new FPGA files now. Already sent the latest to Wendy at ON.
Just out of interest, could that potentially have gone batty for event branching in general? ie: Beyond REPing cases.
I wondered the same thing. I would need to look more carefully to know, for sure, but my design assumption was certainly that the 'jump' signal would be stable for the duration of the instruction. Hearing that event jumps behaved differently than other conditional jumps, I thought to look at the jump-criteria logic and it kind of jumped out at me. Of course, I jumped when the realization struck. I've been relaxed ever since I fixed it, though. And I'm really glad, too, that we fixed the LUT r+w glitch. That would have been a drag to live with.