CPCWiki forum

General Category => Amstrad CPC hardware => Topic started by: zhulien on 16:14, 08 May 16

Title: CPC / Raspberry Pi Bridge Card
Post by: zhulien on 16:14, 08 May 16
Hi Everyone...


I am Julian, I am a very inactive active CPCer from the start  I have much to do...


Anyway, I have previous suggested the following to a couple of people and thought now is time to suggest to this forum and see if there is any interest.

I am wanting someone to partner with to create a hardware expansion for CPC.  Mostly it will be funded by me.

HW Requirements:


- as an Mother X4 expansion card - perhaps it can fit in the 5th slot (that is the through connector) so 5 cards can fit...
- lets the CPC user connect a Raspberry Pi directly to the expansion port
- if the cost is marginal to allow two Pi's to connect to the expansion port at the same time, will consider this


current Work In Progress circuit:
https://docs.google.com/spreadsheets/d/1bS1CLDIN0jPP3GI2pCcTU7_VIf2otQ10bVm-NL0F2eQ/edit#gid=0


SW Requirements:


- build a minimal communication method (API or just a pattern) between CPC and Pi C application.  From this pattern we can then pass data back and forth and work from there, whether the CPC is a dumb terminal to the Pi, or whether there is a greater integration through RSXs



[Added 20170128...
Ultimate Goal of this board when a Raspberry Pi 3B is attached:



- 16kb Memory Mapped I/O Space
- 512Mb General Use RAM 8192 x 64kb blocks accessed as 32768 x 16kb blocks (available in addition to other CPC RAM expansions) usable for data and turbomode
- ARMv8 Native code libraries callable from CPC covering:
   - text, window and 2d graphics primitives
   - opengl 3d graphics
   - video and mp3 playback
   - keyboard, joystick & mouse I/O
- Z80 CPU emulation to run code in turbomode (with fallback to standard CPC if PI board is not present)
- RSXs to make use of the above from BASIC
- a CPC ROM to make the above facilities more easily available without taking up too much of the CPC's RAM

...]


Possible Uses:

- run Z80 emulators on the Pi in parallel to CPC and offload Z80 code
- play NES and other games on your Amstrad CPC (ok, on the Pi... but do we only support Pi video? CPC video is it possible?  or... passthrough the video Genlock style?)
- use the Pi's ethernet from the CPC indirectly thereby gaining internet access
- use the Pi's USB and even HDMI as additional modes on CPC
- use the Pi's audio capabilities from the CPC
- use other PI facilities and RAM (as a RAM drive) from the CPC indirectly


Funding:


- well, I did say 'mostly' funded by me, so this can be done in a few ways.  I am not limited to the following suggestions but I am happy to kick off the project...
    - i fund it 100% and i retain 100% of profits from sales of it (I don't expect to make money from it, but recoup some of my costs if not all)
    - it is funded by myself in conjunction with the partner i can find

Other requirements:


- for me to fund you, you must have proven to have already created a commercial piece of CPC hardware or similar.

I am not a bottomless pit of money but just something fun for me to give to the CPC community (if it cannot even come even with cost)...  I am a software guy, not a hardware guy


Now, it is all in fun but if done in a pretty simple way as Pi's get upgraded we can replace them with newer Pis using this same bridge card.


Anyone want to discuss with me?


Julian (From Melbourne, Australia)
Title: Re: CPC / Raspberry Pi Bridge Card
Post by: Gryzor on 18:21, 08 May 16
This is an interesting proposition. But, I think, before discussing funding etc we need to discuss what is feasible and useful with this setup...
Title: Re: CPC / Raspberry Pi Bridge Card
Post by: steve on 20:54, 08 May 16
They used to link a CPC to a PC for software development, maybe the Pi could perform the same functions as the development PC?, secondly if we want doom like games on the CPC the Pi could function as a graphics terminal like CP/M required.
Title: Re: CPC / Raspberry Pi Bridge Card
Post by: zhulien on 21:26, 08 May 16
Well if the hardware can be interfaced in a fairly efficient way so that the cpc can leverage off the pi hardware and the pi can be easily connected or removed so it is easily upgradable to future pi's then i am happy to fund it... of course to a negotiated amount. I can think of several cheap ways to connect them but lets see what ideas come up that are feasable. If no dma it could still be feasable for fun projects and i also like the idea of a self hosted cross dev system...  if it can be done at the right price i will fund it for myself to have 2...

Perhaps if someone wants to opensource the hardware design and work on a budget if it is worth to go ahead then maybe that would be better? I am thinking a 4 figure budget... not including cents.  Not quite like a comellion card for c64 but a good way to let lots of software experiments happen... could run a full lamp stack c dev env emulated cpus hardware access etc cheaply from the cpc...
Title: Re: CPC / Raspberry Pi Bridge Card
Post by: Bryce on 10:32, 09 May 16
Hi Zhulien,
          first off, DMA isn't possible, the CPC has no provision for this. Next I'd suggest you take a look at the 50 pin expansion connector to see how much access this port actually allows. Other than the data bus, address bus and a few control signals it doesn't offer very much else. You could map i/o pins from the RPi to every pin which would then allow you to emulate things like ROM or RAM expansions. You can also pass data between the two devices, however it would always require software to be running on the CPC side to handle this, there is no real way to control the CPC externally. What the Pi then does with the data is up to you.

Bryce.
Title: Re: CPC / Raspberry Pi Bridge Card
Post by: zhulien on 12:05, 09 May 16
I have looked at the cpc expansion bus but as said im not a hardware guy. Elementary at best. If we just pligged a few io ports of the pi to the address and databus of the cpc what throughout is likely possible? Yep i am fully expecting to code on the cpc side and the pi for them to communicate.  I can code both sides actually pretty well.
Title: Re: CPC / Raspberry Pi Bridge Card
Post by: Bryce on 12:15, 09 May 16
I'm a pure hardware guy, not sure what the theoretical max speed is, but I'm sure some of the coders here will be able to tell you. It will of course depend on what the Z80 needs to do between sending bits.

Bryce.
Title: Re: CPC / Raspberry Pi Bridge Card
Post by: zhulien on 12:34, 09 May 16
well... let's see if anyone want's to charge out their services to build the card so that everyone who wants one (which is at least me twice) can get one and cheaply (not including cost of dev and production) upgrade their CPC in a unique way...
Title: Re: CPC / Raspberry Pi Bridge Card
Post by: zhulien on 17:59, 30 July 16
Just bumping this as there is no job board in the forums... id rather someone with cpc hardware creation experience than someone who has never seen a cpc... the job offer is still opened.
Title: Re: CPC / Raspberry Pi Bridge Card
Post by: zhulien on 16:39, 01 August 16
I have found someone locally here who will be quoting me on the project over the next week or two.  The project has now been scoped as:


- a card in the Mother X4 form factor that has some form of RAM on it that will be 16kb in size (usable) that can be switched into the CPC at #4000 like a Multiface 2/dkTronics but likely different IO port.  It will be directly read/written to by the PI2 or PI3 (both have same pinouts).  Pi will see 16kb at this stage we are considering a 2 stage write process vs paging, so that we can get away with 9 GPIO lines for the full 16kb and 8 GPIO lines for the data, 9 left for control.
- prove CPC / PI stability with constant transfers of data both ways.


After that, *if* we get as far as a production run, the card will be offered for sale below AU$100.  I won't be expecting to make back my 4 figure investment, but it is all in fun - I want two even if i don't sell any more.


Software goal beyond that: HDMI, Ethernet, RAMDISK, WiFi, Analog IO ports, Audio, Video... whatever other wonderful PI hardware we can create an Amstrad CPC API to access...


Will keep you posted...

Title: Re: CPC / Raspberry Pi Bridge Card
Post by: Duke on 19:34, 01 August 16
Cool 8)


Offtopic: Please check your messages regarding M4 boards....
Title: Re: CPC / Raspberry Pi Bridge Card
Post by: Gryzor on 14:30, 08 August 16
This sounds so cool. Hopefully it's not set in the realms of dreams...
Title: Re: CPC / Raspberry Pi Bridge Card
Post by: zhulien on 22:24, 11 August 16
Amiga 600 has the vampire 2 card and c64 has the chameleon... do you think an fpga on the cpc if it pushes up the price is worth the extra cost vs a pi bridgeboard?  For me coding with the pi solution is easier and opens up lots of possibilities that a pure fpga might not... unless the fpga was also the bridge to the pi... best of both worlds but what cost would be acceptable to the cpc community?

For a PI bridgeboard i am hoping to keep the cost below au $100... for use with a Pi 2 or Pi 3...

But if adding an fpga likr a cyclone?  In small qty maybe it will almost double that cost...

Gryzor... if someone wants to be paid to build the card then it will go ahead if we can agree on a cost...  i have one person in the process of quoting but will also need to manage his time between this project and a double degree at uni...

Title: Re: CPC / Raspberry Pi Bridge Card
Post by: TFM on 23:09, 11 August 16
What exactly could be done with a Rasp-PI connected to the CPC?


I mean, is there already some software on the PI which allows to to some things? What could it be?


I don't have one, so I have to ask.  :)
Title: Re: CPC / Raspberry Pi Bridge Card
Post by: Bryce on 23:39, 11 August 16
Amiga 600 has the vampire 2 card and c64 has the chameleon... do you think an fpga on the cpc if it pushes up the price is worth the extra cost vs a pi bridgeboard?  For me coding with the pi solution is easier and opens up lots of possibilities that a pure fpga might not... unless the fpga was also the bridge to the pi... best of both worlds but what cost would be acceptable to the cpc community?

For a PI bridgeboard i am hoping to keep the cost below au $100... for use with a Pi 2 or Pi 3...

But if adding an fpga likr a cyclone?  In small qty maybe it will almost double that cost...

Gryzor... if someone wants to be paid to build the card then it will go ahead if we can agree on a cost...  i have one person in the process of quoting but will also need to manage his time between this project and a double degree at uni...

To interface between a Pi and the CPC requires nothing more than an address decoder and some line buffering. Using an FPGA to do this is cracking a nut with a sledgehammer.

And as TFM just said... But why?

Bryce.
Title: Re: CPC / Raspberry Pi Bridge Card
Post by: cpc4eva on 23:43, 11 August 16
Hi Everyone...

I am Julian, I am a very inactive active CPCer from the start  I have much to do...

Julian (From Melbourne, Australia)


Julian Cassin ?
Title: Re: CPC / Raspberry Pi Bridge Card
Post by: zhulien on 06:13, 12 August 16
What exactly could be done with a Rasp-PI connected to the CPC?


I mean, is there already some software on the PI which allows to to some things? What could it be?


I don't have one, so I have to ask.  :)

New hdmi screenmodes.  Cross development hosted in the cpc to build direct to cpc ram. USB. Ethernet. Wifi. Cpu power. Can use the cpc as a terminal for the pi and vice versa... or complete hybrid software...
Title: Re: CPC / Raspberry Pi Bridge Card
Post by: zhulien on 06:13, 12 August 16

Julian Cassin ?

Yes
Title: Re: CPC / Raspberry Pi Bridge Card
Post by: TFM on 23:36, 12 August 16
New hdmi screenmodes.  Cross development hosted in the cpc to build direct to cpc ram. USB. Ethernet. Wifi. Cpu power. Can use the cpc as a terminal for the pi and vice versa... or complete hybrid software...

The Berry as an terminal? That's an interesting idea for sure. Just thinking if the Pi fits in the case of the CPC...  ;)


Maybe there are f.e. some math libraries on the Pi already to allow it to be a math co-processor. Or some kind of intelligent device.

Title: Re: CPC / Raspberry Pi Bridge Card
Post by: zhulien on 08:36, 24 August 16
Hi everyone. I got my 6128 plus up and running again after a long vacation (he was asleep in the cupboard for many years).  Ive ordered a couple of cpc wifi cards and have a couple of neat projects under way with them... but aside from that.  I have decided to look first at the fpga options i have.  Currently i have had a terasic trex and used to program my c-one all those years back so have a little experience in fpga programming (but not a lot). Trex is out of production but tersasic DE0 looks like a good replacement candidate... it has lots of IOs... perhaps enough to cover the whole cpc bus and more... and floppy? But it isnt really a cpc hardware.  Still if i can get it to communicate with cpc i should also be able to use it as a bridge to the PI.  Benefits being that... yes you can create custom cores in the fpga but also in software entirely on the PI side as an option. 

Aside from the terasic boards can anyone recommend an alternative for this tentatively called "Schwarzenegger" board that i should investigate first?
Title: Re: CPC / Raspberry Pi Bridge Card
Post by: Ygdrazil on 16:35, 07 September 16
Hi there


Any progress on the CPC-RPI bridge card?


This would really come in handy :-)


Regards,
/Ygdrazil
Title: Re: CPC / Raspberry Pi Bridge Card
Post by: zhulien on 18:46, 08 September 16
nope... i have a person willing to take on the project who is an honors uni student but have to wait... unless someone else volunteers.   


I have been in the mean time looking at 5v tolerant FPGAs - seems there are a few, but not too many - it's a lot of voltage levelers if i was to level 50 pins of the expansion port for a 3.3v FPGA, even if they are 8bit ones, that's like 7....
Title: Re: CPC / Raspberry Pi Bridge Card
Post by: zhulien on 08:18, 09 September 16
just a minor update... i have found a possible stopgap solution to interface a PI with the CPC - but am working on getting a quote from the guy who makes those boards to make it less complex and more 'CPC'... to bring the costs down. if he cannot or won't or we cannot agree to make it go forward, it 'could' be the basis of a development board to produce the final solution... or at least as a self-hosted PI->CPC cross compiling solution (I believe the hardware will work out of the box - but isn't the cheapest least complicated solution).
Title: Re: CPC / Raspberry Pi Bridge Card
Post by: zhulien on 08:25, 09 September 16
For an FPGA solution... although it doesn't readily have PI connectivity - I am thinking the GODIL40_XC3S500E DIL FPGA module (40 pin DIL) might suit.  Almost sounds to good to be true, unless i misread the docs wrong... pop out the Z80, wire in this one with the appropriate core (with some awesome extras) and you have a super fast (for new software) but compatible with old software turbo board for CPC...

Z80 drop-in replacement FPGA board
https://shop.trenz-electronic.de/en/TE0261-00B-GODIL40_XC3S500E-DIL-FPGA-module-40-pin-DIL?c=97 (https://shop.trenz-electronic.de/en/TE0261-00B-GODIL40_XC3S500E-DIL-FPGA-module-40-pin-DIL?c=97)
http://www.oho-elektronik.de/pics/UM_GODIL.pdf (http://www.oho-elektronik.de/pics/UM_GODIL.pdf)

Graphics drawing accelerator cartridge creation - Commodore 64 (C64) Forum (http://www.lemon64.com/forum/viewtopic.php?p=734625&sid=998aa4ad4c43812a0b5e07160edf8ebc)
Ruud's Commodore Site: RB6502 (http://www.baltissen.org/newhtm/rb6502.htm)

The 50 pin version would give 10 additional IO ports for PI integration or other... need to create a socket adapter too for this which would raise the profile of it... i think i like the 40 more because of this...
https://shop.trenz-electronic.de/en/TE0262-00B-GODIL50_XC3S500E-DIL-FPGA-module-2-x-50-pin-IDC (https://shop.trenz-electronic.de/en/TE0262-00B-GODIL50_XC3S500E-DIL-FPGA-module-2-x-50-pin-IDC)

and a suitable core?
Projects :: OpenCores (http://opencores.org/project),a-z80

I'm almost sold on this one...
Title: Re: CPC / Raspberry Pi Bridge Card
Post by: zhulien on 08:24, 13 September 16
I have ordered my Xilinx programmer and a couple of GODIL's to see what I can do... will keep you posted
Title: Re: CPC / Raspberry Pi Bridge Card
Post by: Bryce on 10:20, 13 September 16
I have ordered my Xilinx programmer and a couple of GODIL's to see what I can do... will keep you posted

Did you order a real Xilinx programmer or a Chinese knockoff? If it's a Chinese one, be very careful not to click yes if it asks you to update the firmware!

Bryce.
Title: Re: CPC / Raspberry Pi Bridge Card
Post by: zhulien on 11:17, 13 September 16
I ordered a real one, sadly they aren't cheap (the USB cable 2) but luckily got a good price on ebay... with luck it should be working fine as advertised.

the plan:

- put a z80 core into the GODIL and see if CPC works as per normal (this is the biggest risk of it not working before enhancing the core)

- enhance the z80 core to have a turbo mode as follows:
    - new instructions switch between normal and turbo mode and to copy RAM or perhaps just page the internal FPGA RAM at slow CPC speed for it to do normal speed memory transfers
    - normal mode, it executes code from normal CPC RAM at normal CPC speeds with normal Z80 behaviour using the external clock
    - turbo mode, it executes code inside the FPGA with RAM also inside the FPGA at fastest possible using an internal clock but pretending to satisfy the rest of the CPC's timings with nop behaviour

- connect the PI to the additional 4 I/O pins

Can anyone see any flaws in this approach?
Title: Re: CPC / Raspberry Pi Bridge Card
Post by: Gryzor on 13:28, 13 September 16
Did you order a real Xilinx programmer or a Chinese knockoff? If it's a Chinese one, be very careful not to click yes if it asks you to update the firmware!

Bryce.


Oh, the ones that get bricked? 
Title: Re: CPC / Raspberry Pi Bridge Card
Post by: Bryce on 14:58, 13 September 16

Oh, the ones that get bricked?

Yup, the new Firmware bricks them.

Bryce.
Title: Re: CPC / Raspberry Pi Bridge Card
Post by: TFM on 18:48, 13 September 16
If it's a Chinese one, be very careful not to click yes if it asks you to update the firmware!


Why?
Title: Re: CPC / Raspberry Pi Bridge Card
Post by: Gryzor on 12:08, 14 September 16
If I recall correctly from what Bryce had told me many moons ago, the firmware is the original one and it can distinguish between an original device and clones, so it'll brick the clone. Hope I remember this correctly.
Title: Re: CPC / Raspberry Pi Bridge Card
Post by: zhulien on 18:01, 24 September 16
My xilinx programmer arrived... now awaiting the 2 GODIL fpgas...


2 GODIL's arrived :D 


First to work out which way they go in and ensure they are safe by default in a CPC6128 (I'd rather that die than the Plus)...


will keep you all posted, if an FPGA can truely clone a Z80 I can see no reason it won't work at least if the core is compatible enough.
Title: Re: CPC / Raspberry Pi Bridge Card
Post by: zhulien on 13:12, 27 September 16
Here is a good article on ICE on the GODIL Home · hoglet67/AtomBusMon Wiki · GitHub (https://github.com/hoglet67/AtomBusMon/wiki)

I am hoping to give this a try this week if i get the time.  It will prove if it can work or not.  Interestingly,  this page shows that it can work on a Spectrum +2 but not a Spectrum 48K (I don't know much about spectrum board revisions) - so there is still some hope that some CPC can run a GODIL.  Now apparently there is about 40kb of RAM in it which could be used as a fastRAM.  There are other possible uses for a GODIL if it works too, such as... it could be used to run things like gameboy games on a CPC - since even Minimig can run on the same FPGA core it seems maybe other CPU cores could be in there.  Anyway, first see if the things work in some form on a CPC, then we can play with the ideas.

ICE T80 · hoglet67/AtomBusMon Wiki · GitHub (https://github.com/hoglet67/AtomBusMon/wiki/ICE-T80)
Title: Re: CPC / Raspberry Pi Bridge Card
Post by: zhulien on 06:30, 14 October 16
things a bit slow here, i ended up ordering 2 ZIF sockets and also a few Z80 sockets because the GODILs are quite expensive and don't want to lose pins in the Z80 socket.  The ZIFs have arrived, not yet the Z80 sockets - Seems I need to build a small breadboard circuit to program the GODIL the first time to ensure no wrong voltages get applied to the CPC.
Title: Re: CPC / Raspberry Pi Bridge Card
Post by: zhulien on 14:44, 26 January 17
I have put together what i think would be the GPIO mappings from a Pi to CPC.  A couple of things I am unsure of on the CPC side.  I am hoping one of you with more CPC hardware knowledge than me would be able to give some feedback.


https://docs.google.com/spreadsheets/d/1bS1CLDIN0jPP3GI2pCcTU7_VIf2otQ10bVm-NL0F2eQ/edit?usp=sharing (https://docs.google.com/spreadsheets/d/1bS1CLDIN0jPP3GI2pCcTU7_VIf2otQ10bVm-NL0F2eQ/edit?usp=sharing)


The Pi Zero or Pi B+ has 40 GPIO ports we can use:


- For the Pi to be able to map into the CPC address space, have I missed any CPC bus signals we need? 
- I have hijacked 2 address lines (2 lower bits of the upper byte) and set them always high, is that ok?
- Does hardware have to somehow detatch from all bus activity if it isn't the active hardware, I am guessing i have missed something here?  Is there like a latch that if this device sees an IO request for it's port, then it switches in or something?


I am hoping the Pi could map into the address space, preferably as a 16kb chunk (8kb if i have to forego another bit, or even 4kb forgoing another 2 bits)...  There are 4 Level Converters to allow the Pi GPIOs which are 3.3V to connect to the 5V CPC.


If there is an interest in a Pi Zero or such connected to CPC, then maybe this could be worked as a MX board, but this is early days...
Title: CPC / Raspberry Pi Bridge Card - the ΧΦΧ Board
Post by: zhulien on 21:02, 27 January 17

Below is an example PI logic.  My only hardware projects have been dumb things in the past with switches light bulbs etc.


As I have never simulated hardware before, I am guessing the behaviour but trying to think in hardware terms.  I usually think in software.
Of course, with the lack of GPIOs I can't simulate a DkTronics memory expansion, but some other wonderful things are possible.
I am assuming mapping it always into #8000 - #C000.  This allows quick data transfers from normal video memory as well as 16k banked RAM within #4000 - #C000.
In my questions at the bottom, if I need BUSAK, then I will need to sacrifice another GPIO of the address space, unless I am better to replace RAMDIS with BUSAK.  Also if the clock has a use, eg: timing PI operations with the CPC?


My thoughts are as follows... Allowing the PI to have mapped I/O as well as memory, I can use the memory for quick transfers in a similar way Duke's Wifi Card does it from using ROM space of the CPC.  The I/O will tell the PI what I want to do, then, the memory will let me read and write chunks of data.


Am I on the right track so far?


[logic removed as will change until it is right]



questions:   can IORQ and MREQ be high at the same time?
         do i even need RAMRD if I don't need to know about ROM state?  I can reclaim a bit if I don't need RAMRD...
         when the PI sends data to the CPC, how long does it need to keep the databus high?  How does it know when the CPC got the data? BUSAK?  Maybe BUSAK is more important than RAMRD?


Here are the level converters I am thinking of using.   They are not expensive, and needs 4 of them per board.  http://www.ebay.com.au/itm/301893252205?_trksid=p2060353.m1438.l2649&ssPageName=STRK%3AMEBIDX%3AIT (http://www.ebay.com.au/itm/301893252205?_trksid=p2060353.m1438.l2649&ssPageName=STRK%3AMEBIDX%3AIT)
Should I have any other hardware to protect the CPC or the PI?  Or just 4 of them wired to the buses and nothing else?


There are multiple PI boards with the 40 pin/28 GPIO interface.


PI 2b:      https://www.raspberrypi.org/products/raspberry-pi-2-model-b/ (https://www.raspberrypi.org/products/raspberry-pi-2-model-b/)
         900Mhz Quad Core CPU, 1GB RAM, 4 USB, Full HDMI, Ethernet, Audio, Micro SD, 3D Graphics
         
PI 3b:   https://www.raspberrypi.org/products/raspberry-pi-3-model-b/ (https://www.raspberrypi.org/products/raspberry-pi-3-model-b/)
         1.2Ghz Quad Core CPU, Wifi, Blutooth, 1 GB RAM, 4 USB, Full HDMI, Ethernet, Audio, MicroSD slot, 3D Graphics


Imagine... RSXs for BASIC and Z80 code libraries on CPC which produce awesome 3D graphics in Full HD resolution!!!  Then... I will see if Symbos will support this too ;)
Title: Re: CPC / Raspberry Pi Bridge Card
Post by: zhulien on 20:19, 29 January 17

Pi-side Logic:


PI_RAMADDR_START = #8000
PI_RAMADDR_END = #BFFF
PI_IOADDR_UNMAPPED = #0001   ; used as both the I/O address and mode status
PI_IOADDR_MEMORY = #0002   ;
PI_IOADDR_MAPPEDIO = #0003   ;
intPIMode = PI_IOADDR_UNMAPPED
blnInRead = false
blnInWrite = false
Set (ALL GPIOs) BCM0 to BCM27, GPIO0, GPIO1, GPIO5, GPIO21 to INPUT
Set GPIO_RAMDIS to OUTPUT
;Set GPIO_RAMDIS to LOW ;NOT REQUIRED?


while (1)
{
   Read (iorq) BCM25 into REG_IORQ
   Read (mreq) BCM24 into REG_MREQ
   Read (address bus) inputs BCM0-BCM15 into REG_ADDR
   Read (rd) BCM26 into REG_READ
   Read (wr) BCM27 into REG_WRITE
   
   if ((intPIMode == PI_IOADDR_MEMORY) || (intPIMode == PI_IOADDR_MAPPEDIO))
   {
      if ((REG_ADDR >= PI_RAMADDR_START) && (REG_ADDR <= PI_RAMADDR_END))
      {
         if (REG_MREQ == 0)
         {
            // PI is active and we have a memory request
            if (REG_READ == 0)   // READ REQUEST
            {
               if (!blnInRead)
               {
                  blnInRead = true   // start of read cycle
                  set GPIO_RAMDIS to HIGH
                  set (data bus) BCM16-BCM23 to OUTPUT
                  
                  // memory read requests
                  if (intPIMode == PI_IOADDR_MEMORY)
                  {
                     // read data from somewhere in PI RAMDisc memory
                     REG_DATA = readMemory(REG_ADDR);
                  }
                  else if (intPIMode == PI_IOADDR_MAPPEDIO)
                  {
                     // read data from somewhere in PI I/O memory
                     REG_DATA = readIOMemory(REG_ADDR);
                  }
                  put REG_DATA into (data bus) BCM16-BCM23
               }
            }
            else if (REG_WRITE == 0)   // WRITE REQUEST
            {
               if (!blnInWrite)
               {
                  blnInWrite = true   // start of write cycle
                  set GPIO_RAMDIS to HIGH
                  set (data bus) BCM16-BCM23 to INPUT
                  Read (data bus) inputs BCM16-BCM23 into REG_DATA
                  
                  // memory write request
                  if (intPIMode == PI_IOADDR_MEMORY)
                  {
                     // write memory to the PI RAMDisc memory
                     writeMemory(REG_ADDR, REG_DATA);
                  }
                  else if (intPIMode == PI_IOADDR_MAPPEDIO)
                  {
                     // write memory to the PI I/O memory
                     writeIOMemory(REG_ADDR, REG_DATA);
                  }
               }
               else
               {
                  blnInWrite = false      // end of write cycle, is it even a cycle?
               }
            }
         }
         else   
         {
            if (blnInRead)
            {
               if (REG_MREQ == 1)
               {
                  blnInRead = false      // end of read cycle
               }
            }
         }
      }
   }
   else if (REG_IORQ == 0)   // I/O REQUESTS
   {
      if (REG_ADDR == PI_IOADDR_UNMAPPED)
      {
         // deselect PI from address space
         ;set GPIO_RAMDIS to LOW   ; just in case it was high NOT REQUIRED?
         intPIMode = PI_MODE_UNMAPPED
      }
      else if (REG_ADDR == PI_IOADDR_MEMORY)
      {
         // select PI into CPC address space in memory mode
         intPIMode = PI_IOADDR_MEMORY
      }
      else if (REG_ADDR == PI_IOADDR_MAPPEDIO)
      {
         // select PI into CPC address space in mapped I/O mode
         intPIMode = PI_IOADDR_MAPPEDIO
      }
   }
   
   // process I/O requests based on I/O memory
   processIOMemory();
}

Title: Re: CPC / Raspberry Pi Bridge Card
Post by: arnoldemu on 20:32, 29 January 17
is your pi device a co-processor/gfx card?

CPC sends commands, and then pi processes the commands?

Pi is 3v for GPIO and CPC is 5v. Are you using a voltage converter?
Title: Re: CPC / Raspberry Pi Bridge Card
Post by: zhulien on 20:41, 29 January 17
is your pi device a co-processor/gfx card?

CPC sends commands, and then pi processes the commands?

Pi is 3v for GPIO and CPC is 5v. Are you using a voltage converter?


Yes, 4 of them for 32 GPIOs.  The PI has 40 GPIOs on the Model 3 B.  I have only a Model 1 which is not enough but am waiting for a 3B to arrive.  I am plugging the PI via the Voltage Levelers directly to the CPC bus to emulate memory as well as memory mapped I/O (of the PI's hardware).
Title: Re: CPC / Raspberry Pi Bridge Card
Post by: zhulien on 20:48, 29 January 17
Of all the CPC signals I've mapped to, what would be the next most 'useful' one that I haven't?  I have one more GPIO...


https://docs.google.com/spreadsheets/d/1bS1CLDIN0jPP3GI2pCcTU7_VIf2otQ10bVm-NL0F2eQ/edit#gid=0

Title: Re: CPC / Raspberry Pi Bridge Card
Post by: Duke on 21:52, 29 January 17
You must drive the datalines from the falling edge of RD or WR to the rising edge ( you can see all these timings in the z80 manual ).
BUSAK is no use without BUSRQ and strictly not needed, because you know by the next cycle it will release the bus, which may turn in handy if you cannot maintain I/O mapping at all times.
The important signals for your purpose is A15-A0, D0-D7, RD, WR, IORQ, MREQ, ROMEN, RAMDIS, ROMDIS, BUSRQ. Of course if you need no rom mapping, you can discard ROMEN and ROMDIS.
BUS_RESET and RESET is nice to have if you need to delay startup time.
RAMDIS or ROMDIS will need to be driven high to not drive data lines on RD and to not write to base memory on WR. There is probably more I forgot right now :)
Title: Re: CPC / Raspberry Pi Bridge Card
Post by: zhulien on 22:24, 29 January 17
I've refactored the spreadsheet so it is much more clear.  I'm now debating ROMEN and ROMDIS in please of BRST & RESET - as I have exhausted all the GPIO's I reasonably have access to.  32 of them.  Thanks for the falling edge tip, I'm sure I will get lots of bugs otherwise.  If I don't need the RESETs, then the ROM support could be useful to emulate yet another ROMBoard, but there are really good ROMBoard solutions already :D


To time the rising and falling edges, do I need to monitor the clock?  investigating... http://www.piclist.com/techref/mem/dram/slide4.html (http://www.piclist.com/techref/mem/dram/slide4.html)


Actually that explains a lot when I was wondering... how do i know when the CPU finished reading.  now I know.
Title: Re: CPC / Raspberry Pi Bridge Card
Post by: Duke on 22:51, 29 January 17
To time the rising and falling edges, do I need to monitor the clock?  investigating... http://www.piclist.com/techref/mem/dram/slide4.html (http://www.piclist.com/techref/mem/dram/slide4.html)

You don't need to monitor the clock, ideally, I don't know if PI has this, what I use on the Cortex series, is edge detectors, meaning you can setup an interrupt or event for a given gpio. I am using the event in a interrupt disabled closed loop in tight assembly, because a few too many instructions will skew the timing.
Then you just issue the instruction WFE (wait for event), do your checkings and drive/read whatever lines, WFE again for the rising edge, loop.
Of course you can also just loop after driving the data lines, while ( gpio(RD/WR/ROMEN/MREQ/ETC)== 0 ) ;
Title: Re: CPC / Raspberry Pi Bridge Card
Post by: zhulien on 00:06, 30 January 17
I updated the logic in the previous page to cater for rising and falling clock edges.  Currently i only have the original Raspberry Pi which doesn't have enough I/Os, I am waiting for the new one to arrive so can't test much really until then.


In this version, the rising and falling, for a read, I start on the falling, then finish on the rising for which the mreq stops.  For a write, since both the start and end of the cycle on on the rising, does it really matter?  I am guessing that as soon as the WR operation starts, the data is immediately available and it's up to me to do what i want with it quickly.


With IOREQ, are timings important for that?  I would have thought as long as it's the IO port I am decoding, then it's mine. 


Actually I don't need the clock, I can detect the edges of the MREQ.
Title: Re: CPC / Raspberry Pi Bridge Card
Post by: genesis8 on 00:20, 30 January 17
Use the PI as a RTC for the CPC is on your feature list ?
Title: Re: CPC / Raspberry Pi Bridge Card
Post by: zhulien on 06:16, 30 January 17
Use the PI as a RTC for the CPC is on your feature list ?


It is now :)
Title: Re: CPC / Raspberry Pi Bridge Card
Post by: Ygdrazil on 11:30, 30 January 17

Hi Zhulien


Great news! As a big fan of the RPI and CPC, the CPC-RPI bridge is the project. Was thinking of doing something like this for a long time!


How is the bridge mounted? On the expansion bus (with additional pins) or between the CPC motherboard and the Z80? 


Keep up the good work :-)


Regards,
/Ygdrazil


It is now :)
Title: Re: CPC / Raspberry Pi Bridge Card
Post by: zhulien on 12:23, 30 January 17
Expansion bus. With 40 gpios mapped for now
Title: Re: CPC / Raspberry Pi Bridge Card
Post by: zhulien on 20:12, 02 February 17
My pi 3b arrived so just waiting for the voltage levellers...


In the meantime some ideas I would like to consider...



Pi hardware exposed:‎

Hdmi FullHD
3d graphics‎
Audio
Mp3‎

Wifi
Bluetooth
Ethernet

Rtc
‎Sdcard

Simulated cpc hardware:


512mb Ram expansion‎

Memory mapped io to pi for hardware activation and control of other operations.‎

Can register jumpblocks to pi. Eg register an address with a target of a call that can be synchronous or asynchronous. Sync will basically loop to itself until pi is ready then pi will change the loop to a return. Async will just be a return immediately but it triggers a process. The process can be read later.. or ignored. Both cases registers are passed into the jumpblock.‎


Transformations. Eg... register a transformation to be triggered based on a call or mapped io. A transformation could be eg... fill memory with a sine wave xor 2 memories multiple can then be triggered by using an ldir. I wonder how much processing can be achieved in a single cpc instruction cycle?


Title: Re: CPC / Raspberry Pi Bridge Card
Post by: zhulien on 09:32, 04 February 17
Although i have access to 32 gpio ports 4 are on this ugly flat camera connector plastic ribbon type thing... 3 i can forego but 1 i cannot which is ramdis. 


Are there ICs that eg... block a signal in a direction so i can connect ramdis that is output and and the rd signal that is always input to the same gpio? So that when the gpio is in it reads rd... but if it is out it write to ramdis? Ramdis needs to be kept high on out... so is such an ic a latch?
Title: Re: CPC / Raspberry Pi Bridge Card
Post by: zhulien on 03:49, 08 February 17
I believe the only part i am waiting for now is the voltage levelers.  Our local electronics stores only sell single line voltage levelers which I would have to use 30+ of if i got them.  That would make a very busy prototype board.


I am now considering the following... what do you think?


16 address lines, all input to PI
8 data lines, I/O to and from PI
RAMDIS (necessary) output from PI
RD, WR to control reading and writing
BRST i am considering attaching to the same GPIO as address line 0, with directions filtered by diodes (can anyone see any issues with this?)
this leaves 1 GPIO left for something else... *and* more importantly I don't need to use the horrible flat cable camera GPIOs of the PI... Just a single 40 pin ribbon cable to connect.


At first I thought I need MREQ and IORQ, but now I don't believe I do, because the PI can monitor everything.  It only matters if i want to know the difference between an I/O request and a memory request and I cannot see why I need to since I won't be sharing address space between the MREQ and IORQ anyway within the PI.


Now here is an interesting thing... If I extend the 40 pins to multiple sockets... I can cater for multiple PIs at once with only the cost of sockets added and board size I believe.  So... why do this?  In theory as follows.


All PIs are monitoring the bus.  Consider if PIs are used for transformations.  Multiple PIs can perform different transformations of the same data at the same time with a simple LDIR.  Consider using a 3d library.  The main PI outputting the 'front' display, subsequent PIs outputting peripheral displays with no additional CPC overheads.  Just like Gran Turismo on the PS3... Maybe we could see a Star Strike 2 one day with peripheral displays... or a Castle Master or similar?


OK, this is really GT5 on PS3 (not the 6128Plus :D )  https://www.facebook.com/whateverjulian/videos/285077698521642/ (https://www.facebook.com/whateverjulian/videos/285077698521642/)


How will I know to enable the PI or disable it and not be conflicted with every other memory read/write occuring on the CPC?  I can make sure a particular 'pattern' is in a part of memory to activate the PI... which from a PI's perspective would be a simple string compare.  ie: if ALLPISAREGO is sent to the bus in sequence (can be an LDIR too)... initialising it backward so it doesn't trigger the PI by default...


I am also investigating Spectrum, Sega, PCW and MSX options for the hardware too.  So far I believe the Spectrum, Sega, PCW will be very trivial to support in the same hardware.  The MSX I am still investigating to do with CS1, CS2 and BUSDIR...
Title: Re: CPC / Raspberry Pi Bridge Card
Post by: zhulien on 22:10, 10 February 17

Just an update because someone in the CPC accelerator thread suggested that everyone should make something and not just talk.  Our projects are being researched, funded and developed through my company and will be likely released in time where the research has proven (hoping sometime this year).  We had advertised locally as well as directly to a few community members to have the hardware work contracted to them, but they had turned us down due to other commitments - so we are taking on this ourselves.

We now have now an abundance of 6128 Pluses, CPC 6128s, a 464 and a few 664s for testing. I got my first PI 3B a couple of weeks ago, GODIL FPGAs, and JustCPC 128ks and all especially for such developments as well as a new PCW, PCW16 and MSX2.  Initial development focuses on CPC as that is what we are most familiar with - we are also mainly a software team - much of our code will be portable to the other Z80 systems.

Some products/projects will be fully open, in the public domain with source code provided (as with the 8BML, VB6 Cross Compiler) and some will be sold but as affordable as possible because we want every CPC owner (and more) to have a new Graphics card with parallel processing capabilities, acceleration, and a few other bells and whistles. We have chosen the PI bolted onto the CPC directly as the PI over 3 generations... have remained backward compatible with their PIs - so our hope is that future upgrades will be possible and inexpensive.

I am waiting still for a few more components to arrive that cannot be bought locally in the electronics shops (Jaycar doesn't really sell much electronic components anymore).  We have more plans for the PI than I have stated here but we are excited still and will update as we progress.

Will it be a CPC if it has a graphics card?  Well... is a PC a PC if you use cards instead of all the onboard features? Definitely!!!  In practice, on the CPC... a Graphics Card won't retarget existing software (CP/M and BASIC could be possible to retarget), but that doesn't mean we all can't have fun coding on our CPCs doing new things in Z80 which we all know and love.

As for the VB6 Cross Compiler... that is the only project that is currently inactive, because we could not find someone competent in Z80 code generation willing to finish it off.  We can and in time we might... but it is the lowest priority of all the projects at this time.
Title: Re: CPC / Raspberry Pi Bridge Card
Post by: keith56 on 04:01, 11 February 17
This sounds an fascinating and mind boggling project! I can't say I understand much of the technical stuff you've described here, but I certainly wish you luck with it, and will be interested in getting my hands on the final product at what ever time it is ready!

Good luck with such an ambitious project.
Title: Re: CPC / Raspberry Pi Bridge Card
Post by: krusty_benediction on 17:38, 28 February 17
Atari ST community has a similar card : http://joo.kie.sk/?page_id=384

I would love to have an equivalent on my CPC (ROM, RAM, floppy drive emulation, HDD emulation with a specific firmware, internet access, files, images, snapshots transfers, soundplayer, video acquisition... ) to replace all the different cards more or less maintained
Title: Re: CPC / Raspberry Pi Bridge Card
Post by: Gryzor on 18:17, 09 July 17
I do have the Atari equivalent. It's a beast and can do tremendous stuff, but it's not the easiest add-on to use...


Unfortunately, its developer had to abandon further development and selling because of the crippling taxes he had to endure.
Title: Re: CPC / Raspberry Pi Bridge Card
Post by: LambdaMikel on 21:56, 01 June 18
FWIW - here is a great project that gives some insights to some of the engineering challenges one faces in making such a device.


As already suspected, being able to quickly react to an address with the correct byte being put on the databus is extremely challenging with a Raspberry Pi, and only works with a trick here:


https://hackaday.com/2018/05/31/reverse-emulating-nes-nintendception/ (https://hackaday.com/2018/05/31/reverse-emulating-nes-nintendception/)


The trick is explained from 11'40'' on here:


https://www.youtube.com/watch?v=ar9WRwCiSr0&t=640&authuser=1

Title: Re: CPC / Raspberry Pi Bridge Card
Post by: LambdaMikel on 22:03, 01 June 18
The trick is explained from 11'40'' on here


Having said that, this trick (basically, address prediction / guessing) won't work well for the CPC Memory.
Title: Re: CPC / Raspberry Pi Bridge Card
Post by: LambdaMikel on 23:07, 01 June 18
But then, he is using a Pi Zero... the most recent Pi 3B+ should be almost 2.5 times as fast as the Pi Zero. So maybe it is within range.


What do hardware experts think here? Is that feasible? My suspicion is still "no", because you actually have to do some computation in order to react to an address in an intelligent way (OK, it could just be a memory lookup, but then it is not that interesting).
Title: Re: CPC / Raspberry Pi Bridge Card
Post by: Gryzor on 07:48, 02 June 18
I watched that video a couple of days ago, really really nice and interesting. I also liked the philosophical angle he threw in.


That said, although it's extremely interesting and impressive, is it practical?