Readme.md 2.71 KB
Newer Older
Christian Fibich's avatar
Christian Fibich committed
1
2
3
4
# uSynth Audio Synthesizer #

This project implements a tiny ADSR audio synthesizer in Verilog.

Christian Fibich's avatar
Christian Fibich committed
5
6
7
* Example 1: [_Still Alive_ from Portal](https://clyp.it/kdg230zr)
* Example 2: [_Toccata and Fugue in D minor_ by JSB](https://clyp.it/sl5bqfth)

Christian Fibich's avatar
Christian Fibich committed
8
9
10
11
12
13
14
15
16
17
18
## Hardware Description ##

The synthesizer core is available in `hdl/usynth` with
`usynth.v` being the top level.

This core has the following parameters:

* `NUM_VOICES` selects the number of available voices (i.e., notes that can be played at the same time)
* `WAVEFORM` selects the implemented waveform, where
  * `0` is square wave
  * `1` is sine wave via DDS
Christian Fibich's avatar
Christian Fibich committed
19
20
21
22
23
  
  
![uSynth](https://es.technikum-wien.at/fibich/usynth/raw/master/docs/uSynth.png)
  
  
Christian Fibich's avatar
Christian Fibich committed
24
25
26
27

The following ports are present:

* `clock`: System Clock
Christian Fibich's avatar
Christian Fibich committed
28
* `ce25`: 24 MHz Clock Enable (*FIXME: name*)
Christian Fibich's avatar
Christian Fibich committed
29
30
31
32
33
34
35
36
37
* `reset`: High-active asynchronous reset
* `enable`: One enable signal for each voice
* `play_note`: One gate signal for each voice
* `freq`: Frequency for each voice
* `a`: Attack rate for each voice
* `d`: Decay rate for each voice
* `s`: Sustain level for each voice
* `r`: Release rate for each voice
* `envelope`: Envelope generator enable for each voice
Christian Fibich's avatar
Christian Fibich committed
38
39
40
* `pwm`: The output signal. Needs external low pass filter


Christian Fibich's avatar
Christian Fibich committed
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70

The synthesizer core (each voice) works as follows:

* The `tone_generator` module generates a signal of the specified
  frequency and waveform at maximum amplitude
* When `envelope` is `1` for the voice, this signal is mixed with
  the envelope generated by the `envelope_generator`.
  * Until `play_note` is 0, nothing happens
  * When `play_note` becomes 1, the amplitude is incremented
    every _N_ samples by the _Attack Rate_
  * When the maximum amplitude is reached, the envelope generator
    decrements the amplitude every _N_ samples by the _Decay Rate_
  * Until the `play_note` signal becomes 0, the signal is held at
    the _Sustain Level_.
  * When the `play_note` signal becomes 0, the envelope generator
    decrements the amplitude every _N_ samples by the _Release Rate_

## Toplevel ##

The top level design in `impl/hx8k` implements an 8 voice square
wave synthesizer for the Lattice HX8K breakout board. This synthesizer
can be controlled via the UART2BUS core and a simple bus interface.

The `tools/midi.py` script uses `python-mido` to play standard
midi files using this demo design.

The toplevel can be built by executing `make` in `impl/hx8k`.

## Prerequisites ##

Christian Fibich's avatar
Christian Fibich committed
71
72
73
* `pyserial` for `tools/*.py`

* `python-mido` for `tools/midi.py`
Christian Fibich's avatar
Christian Fibich committed
74
75
76
77
78

For building the toplevel:

* `yosys`, `arachne-pnr` and `icestorm`

Christian Fibich's avatar
Christian Fibich committed
79
80
81
82
83
Useful udev rule for using HX8K breakout board via `/dev/ttyHX8K` 

    SUBSYSTEM=="tty",ATTRS{idVendor}=="0403",ATTRS{idProduct}=="6010",ATTRS{product}=="Lattice FTUSB Interface Cable", SYMLINK+="ttyHX8K"


Christian Fibich's avatar
Christian Fibich committed
84
85
86
87
88
89
90