Can someone prove me wrong on this??
cbmeeks
Posts: 634
Ok, according to Gunther's SXSim (awesome!!), the "Delay Code Generator" at SXList is not accurate!!!!
At least with my tests. For example, on the breezeway (for NTSC), you need 0.6µS. Well, I am still running at 80 Mhz so that should be 48 clocks. Now, subtract two for the "mov rb, #5" command gives you 46 clocks. Well, even though I put 46 clocks into the code generator, it was doing 48!!! Just about every one of them over about 20 clocks had 2 extra!!!!
So, I have been running my code in the SXSim and setting breakpoints and literally watching/counting clocks to make sure all is accurate after I adjusted for the error.
Now, below is a sub-routine I am using that should setup the beginning of a scanline (10.9µS). I have ran this through SXSim and it says 872 clocks exactly!
So, could someone point out if this is wrong? If not, I assume I am correct. hehe
Thanks!
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
http://metroidclassic.com
=========
DMCA Sucks
RIAA Sucks
At least with my tests. For example, on the breezeway (for NTSC), you need 0.6µS. Well, I am still running at 80 Mhz so that should be 48 clocks. Now, subtract two for the "mov rb, #5" command gives you 46 clocks. Well, even though I put 46 clocks into the code generator, it was doing 48!!! Just about every one of them over about 20 clocks had 2 extra!!!!
So, I have been running my code in the SXSim and setting breakpoints and literally watching/counting clocks to make sure all is accurate after I adjusted for the error.
Now, below is a sub-routine I am using that should setup the beginning of a scanline (10.9µS). I have ran this through SXSim and it says 872 clocks exactly!
So, could someone point out if this is wrong? If not, I assume I am correct. hehe
Thanks!
;=============================================================================================== ; LINESETUP ; ; returns in exactly 872 clocks 10.9µS @ 80Mhz ; The 872 clocks includes the call and the return (6 clocks) ; Some of the call/return is taken from the back porch and one clock is taken from the ; Sync Tip because it was returning with 873 clocks :-/ ;=============================================================================================== LineSetup ;-- Front Porch 1.5µS --------------------------------------------------------------- mov rb, #( 5 ) ;(2) BLACK mov w, #$1D mov d1, w frontporch_0: decsz d1 jmp frontporch_0 nop nop ;-- Sync Tip 4.7µS --------------------------------------------------------------- mov rb, #( 0 ) ;(2) Sync mov w, #$5D mov d1, w synctip_0: decsz d1 jmp synctip_0 nop ; nop ;removed to make entire subroutine EXACTLY 10.9µS ;-- Breezeway 0.6µS --------------------------------------------------------------- mov rb, #( 5 ) ;(2) BLACK mov w, #$0B mov d1, w breezeway_0: decsz d1 jmp breezeway_0 nop nop ;-- Color Burst 2.5µS --------------------------------------------------------------- mov rb, #( 5 ) ;(2) BLACK mov w, #$31 mov d1, w colorburst_0: decsz d1 jmp colorburst_0 jmp $+1 ;-- Back Porch 1.6µS --------------------------------------------------------------- mov rb, #( 5 ) ;(2) BLACK mov w, #$1E mov d1, w backporch_0: decsz d1 jmp backporch_0 ret ;(3 + 3 = 6)
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
http://metroidclassic.com
=========
DMCA Sucks
RIAA Sucks
Comments
[noparse][[/noparse]code]
; -- Color Burst 2.5uS
· MOV rb,#5····· ' 2
· MOV W, #$31 ' 1
· MOV d1, W··· ·' 1
· DJNZ d1, $·····' 2/4 (2 + 4*48 = 194)
· JMP $+1······· ' 3
So this routine looks like 201 cycles. so thats 2.5125 uSec @ 80MHz
Of course the pin really isn't set until after the "MOV rb,#5" instruction.
Assuming the next instruction will change the pin, with a "MOV rb,#x" then it's still 201 cycles.
Bean
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
"SX-Video·Module" Now available from Parallax for only $28.95
http://www.parallax.com/detail.asp?product_id=30012
"SX-Video OSD module" Now available from Parallax for only·$49.95
http://www.parallax.com/detail.asp?product_id=30015
Product web site: www.sxvm.com
Those that would give up freedom for security will have neither.
Post Edited (Bean (Hitt Consulting)) : 12/3/2005 12:53:08 PM GMT
I tried to make SXSim count clock cycles as accurate as possible. Nevertheless, another user made me aware of a problem concerning the increment of the RTCC in SXSim. This will be fixed in the next version. Nevertheless, I can't guarantee that there still are situations where SXSim does not exactly count the clock cycles. Seems as if I got some more work to do making SXSim simulate the SX-internal instruction pipeline exactly as it is.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Greetings from Germany,
G
G
would be great if you could count the clocks by yourself and then compare it to SXSim's results. Should there be any difference, please let me know, and send the code you've been testing. Maybe this helps me to fix any remaining timing bugs in SXSim.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Greetings from Germany,
G
·http://www.piclist.com/cgi-bin/delay.exe?Delay=46&Type=cycles&Regs=d1+d2+d3+d4&clock=80&name=Delay&CPU=SX
The mov's take a cycle each. jmp takes 3 cycles in turbo mode. decsz takes 1 cycle if the condition is false and·2 if it is true. My old SX-Key manual actually says 3, but the current datasheet says 2 and that makes a lot more sense.
So, the mov's take 2 cycles. The first 11 times through the loop, decsz takes 1 and jmp takes 3·so 4 times 11 = 44 for a total of 46 so far. On the 12th cycle, the result is zero and decsz takes·2 cycles to skip out for a total of 48 cycles.
I believe you are correct, the delay generator doesn't take into account the final 2 cycles. I'll let·the author·know.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
---
James Newton, Host of SXList.com
james at sxlist,com 1-619-652-0593 fax:1-208-279-8767
SX FAQ / Code / Tutorials / Documentation:
http://www.sxlist.com Pick faster!
Well, I knew I wasn't crazy...lol
Every loop I checked had two extra clocks. I spent a lot of time trying to figure out why my display didn't look correctly. My fault for assuming.
G
You can use SX/B as a delay generator. And it's code is not affected by code pages.
For example with freq as 80MHz a "PAUSEUS 0.575" generates the following code:
This takes exactly 46 cycles.
Bean.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
"SX-Video·Module" Now available from Parallax for only $28.95
http://www.parallax.com/detail.asp?product_id=30012
"SX-Video OSD module" Now available from Parallax for only·$49.95
http://www.parallax.com/detail.asp?product_id=30015
Product web site: www.sxvm.com
Those that would give up freedom for security will have neither.
·
Thanks, I will give it a try.
I wished the next version of SX-Key would have a tool for generating loops. Something that would take your FREQ value and just ask you for how many clocks or seconds(µSeconds). Then, plop the code down.
For now, I use the online version and just copy/paste. No biggie but would be a neat tool.
cbmeeks
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
http://metroidclassic.com
=========
DMCA Sucks
RIAA Sucks
-Dan
·
http://www.piclist.com/cgi-bin/delay.exe?Delay=46&Type=cycles&Regs=d1+d2+d3+d4&clock=80&name=Delay&CPU=SX
produces:
Thanks for letting me know!
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
---
James Newton, Host of SXList.com
james at sxlist,com 1-619-652-0593 fax:1-208-279-8767
SX FAQ / Code / Tutorials / Documentation:
http://www.sxlist.com Pick faster!
cbmeeks
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
http://metroidclassic.com
=========
DMCA Sucks
RIAA Sucks