Skip to content

Commit 4f643f9

Browse files
committed
Update AY8913 peripheral 20 docs
1 parent bc448fd commit 4f643f9

File tree

1 file changed

+53
-4
lines changed

1 file changed

+53
-4
lines changed

docs/user_peripherals/20_AY8913.md

Lines changed: 53 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,27 @@ Peripheral index: 20
1919

2020
## What it does
2121

22-
This is a replica of 8-bit classic **[AY-3-8913](https://en.wikipedia.org/wiki/General_Instrument_AY-3-8910)** 3-voice programmable sound generator (PSG) chip from General Instruments. The AY-3-8913 is a smaller variant of AY-3-8910 or its analog YM2149.
22+
This is a replica of 8-bit classic **[AY-3-8910/AY-3-8912/AY-3-8913](https://en.wikipedia.org/wiki/General_Instrument_AY-3-8910)** 3-voice programmable sound generator (PSG) integrated into a modern RISC-V as a peripheral.
2323

24+
The AY-3-891x family of programmable sound generators was introduced by General Instrument in 1978. Variants of the AY-3-891x were broadly used in:
25+
26+
- home computers: Amstrad CPC, Atari ST, Oric-1, Sharp X1, MSX, ZX Spectrum 128/+2/+3
27+
- game consoles: Intellivision, Vectrex
28+
- and many arcade machines
29+
30+
### Technical capabilities
31+
32+
- **3 square wave** tone generators
33+
- A single **white noise** generator
34+
- A single **envelope** generator able to produce 10 different shapes
35+
- Chip is capable to produce a range of waves from a **30 Hz** to **125 kHz**, defined by **12-bit** registers.
36+
- **16** different volume levels on a logarithmic scale
2437

2538
## Register map
2639

27-
The behavior of the AY-3-891x is defined by 14 registers. All registers are READ ONLY!
40+
The behavior of the AY-3-891x is defined by 14 registers. The register map matches the original AY-3-891x and should be able to play the original tunes without modifications.
2841

42+
All registers are **read only** in this peripheral and start in **unknown** uninitialised state upon reset!
2943

3044
| Address | Access | Bits used | Function | Description |
3145
|---------|--------|----------------|------------------|------------------------|
@@ -44,10 +58,45 @@ The behavior of the AY-3-891x is defined by 14 registers. All registers are READ
4458
| 12 | R | ```xxxxxxxx``` | ---//--- | 8-bit coarse frequency |
4559
| 13 | R | ```....xxxx``` | Envelope Shape | 4-bit shape control |
4660

61+
### Square wave tone generators
62+
63+
Square waves are produced by counting down the 12-bit counters. Counter counts up from 0. Once the corresponsding register value is reached, counter is reset and
64+
the output bit of the channel is flipped producing square waves.
65+
66+
### Noise generator
67+
68+
Noise is produced with 17-bit [Linear-feedback Shift Register (LFSR)](https://en.wikipedia.org/wiki/Linear-feedback_shift_register) that flips the output bit pseudo randomly.
69+
The shift rate of the LFSR register is controller by the 5-bit counter.
70+
71+
### Envelope
72+
73+
The envelope shape is controlled with 4-bit register, but can take only 10 distinct patterns. The speed of the envelope is controlled with 16-bit counter. Only a single envelope is produced that can be shared by any combination of the channels.
74+
75+
### Volume
76+
Each of the three AY-3-891x channels have dedicated DAC that converts 16 levels of volume to analog output. Volume levels are 3 dB apart in AY-3-891x.
77+
78+
## IO pins
79+
80+
There is a single PWM output signal that is connected to all the output pins uo_out[7:0].
81+
The input pins are not used.
82+
4783
## How to test
4884

49-
TODO: Explain how to use your project
85+
All register state are in **unknown** uninitialised state upon reset. The very first thing you should do is to set them to zero!
86+
87+
In order to play a standard pitch A440 note you have to enable Channel A tone in the mixer:
88+
89+
register[7] = 0b00_001_000
90+
91+
Set volume loud:
92+
93+
register[8] = 0b0000_1111
94+
95+
Set A440 tone using the formulas:
96+
97+
register[0] = (2_000_000 // (16 * 440)) & 0xFF
98+
register[1] = (2_000_000 // (16 * 440)) >> 8
5099

51100
## External hardware
52101

53-
Tiny Tapeout Audio PMOD
102+
(Tiny Tapeout Audio PMOD)[https://store.tinytapeout.com/products/Audio-Pmod-p716541601]

0 commit comments

Comments
 (0)