6502.org Forum  Projects  Code  Documents  Tools  Forum
It is currently Fri Nov 22, 2024 7:36 pm

All times are UTC




Post new topic Reply to topic  [ 558 posts ]  Go to page Previous  1 ... 31, 32, 33, 34, 35, 36, 37, 38  Next
Author Message
 Post subject: Re: TTL 6502 Here I come
PostPosted: Sat Dec 08, 2018 3:18 pm 
Offline
User avatar

Joined: Sun Oct 18, 2015 11:02 pm
Posts: 428
Location: Toronto, ON
Thanks to all for the wonderful comments! Very much appreciated. (And always nice when you drop by Axel. :))

Getting down to some debugging this weekend. I had a chance to pick up a few VIC-20 cartridges at WoC that are misbehaving. The ever-popular Omega Race runs perfectly, but Avenger and Pin Ball show some problems with character graphics. We’ll also need to figure out what went wrong with KimKlone.

In the meantime, please don’t hesitate to let me know of anything that might improve the website or datasheet. As always, any and all feedback welcome.

Cheers,
Drass

[EDIT] *** False alarm regarding the VIC-20 cartridges. There is no bug. I had simply neglected to disable the 6510 port when testing. :roll: Naturally, any programs that use address $0000 or address $0001 will fail if the 6510 port is enabled on the TTL CPU.[/EDIT]

_________________
C74-6502 Website: https://c74project.com


Top
 Profile  
Reply with quote  
 Post subject: Re: TTL 6502 Here I come
PostPosted: Wed Jan 02, 2019 9:47 am 
Offline
User avatar

Joined: Tue Nov 16, 2010 8:00 am
Posts: 2353
Location: Gouda, The Netherlands
Nice to see you got this projected finished with excellent results.


Top
 Profile  
Reply with quote  
 Post subject: Re: TTL 6502 Here I come
PostPosted: Thu Jan 03, 2019 10:54 pm 
Offline
User avatar

Joined: Sun Oct 18, 2015 11:02 pm
Posts: 428
Location: Toronto, ON
Thanks Arlet! Gotta credit ttlworks and dr Jefyll here. They’ve been wonderful collaborators. And I certainly remember your encouraging and informative comments early in the process as well.

Great to see you posting here again. :)

_________________
C74-6502 Website: https://c74project.com


Last edited by Drass on Thu Jan 03, 2019 11:38 pm, edited 1 time in total.

Top
 Profile  
Reply with quote  
 Post subject: Re: TTL 6502 Here I come
PostPosted: Thu Jan 03, 2019 11:36 pm 
Offline
User avatar

Joined: Sun Oct 18, 2015 11:02 pm
Posts: 428
Location: Toronto, ON
Happy New Year folks!

It’s been a busy few weeks, and the focus continues to be testing with the Commodore 64. I’ve now worked through quite a few games from various “best of” lists, and TTL CPU has run everything I’ve tried! :D I have a 1541 Ultimate cartridge on order to be able to run a few of the more demanding demos as a final test, but all indications are that the CPU is indeed cycle-accurate at this point.

Speaking of cartridges, sjgray had mentioned at WoC that the C64 EasyFlash 3 Cartridge by Retro Innovations would make an excellent test case. (Thanks for the tip Steve!). Well, he was right; I finally got my hands on one and indeed the TTL CPU failed to work with it. (For those interested, the cartridge’s function and logic are explained in detail in this brief paper by Thomas Giesel. It’s very clever).

In a nutshell, EasyFlash replaces the C64’s Kernal ROMs from the expansion slot. To do so, it takes over the bus during Phase 2 to (among other things) interrogate the state of the internal memory map in the C64. It does so by pulling A14 low and watching /ROMH on the expansion port to get its result. It then releases A14 to let the CPU complete the memory access. Here is a what that looks like on the scope with the 6510 installed (A14 in green, /ROMH in red):
Attachment:
ef 6510.png
ef 6510.png [ 19.43 KiB | Viewed 2982 times ]
By contrast, here is the same trace with the TTL CPU installed:
Attachment:
ef ttl.png
ef ttl.png [ 18.86 KiB | Viewed 2982 times ]
A14 goes low with the TTL CPU, but there's *a lot* of oscillation on the signal and the voltage settles at around 2V! That’s kinda no man’s land, and could easily be read as a “1” by the C64’s TTL level logic. Indeed it looks like that’s exactly what happens, and /ROMH remains high and the cartridge fails.

Kicking it around with ttlworks and dr Jefyll, we theorized that this was evidence of a collision on the address bus on A14, with the cartridge pulling low even as the CPU pulls high (AEC is high throughout, so the CPU’s bus driver is definitely active). The cartridge seems to be simply overwhelming the weak NMOS driver on the 6510 to land at a logic 0, but fails to do the same with the 74AC541 in the TTL CPU.

The solution was to install a 100 Ohm series resistor on the A14 pin at the CPU to “weaken” it a little. Here is the capture with the resistor in place:
Attachment:
ef ttl 100.png
ef ttl 100.png [ 19.35 KiB | Viewed 2982 times ]
A14 is being pulled low much more decisively now, and /ROMH reflects that. It’s an almost perfect match to the 6510, and the cartridge now works perfectly with the TTL CPU. :D Looks like it wil be worthwhile to allow for some series resistors on the socket adapter of the CPU to better emulate the NMOS “weak” drivers. The objective here is to be “pin-compatible”, so I’m glad we caught this detail.

If all goes well, I’ll be starting on the optional K24 Card for the CPU shortly. This card implements a 24-bit address bus, 65816 opcodes and the ability to switch instruction sets on the fly. I’ve written a (VERY) simple task-switching scheme which should allow the SBC to run several programs concurrently, each in its own 64k partition and using a mix of instruction sets. It will be very interesting to see if that turns out to be possible. Can’t wait to find out! :)

Cheers for now,
Drass

_________________
C74-6502 Website: https://c74project.com


Last edited by Drass on Fri Jan 04, 2019 7:29 am, edited 1 time in total.

Top
 Profile  
Reply with quote  
 Post subject: Re: TTL 6502 Here I come
PostPosted: Fri Jan 04, 2019 7:04 am 
Offline
User avatar

Joined: Thu Dec 11, 2008 1:28 pm
Posts: 10985
Location: England
That's even more than digitally compatible! Worth doing though, for interesting peripherals.


Top
 Profile  
Reply with quote  
 Post subject: Re: TTL 6502 Here I come
PostPosted: Sun Jan 06, 2019 9:09 pm 
Offline
User avatar

Joined: Sun Oct 18, 2015 11:02 pm
Posts: 428
Location: Toronto, ON
I agree. Certainly worth doing, even if for no other reason than to learn where the potholes are!

_________________
C74-6502 Website: https://c74project.com


Top
 Profile  
Reply with quote  
 Post subject: Re: TTL 6502 Here I come
PostPosted: Tue Feb 12, 2019 11:09 pm 
Offline
User avatar

Joined: Sun Oct 18, 2015 11:02 pm
Posts: 428
Location: Toronto, ON
It’s time once again for a brief update on the project. The past few weeks have allowed limited project time, but I do have some progress to report.

First, I am declaring C64 and VIC 20 testing complete — with no known issues! The testing included over 75 games, various demos, and both the EasyFlash and 1541 Ultimate cartridges. I tested also JiffyDOS, GEOS, and various other C64 FastLoaders — all without a problem. (I was particularly pleased that the TTL CPU ran the demos successfully, as these tend to be very demanding in terms of timing and compatibility). At this stage, I think I can safely say that the TTL CPU is, for all practical purposes, a faithful emulation of the both the NMOS 6502 and 6510.

It’s very satisfying to know that every known detail has been addressed, and that no little mysteries remain lurking in the shadows. All in all, I couldn’t be happier. Here are the updated test results:
Attachment:
c74-6502 compatibility testing.pdf [173.42 KiB]
Downloaded 95 times

Beyond that, I’ve made a solid start on the K24 card, and nearly completed assembly. I’m still awaiting the arrival of a 74VHC27 IC which has since become an out-of-stock item from the usual sources. I’ve used this IC (a 3-input NOR) in the other cards as well, so I’ll have to pick a suitable replacement for the final iteration of the CPU. It is a bit distressing to see these chips go out of production. (Toshiba seems to be manufacturing it still but in a TSSOP package only). Anyway, it’s the first time I see this happen so I was more than a bit surprised.

Incidentally, Dr Jefyll suggested I take a look at https://www.findchips.com, which turned out to be a great resource. You type in a part number, and it shows you a list of suppliers, along with pricing and current inventory. Very handy. As a last resort, I do have a 74HC27 I can use. It will be slow in this design, but at least it would allow me to get K24 tested, even if at slow speeds only. Hopefully, the part will arrive soon and I won’t have to resort to that.

In the meantime, here is a pic of the new upstart, eager to join his peers in the line of duty:
Attachment:
C61AD579-7D19-4F76-A9BE-1E960F4986B6.jpeg
C61AD579-7D19-4F76-A9BE-1E960F4986B6.jpeg [ 2.81 MiB | Viewed 1950 times ]

Cheers for now,
Drass

_________________
C74-6502 Website: https://c74project.com


Top
 Profile  
Reply with quote  
 Post subject: Re: TTL 6502 Here I come
PostPosted: Wed Feb 13, 2019 10:47 am 
Offline
User avatar

Joined: Thu Dec 11, 2008 1:28 pm
Posts: 10985
Location: England
Great result!


Top
 Profile  
Reply with quote  
 Post subject: Re: TTL 6502 Here I come
PostPosted: Wed Mar 06, 2019 1:16 pm 
Offline
User avatar

Joined: Sun Oct 18, 2015 11:02 pm
Posts: 428
Location: Toronto, ON
Thanks BigEd! I really wanted to nail the “plug-compatible” milestone. :)

Getting ready to test the ttlworks-inspired K24 card this weekend. It wil be very cool to see it run in the TTL CPU!

_________________
C74-6502 Website: https://c74project.com


Top
 Profile  
Reply with quote  
 Post subject: Re: TTL 6502 Here I come
PostPosted: Thu Mar 07, 2019 5:02 pm 
Offline
User avatar

Joined: Fri Nov 09, 2012 5:54 pm
Posts: 1431
Old picture from 2002:
Attachment:
K24_2002.png
K24_2002.png [ 155.1 KiB | Viewed 1511 times ]

Note the difference between the contents of $000400 (screen memory) and $010400 (not screen memory).

Most of the K24 circuitry is similar to things we already had in the TTL CPU,
so I think that getting K24 up and running won't be too difficult.
Maybe just some wrong connections in the schematic or a few bugs in the microcode,
fingers crossed.

C64 Kernal + Basic will work with K24, no patches required.

Monitor programs which use RTI for starting user code won't work with K24,
that's because K24 RTI fetches one more Byte from stack: PBR, the program bank register.

Code that makes use of the UFOs (NMOS 6502\6510 instructions unforseen by the designers)
won't work with K24, but UFOs also won't work with the 65C02 and the 65816.

Looking forward to seeing that old K24 concept getting back to life again.
Good luck !


Top
 Profile  
Reply with quote  
 Post subject: Re: TTL 6502 Here I come
PostPosted: Sun Mar 10, 2019 11:35 pm 
Offline
User avatar

Joined: Sun Oct 18, 2015 11:02 pm
Posts: 428
Location: Toronto, ON
Success!!!

As ttlworks predicted, it wasn’t too hard to get the K24 card going. I had reversed the pins in one of the connectors, and had to make one other patch besides. Then the thing sprung to life!

The C74-SBC has 512K of RAM on-board, and a connector to Garth’s 4MB WM-1 RAM Module. Now that’s a lot of RAM! For now, I just kept to the 8 banks on the SBC, and wrote a little code to exercise the basics (see below). I started by using the C74-6502’s CFG opcode ($42) to enable the 65816 microcode, and to set the K24 AUX bit high. The SBC uses the K24 AUX signal to select the FAST or SLOW clocks, and it was very cool to see the CPU speed up in response. Things were off to a great start!

The test code is very simple. We begin with just writing and reading from high RAM using the “abs lng” addressing mode. It’s very nice to reach into another bank so easily, and I was able to quickly verify that the right things were written to the right banks. I also tried the PLB instruction, and set the Data Bank Register in a quick loop to iterate through the banks. Once again, I was able to confirm that the data was intact, and that absolute addresses correctly followed the DBR in the loop, which was great.

Finally, I got up the nerve for a long jump to another bank — and that went off without a hitch. To celebrate, I wrote a quick little loop to flash some LEDs on A VIA port. It was great to see those LEDs do a little multicolour dance once the whole thing was working. Yay!!! Queue the Mariachi music! :P

I did discover a problem in the K24 65816 microcode — the PHX and PHY instructions reference the DBR, which is not a good thing when switching banks. Took a little while to figure out what was wrong, but I could clearly see the error in the microcode once I tracked it down. It’s unfortunate, but odds are this is not the only problem. The fact is that, absent a comprehensive test suite, the 65816 microcode is bound to have bugs that will likely remain undetected. Sure makes one appreciate the Dormann 6502 and 65C02 test suites all the more!

Lots more testing to be done, but I think it’s fair to say that ttlworks’ K24 concept is alive and well in the C74-6502! I’m glad we got here Dieter! :)

I have a couple of demos planned that will make use of the larger address space on the C74-6502, so that will be fun. In the meantime, it’s nice to be chaulking up another milestone — getting closer to the finish line!

Cheers for now,
Drass

Code:
; Check24 -- Run a few checks on the K24 Card
;-----------------------------------------------------------------------------
;
; assembled with AS65 from http://www.kingswood-consulting.co.uk/assemblers/
; command line switches: -l -m -w -h0
;                         |  |  |  no page headers in listing
;                         |  |  wide listing (133 char/col)
;                         |  expand macros in listing
;                         generate pass2 listing
;-----------------------------------------------------------------------------

   org $c000 

start   lda #$83      ; Select 65816 opcodes + fast clock
   db $42, $00      ; C74-6502 CFG opcode, puts A into CFG register

   ; test lda/sta abs lng
   ; Store some values in banks 0..7
   
   lda #$00      
   db $8f, $00, $20, $00   ; sta $002000
   lda #$01
   db $8f, $00, $20, $01   ; sta $012000 ...
   lda #$02
   db $8f, $00, $20, $02
   lda #$03
   db $8f, $00, $20, $03
   lda #$04
   db $8f, $00, $20, $04
   lda #$05
   db $8f, $00, $20, $05
   lda #$06
   db $8f, $00, $20, $06
   lda #$07
   db $8f, $00, $20, $07

   ; now check that they are there

   db $af, $00, $20, $00   ; lda $002000
   cmp #$00
   bne error
   db $af, $00, $20, $01   ; lda $012000 ...
   cmp #$01
   bne error
   db $af, $00, $20, $02
   cmp #$02
   bne error
   db $af, $00, $20, $03
   cmp #$03
   bne error
   db $af, $00, $20, $04
   cmp #$04
   bne error
   db $af, $00, $20, $05
   cmp #$05
   bne error
   db $af, $00, $20, $06
   cmp #$06
   bne error
   db $af, $00, $20, $07
   cmp #$07
   bne error

   jmp dbr

error   jmp error

   ; Check the values again using DBR

dbr   ldx #$07      ; Check the values at $2000
lp1   txa
   pha
   db $ab         ; plb -- points DBR to the bank
   cpx $2000
   bne error
   dex         ; ok, next bnk
   bpl lp1

   ; Test running code in bank 4

next   lda #$a9      ; put "lda #$aa" at $044000
   db $8f, $00, $40, $04
   lda #$aa
   db $8f, $01, $40, $04   

   lda #$5c      ; put a long jump back
   db $8f, $02, $40, $04
   lda #lo(back)
   db $8f, $03, $40, $04
   lda #hi(back)
   db $8f, $04, $40, $04
   lda #$00
   db $8f, $05, $40, $04

   db $5c, $00, $40, $04   ; jump to it!
   
   jmp error

back   cmp #$aa      ; check to see if things went well over there
   beq success
   jmp error

   ; Success -- puts on a little light show on the LEDs on the VIA

success   lda #00         ; back to bank 0
   pha
   db $ab

   lda #$ff      ; Initialize VIA
   sta $a000
   sta $a001
   sta $a002
   sta $a003

   lda #$41      ; Initialize LEDs to rotate
   sta $a000

   lda #$5c
   db $8f, $00, $40, $04   ; Put a long jump to "loop" in bank 4 at $4000
   lda #lo(loop)
   db $8f, $01, $40, $04
   lda #hi(loop)
   db $8f, $02, $40, $04
   lda #$00
   db $8f, $03, $40, $04

   db $5c, $00, $40, $04   ; jump to it!

   jmp error

loop   inc $1000   ; Freq loop
   bne loop
   inc $1001
   lda $1001
   cmp #$40
   bne loop
   lda #$0
   sta $1001

   lda $a000   ; bottom row
   and #$0f
   asl a
   cmp #$10
   bne skip
   lda #$01
skip   sta $1002

   lda $a000
   and #$f0
   ora $1002
   sta $a000

   lda $a000   ;top row
   and #$f0
   lsr a
   cmp #$08
   bne skip2
   lda #$80

skip2   sta $1002

   lda $a000
   and #$0f
   ora $1002
   sta $a000

   db $5c, $00, $40, $04   ; jump to it!

nmi_trap
irq_trap jmp irq_trap

        org $fffa
        dw  nmi_trap
   dw  start
   dw  irq_trap

   end start

_________________
C74-6502 Website: https://c74project.com


Top
 Profile  
Reply with quote  
 Post subject: Re: TTL 6502 Here I come
PostPosted: Mon Mar 11, 2019 12:00 am 
Offline
User avatar

Joined: Wed Mar 01, 2017 8:54 pm
Posts: 660
Location: North-Germany
Congratulations ! Graet work !


Top
 Profile  
Reply with quote  
 Post subject: Re: TTL 6502 Here I come
PostPosted: Mon Mar 11, 2019 7:48 am 
Offline

Joined: Sun Oct 14, 2012 7:30 pm
Posts: 107
Did you try running the Lorenz tests on this for the C64?


Top
 Profile  
Reply with quote  
 Post subject: Re: TTL 6502 Here I come
PostPosted: Mon Mar 11, 2019 8:19 am 
Offline
User avatar

Joined: Thu Dec 11, 2008 1:28 pm
Posts: 10985
Location: England
Very impressive... is the K24-6502 something like an '816 in emulation mode? Or more like an '816 in 8/8 native mode?


Top
 Profile  
Reply with quote  
 Post subject: Re: TTL 6502 Here I come
PostPosted: Mon Mar 11, 2019 11:34 am 
Offline
User avatar

Joined: Sun Oct 18, 2015 11:02 pm
Posts: 428
Location: Toronto, ON
Thanks! K24 adds an interesting dimension — having a plug-compatible NMOS 6502/6510 emulation along with 65816-like extended addressing in one package seems intriguing. Would make a cool add-on to a vintage NMOS machine!

Quote:
is the K24-6502 something like an '816 in emulation mode? Or more like an '816 in 8/8 native mode?
I think the former (although honestly I can barely keep those differences straight!). Paraphrasing from the C74-6502 Datasheet:

The K24 microcode is analogous to the 65816’s Emulation Mode (E flag = 1 and M and X flags are implied to be 1). All but MVN, MVP, XCE and COP are implemented in the microcode. It is “generally compatible”, with the following caveats:

  • Not cycle accurate
  • The ABORT and COP Interrupt Vectors are not implemented.
  • Opcode $42 (WDM) is replaced by the CFG instruction, which will exchange the contents of the A accumulator with the CFG register
  • Opcode $02 ( COP) is replaced by the SPI instruction, which will swap 8 bits with a
    selected SPI device over 8 cycles (K24 has an SPI Mode 3 interface on a dedicated SPI header)
  • The Direct Page register (DH) is 8 bits and points only to page boundaries. The PHD and PLD instructions still push and pull 16 bits on the stack with $00 as the low byte.
  • The A & B accumulators cannot be combined into a 16 bit C register. TCS, TSC use only the A accumulator (low-byte); TCD, TDC only the B accumulator (high-byte).
  • SP is 8 bits. The stack is fixed to bank $00 page $01 and all opcodes which push or pull values on the stack will wrap on a page boundary.
  • Other rules for crossing bank boundaries are correctly applied (e.g., Abs,Y or [Ind],Y)

Quote:
Did you try running the Lorenz tests on this for the C64?
hmmm, I have not. I spent lots of time with a bunch of C64 software and cartridges, which all went very well. It might be interesting to have a look at the Lorenz suite at some point. I’ll make a note to get to it! Thanks.

_________________
C74-6502 Website: https://c74project.com


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 558 posts ]  Go to page Previous  1 ... 31, 32, 33, 34, 35, 36, 37, 38  Next

All times are UTC


Who is online

Users browsing this forum: No registered users and 32 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to: