r/homebrewcomputer • • 17d ago

question about the clock

Post image

hello there, so far for my z80 computer i made a corcuit that and have a question, i want to use a separate clock for my modules and i will be using a 10Mhz cmos z80 with at28c256 eeprom and as6c62256a ram and the eeproms access time is 150ns. So my question is what type frequency clock should i use? i have 4 mhz crystal and 5-6 mhz oscillator

48 Upvotes

31 comments sorted by

3

u/LiqvidNyquist 17d ago

If you can find a copy of the z80 datasheet online, one with the timing diagrams and parameters that include a 10 MHz CMOS version, that will be useful for you.

In general, the z80 provides two clock cycles for your memory access. Actually could be more like two and a half but since there's a delay in creating the RD and MREQ signals it's closer to two. So with a 6 MHz clock, that's 166 ns per cycle, so you would have roughly 330 ns of time. The data needs to be on the bus a little before the end of the last cycle by about 40 ns, so let's call it 290 ns. Then your RAM access plus decode time (how long it takes for your 74xx138 to tun on it's decode output in response to its inputs) needs to be under this time. WIth a 140 ns RAM access time you should be okay.

2

u/Maestro_gaylover 17d ago

this should be the datasheet i have been using

https://www.alldatasheet.com/html-pdf/523965/ZILOG/Z84C0010PEG/154/1/Z84C0010PEG.html

and my eeprom has 150ns while ram has 70ns so i guess 6Mhz is okay? also i dont see any problem on my schematic

2

u/LiqvidNyquist 17d ago

Yes, I waas looking at the same one, Figure 6 for the waveform and the "AC Characteristics" on page 31 (aka 35) for the numerical values.

1

u/Maestro_gaylover 17d ago

so wait, if i multiply it by two, i should be theoretically be allowed to use 10mhz? (maybe 8 since the sio is i think 8mhz? its a z84c4008peg)

1

u/LiqvidNyquist 17d ago

Multiply what by two?

In all cases, you need to go through the waveforms and timing characteristics on the datasheets. What I'm giving you is just a rough off-the-cuff estimate.

The SIO *might* be able to run with a faster CPU because the CPU actually stretches out IO cycles (for the IN and OUT instructions) to use three clocks to allow for slower I/O devices.

1

u/Maestro_gaylover 17d ago

no at like before, you multiplied the 166ns by two to get like 330ns

2

u/LiqvidNyquist 17d ago

At six MHz, one clock cycle is 166ns, which is one divided by 6,000,000. Since the CPU let the bus cycle take two clocks, that's 166x2 or 330 ns.

At 10 MHz, that rough calculation means one clock cycle is 100 ns (1/10,000,000). Two clock cycles is 200 ns. So you have roughly 200 ns for *both* the 74138 to respond and then the SRAM or EEPROM to put the data on the bus. The 74HC138 datasheet doesn;t specifically list a max time for delay at 5.0V VCC, but does list a 20 ns max at 4.5V. So that means your "memory subsystem" (the 138 plus the SRAM) has an access time of (20+140 - 160 ns). So you ought to be able to run inside of the 200 ns allowance.

1

u/Maestro_gaylover 17d ago

the specific 138 i have is st m74hc138 and the paper does say at 5v its 16ns but we do still have time for it

1

u/SpontaneousDegen 17d ago

ST wasn't cooperating on a datasheet, so I looked at the TI one.

16ns is WAY too fast for a 74HC138. The worst case PROPAGATION DELAY (tpd) is 39ns or 45ns, depending on which type of input is changing. Note: 5V parts are traditional specified for 5V+-10%, so you use the 4.5V number.

The tt spec (which I believe is the rise/fall time, but they are being a little sloppy on notation) is 22ns.

1

u/Maestro_gaylover 17d ago

2

u/SpontaneousDegen 16d ago

Yes, the marketing bullet point says: tpd = 16 ns (TYP.) AT VCC = 5 V.

That says its a typical value. What happens when your voltage droops? Say your circuit is powered by a 5V USB port, and the voltage droops to 4.5V. (side note: 5V USB is only guaranteed to provide you with 4.2V under load and long cables.)

What happens when your workbench is in an unheated garage on the coldest day of winter (temperature at 10 deg C or less)?

Many buildings in Europe (especially older ones) do not have air conditioning. Summer 2026, France hit 43 deg C, Germany and Austria hit 41 deg C, and one part of Italy hit 48 deg C.

And you can always get a batch of components at one or the other end of the allowed range; you cannot buy "typical" parts.

The only guaranteed characteristics are the maximums and minimums. Good design practice requires some margin; worst cast values provide you with that margin. From this data sheet, at 4.5V, tpd = 30 or 31ns max (guaranteed over Time/Temperature/Process).

Occasionally, you have to fudge things a little. Then you have to consider this violation VERY carefully and provide as much margin as you can (possibly implement a test to catch failing product).

1

u/LiqvidNyquist 16d ago

Agree with you. On the 4.5V point particularly. The number I quoted was pulled from here (page 7 of 15): https://www.alldatasheet.com/datasheet-pdf/view/1676595/NEXPERIA/74HC138PW.html

I used the 25C value rather than the full commercial since this is a hobby project, but for a "real" design obviously you'd use the worst case.

And yeah, the transisition time is pretty poor so on top of everything else you need to take that into consideration. And my earlier post obviously oversimplified that the prop for clock falling edge to RD/MREQ was roughyl a half cycle, and that also doesn;t account for clock duty cycle and jitter and rise/fall times under various capacitative loads.

My main goal in posting the earlier reply was to get the OP to the point where computing ballpark values from a datasheet was an option rather than just asking reddit, so hopefully this discussion can get the ball rolling for the OP. But 100% agree I oversimplified, this isn't what I would do for a commercial design.

2

u/S52_DiDah 17d ago

Issues with the demultiplexer. Outputs must NOT be connected to ground. How are you planning to write the assembly code for it?

1

u/Maestro_gaylover 17d ago

i have t48 programmer, i will flash my programms to the eeprom beforehand

1

u/S52_DiDah 17d ago

Not a bad flasher. What about writing the code?

1

u/Maestro_gaylover 17d ago

i ddint write the code now but i will be using vs code

1

u/S52_DiDah 17d ago

I'm asking if you understand assembly of the Z80 chip

1

u/Maestro_gaylover 17d ago

well i am learning assembly in college for micropchips and microcontrollers so i do understand basic of it

1

u/IQueryVisiC 17d ago

With „separate“, you mean a clock divider?

2

u/Maestro_gaylover 17d ago

no, as you can see there is a 1.8432mhz clock for the rx/tx. i was wondering if i can use another clock for the other stuff like the cpu clock etc.

1

u/IQueryVisiC 17d ago

Ah I skimmed and only saw one clock above the CPU .

1

u/Icy-Culture-993 17d ago

74HC138 - Y0 thru Y7 are OUTPUTs, so they must not be connected to ground!

1

u/Maestro_gaylover 17d ago

ok yeah, i just use 138 just for like 3 pins but thanks, anything that should be grounded or connected to vcc?

1

u/SpontaneousDegen 17d ago

You might want to check the datasheet for your 1.8MHz oscillator. The ENable pin should probably be tied active instead of floating.

1

u/Maestro_gaylover 17d ago

theres no enable pin on my oscillator so i just didnt connected it, i will change it on the schematic

2

u/SpontaneousDegen 16d ago

Great! ECAD software often gets picky about matching the pins on the schematic symbols to the pins on the footprints, so getting the schematic symbols correct is important.

1

u/SpontaneousDegen 16d ago

I noticed a couple more little issues to check on the schematic.

- The NMI pullup (CPU pin 17)/bus break out does not have a dot on the T junction - it may not be connected.

- I don't see any decoupling caps on the power pins of the chips and the oscillator. Check the datasheets for recommendations, but a 0.1 uF ceramic rated for at least 10V (2x the applied voltage) is a decent start. You may also want a bigger cap such as a 22uF electrolytic to provide a larger current buffer for surges.

1

u/Maestro_gaylover 16d ago

i might add those too, i use a type c pd and a step down module to get 5v but i do not know how clean the power is

1

u/roberts7531new 16d ago

note that in addition to the memory decoder outputs that are shorted to gnd, I see that WR is also shorted to VCC, see near EEPROM

As for the clock question, I dont know the math off the top off my head, but I think you should be safe up to like 10MHz

1

u/Maestro_gaylover 15d ago

the eeprom is connected to vcc to prevent writing to it

1

u/roberts7531new 13d ago

yeah, but theres is a WR label there as well