Getting data to/from the X16

Chat about anything CX16 related that doesn't fit elsewhere
Wavicle
Posts: 284
Joined: Sun Feb 21, 2021 2:40 am

Getting data to/from the X16

Post by Wavicle »



1 hour ago, Scott Robison said:




Just to be clear: It's not necessarily that the FPGA needs a lot of logic cells to allow an external source (such as the X16) to interact with SPI. It's that in order to add the flexibility to VERA to allow it to directly store bytes from SPI to video RAM without passing through the CPU first would require more logic cells than are currently allocated to it. Even if there are enough logic cells left to support a "fire and forget" strategy for the next X bytes, it's not as though we're dealing with a full blown multitasking friendly CPU or OS. Typically (or so it seems to me) if you have an ability to tell the hardware "transfer the next X bytes without the use of the CPU" you would generally want to signal the main system when that process is complete so that it can set up the next transfer. Given the typical implementation of the kernal, it would wind up sitting in a busy loop waiting for the signal that the transfer is done.



I see several possibilities:



1. There aren't enough logic cells available to add the functionality to support both CPU and VRAM delivery options.



2. There are enough logic cells available but it increases the complexity meaning there is another thing that could go wrong, and it doesn't really improve CPU performance because it still has to wait for the delivery notification.



3. There are enough logic cells available and the kernal becomes more complex due to dealing with an interrupt driven SPI interface so that the CPU can go on about other business while waiting for the background VRAM transfer to complete.



In a perfect world, sure, it would be nice to support this mode. I think the general purpose approach is more than adequate for most tasks, even if it isn't optimal for loading into VRAM. It's not like sales of the C=64 were too negatively impacted by its slow IEC bus protocol.



The bigger challenge with such functionality may be VRAM contention. Based on the way the sprite composer works, I suspect that the VRAM is 32 bits wide clocked at 25MHz. It isn't clear what timing guarantees VERA provides; a random read requires at least two bus operations which the CPU cannot do in less than 6 or 8 cycles - I forget exactly - however a bus mastering expansion card could do those two operations in exactly two bus cycles giving us roughly 4 cycles @ 25MHz from writing ADDRx until the data needs to be on data bus without violating tDSR (maybe only 3 depending on the latency of the bus transceivers) - unless VERA can bus master and assert RDY#. The bus mastering story with X16 isn't quite clear so I am suspecting that VERA doesn't do that.

This is primarily a problem for handling random reads from the system bus; sequential reads can probably be anticipated. Writes could be posted to alleviated VRAM pressure, but that's only meaningful if the posted write FIFO can drain during HBLANK.

I could see a SPI-to-VRAM mechanism improving performance of some specific/niche activities; e.g. you could stream frames from the SD card directly to VRAM for video playback. Not sure that would be enough to justify the complexity though.

Scott Robison
Posts: 952
Joined: Fri Mar 19, 2021 9:06 pm

Getting data to/from the X16

Post by Scott Robison »



46 minutes ago, Wavicle said:




I could see a SPI-to-VRAM mechanism improving performance of some specific/niche activities; e.g. you could stream frames from the SD card directly to VRAM for video playback. Not sure that would be enough to justify the complexity though.



Agreed.

Ed Minchau
Posts: 503
Joined: Sat Jul 11, 2020 3:30 pm

Getting data to/from the X16

Post by Ed Minchau »



4 hours ago, Scott Robison said:




Agreed.



 


5 hours ago, Wavicle said:




I could see a SPI-to-VRAM mechanism improving performance of some specific/niche activities; e.g. you could stream frames from the SD card directly to VRAM for video playback. Not sure that would be enough to justify the complexity though.



See, that was my incorrect assumption when I made video demos for the x16.   It seemed logical to me that transfer from SD card to VRAM would be faster than 140kb/s rather than slower.  So that's exactly what I was doing, loading tilemaps and palettes directly from SD card and playing them at 20 fps. Well, it won't work on the actual hardware. 

It's just something that wasn't explicitly stated in the documentation that loading to VRAM is slower. No mention of that speed at all, actually. 

BruceMcF
Posts: 1336
Joined: Fri Jul 03, 2020 4:27 am

Getting data to/from the X16

Post by BruceMcF »



57 minutes ago, Ed Minchau said:




 



See, that was my incorrect assumption when I made video demos for the x16.   It seemed logical to me that transfer from SD card to VRAM would be faster than 140kb/s rather than slower.  So that's exactly what I was doing, loading tilemaps and palettes directly from SD card and playing them at 20 fps. Well, it won't work on the actual hardware. 



It's just something that wasn't explicitly stated in the documentation that loading to VRAM is slower. No mention of that speed at all, actually. 



The only reason I could see for it being SLOWER is to reduce the size of the binary, by reusing a load to RAM routine and then reuse a copy from RAM to "VRAM" routine ...

... IOW, a bespoke routine ought to be roughly the same for "LDA SPIDATA : STA PORTA" as "LDA SPIDATA : STA (TARG),Y". If the operation is too FAST, so that when the "Ready" flag is checked, it fails the first time for the one clock faster transfer and succeeds for the one clock slower one, a NOP would tune that up.

But that wouldn't entail a Vera design change, that would entail a Kernel code change. Someone who can make out what is happening with ca65 assembly code could look at what is happening with the VRAM load and see if they can come up with a revision that speeds it up and make a request to pull that version of the code.

rje
Posts: 1263
Joined: Mon Apr 27, 2020 10:00 pm
Location: Dallas Area

Getting data to/from the X16

Post by rje »


Would the pi1581 give a reasonable data transfer rate?  Assuming the x16 could do fast serial?

BruceMcF
Posts: 1336
Joined: Fri Jul 03, 2020 4:27 am

Getting data to/from the X16

Post by BruceMcF »



On 12/5/2021 at 6:25 PM, rje said:




Would the pi1581 give a reasonable data transfer rate?  Assuming the x16 could do fast serial?



Original C64 1541 mode was 0.35KB/second ... C128/1581 fast serial was 1.6KB/s ... burst mode was around 4KB/s.

Unless you are filling up a big chunk of High RAM, burst mode would be "fast enough" for most purposes, but AFAIU, they would have to connect the IEC SRQ line to a VIA serial shift register pin.

As a guess, so long as the SRQ line is hooked up to a VIA GPIO, the X16 might be able to bit-bang fast mode.

xanthrou
Posts: 165
Joined: Mon Jan 25, 2021 11:57 am

Getting data to/from the X16

Post by xanthrou »


Irrelevant question, but would the X16 support MMC cards, since most SD sockets do have backwards compatibility with MMC cards?

BruceMcF
Posts: 1336
Joined: Fri Jul 03, 2020 4:27 am

Getting data to/from the X16

Post by BruceMcF »



On 12/7/2021 at 11:56 AM, xanthrou said:




Irrelevant question, but would the X16 support MMC cards, since most SD sockets do have backwards compatibility with MMC cards?



Only MMC cards that support SPI mode, since the X16 uses SPI mode to access the card.

martinot
Posts: 115
Joined: Fri Aug 21, 2020 3:32 pm

Getting data to/from the X16

Post by martinot »



On 1/3/2021 at 1:38 AM, m00dawg said:




I can't remember why but as I recall there were some good reasons for dropping Serial UART from the Vera. I'm trying to remember this from a post on FB (though I no longer use FB so can't go reference it). Anyways! We had an interesting conversation on the Unofficial Discord about getting data to/from the X16. For development, having to constantly remove and insert the SD card might get old. And likewise, transferring files (like maybe tracker files, text files, etc.) to/from another machine could be convenient. This is especially true given SD cards aren't really meant for long-term storage - if you don't power them up every so often, particularly as wear due to writes, the data can be corrupted. This has happened to me a time or two with a Raspberry Pi I only use during Christmas (for a light show, of course!).



So, I'm trying to think aloud about what sort of options might be usable. Of course doing something with the User Port is an option, eventually I'd expect someone is going to implement a serial or even a NIC on an expansion card, then there's IEC Serial. The only serial work I've done is RS232 and I was pondering something like ADTPro where files can be copied over serial with the help of apps on both sides. That, of course, requires RS232 so currently isn't a viable option, though IEC serial presents a potential option, maybe, with using the IEC to Parallel interfaces on PC (I haven't used one in a de...err several years we'll say).



The thought of a Wifi-enabled SD card was tossed around too. I've never used one but that would be an option.



And then the user port might be able to be used for some sort of soft-serial type of solution?



Any other thoughts folks might have? Note, this isn't a dig on the design or lack of serial - this isn't a thread meant to wish for a UART on the X16 or anything. Not trying to be a jerk haha I just didn't want this thread to spiral into a wishlist thread as often happens many times (e.g. whenever someone mentions the word "sound").



I'm just trying to think aloud with the options we have currently and what might be possible or what other folks are thinking about as a potential solve?



Serial port would be good, but why not Ethernetport?

TomXP411
Posts: 1783
Joined: Tue May 19, 2020 8:49 pm

Getting data to/from the X16

Post by TomXP411 »



On 12/21/2021 at 1:57 PM, martinot said:




Serial port would be good, but why not Ethernetport?



Ethernet requires a controller and code to support a network. That's a lot of code to add to the system ROM.

Having said that... I really wish the system had both a real serial UART and a network interface of some sort. In fact, I'm really warming to the idea of Scott's PI2IEC. After using my MiSTer with a built in FTP server, it's amazingly easy and fast to get programs over to my various retro platforms. Just open up WinSCP, drop the files in, and you're done. 

 

 

Post Reply