6502.org Forum  Projects  Code  Documents  Tools  Forum
It is currently Sun May 12, 2024 4:20 am

All times are UTC




Post new topic Reply to topic  [ 4 posts ] 
Author Message
PostPosted: Tue Apr 08, 2003 2:34 am 
Offline

Joined: Tue Mar 18, 2003 12:21 am
Posts: 36
Location: ChristChurch New Zealand
Firstly the other post I wrote can be ignored - that was kinda silly of me to post that..


Ok I want to base this help around the opcode instruction LDA with a 16 bit address - absolute (not an 8bit immediate value).

LDA $aaaa

If one clock tick is the same as a cycle and there fore a processor can perform many instructions (opcodes) per second, what is the ruff process in digital logic for this opcode..

What I mean by ruff process is why does this take 4 cycles (ticks) and do the address lines for reading the address got high appropriatly for only 1 cycle (tick)..

I am mainly confused at when and how long the address lines go high to read the address for the accumulator and how that has to do with design and getting the propagational delay right!!

_________________
NPastoll


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: Tue Apr 08, 2003 4:27 am 
Offline
User avatar

Joined: Fri Aug 30, 2002 9:02 pm
Posts: 1686
Location: Sacramento, CA
1202,

This I can answer with a reference. Do you have the WDC datasheet for the W65C02S? If not, get it.

On page 27 (my copy is dated Mar 6, 2000 on the bottom of page 1), there is a description of each address mode and what exactly is being done during each clock cycle (Table 5-5).

To answer your question about LDA $HHLL, here what's being done:
Code:
cycle      Address Bus    Data Bus    R/W    Description
   1         PC                $AD     R   Fetch the OPcode
   2         PC+1              $LL     R   get the low order address
   3         PC+2              $HH     R   get the upper order address
   4         $HHLL             $dd     R   read the data @ $HHLL
I hope this helps.

Daryl
http://65c02.tripod.com
Code:


Top
 Profile  
Reply with quote  
PostPosted: Tue Apr 08, 2003 4:52 am 
Offline

Joined: Tue Mar 18, 2003 12:21 am
Posts: 36
Location: ChristChurch New Zealand
Thanks again

_________________
NPastoll


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: Tue Apr 08, 2003 5:56 am 
Offline
User avatar

Joined: Fri Aug 30, 2002 1:09 am
Posts: 8433
Location: Southern California
I'm not sure if the "tick" refers to an entire cycle or just the time that phase 2 is high. Maybe someone else has an answer. Sometimes they're also called "T states" or "clocks." I personally don't like to use the word "cycles" because in the language of some other processors, a cycle may be a set of 4, 8, 12, or other number of down-up cycles of the clock source. With the 6502, they're the same thing, so 1 cycle is 1 microsecond (not 4 etc) at 1MHz.

For the first half of a 6502 cycle, phase 2 low. For the second half, phase 2 is high. The duty cycle has to do with the ratio of low time to high time. Ideally, they'll be equal, or close to it. If one is considerably shorter than the other, it will start limiting the maximum operating speed of the processor. There is seldom a good reason to have the duty cycle much above or below 50%. If you have a 1MHz clock (which is a small fraction of the maximum speed of modern 6502's) and phase 2 is low 500ns and high 500ns, you have 50% duty cycle. Note that the term is not "duty cycles," and that you can measure duty cycle with a single cycle of down-up.

The processor does various things internally in the first half of the cycle, when phase 2 is low. One is to set up the address bus and R/W\ line with enough time that they will be valid and stable before phase 2 goes up. After phase 2 goes up, it will take several nanoseconds for RAM-select logic, for example, to get the "all ready" signal through to the RAM's CS input pin. This time is the logic's propagation delay. After that, it will take some time for the RAM to respond and get valid, stable data on the data bus (assuming, for the example, that you're reading the RAM). This time is the memory's access time. (Actually, if you look at the timing diagrams, you'll see other things that could be considered access time for other configurations, but this one will typically be one of the most important ones for a 6502 system.) The data must be valid and stable a certain amount of time (like 10ns) before phase 2 goes down, in order for the processor to latch onto it without errors. That's the processor's data-read setup time. So you see three major timings that must be considered that must fit within the time that phase 2 is up in the last half of a cycle. The memory's access time will normally be a lot longer than the other two.

I should mention here that I've seen some projects where people didn't use the phase 2 signal in the RAM-select glue logic, and then they wind up with problems, sometimes that the computer won't work at all. The problem is that there are times when phase 2 is low that R/W\ could be low when an address you don't want to write to is on the address bus. For reliable operation, your RAM-select logic must wait for phase 2 to go up before making the RAM CS\ input true, in order to make sure that the address and R/W\ lines are valid and stable first. And for the same reason, the logic must de-select the RAM when phase 2 goes down.

Usually the maximum propagation delays, setup times, or access times will be the ones you need to plan around in order to get reliable operation. If you want to push your luck, you can hope that the actual parts you get to put in your circuit meet not only the typical delays, but are even near the minimums. The times for any given part will normally be slower at high temperatures and lower power supply voltages.

You do not have to add a gate's output slew rate to the propagation delay times. It's already included. However if your capacitive loads loads are heavy, you need to be aware that those slew rates will increase. A data sheet for a 74HC00 for example may include propagation delays for 15pf load and a 50pF load. From those you can more-or-less extrapolate how much of the delay is in the gate itself and how much is from the slew rate, and then figure how much longer it may get if you have, for example, a 100pF load (which is probably heavier than you'll have on a simple 6502 project).

As a parenthetical note, I might add that there may be a hold time too which was not mentioned above, where the data has to remain for a little while after the clock goes down; but that's not normally a problem in a simple 6502 system because it will take awhile for the RAM (or whatever is putting data on the bus) to turn off its outputs and go to high impedance, and the capacitance on the bus will hold the data until something else asserts new data.

To directly answer one of your questions, the propagation delays and other timings are very important; although if you run at the snail speed of 1MHz, you'll hardly find logic and memory that's not fast enough for the job.

The above paragraphs describe only part of what happens in one cycle. As Daryl pointed out, there will be one of these read operations to get the op code of your example LDA abs, another for the low address byte, and yet another for the high address byte. The fourth cycle is where the address mentioned by that operand is actually read. The instruction starts with an op code, and usually has an operand following the op code. In the case of the 6502, operands are always one or two bytes.

Most 6502 instructions do not merge op code and operand in the same byte. The 65c02 instructions BBS, BBR, SMB, and RMB are slight exceptions to the rule in that the part of the operand that specifies which bit to operate on is included in the op code.


> Firstly the other post I wrote can be ignored - that was kinda silly of me to post that..

Remember you can edit or delete your own posts. I have edited my own a few times after realizing that something I said could be misleading. It would also be good for forum "housekeeping," so future readers looking through the archives for certain information don't have so much extraneous stuff to slow them down. If you have four questions about clocks, it would be best to put them all under one subject (Hardware -> clocks).

Garth


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 4 posts ] 

All times are UTC


Who is online

Users browsing this forum: No registered users and 4 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: