Post by hydrophilic on Jan 24, 2015 2:09:36 GMT
The problem is due to C64 compatibility... the cartridge port does not have a 2MHz line, so the chips in it can't directly sync with the CPU. All the I/O chips inside C128 are driven by 1MHz (except the VIC-II which actually generates the 1MHz signal by 8x division of the dot clock). Access to an I/O chip will slow the CPU down to 1MHz for a single cycle (well, half the time). This makes simple cartridges work in 2MHz mode because most just have standard registers that can be read/written.
However an advanced cartridge, like the REU and presumably the 64NIC, perform DMA -- dynamic memory access. They turn off the CPU (similar to the way the VIC does) so the cartridge can read/write RAM (or ROM or even I/O chips). It seems the RAM access is not reliable in 2MHz when the cartridge is still being clocked by the 1MHz line...
So I was thinking the cartridge could divide the dot clock by 4 to get its own internal 2MHz. Using this might allow DMA operations to succeed... but it would require a special initialization program to be run on the C128 so the cartridge can predict when the bus slows down. You see in fast mode with the VIC screen blanked, the CPU can *not* run 100% of the time at 2MHz. 5 cycles of each raster the VIC-II will access the bus to perform DRAM refresh (this slows the CPU or 'smart cartridge' to 1MHz). The setup program would have to indicate to the cartridge when a raster begins and how many cycles are in a raster (63 for PAL, 65 for NTSC)... with that info the cartridge can predict when to stretch its internal 2MHz line.
A simple way to test if this could work is to connect the 2MHz line from inside the 128 to the clock line inside the cartridge (and also cut the cartridge's normal connection to the 1MHz line). If this works, then building the divide by 4 counter and 'raster sync' circuit would be justified.
Oh yeah, a simpler solution may be software only! Like I said above, I presume the problem with the 64NIC in 2MHz-mode is the DMA. I've never tried programming one on a CBM, but according to the chip maker, the Ethernet chip can be run using either internal RAM buffers or with DMA. So maybe if you change the software to use non-DMA mode it will be just fine at 2MHz. Edit ...or if you can control when DMA occurs, then slow down the system to 1MHz for the transfer, and re-enable 2MHz until another transfer is needed. /Edit
However an advanced cartridge, like the REU and presumably the 64NIC, perform DMA -- dynamic memory access. They turn off the CPU (similar to the way the VIC does) so the cartridge can read/write RAM (or ROM or even I/O chips). It seems the RAM access is not reliable in 2MHz when the cartridge is still being clocked by the 1MHz line...
So I was thinking the cartridge could divide the dot clock by 4 to get its own internal 2MHz. Using this might allow DMA operations to succeed... but it would require a special initialization program to be run on the C128 so the cartridge can predict when the bus slows down. You see in fast mode with the VIC screen blanked, the CPU can *not* run 100% of the time at 2MHz. 5 cycles of each raster the VIC-II will access the bus to perform DRAM refresh (this slows the CPU or 'smart cartridge' to 1MHz). The setup program would have to indicate to the cartridge when a raster begins and how many cycles are in a raster (63 for PAL, 65 for NTSC)... with that info the cartridge can predict when to stretch its internal 2MHz line.
A simple way to test if this could work is to connect the 2MHz line from inside the 128 to the clock line inside the cartridge (and also cut the cartridge's normal connection to the 1MHz line). If this works, then building the divide by 4 counter and 'raster sync' circuit would be justified.
Oh yeah, a simpler solution may be software only! Like I said above, I presume the problem with the 64NIC in 2MHz-mode is the DMA. I've never tried programming one on a CBM, but according to the chip maker, the Ethernet chip can be run using either internal RAM buffers or with DMA. So maybe if you change the software to use non-DMA mode it will be just fine at 2MHz. Edit ...or if you can control when DMA occurs, then slow down the system to 1MHz for the transfer, and re-enable 2MHz until another transfer is needed. /Edit