Yes, you're absolutely right MSB/LSB concept. I apologize for the confusion.Did you mean to say most significant bit? The LSB would be RA0 corresponding to either A1 or A9 depending on C2M’s state. Or VA0 or VA8 if video is accessing memory.
I don’t understand what the problem is? For the original 128K Mac, there were only eight RAM address lines. RA7 was the MSB which corresponds to A8 or A16 depending on C2M’s state. Or VA7 or S5 if video is accessing memory. When they created the 512K upgrade, they implemented the additional ‘253 to multiplex A17 and A18 to create RA8. This caused no problems, and RA9 is proposed to be created the same way, so I’m not sure about the problem you describe?
I think one could completely scramble the RAM address lines before connecting them to the DRAM, and as long as it was consistent for all DRAM, it wouldn’t matter. They only care that every row is refreshed within the refresh cycle window, and the system only cares that bytes written to RAM remain where ever they are stored until read back from the same location.
I could be wrong, and if so please feel free to correct me!
The address signals I’m referring to come straight from the truth table in my previous reply here: https://68kmla.org/bb/index.php?thr...y-upgrade-board-development.47308/post-533221
Indeed, the video circuitry is providing the refresh functionality on the early Macs. I understand what you are saying regarding the connection of these video address lines creating the limitation of only 256 cycles for refresh on the Mac 128/512K, and the benefit the Mac Plus has in its video address line connections to provide 512 cycles for refresh.The 12-bit video access counter is scrambled with the DRAM memory address bus. This "scrambling" logic in the 12-bit counter is identical across the Plus/128K/512K Macs (using 74LS393s and 74LS257s) except for RAF8 generation (the final stage of the 74LS253). Perhaps the video access counter plays also a role in generating refresh cycles. This is a reasonable guess, as video address counters in older PC systems were often used for DRAM refresh to avoid CPU overhead. The Mac Plus generates 512 refresh cycles, while the 128K/512K Macs only generate 256 cycles. See the potential connection with the way RAF8 is created?
Moving on from RAF8, 10-bit DRAM ICs won't work unless the combinatorial GAL equation stored in the "CAS" IC from the Mac Plus is fully understood. Even then, additional circuitry would be necessary to create CAS lines for 1MB RAM banks. This highlights another limitation: the 512K Mac only accesses RAM in 512KB chunks.
Assuming the logic was specifically designed for 256 refresh cycles, some additional circuitry would be needed to generate up to 512 cycles. I suspect this modification would be less complex than adapting for 10-bit DRAM ICs.
Therefore, my conclusion is that 256 cycles are generated for each 512KB memory bank for DRAM refresh. I believe the generation of these cycles is related to the 12-bit video address counter.
For fun, I've ordered some 512-cycle 9-bit DRAM ICs to test this theory in practice.
Almost. According to this, the Mac uses 21888 bytes of memory for video RAM. That must be for both the main and alternate screen buffers selected by the VIDPG2 signal. So for one buffer written to the screen, it’s 21888 / 2 = 10944 locations accessed at a rate of 60 Hz. Crunching the numbers, I think the Mac 512K completes 10 refresh cycles (size 256) in one screen redraw.Here's my math which should be double checked:
- 14-bit video counter contains 16384 data locations accessed at a frequency of 60 Hz, so at least every 16 ms. (1 / 60 = ~0.016)
- Mac 512K DRAM ICs must be refreshed at least every 4 ms.
- In 4 ms, the video counter accesses 4096 data locations in memory (16384 / 16 x 4 = 4096).
- That means 16 complete refresh cycles (refresh cycle size of 256) occur every time the screen is redrawn. (4096 / 256 = 16)
Oh okay, I must have misinterpreted you.You're right. DRAM refreshing task is not a dedicated system downtime for memory refresh. Perhaps my overly detailed explanation of the refresh mechanism "/RAS only" led you to believe otherwise.
Generally speaking, DRAM refresh operates more like a background task working in tandem with other two processes. Reading or writing data to RAM automatically refreshes the accessed rows, eliminating the need for dedicated refresh cycles in most cases.
Video refresh, which consumes a significant portion of CPU time (around a third in 128/512K Macs), provides another opportunity. The video address counter, used to track screen updates, is used to generate memory addresses for DRAM refresh, thereby piggybacking on the existing video access cycles and eliminating additional overhead.
This collaborative approach minimizes the impact of refresh on CPU performance. The downtime caused solely by DRAM refresh typically falls around 5% of total CPU time, and it further varies depending on the specific application's memory access patterns.
Programmers in the 1980s were well aware of this behavior and factored it into their coding practices.
I leaved here some interesting numbers I found that shows how the 128/512K Macs timing is built around the video timing.
The Mac timing is a bit odd and built around the Video timing.
- Base clock is 7.83 MHz (*2)
- Line frequency is 22.255 kHz.
- Thus a video line is exactly 352 clock cycles
- A 68k needs 4 cycles per read/write
- This gives 88 memory access slots
- One line is 512 pixel or 32 (16 bit) words
- CPU and video access RAM alternating during the first 64 access slots
- CPU gets 24 exclusive slots during horizontal retrace.
- CPU gets as well all slots during vertical retrace
- There are ~32,560 access slots in frame (Refresh is 60.14 Hz)
- There are 342 lines per screen
- Resulting in 342 x 32 = 10,944 video reads
- This leaves about 2/3rd for the CPU
- If the CPU would utilize memory at all times, the effective speed would be close to 5.2 MHz
- Since the 68k isn't, and it's only stopped when there is a memory access, effective speed is more like 6 MHz
Still waiting for the arrival of the new DRAM ICs.The relevant difference is that VA8 and HIGH from RA0 and RA8 are swapped, so when C2M is high, there are nine bits of VAx lines going to RA0-RA8 which creates 512 cycles for refresh. A9 and A18 had to follow suit for consistency, otherwise when the CPU writes to memory for video data, it would be all messed up.
I was about to write to you! I like very much the approach you've taken now of testing those modifications on RA0 and RA8 (CPU access / 74253´s) use solely the system memory. The results are very interesting.I played around with swapping those signals on U4F and U13G at first by cutting traces and wiring bodge wires, but decided to put together a couple little carrier boards which connect all the pins of the ICs back to the logic board except those which we want to try to swap. The pins to swap are connected to jumper pins to make it easy to go between stock and swapped.
Have you tried changing the signal on pin #2 of U2F from VA13 to S5 (Pull-Up)? I haven't thought thoroughly about these modifications yet, but it's worth trying since it definitely modifies RAM address bit RA0 for sound (on the 74257s), as it does in the Mac Plus.As you can see, the system still works as expected with the pins swapped, but the audio is horribly destroyed. Theoretically, the video VA# lines going to the RAM circuit should now count sequentially from 0 to 511 instead of just counting sequentially from 0 to 256. Obviously, the VA# lines access addresses beyond these values, but sequentially accessed is key for /RAS-only refresh.
I have not, and I recall you mentioning this difference previously, and I never really thought too much about it. I hadn't realized it was part of the sound circuit, and I just now noticed that it produces RA# lines which didn't make sense at first until I noticed it's only active during DMA access while the '253s are inactive. I don't quite fully understand how the memory access circuit for sound and speed control for the floppy drive works (which they share?), but in my head it seems that the CPU would put sound data into RAM via the '253s, then the sound hardware would read that data out via the '257s. Since swapping those signals affected RA0, it makes sense that a bit of data placed into RAM destined for the sound hardware accessed via RA0 with C2M low will be out of place. Instead of VA8, placing S5 (pull up) on pin 2 of U2F as you mentioned makes sense, but wouldn't VA8 need to go somewhere else, not just stay out of the picture? I'm looking at the schematic, and I'm just not seeing it anywhere else.Have you tried changing the signal on pin #2 of U2F from VA13 to S5 (Pull-Up)? I haven't thought thoroughly about these modifications yet, but it's worth trying since it definitely modifies RAM address bit RA0 for sound (on the 74257s), as it does in the Mac Plus.
You could try adding some capacitors between +5V and GND near ICs on your prototype. Another thing could be any 74LS253s used on the prototype could be swapped with 74F253s dive that is what Apple used in the Mac. I believe the 74F series has a shorter propagation delay. That may not be the issue, but I suppose it’s worth trying?I test the prototype using the system's RA0 and RA8. Here are the results:
After restarting the Mac at least twice, the startup chime sounded as expected. (The first two times the chime sounds distorted, and boot process ends with the Sad Mac icon)
Most of the time, I could boot the OS from ROM (ROM-INATOR) or using Floppy Emu. I was even able to boot “Dark Castle” a couple of times before it crashed. Randomly appearing bad pixels and crashes time to time.
I'm cautiously optimistic, suspecting the stability issues might be due to insufficient power to drive the prototype board, poor connections, lack of proper grounding, parasitic capacitances, or interference.
Consistently, after disconnecting and reconnecting the logic board and AC power cord, I needed to restart the Mac several times to reach the happy Mac icon with a clear chime sound. It's as if something needs to be pre-charged with some residual voltage.
I suspect the way I deliver the 5VDC and ground is part of the problem. Maybe the bodge wires are insufficient for powering this RAM chip? Each of these RAM chips (AS4C256K16FO) consumes around 700 mA, while the 41256s consume about 30-40 mA each. That means a single one of these RAM chips consumes as much as sixteen 41256s!
Next test will be to gate CAS0 and CAS1 with C2M and see what changes...
I just added a 10uF capacitor for general decoupling. Also added a pair of 0.1 uF capacitors next to the 74LS244s. The distorted chime seems to be gone!. It looks like almost all boot attempts now reach the waiting floppy disk icon in one shot. However, I don't see any noticeable improvement with the bad pixels. Most, if not all, of the bad pixels appear when the CPU is doing some heavy task like reading data or launching an app.You could try adding some capacitors between +5V and GND near ICs on your prototype. Another thing could be any 74LS253s used on the prototype could be swapped with 74F253s dive that is what Apple used in the Mac. I believe the 74F series has a shorter propagation delay. That may not be the issue, but I suppose it’s worth trying?
I only used LS253s on my breadboard, but now that I desoldered and socketed U13G, I could move it to a breadboard and utilize the unused half to generate RA9.
It certainly seems like we’re getting close to cracking it!
We're making strides for sure, let's keep pushing.It certainly seems like we’re getting close to cracking it!
Remember that the prototype is currently using system RA0 and RA8. Therefore, the 74253 is not needed at this stage.Another thing could be any 74LS253s used on the prototype could be swapped with 74F253s dive that is what Apple used in the Mac. I believe the 74F series has a shorter propagation delay. That may not be the issue, but I suppose it’s worth trying?