News:

Printed Amstrad Addict magazine announced, check it out here!

Main Menu
avatar_SerErris

AY-3-8912 hardware emulator replacement

Started by SerErris, 21:20, 05 September 23

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

SerErris

Hi,

I stumbled on two resources to actually emulate a AY-3-8912 on an ATMega8.

The first is the bassis of this approache from here:
https://www.avray.ru/

It does all the heavy lifting in terms of AY Sound emulation. But it does not emulate the IO port, so for a CPC that would be unsable.

But wait, there is more.

Someone did the rest and implemented it including the fully functional IO port.
https://www.vretrodesign.com/products/ay-3-8912-functional-equivalent

That looks very promising.

I did order one of those and will run a test, if that is actually working fully in a CPC environment.

From the website:
Features include:
  • 3 channels of tone + noise 
  • Bidirectional 8-bit input/output port with built-in pullup resistors
  • Support for clock frequencies from 1MHz to 2MHz
  • Pin compatible with the AY-3-8912
  • Designed for Sinclair Spectrum(128K/+2/2A/2B/+3) and Amstrad (CPC range) computers
  • Output levels closely match the AY-3-8912
  • Frequency response equivalent to the AY-3-8912 

That sounds absoultely promising.
Proud owner of 2 Schneider CPC 464, 1 Schneider CPC 6128, GT65 and lots of books
Still learning all the details on how things work.

eto

I also saw that yesterday on Facebook. I wonder what microcontroller is used on the other type. 

SerErris

The microcontroller is always the same, it is just different software - e.g. software that simply does not implement the IO bus vs. software that does.
Proud owner of 2 Schneider CPC 464, 1 Schneider CPC 6128, GT65 and lots of books
Still learning all the details on how things work.

genesis8

For the second link (with IO), the description mentions another version : https://www.vretrodesign.com/products/ay-3-8912a-ts-replacement-ic-turbo-sound-version (turbo sound) only for the ZX Spectrum.

I just checked, Turbo Sound is just a second AY, so it should be only a problem of no current software on Amstrad CPC to use it and not a hardware problem.

This replacement and you would have 2 AY, as it is the case if you use a Play2CPC.

Is there someone who will come to the Benediction Coding Party 3 and willing to test the turbo sound version in his CPC if I buy one ?
____________
Amstrad news site at Genesis8 Amstrad Page

SerErris

#4
The question is if you can address the second one ... I am not sure how that is achieved in a TS inside the Speccy.

Everything is possible with a hardware mod, but I am not sure if it can be done with just replacing the AY-3-8912 with the TS version in a CPC.

Looking this up, it looks like the Turbosound is an external card for the spectrum. That obviously would work with a CPC in some way, but you need hardware design first to run it (similar to the Play2CPC).
Proud owner of 2 Schneider CPC 464, 1 Schneider CPC 6128, GT65 and lots of books
Still learning all the details on how things work.

robcfg

@SerErris , it looks definitely promising!

I've taken a look at their website, and it's being advertised on the CPC section, it should handle the I/O port as well, which is nice.

Please let us know how it goes when you test it!

eto

If I am not mistaken, on the Speccy the second AY uses a different I/O port. This is closer to what the Playcity/Play2CPC is doing.

Since it's emulation anyway, it would probably be possible to add new modes to the AY emulation so you can address 6 channels directly. However, as with all these kind of gimmicks, it will not be adopted if it requires desoldering ICs.  

SerErris

Quote from: eto on 12:47, 10 September 23However, as with all these kind of gimmicks, it will not be adopted if it requires desoldering ICs. 
Yep this will be one of two things:
1. replacement of a broken AY (then in its original form)
2. addition as an external module.

The later one should be pretty much simple to achieve. As I said already it is just a new hardware card and software to use it. The Dual AY itself is already done. 
Proud owner of 2 Schneider CPC 464, 1 Schneider CPC 6128, GT65 and lots of books
Still learning all the details on how things work.

andycadley

From that page (don't know if they've updated it recently):

Note: the AY-3-8912A-TS is not compatible with the CPC range Amstrad computers.

The TurboSound on the Speccy is just another AY on another two addresses. So I'd imagine they've included some sneaky address decoding to make it work when just plugged into the AY socket and I doubt that would play well with the CPC scheme where the AY is not directly addressable.

SerErris

I am not 100% sure what they do on the TS version. It could be, that they use the A8 input. This could add an additional address bit or select multiple of those chips (2) ... You can let one chip react on A8 high and the other on A8 low.

On CPC this line connected to +5V so always high. 

Also On Spectrum 128 the same line is connected to +5V so always high.

A main difference however is that the spectrum is connecting the CPU directly to the sound chip, vs CPC going through the PIO. 

That should not make any difference ...

Some time went on:
I researched how the turbo sound works, and that should work the exact same way on CPC.

The original Turbosound board has an AND gate + two D-Flipflops on it, that enables it to use it to select on or the other and using the A8 to activate it (or not). So A8 does not need any external connection as it is driven internally by the card. 

How does it work? For address you send over FE or FF, which selects Chip0 or Chip1 to actually work on it. If you just send 00-0F, it will go to the previous selected chip. So only one chip actually works with the processor, and you would need to select it first and then send the whole instruction to it as normal.

As I said, that exact same thing will work with CPC. However you still need the full IO port mapped, otherwise the CPC keyboard will not work anymore.
Proud owner of 2 Schneider CPC 464, 1 Schneider CPC 6128, GT65 and lots of books
Still learning all the details on how things work.

eto

Quote from: SerErris on 19:28, 10 September 23
Quote from: eto on 12:47, 10 September 23However, as with all these kind of gimmicks, it will not be adopted if it requires desoldering ICs. 
Yep this will be one of two things:
1. replacement of a broken AY (then in its original form)
2. addition as an external module.

The later one should be pretty much simple to achieve. As I said already it is just a new hardware card and software to use it. The Dual AY itself is already done.
The later one is what the sound-part of the PlayCity is doing. https://www.cpcwiki.eu/index.php/PlayCity

Maybe it's possible to make a Playcity compatible version of the Dual AY as this is already supported by some software.


SerErris

I would say, but this just on a very simple expansion board and you have 9 channels ... the two are directly programmed with IO vs. the exiting one is programmed via the PIO chip.

That should actually work, however is leading us away from the original aim of a replacement AY.
Proud owner of 2 Schneider CPC 464, 1 Schneider CPC 6128, GT65 and lots of books
Still learning all the details on how things work.

zhulien

I have a terasic t-rex and that has sound, it's an FPGA so someone has at least implemented AY's in FPGA.  I wonder how many AY's can fit in a single FPGA?  Someone could perhaps make a 10 AY FPGA sound card with compatability to PlayCity.

Having said that, some nice sound drivers for PlayCity and internal CPC Audio will eventually be done by someone, ideally different options: 9 front channels (6 music, 3 soundeffects), 6 front channels (music or soundeffects mixed), 3 back channels (sound effects) - so we can have surround sound in CPC games.

SerErris

Sure someone has implemented in an FPGA, as there is a working (multiple) computers on MISTER project (Atari, Amstrad, Arcade machines etc).

The number of AYs depend on the FPGA :-) 

However the FPGA implementation is 321 lines of verilog code

It has some registers:
1. address register 8bit
2. PSG registers 16*8bit
3. dout register (8bit) (this is for reading the registers)
4. some auxiliary internal bits (also regs in verilog)
   in total about 4+1+3+17+5+3+12+1+16+5+2
5.Die Outputregister A,B,C = 3x6 bit.

In total, if I did not count or add wrong, this is 231 flipflops, depending on the FPGA architecture that is 231 LUTs or Macrocells.

So this can be even implemented in a small CPLD with 256 Cells. 

FPGAs can have that much of them in a single chip:
Intel Cyclone V 110k LUTs = 476
Lattice iCE40 from 384 Cells to 7680 Cells. The smallest one can just hold one chip, but the largest one can hold 33

This is not calculating any more complex logic then required by the LUTs here, but I doubt, that this is actually an issue and the LUTs we need for FlipFlops are already enough to have the rest of the logic fit.
The iCE401K could host 5 of those chips, fits in a 7x7 mm QFN package and cost in larger numbers $4.66 - 

The beauty of an FPGA implementation would be, that you could set each chip to an indivudal address, so you could directly address the chips, which is not possible with the real chips, as they all react to the same address (0000). 

But the FPGA can be programmed to react on addresses 0 to 4 and you can directly programm each individually. 



Proud owner of 2 Schneider CPC 464, 1 Schneider CPC 6128, GT65 and lots of books
Still learning all the details on how things work.

BSC

Sounds like a nice learning project. What would you guys recommend as a playground to start with? I imagine some kind of IDE where I could edit the verilog (or other relevant types of) code, then run a simulation of the FPGA to see if it works as expected. Maybe paired with tools like virtual oscilloscopes etc. 
** My SID player/tracker AYAY Kaeppttn! on github **  Some CPC music and experiments ** Other music ** More music on scenestream (former nectarine) ** Some shaders ** Some Soundtrakker tunes ** Some tunes in Javascript

My hardware: ** Schneider CPC 464 with colour screen, 64k extension, 3" and 5,25 drives and more ** Amstrad CPC 6128 with M4 board, GreaseWeazle.

SerErris

I can only recommend the following (to learn verilog and FPGA):

First get yourself a Terasic DE10-nano or lite. Lite is better for the course, nano is better because it is the base hardware of the MISTer project.

In the MISTer project you have pretty much anything from the 80s now running on an FPGA including AMIGA, ST, C64, Amstrad and what not. Also consoles and even Arcade machines.

I would really just jump right away into "Computer Architetecture Tutorial Using an FPGA" by Robert Dunne. This is available as ebook or book. 

It will build on the DE10-lite, because of switches and LEDs. where the DE10-nano has very few switches, buttons and LEDs. But other than that it does not make any difference.

You programm it with Quartus Lite and that includes a simulator as well.

The downside is: Hardware cost you ~150€ and if you go DE10-Standard it will even go up to ~500€. But the later one is really if you want to develop more - so maybe something later.

A good starting simulator can be found here:
https://edaplayground.com/

I can also recommend to get a copy of "Designing Video Game Hardware in Verilog" from Steven Hugg
https://www.amazon.com/gp/product/1728619440/ref=as_li_tl?ie=UTF8&camp=1789&creative=9325&creativeASIN=1728619440&linkCode=as2&tag=ws8b-20

It is a very good introduction to Verilog but as well into understanding digital cirquitry. It comes with its own simulator, that even can simulate the video output etc.

https://8bitworkshop.com

The book is USD10 (as ebook) and they are using the Lattice iCE40 USB stick, which is very cheap and simple to use.
You can get it from mouser and other sources for USD50.

From my personal experience:
Looking at ready made code (without any comments in it) you will have a hard time to understand what they are doing. 

So better start from ground up, and after you have the basics - get into understanding on how they implemented a CPC.

The great thing about VHDL is, that you actually build everything together like a real computer. So you do have a mainboard, and it has chips. All the chips are getting connected and thats it. Obviously you need to implement all the chips, but that is just going level after level into more detail, or even reuse what others have done.
Proud owner of 2 Schneider CPC 464, 1 Schneider CPC 6128, GT65 and lots of books
Still learning all the details on how things work.

zhulien

If you can put 3 AY's, 2 SIDs and 2 8bit DACs into a single FPGA at a cheapish price, that would make a really awesome soundcard.

SerErris

It arrived today ... from NZ. Was not aware that it is produced in NZ, but that was quite fast shipping and explained the shipping cost. However I needed to pay customs on my own.
Proud owner of 2 Schneider CPC 464, 1 Schneider CPC 6128, GT65 and lots of books
Still learning all the details on how things work.

Rabs

Quote from: SerErris on 23:07, 23 September 23It arrived today ... from NZ. Was not aware that it is produced in NZ, but that was quite fast shipping and explained the shipping cost. However I needed to pay customs on my own.
How did you get on? Looks like I have a problem AY to replace on a 6128. Thinking of using this as an alternative to an expensive real AY replacement.

eto

Quote from: Rabs on 17:54, 03 October 23
Quote from: SerErris on 23:07, 23 September 23It arrived today ... from NZ. Was not aware that it is produced in NZ, but that was quite fast shipping and explained the shipping cost. However I needed to pay customs on my own.
How did you get on? Looks like I have a problem AY to replace on a 6128. Thinking of using this as an alternative to an expensive real AY replacement.
You can replace it with a 8910A:

https://www.cpcwiki.eu/forum/amstrad-cpc-hardware/ay-3-8910-adapter-for-amstrad-cpc-to-stop-exploitation-for-ay-3-8912!/msg224245/#msg224245

Rabs

Thanks, I would but the 8910 seems more expensive in the UK on eBay. Anyway, after replacing the membrane, which was broken (end fell off when I removed it from the connector), and scoping out the PIO Port A to see the pulses from the AY as I press a key and convincing my self it was broken, it started to work! Maybe I could offer a service to fix broken AYs by just looking at them  :) .

BSC

Quote from: SerErris on 13:21, 18 September 23I can only recommend the following (to learn verilog and FPGA): [long list of interesting things]
Thank you very much, SerErris, that was really interesting and I checked out all your links and suggestions. Now I only need to find (a way to free up) some time .. :)
** My SID player/tracker AYAY Kaeppttn! on github **  Some CPC music and experiments ** Other music ** More music on scenestream (former nectarine) ** Some shaders ** Some Soundtrakker tunes ** Some tunes in Javascript

My hardware: ** Schneider CPC 464 with colour screen, 64k extension, 3" and 5,25 drives and more ** Amstrad CPC 6128 with M4 board, GreaseWeazle.

SerErris

Hi, I had no time to work on it, maybe next week.

I also need to think of some good music examples to validate the sound quality.

Any good examples, that can test the soundchip?

I would also love some very atomic tests, that can test individual parts and do a real comparison.

Maybe my own basic sound test can be used for that.
Proud owner of 2 Schneider CPC 464, 1 Schneider CPC 6128, GT65 and lots of books
Still learning all the details on how things work.

SerErris

Okay,

I just opened my newest CPC464 and removed the AY and socketed it. I also took the chance and replaced the two Elkos and gave it a good clean. Also removed the printer port mod and relocated the reset button cables to the underside of the PCB. So it is not that obvious anymore and also not partially blocking the expansion port.

Anyhow I did a first g test run and it looks pretty good and also sounds through the small speaker rather good.

I will post some pictures and sound comparisons tomorrow
Proud owner of 2 Schneider CPC 464, 1 Schneider CPC 6128, GT65 and lots of books
Still learning all the details on how things work.

Rabs

I have one on order.

Although cheaper than a real AY, with the addition of shipping it works out about the same, but I am interested to see how it performs.

Thanks for the info.

Powered by SMFPacks Menu Editor Mod