Should I start with a 6502?
-
qwertykeyboard
- Posts: 20
- Joined: 09 Jul 2018
- Location: Canada
Re: Should I start with a 6502?
Now, I'm reading over the 6502 primer and having trouble understand how clock generation works. What are the different phase clocks for and how come there isn't just a single clock pin like on the Z80? Is it possible to hook up a 555 timer at a few hertz to the 6502? because the primer has no mention of this.
Re: Should I start with a 6502?
As the local curmudgeon, the fundamental question is "What is the goal?".
Is it to get a chip to make blinking lights? A terminal connected to a monitor?
Why 8-Bit? Why not a modern micro controller?
Are you breadboarding or soldering?
There are several "minimal chip count" schematics available for both the 6502 and the Z80.
The singular advantage of a Z80 is that if you wish to go beyond "blinking lights", it's not that far to get CP/M and solid state storage on your machine, and, once there, you have access to a true bounty of software to run. 6502, not so much.
All of the processors (8 bit and modern micro controllers) suffer similar problems when it comes to dealing with decoding logic, peripheral interfaces, etc. No one is particularly "harder" than another if you stay "happy path" and use appropriate logic and support chips. Many microcontollers are "easy" as they need very few, if any, extra logic (which for many makes them less interesting from a "build a computer" point of view).
The 6502 and Z80 are still both produced, which is very helpful. Modern chips, modern standards. You're not salvaging something from a 30 year old machine.
The Z80 has a wider selection of tools to choose from also, both native and cross development. Not to say they don't exist for the 6502, just that there's more for the Z80.
There have been great wars raged over the advantages and disadvantages of one over the other, but in the end, it's probably more personal taste that will drive this decision. But, again, depends on your goals.
Is it to get a chip to make blinking lights? A terminal connected to a monitor?
Why 8-Bit? Why not a modern micro controller?
Are you breadboarding or soldering?
There are several "minimal chip count" schematics available for both the 6502 and the Z80.
The singular advantage of a Z80 is that if you wish to go beyond "blinking lights", it's not that far to get CP/M and solid state storage on your machine, and, once there, you have access to a true bounty of software to run. 6502, not so much.
All of the processors (8 bit and modern micro controllers) suffer similar problems when it comes to dealing with decoding logic, peripheral interfaces, etc. No one is particularly "harder" than another if you stay "happy path" and use appropriate logic and support chips. Many microcontollers are "easy" as they need very few, if any, extra logic (which for many makes them less interesting from a "build a computer" point of view).
The 6502 and Z80 are still both produced, which is very helpful. Modern chips, modern standards. You're not salvaging something from a 30 year old machine.
The Z80 has a wider selection of tools to choose from also, both native and cross development. Not to say they don't exist for the 6502, just that there's more for the Z80.
There have been great wars raged over the advantages and disadvantages of one over the other, but in the end, it's probably more personal taste that will drive this decision. But, again, depends on your goals.
- BigDumbDinosaur
- Posts: 9428
- Joined: 28 May 2009
- Location: Midwestern USA (JB Pritzker’s dystopia)
- Contact:
Re: Should I start with a 6502?
cbmeeks wrote:
If I could throw my $0.02 USD in, here is why I suggest going with 6502 (65C02, actually)...
On the software side, I've always felt that the 65xx assembly language is intuitive and logical. As someone else once noted here, it's easy to envision solutions with 65xx assembly language. To me, the Z80 assembly language is obtuse, not unlike the x86 assembly language. When I see Z80 source code, I see a mess. When I see most 65xx source code, I see the flow of logic, even in source code with a paucity of comments.
x86? We ain't got no x86. We don't NEED no stinking x86!
Re: Should I start with a 6502?
BigDumbDinosaur wrote:
To me, the Z80 assembly language is obtuse, not unlike the x86 assembly language.
Cat; the other white meat.
-
qwertykeyboard
- Posts: 20
- Joined: 09 Jul 2018
- Location: Canada
Re: Should I start with a 6502?
whartung wrote:
As the local curmudgeon, the fundamental question is "What is the goal?".
Is it to get a chip to make blinking lights? A terminal connected to a monitor?
Why 8-Bit? Why not a modern micro controller?
Are you breadboarding or soldering?
There are several "minimal chip count" schematics available for both the 6502 and the Z80.
The singular advantage of a Z80 is that if you wish to go beyond "blinking lights", it's not that far to get CP/M and solid state storage on your machine, and, once there, you have access to a true bounty of software to run. 6502, not so much.
All of the processors (8 bit and modern micro controllers) suffer similar problems when it comes to dealing with decoding logic, peripheral interfaces, etc. No one is particularly "harder" than another if you stay "happy path" and use appropriate logic and support chips. Many microcontollers are "easy" as they need very few, if any, extra logic (which for many makes them less interesting from a "build a computer" point of view).
The 6502 and Z80 are still both produced, which is very helpful. Modern chips, modern standards. You're not salvaging something from a 30 year old machine.
The Z80 has a wider selection of tools to choose from also, both native and cross development. Not to say they don't exist for the 6502, just that there's more for the Z80.
There have been great wars raged over the advantages and disadvantages of one over the other, but in the end, it's probably more personal taste that will drive this decision. But, again, depends on your goals.
Is it to get a chip to make blinking lights? A terminal connected to a monitor?
Why 8-Bit? Why not a modern micro controller?
Are you breadboarding or soldering?
There are several "minimal chip count" schematics available for both the 6502 and the Z80.
The singular advantage of a Z80 is that if you wish to go beyond "blinking lights", it's not that far to get CP/M and solid state storage on your machine, and, once there, you have access to a true bounty of software to run. 6502, not so much.
All of the processors (8 bit and modern micro controllers) suffer similar problems when it comes to dealing with decoding logic, peripheral interfaces, etc. No one is particularly "harder" than another if you stay "happy path" and use appropriate logic and support chips. Many microcontollers are "easy" as they need very few, if any, extra logic (which for many makes them less interesting from a "build a computer" point of view).
The 6502 and Z80 are still both produced, which is very helpful. Modern chips, modern standards. You're not salvaging something from a 30 year old machine.
The Z80 has a wider selection of tools to choose from also, both native and cross development. Not to say they don't exist for the 6502, just that there's more for the Z80.
There have been great wars raged over the advantages and disadvantages of one over the other, but in the end, it's probably more personal taste that will drive this decision. But, again, depends on your goals.
- BigDumbDinosaur
- Posts: 9428
- Joined: 28 May 2009
- Location: Midwestern USA (JB Pritzker’s dystopia)
- Contact:
Re: Should I start with a 6502?
qwertykeyboard wrote:
Now, I'm reading over the 6502 primer and having trouble understand how clock generation works. What are the different phase clocks for and how come there isn't just a single clock pin like on the Z80? Is it possible to hook up a 555 timer at a few hertz to the 6502? because the primer has no mention of this.
In the 1970s, when the 6502 first appeared (there was also a 6501), the hardware available to generate clock signals wasn't nearly as robust as it is now. Circuits typical used a crystal oscillator, whose output was weak. So the 6502 was designed to accept the weak output of the oscillator and then produce "boosted" outputs for use by other parts of the circuit.
On the WDC 65C02, you have the PHI2 input, which receives the signal from the clock oscillator (which signal I refer to as Ø2 in my writings, the Ø symbol often used in electrical power generation to mean "phase"). Internal timing in the 65C02 is based upon PHI2. The 65C02 also has two clock outputs: PHI2O, which is the "boosted" form of Ø2, and PHI1O, which is the inversion of PHI2O. Succinctly stated, when PHI2 is high, PHI2O will be high and PHI1O will be low.
The 65C02 as designed was intended to be a "drop-in" replacement for the NMOS 6502. As much 6502-powered hardware of the past makes use of PHI2O and PHI1O, the modern form of the 65C02 continues to have these outputs. These days, new designs mostly utilize "can" oscillators that are able to generate a strong and reasonably symmetric clock output that readily services the microprocessor (MPU) and other system devices, such as a 65C22. Hence the need for PHI2O and PHI1O has markedly decreased. In fact, WDC's data sheet for the 65C02 recommends that the PHI2O and PHI1O outputs not be used in new designs, as the relationship between those signals and PHI2 (the clock input) is neither specified or tested:
- 3.8 Phase 2 In (PHI2), Phase 2 Out (PHI2O) and Phase 1 Out (PHI1O)
Phase 2 In (PHI2) is the system clock input to the microprocessor internal clock. During the low power Standby Mode, PHI2 can be held in either high or low state to preserve the contents of internal registers since the microprocessor is a fully static design. The Phase 2 Out (PHI2O) signal is generated from PHI2. Phase 1 Out (PHI1O) is the inverted PHI2 signal. An external oscillator is recommended for driving PHI2 and used for the main system clock. All production test timing is based on PHI2. PHI2O and PHI1O were used in older systems for system timing and internal oscillators when an external crystal was used.
- Timing Notes:
1. Timing measurement points are 50% VDD.
2. PHI1O and PHI2O clock delay from PHI2 is no longer specified or tested and WDC recommends using an oscillator for system time base and PHI2 processor input clock.
As for using a 555 timer as a clock source, it will work, although achieving a reasonably symmetric clock may be a challenge. A low speed oscillator using a comparator may be better.
x86? We ain't got no x86. We don't NEED no stinking x86!
Re: Should I start with a 6502?
Very well said, BDD.
Something else I'd like to point out is that the Z80 world has CP/M. Which is an asset that I wished the 6502 world had.
HOWEVER, I personally feel that to really get good use out of CP/M, you need much more than the 64K the Z80 is limited to (the 6502 is also limited to 64K). So in order to make CP/M shine, you need a more advanced computer with 128K, 512K, etc. Which means more bank switching, more decoding logic, etc.
Something else I'd like to point out is that the Z80 world has CP/M. Which is an asset that I wished the 6502 world had.
HOWEVER, I personally feel that to really get good use out of CP/M, you need much more than the 64K the Z80 is limited to (the 6502 is also limited to 64K). So in order to make CP/M shine, you need a more advanced computer with 128K, 512K, etc. Which means more bank switching, more decoding logic, etc.
Cat; the other white meat.
- GARTHWILSON
- Forum Moderator
- Posts: 8774
- Joined: 30 Aug 2002
- Location: Southern California
- Contact:
Re: Should I start with a 6502?
qwertykeyboard wrote:
Now, I'm reading over the 6502 primer and having trouble understand how clock generation works. What are the different phase clocks for and how come there isn't just a single clock pin like on the Z80? Is it possible to hook up a 555 timer at a few hertz to the 6502? because the primer has no mention of this.
For simple systems, phase 2 is all you need. The primer's clock-generation page gives a few clock options. I'm not sure the 555 will have adequately fast edges (ie, how quickly it gets from high to low, or vice-versa, regardless of frequency) for the 65c02's being produced today. A couple of members here ran into trouble with inadequate slew rate when using WDC processors. Also, heed what it says there about non-WDC 65c02's needing to stay below a certain maximum time on the phase-2-low time, meaning you would not be able to use a 1Hz square wave for example. (The WDC ones can be stopped indefinitely with phase 2 either high or low; but other brands can only be stopped with phase 2 high.) There's a circuit there for single-clocking which lets you stop indefinitely in any cycle, but only with phase 2 high, and the phase-2-low time stays below the maximum allowable time for Rockwell, CMD, Synertek, and other manufacturers. For an oscillator, a crystal oscillator can is usually the best way to go. The circuit at the top of the circuit potpourri page shows different clock options too. The notes below it tell what you need to know (particularly Note 1 in this case). Someone suggested separating out the different options of that part of the diagram, with individual very small diagrams of just the clock circuit, and offered to do it for me so I could edit the page and insert this part with less work; so that may be coming.
Quote:
Honestly, the goal of this is just to build a computer completely from scratch to understand the architecture. I was planning to use a breadboard and slowly add stuff like RAM and I/O as time goes on to see where that takes me.
Best of luck, and again, my apologies for having to punch this reply out without taking the time to make it more clear.
http://WilsonMinesCo.com/ lots of 6502 resources
The "second front page" is http://wilsonminesco.com/links.html .
What's an additional VIA among friends, anyhow?
The "second front page" is http://wilsonminesco.com/links.html .
What's an additional VIA among friends, anyhow?
Re: Should I start with a 6502?
qwertykeyboard wrote:
Honestly, the goal of this is just to build a computer completely from scratch to understand the architecture. I was planning to use a breadboard and slowly add stuff like RAM and I/O as time goes on to see where that takes me.
Why?
Because you have Garth's primer and this forum.
There's isn't a forum comparable to this one. So, any problems you might encounter, you'll find expert help here.
You can always use the skills learned from building a 6502 to build pretty much anything else later on.
-
qwertykeyboard
- Posts: 20
- Joined: 09 Jul 2018
- Location: Canada
Re: Should I start with a 6502?
So, I have a 6502 processor in hand. Should I try wiring up a NOP test? Also, how would I go about making a single step clock signal with any kind of de bounce so that I can observe that the address lines are counting up with led's?
With regards to the logic chips, I intend to order an assortment of them so that I will have them on hand when I need them. Which ones should I get?
Thanks,
With regards to the logic chips, I intend to order an assortment of them so that I will have them on hand when I need them. Which ones should I get?
Thanks,
- BigDumbDinosaur
- Posts: 9428
- Joined: 28 May 2009
- Location: Midwestern USA (JB Pritzker’s dystopia)
- Contact:
Re: Should I start with a 6502?
qwertykeyboard wrote:
Should I try wiring up a NOP test?
Quote:
Also, how would I go about making a single step clock signal with any kind of de bounce so that I can observe that the address lines are counting up with led's?
Quote:
With regards to the logic chips, I intend to order an assortment of them so that I will have them on hand when I need them. Which ones should I get?
It's best to not use 74S, 74LS or 74ALS, as these logic families are not CMOS-compatible and also tend to consume quite a bit more power than CMOS devices.
x86? We ain't got no x86. We don't NEED no stinking x86!
- GARTHWILSON
- Forum Moderator
- Posts: 8774
- Joined: 30 Aug 2002
- Location: Southern California
- Contact:
Re: Should I start with a 6502?
qwertykeyboard wrote:
With regards to the logic chips, I intend to order an assortment of them so that I will have them on hand when I need them. Which ones should I get?
http://WilsonMinesCo.com/ lots of 6502 resources
The "second front page" is http://wilsonminesco.com/links.html .
What's an additional VIA among friends, anyhow?
The "second front page" is http://wilsonminesco.com/links.html .
What's an additional VIA among friends, anyhow?
-
qwertykeyboard
- Posts: 20
- Joined: 09 Jul 2018
- Location: Canada
Re: Should I start with a 6502?
Thanks for the input everyone! Ok, so I salvaged a NMOS 6502 out of an old piece of equipment just so I can play around with it for a little bit but I intend to purchase a new WDC cmos variant later on.
So what I did is hardwired the 6502 in NOP mode and hooked A0-A6 to the data pins of my arduino and used one of the data pins as a clock. I wrote this bit of code:
It does 2 clock cycles before reading off the address bus since 2 clock cycles are needed to complete the NOP instruction.
So I just read off the address bus and printed the output to the serial monitor and got something like this:
Which looks to me that it is counting in binary, however, it doesn't start at EAEA, but a little bit higher than that. Why is that?
So what I did is hardwired the 6502 in NOP mode and hooked A0-A6 to the data pins of my arduino and used one of the data pins as a clock. I wrote this bit of code:
Code: Select all
int Add0 = 2;
int Add1 = 3;
int Add2 = 4;
int Add3 = 5;
int Add4 = 6;
int Add5 = 7;
int Add6 = 8;
int Mclock = 13;
int output;
void setup() {
// put your setup code here, to run once:
Serial.begin(9600);
pinMode(Add0, INPUT);
pinMode(Add1, INPUT);
pinMode(Add2, INPUT);
pinMode(Add3, INPUT);
pinMode(Add4, INPUT);
pinMode(Add5, INPUT);
pinMode(Add6, INPUT);
pinMode(Mclock, OUTPUT);
}
void loop() {
// put your main code here, to run repeatedly:
digitalWrite(Mclock, HIGH);
delay(0.00001);
digitalWrite(Mclock, LOW);
delay(0.00001);
digitalWrite(Mclock, HIGH);
delay(0.00001);
digitalWrite(Mclock, LOW);
output = digitalRead(Add6);
Serial.print(output);
output = digitalRead(Add5);
Serial.print(output);
output = digitalRead(Add4);
Serial.print(output);
output = digitalRead(Add3);
Serial.print(output);
output = digitalRead(Add2);
Serial.print(output);
output = digitalRead(Add1);
Serial.print(output);
output = digitalRead(Add0);
Serial.print(output);
Serial.println();
delay(0.00001);
}So I just read off the address bus and printed the output to the serial monitor and got something like this:
Code: Select all
1101101
1101110
1101111
1110000
1110001
1110010
1110011
1110100
1110101
1110110
1110111
1111000
1111001
1111010
1111011
1111100
1111101
1111110
1111111
0000000
0000001
0000010
0000011
0000100
0000101
0000110
0000111
0001000
0001001
0001010
0001011
0001100
0001101
0001110
0001111
Re: Should I start with a 6502?
Hi, qwertykeyboard
In fact it *does* start at $EAEA but you're not seeing that very first cycle because this procedure you're using is slightly misguided: "It does 2 clock cycles before reading off the address bus since 2 clock cycles are needed to complete the NOP instruction." Instead, try reading off the address in the first cycle. Here's why.
With 65xx processors all opcodes are a single byte, and sometimes an instruction will have one or more operand bytes following the opcode. For performance reasons the processor always follows the opcode fetch with a fetch of the following byte, and often this saves time. NOP is one of the exceptions, however, as there are no operand bytes following the opcode. But the extra fetch happens anyway.
So! After having fetched the Rest Vector the CPU goes to $EAEA to find its first instruction. It fetches the byte at $EAEA, which is the opcode. It then fetches the byte at $EAEB while the NOP completes its execution. But this fetch is actually pointless because there's no operand. After the NOP has completed the CPU will go looking for the next opcode... at $EAEB! IOW it fetches that same byte again. This same pattern repeats endlessly, with the address bus incrementing after the 1st, 3rd, 5th cycle and so on. I hope I explained that so it makes sense!
-- Jeff
qwertykeyboard wrote:
it doesn't start at EAEA, but a little bit higher than that. Why is that?
With 65xx processors all opcodes are a single byte, and sometimes an instruction will have one or more operand bytes following the opcode. For performance reasons the processor always follows the opcode fetch with a fetch of the following byte, and often this saves time. NOP is one of the exceptions, however, as there are no operand bytes following the opcode. But the extra fetch happens anyway.
So! After having fetched the Rest Vector the CPU goes to $EAEA to find its first instruction. It fetches the byte at $EAEA, which is the opcode. It then fetches the byte at $EAEB while the NOP completes its execution. But this fetch is actually pointless because there's no operand. After the NOP has completed the CPU will go looking for the next opcode... at $EAEB! IOW it fetches that same byte again. This same pattern repeats endlessly, with the address bus incrementing after the 1st, 3rd, 5th cycle and so on. I hope I explained that so it makes sense!
-- Jeff
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
- BigDumbDinosaur
- Posts: 9428
- Joined: 28 May 2009
- Location: Midwestern USA (JB Pritzker’s dystopia)
- Contact:
Re: Should I start with a 6502?
GARTHWILSON wrote:
The '138 3-to-8-line and '154 4-to-16-line decoders are always tempting to the newbies, but their propagation delays are quite long, and the fine-grained address decoding they are usually desired for comes with a speed penalty.
x86? We ain't got no x86. We don't NEED no stinking x86!