TTL 6502 Here I come
Re: TTL 6502 Here I come
Dr Jefyll wrote:
Can I presume your makeshift toggle-clock switch is debounced somehow? Just checking.
Quote:
Also, is it the ribbon cables which carry +5 and ground to the CPU boards? Personally I don't trust jumpers for that. I usually take the time to establish soldered power connections, even if it's just a temporary test setting. This is in the "essential to sanity" category you mentioned.
Quote:
Thanks for sharing the pics, and good luck with the debug!
C74-6502 Website: https://c74project.com
Re: TTL 6502 Here I come
BigDumbDinosaur wrote:
Drass wrote:
Here is a closer look at the inter-connected boards:
C74-6502 Website: https://c74project.com
- BigDumbDinosaur
- Posts: 9427
- Joined: 28 May 2009
- Location: Midwestern USA (JB Pritzker’s dystopia)
- Contact:
Re: TTL 6502 Here I come
Drass wrote:
BigDumbDinosaur wrote:
Drass wrote:
Here is a closer look at the inter-connected boards:
x86? We ain't got no x86. We don't NEED no stinking x86!
Re: TTL 6502 Here I come
BigDumbDinosaur wrote:
I purchased his "Endless Wire" LP in a record shop in Thunder Bay in late 1978
(Incidentally, my wife wondered why I was humming "The Wreck Of The Edmund Fitzgerald" all yesterday afternoon ...
C74-6502 Website: https://c74project.com
- BigDumbDinosaur
- Posts: 9427
- Joined: 28 May 2009
- Location: Midwestern USA (JB Pritzker’s dystopia)
- Contact:
Re: TTL 6502 Here I come
Drass wrote:
BigDumbDinosaur wrote:
I purchased his "Endless Wire" LP in a record shop in Thunder Bay in late 1978
Quote:
And amazing the LPs are still in great condition. Nicely done!
Quote:
(Incidentally, my wife wondered why I was humming "The Wreck Of The Edmund Fitzgerald" all yesterday afternoon ...
)
x86? We ain't got no x86. We don't NEED no stinking x86!
Re: TTL 6502 Here I come
After all the checking and re-checking, it's hard to believe this got through the QA process:
S->PCH (a 74CBT3245 buffer) carries the result of the 16-bit Incrementer to the high-byte of the PC register, and all eight data lines were going to the wrong pins ... argh! This little mishap had the effect of inverting the bit-order of the high-byte of PC every cycle.
Good thing I picked up some practice patching the SBC. Here is what the afflicted area looked like after some head-scratching and careful rework:The output pins of S->PCH are lifted off the board, jumpers are soldered to each and then run to the correct pads below the raised pins. I used some silicone to cover the pads after the jumpers were soldered on, and amazingly there were no shorts once the job was complete. The multimeter confirmed all the data line connections are now correct and sound.
With that fix in place, I'm thrilled to report that the CPU passed it's first significant test! It ran a complete reset sequence and then went on to execute NOPs in succession beginning at address $EAEA, two cycles per NOP. Wow, this means that the basic piping is working: reading the data bus, latching into IR, stepping through microcode, incrementing PC. Hurray!

Next step is to run systematically through microcode and exercise the circuitry. The microcode is composed of about 190 unique micro-instructions, with many being only slight variations of fundamental operations. It's worth spending a little time optimizing the testing to run through a minimum set of basic operations before moving on to full opcodes and test suites. Here's hoping the inevitable problems that arise may be patched rather than requiring new PCBs! Gonna be a lot of fun.
Cheers for now,
Drass
Good thing I picked up some practice patching the SBC. Here is what the afflicted area looked like after some head-scratching and careful rework:The output pins of S->PCH are lifted off the board, jumpers are soldered to each and then run to the correct pads below the raised pins. I used some silicone to cover the pads after the jumpers were soldered on, and amazingly there were no shorts once the job was complete. The multimeter confirmed all the data line connections are now correct and sound.
With that fix in place, I'm thrilled to report that the CPU passed it's first significant test! It ran a complete reset sequence and then went on to execute NOPs in succession beginning at address $EAEA, two cycles per NOP. Wow, this means that the basic piping is working: reading the data bus, latching into IR, stepping through microcode, incrementing PC. Hurray!
Next step is to run systematically through microcode and exercise the circuitry. The microcode is composed of about 190 unique micro-instructions, with many being only slight variations of fundamental operations. It's worth spending a little time optimizing the testing to run through a minimum set of basic operations before moving on to full opcodes and test suites. Here's hoping the inevitable problems that arise may be patched rather than requiring new PCBs! Gonna be a lot of fun.
Cheers for now,
Drass
C74-6502 Website: https://c74project.com
Re: TTL 6502 Here I come
Drass wrote:
This little mishap had the effect of inverting the bit-order of the high-byte of PC every cycle.
Seriously, nice work on the patch. Did you consider placing four jumpers on each side of that IC, instead of all eight on one side? It might've been slightly less crowded if the swaps of D0<->D7 and D2<->D5 were on one side and the swaps for D1<->D6 and D3<->D4 were on the other.
Drass wrote:
this means that the basic piping is working: reading the data bus, latching into IR, stepping through microcode, incrementing PC. Hurray!

Drass wrote:
It's worth spending a little time optimizing the testing to run through a minimum set of basic operations before moving on to full opcodes and test suites.
J
In 1988 my 65C02 got six new registers and 44 new full-speed instructions!
https://laughtonelectronics.com/Arcana/ ... mmary.html
https://laughtonelectronics.com/Arcana/ ... mmary.html
Re: TTL 6502 Here I come
Dr Jefyll wrote:
Drass wrote:
This little mishap had the effect of inverting the bit-order of the high-byte of PC every cycle.
Quote:
Did you consider placing four jumpers on each side of that IC, instead of all eight on one side? It might've been slightly less crowded if the swaps of D0<->D7 and D2<->D5 were on one side and the swaps for D1<->D6 and D3<->D4 were on the other.
Quote:
I'm impressed with your restraint! Surely you must be tempted to temporarily skip the detailed tests and immediately try some real code, just to see what happens!
Seriously, it's not restraint. The CPU won't get very far with "real" code. It's going to be faster to be more methodical:
- Can it write to every register?
Can it read from every register?
Can it set/reset flags?
Can it pass data through the ALU?
Can it use SP, DP and T for addressing?
C74-6502 Website: https://c74project.com
Re: TTL 6502 Here I come
Drass wrote:
argh! This little mishap had the effect of inverting the bit-order of the high-byte of PC every cycle.
Nice work on the patch. //I'm just happy that we don't have much signal traces on the inner layers of the PCB.
Back in 2002 (15 years ago), when I did build my first TTL CPU, I think there were to test suites,
there wasn't much info about building and debugging TTL CPUs in the internet, and I had not been a forum member.
Just peeling most of the bugs out of the microcode took me about three months.
I remember, that I had started debugging with LEDs and DIP switches on the bus.
The next step was writing a crude monitor program while deliberately and intentionally avoiding the use
of a lot of the 6502 instructions and addressing modes.
When I tried to get the C64 Kernal + Basic up and running, it displayed odd stuff for the amount of free memory.
It turned out, that something in the flag evaluation went wrong: CMP had affected the V flag,
what had confused them floating point math routines pretty much.
Drass, don't worry: sooner or later (February 2018 maybe) I think you are through with debugging that TTL CPU.
Hey, if it would be easy, and if it wouldn't be quite labor intensive, a lot more hobbyists would be building TTL CPUs...
It's not that the CPU intentionally refuses to come to life.
Re: TTL 6502 Here I come
Thanks Dieter. As it turns out, there was lots of progress this weekend ...
Running the circuitry through it’s basic operations revealed more assembly problems, these almost entirely due to poor soldering. I suspect it’s the result of not allowing the iron to linger long enough at each pin during drag-soldering, or perhaps not enough solder applied in the first place. Whatever the cause, the pins in question would only make contact with the board when pressed down against the pads - this despite looking very much as if they were bonded to the pads below. Anyway, re-soldering fixed these problems in every case I could find.
Then it was time to hook up the TTL CPU to the SBC. I used extra jumpers to tie the diagnostic LEDs on the SBC to the appropriate CPU-internal signals. This would display both the current opcode and current cycle being executed on the SBC - very handy for debugging. In the pic below, the CPU is retrieving the high-byte of the reset vector at $FFFD during cycle 5 of the reset sequence (Opcode = 0, Q Reg = 5, Databus = $C0 - the start of ROM on the SBC is at $C000). Note the empty IC socket bottom-left on the SBC - that’s where the WDC 65C02 would normally go!My wife made the wonderful wooden switch-boxes shown; the toggle-switch on the left is a NAND-debounced step clock while the red push-button above the SBC is a convenient power switch for the whole setup. The on-board push-button for the step-clock on the SBC itself proved a bit dodgy, so it was necessary to pull the main-clock oscillator out entirely and wire-up the external manual clock to the oscillator IC socket (yellow-lead in the pic).
And with that done, things were ready to go. I sparked up the Kowalski assembler and coded up this little sequence:I gotta say, it’s absolutely amazing to see the TTL CPU step it’s way through this code. I’m thrilled to report the little contraption performed admirably! Register loads, memory writes and address calculations (including inserting an extra cycle into the microcode pipeline to adjust the high-byte of addresses) all worked correctly. Even the JSR and BCC backwards branch at the end worked perfectly. So exciting!
The next step is to try some I/O on the VIA, and if that works, perhaps wire-up a 555 timer and let the thing loose on Klaus’ test suite (which I will edit to report it’s progress to a VIA port). Lots of testing remains, so it will be some time yet before the CPU can be said to be working ... still, a lot is already happening. Can’t wait to see what happens from here!
Cheers for now,
Drass
Running the circuitry through it’s basic operations revealed more assembly problems, these almost entirely due to poor soldering. I suspect it’s the result of not allowing the iron to linger long enough at each pin during drag-soldering, or perhaps not enough solder applied in the first place. Whatever the cause, the pins in question would only make contact with the board when pressed down against the pads - this despite looking very much as if they were bonded to the pads below. Anyway, re-soldering fixed these problems in every case I could find.
Then it was time to hook up the TTL CPU to the SBC. I used extra jumpers to tie the diagnostic LEDs on the SBC to the appropriate CPU-internal signals. This would display both the current opcode and current cycle being executed on the SBC - very handy for debugging. In the pic below, the CPU is retrieving the high-byte of the reset vector at $FFFD during cycle 5 of the reset sequence (Opcode = 0, Q Reg = 5, Databus = $C0 - the start of ROM on the SBC is at $C000). Note the empty IC socket bottom-left on the SBC - that’s where the WDC 65C02 would normally go!My wife made the wonderful wooden switch-boxes shown; the toggle-switch on the left is a NAND-debounced step clock while the red push-button above the SBC is a convenient power switch for the whole setup. The on-board push-button for the step-clock on the SBC itself proved a bit dodgy, so it was necessary to pull the main-clock oscillator out entirely and wire-up the external manual clock to the oscillator IC socket (yellow-lead in the pic).
And with that done, things were ready to go. I sparked up the Kowalski assembler and coded up this little sequence:
Code: Select all
ROM = $c000
VECTORS = $fffa
*= ROM
start sei ;manipulate flags
sed
sec
lda #0
php ; check P on the data bus
cli
cld
clv
clc
lda #1
php ; check P on the data bus
lda #$aa ; write to A
sta $10 ; write to memory zero page - $AA on D BUS
lda #$40
sta $11
sta $0400 ; write to memory - $40 D BUS, $0400 A BUS
ldx #$bb ; write to x
stx $0401 ; read from x - check $BB D BUS
ldy #$cc ; write to y
sty $0402 ; read from y - check $CC D BUS
ldy #$ff
lda $00ff,y ; ALU address addition - check A BUS $01FE
lda ($10),y ; Indirect - Check A BUS $41A9
jsr subr ; stack frame
lda #$65 ; check $65 on D BUD
clc
bcc start ; brach test
subr lda #$56 ; check $56 D BUS
rts
*= VECTORS
.dw start
.dw start
.dw start
The next step is to try some I/O on the VIA, and if that works, perhaps wire-up a 555 timer and let the thing loose on Klaus’ test suite (which I will edit to report it’s progress to a VIA port). Lots of testing remains, so it will be some time yet before the CPU can be said to be working ... still, a lot is already happening. Can’t wait to see what happens from here!
Cheers for now,
Drass
C74-6502 Website: https://c74project.com
Re: TTL 6502 Here I come
Nice progress! I know the feeling 
Axel.
Axel.
Re: TTL 6502 Here I come
Nice progress, and the debugging goes faster than I had expected so far.
Would suggest to focus on the UART as soon as possible and to try to get a monitor program up and running which makes use of that UART.
With a monitor program, you could get test code from the PC into the computer without burning it into the EEPROM,
what would make debugging a lot more fun.
Back in 2002, I only had EPROMs in ceramic package with a window, but not EEPROMs.
So I always had at least 5 EPROMs on the desk when trying out some test code, and I made sure that three of them always were in the UV eraser...
Go, Drass, go !
Drass wrote:
The next step is to try some I/O on the VIA, and if that works, perhaps wire-up a 555 timer and let the thing loose on Klaus’ test suite
With a monitor program, you could get test code from the PC into the computer without burning it into the EEPROM,
what would make debugging a lot more fun.
Back in 2002, I only had EPROMs in ceramic package with a window, but not EEPROMs.
So I always had at least 5 EPROMs on the desk when trying out some test code, and I made sure that three of them always were in the UV eraser...
Go, Drass, go !
Re: TTL 6502 Here I come
Ax2013 wrote:
Nice progress! I know the feeling 
ttlworks wrote:
Nice progress, and the debugging goes faster than I had expected so far.
Quote:
Would suggest to focus on the UART as soon as possible and to try to get a monitor program up and running which makes use of that UART.
With a monitor program, you could get test code from the PC into the computer without burning it into the EEPROM,
what would make debugging a lot more fun.
With a monitor program, you could get test code from the PC into the computer without burning it into the EEPROM,
what would make debugging a lot more fun.
Btw, I did manage to confirm writing to the VIA by running a tight INC loop on the VIA ports:
Code: Select all
loop inc porta
bne loop
inc portb
jmp loopOh, and the whole thing also worked with a 6MHz clock.
I'm looking forward to further shaking down these boards this weekend.
C74-6502 Website: https://c74project.com
Re: TTL 6502 Here I come
I started a run of Klaus' test suite, and things went wrong straight away - no surprise there. After all, it would have been a miracle if it worked first time. Examining the debris, I found the CPU was stuck on the BRK trap in the test suite. A run-away PC register, I thought. It didn't take long to find the last bit of code the CPU had executed before getting lost, but it was not what I expected:
Yup, nothing there, just pushing and pulling from the stack. Stepping through, I found something surprising: the PHP at the end of the sequence was somehow resetting IR! The logic probe confirmed that the control signal used to clear IR (in order to trigger an interrupt) was not in fact firing during the offending cycle. And unlike previous errors, there seemed to be no flaky solder joints in the signal path. But, I reasoned, something must be pulsing the signal somehow. IR is a 74AC273, so even a momentary pulse on its /CLR input would be enough to inflict the critical damage.
Well, it turns out that the IR-Reset signal is generated in Card B but the IR itself is on Card A, and that implies a treacherous journey across the boards for this sensitive signal. Still, figuring out what was happening was going to be a challenge. Thankfully, just when I thought the inevitable oscilloscope purchase was finally upon me, dr Jefyll suggested a cheaper (and frankly much more sensible) way forward: "I'd give some attention to the VCC and GND connections." In actual fact, I had yet to follow the earlier pointer regarding more robust VCC and GND connections, let alone connecting the many GND lines on the inter-card connectors. My bad!
Lesson learned: after making many more jumpers and wiring everything up (including GND lines to the SBC), the rogue behaviour vanished! Amazing. Hunting this problem down has been just so interesting, and the solution seems like a bit of black magic. It's one thing to read about low-impedance paths, and quite another to witness their effects! I’m surmising that in addition to providing a good return path for signals, the GND lines here also serve to connect the ground planes on each board together to provide a common reference. Is it plausible that absent these connections, an IC generating a “high” voltage on Card B might be seen as a “low” voltage on Card A, enough to accidentally trigger a /CLR signal like IR-Reset?
Either way, it’s been an amazing learning experience and a very satisfying fix to make. And to top it all off, the CPU then ran the full NMOS 6502 test suite to completion. Double hurray!!!
Man, what a day
Code: Select all
c264 : a901 > lda #1 ;precharge accu
c266 : 28 > plp
c267 : 48 pha
c268 : 08 > php ;save flagsWell, it turns out that the IR-Reset signal is generated in Card B but the IR itself is on Card A, and that implies a treacherous journey across the boards for this sensitive signal. Still, figuring out what was happening was going to be a challenge. Thankfully, just when I thought the inevitable oscilloscope purchase was finally upon me, dr Jefyll suggested a cheaper (and frankly much more sensible) way forward: "I'd give some attention to the VCC and GND connections." In actual fact, I had yet to follow the earlier pointer regarding more robust VCC and GND connections, let alone connecting the many GND lines on the inter-card connectors. My bad!
Lesson learned: after making many more jumpers and wiring everything up (including GND lines to the SBC), the rogue behaviour vanished! Amazing. Hunting this problem down has been just so interesting, and the solution seems like a bit of black magic. It's one thing to read about low-impedance paths, and quite another to witness their effects! I’m surmising that in addition to providing a good return path for signals, the GND lines here also serve to connect the ground planes on each board together to provide a common reference. Is it plausible that absent these connections, an IC generating a “high” voltage on Card B might be seen as a “low” voltage on Card A, enough to accidentally trigger a /CLR signal like IR-Reset?
Either way, it’s been an amazing learning experience and a very satisfying fix to make. And to top it all off, the CPU then ran the full NMOS 6502 test suite to completion. Double hurray!!!
Man, what a day
C74-6502 Website: https://c74project.com
Re: TTL 6502 Here I come
Drass wrote:
the CPU then ran the full NMOS 6502 test suite to completion. Double hurray!!!
In 1988 my 65C02 got six new registers and 44 new full-speed instructions!
https://laughtonelectronics.com/Arcana/ ... mmary.html
https://laughtonelectronics.com/Arcana/ ... mmary.html