EE 552

Project Documentation:

Vox-o-Tron

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Fong, Charlena

Objois, Marc-Julien

Shterngartz, Mariya

Single, Catherine


Declaration of Original Content

The overall structure of the Vox-o-tron and the filter design unit are original content.  These are described in the General Description of Operation section. The FIR filter design concept comes from references #2, #5, and #6 (in the reference section).  The shift register method of serial to parallel / parallel to serial conversion was suggested by Dr. Duncan Elliott.

 

Members:

 

 

____________________

 

____________________

 

____________________

 

____________________

 

 

Abstract

 

The Vox-o-Tron is a vocoder-like device.  Vocoders are widely used in electronic genres.

 

This report covers the design of a digital implementation of a vocoder using a single FLEX10K20 FPGA, a digital to analogue converter, and an analogue to digital converter.  Also, the external support circuitry for the converters is covered.

 


Table of Contents

 

Achievements...................................................................................................................... 1

I/O Description..................................................................................................................... 1

General Description of Operation........................................................................................ 1

Convolver Operation................................................................................................... 2

Input Decoder.................................................................................................................. 2

IO Signals............................................................................................................................ 3

External IO:................................................................................................................. 3

Internal IO:................................................................................................................... 3

Design Hierarchy................................................................................................................. 4

Resource Usage................................................................................................................. 5

Input Decoder (A/D Converter Interface)......................................................................... 5

Output Encoder (D/A Converter Interface)...................................................................... 5

FIR Unit (Convolver)........................................................................................................ 5

Experiment Results (Design Considerations).................................................................... 5

Convolver......................................................................................................................... 5

ADC Mode / Clocking...................................................................................................... 5

DAC Mode....................................................................................................................... 6

Component Layout.......................................................................................................... 6

References.......................................................................................................................... 7

Schematics / Connection information................................................................................. 8

Chip Settings: ADC..................................................................................................... 9

Chip Settings: DAC..................................................................................................... 9

Index to Test Cases / Verification..........................................................................................

ADC Interface....................................................................................................................

DAC Interface....................................................................................................................

Circular Buffer...................................................................................................................

Convolver...........................................................................................................................

FIR Unit..............................................................................................................................

ADC Interface Design Verification and Testing.....................................................................

Digital-to-Analogue Converter Interface Design Verification and Testing.............................

Circular Buffer Design Verification and Testing....................................................................

Convolver Design Verification and Testing...........................................................................

FIR Unit Design Verification and Testing...............................................................................

Index for Test Benches.........................................................................................................

DAC Interfacing.................................................................................................................


Achievements

The Vox-o-Tron’s internal digital circuitry behaves as intended.  The inputs from the ADC (analogue to digital converter) are convolved and output to the DAC (digital to analogue converter).  Unfortunately, the noise inherent in the physical implementation of the support circuitry makes the device unusable.

 

In terms of processing, the Vox-o-Tron is able to support a sampling rate of 48kHz, but using a FLEX10K20 FPGA, can only accommodate 8 bit processing.  Using the same grade of chip with a higher gate count, 24 bit processing would be possible at this rate.  In fact, the system is clocked such that the sampling rate is 49.1kHz, which is within tolerances of the ADC (the DAC has no problem with very high sampling rates).

 

I/O Description

The Vox-o-tron has two analogue audio inputs and one analogue audio output.  The fist input is known as the exciter input.  The second input is referred to as the carrier signal.  These inputs usually consist of a voice and a synthesizer respectively.  Optionally, another audio output could be added, as well as a frequency shifting controls.  The additional output could be used to monitor a clean or frequency shifted exciter signal.   Frequency shifting controls could be used to modify the base frequencies in the exciter signal.  Also, a VGA monitor output could be integrated into the system to display the frequency spectrum of the voice input. 

 

General Description of Operation

The operation of a musical vocoder in general is as follows.  The exciter signal has its frequency spectrum imposed on the carrier signal.  In musical vocoders, this is done approximately.  Most of these devices are analogue, and use an array of discrete bands in the frequency range of human speech to control a corresponding array of band-pass filters (BPF’s) which act on the carrier signal.  In a digital system, it is possible to do the same except with many more frequency bands by convolving the carrier signal with the exciter signal.

 

Rather than approximate the frequency spectrum of the exciter signal to filter the carrier signal, they are convolved together, thereby multiplying the frequency spectrums together.  The exciter signal is connected to the left channel of the stereo A/D converter (CS5360).  The carrier signal is connected to the right channel of the CS5360.  These signals are sampled at 49.1 kHz.  Both of the resulting digital signals pass through an audio signal decoder, which converts the serial data (which is in the I2S format described in the CS5360 documentation, attached) into two parallel 8-bit data streams.  The data coming in has 24 bits per channel, but only the most significant 8 bits are used to reduce the size of the processing hardware.  The signals are stored in two 128-value (in this case, 128 byte) buffers comprised of the on-chip SRAM cells.  Every time a new sample is stored, the buffers are immediately convolved.  The result of the convolution is output to the DAC interface, which converts the single 8 bit parallel data into an I2S data stream (described in the CS4334 documentation, attached).

 

Convolver Operation

The convolving is done using a method developed by the team based on the FIR filtering techniques described in references #2, #5, and #6.  Convolution of two discrete-time filters is accomplished by multiplying the two signals together, coefficient by coefficient, then summing all the resultant values.  The convolver accesses all of the values stored in the buffer, feeding them into a pipelined multiplier.  The result of each operation is a 16 bit number.  An adder sums the values coming out of the multiplier, then truncates this value to the last 7 bits, preceded by the sign bit.

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 


Figure 1: Block Schematic of Vox-o-Tron

 

Input Decoder

The input decoder converts the serial data from the A/D converter into two parallel data streams.  It effectively separates the left and right channel information and produces two standard logic vectors.  This is done by shifting the incoming bits through a 64-bit shift register.   The resulting vector contains, in sequence, a 24-bit value representing the current left channel sample, 8 bits representing a peak signal level detection value for the left channel, a 24-bit value representing the current right channel sample, and 8 bits representing a peak signal level detection value for the right channel.  Eight bits of data from the left and right channels can be read from bits 63 down to 56, and 31 down to 24, respectively.   This data is latched at the end of the cycle.  See crystal data sheets [1].

 

Circular Buffer

The circular buffer allows one to continually add values to RAM and read them in order of newest to oldest (LIFO: Last In, First Out).

 

FIR Unit (Convolver)

This block must perform convolution on a signal based upon a filter's impulse response.  In this case, the exciter signal will be convolved directly with the carrier signal.  To accomplish this, the coefficients of the incoming audio data buffers must all be multiplied together then summed.   This means that the data must be fetched from the circular buffers as many times as there are elements in the buffers.  In this case, 128 times. 

 

DAC Interface

The DAC interface performs the opposite function as the ADC interface.  It converts parallel data into serial data.  This is performed by latching the parallel data into a shift register (of which the most significant bit is mapped to the serial output, sdata).  The data is then shifted out on the sdata clock.  See crystal data sheets [2].

 

IO Signals

External IO:

Note: all IO signals for the Vox-o-Tron are analogue.

 

IO Signal

Type

Source

Destination

Exciter input

Line level monophonic analogue audio.

Any audio source.  Typically voice.

CS5360 ADC

Carrier input

Line level monophonic analogue audio.

Any audio source.  Typically audio from a synthesizer

CS5360 ADC

Master output

Line level monophonic analogue audio.

CS4334 DAC

Audio source, mixer, etc.

 

Internal IO:

 

IO Signal

Type

Source

Destination

serialAudioInput

Input to FPGA: I2S format (from CS5360 documentation).  Contains left and right channel data, and peak signal level (PSL) detection bits.

CS5360 ADC (pin 9)

Pin 23 on the FLEX_EXPAN_A port of the UP1 education board (fitted with a FLEX10K20RC240-4 FPGA)

lrclk

Input to FPGA: 50% duty cycle clock at the sampling frequency of the ADC.

CS5360 ADC (pin 12)

Pin 24 on the FLEX_EXPAN_A port

sclk

Input to FPGA: 50% duty cycle clock at 64X the sampling frequency.

CS5360 ADC (pin 8)

Pin 22 on the FLEX_EXPAN_A port

reset

Input to FPGA: pushbutton signal

PB1 on the UP1 board

Pin 28 of the FLEX10K20 chip

chipReset

Output from FPGA: active low reset signal.

Pin 18 on the FLEX_EXPAN_A port

CS5360 ADC (pin 18)

serialAudioOutput

Output from FPGA: I2S format (from CS4334 documentation).  Contains left and right channel.

Pin 15 on the FLEX_EXPAN_A port

CS4334 DAC (pin 1)

lrclkOut

Output from FPGA: 50% duty cycle clock at the sampling frequency

Pin 16 on the FLEX_EXPAN_A port

CS4334 DAC (pin 3)

mclk, mclk2

Output from FPGA: clocks at 256X the desired sampling frequency

For mclk: pin 17 on FLEX_EXPAN_A

For mclk2: pin 21 on FLEX_EXPAN_A

For mclk: pin 4 on the CS5360

For mclk2: pin 7 on the CS4334

 

Note: mclk and mclk2 are separated to allow for alternate designs to use different master clock speeds for the ADC and DAC.

 

Design Hierarchy

 

Vox-o-tron (main structure)

 

3

 
 

 

 

 

 

 

 

 

 

3

 

3

 

x

 

x

 
 

 

 

 

 

 

 


3

 
 3

 

 

 

Fig. 2: Design Hierarchy


Resource Usage

Input Decoder (A/D Converter Interface)

From the compilation report, the decoder uses 104 logic cells on a FLEX10K20RC240-4 chip.

Output Encoder (D/A Converter Interface)

The output encoder uses up 34 logic cells.

FIR Unit (Convolver)

The compilation report states that the convolver uses 394 logic cells.

 

 

In total, Vox-o-tron’s VHDL code uses up 511 of the available 1152 cells (using 8 bit processing).

 

 

Experiment Results (Design Considerations)

Convolver

The convolver needs to multiply and add.  Adders are not difficult to implement (particularly simple ripple-carry adders).  The size of a multiplier as implemented by lpm_mult goes up exponentially with the data width.  As an initial test, a 20-bit multiplier was compiled by Max+plus II.  The resulting design required 1259 logic units.  This is over 100 more logic units than are present in a FLEX10K20.  Instead of using a larger device, the data width was cut down to 8 bits.  This resulted in a multiplier which takes up roughly 30% of the capacity of the FLEX10K20.

 

For testing purposes, the 20-bit multiplier was benchmarked to see how much processing can occur in one audio clock cycle.  The limiting factor in the speed of the convolver is how fast the multiplier can output data.  The fastest an lpm_mult can go is when it is set to calculate in four pipeline stages (according to the Max+plus II online help).  Thus, the registered performance of a 20-bit lpm_mult was tested using Max+plus II’s registered performance analysis tool.  With constant data coming in, the multiplier can output 128 products in one cycle of a 56kHz clock.  Given that the target sampling rate was set to 48kHz, the actual calculations were proved to not be an issue.  Any additional latency comes from any setup of the convolving process and post-processing.

 

After compiling the FIR unit (which ties the convolver to the input buffers), it was found that the maximum sampling rate would be approximately 52kHz, which is still faster than the target sampling rate.

 

ADC Mode / Clocking

The ADC was set to operate in master mode, format 0 (specifications included in CS5360 documentation, attached).  In this mode, a master clock (MCLK) is sent to the ADC, and it generates an LRCLK (left/right clock: runs at the sampling frequency), and an SCLK (serial clock), which are externalized.  MCLK must run at 256X the desired sampling rate.  Starting off with an 48kHz sampling frequency, this means MCLK must run at 12.288MHz, which is the UP1 board’s 25.175MHz clock divided by 2.049.  The closest integer divider is 2, giving an MCLK running at 12.5875MHz.  This corresponds to a sampling rate of 49.1kHz, which the ADC is able to handle.

 

This ADC features peak signal level detection.  This is a powerful feature of high resolution ADCs which is completely ignored for the sake of this project.

 

 

DAC Mode

The DAC is put into Base Rate Mode (BRM) by providing an MCLK and LRCLK to it where the ratio of MCLK/LRCLK is 256.  Also, it is set to internal SCLK mode by setting the (not DEM)/SCLK line to low logic level.  After a few transitions of MCLK, the DAC realizes it must generate its own SCLK.  Also, this setting turns on digital de-emphasis, which eliminates imaging.  In this mode, the DAC converts 16 bits per channel and is able to reach ridiculously high sample rates.  Here, the LRCLK generated by the ADC is fed into the DAC (buffered by the FLEX10K20).  No SCLK is necessary, as it is generated internally.  However, SDATA (the serial data stream fed to the DAC) must be clocked on a synchronized SCLK.  The SCLK used to do this comes from the ADC.

 

 

Component Layout

The analogue signal lines are very sensitive to the 5-Volt digital lines.  Unfortunately, these were not isolated adequately in Vox-o-Tron, resulting in crippling noise on the ADC analogue inputs.  This was compounded by the fact that all wiring was done with thin wire-wrap wire.  Also, it is possible that the pins soldered to the board containing the surface-mount chips (both the DAC and ADC) were too long and close together, resulting in antenna-like interference.

 

 

 


References

1.Crystal Semiconductors, Crystal Semiconductors, www.crystal.com

ADC CS5360, http://www.cirrus.com/products/overviews/cs5360.html

DAC CS4334, http://www.cirrus.com/products/overviews/cs4334.html

2. Student Application Notes (Winter 99) on FIR filters, Norman Bo, Kelvin Leung, David Ritter, www.ee.ualberta.ca/~elliott/ee552/studentAppNotes/99w/FIRFilter/

3. Sampling and Filtering, Michael Cohen, screwdriver.bu.edu/cn760-lectures/l3/l3np/ppframe.htm

4. How Vocoders Work, Craig Anderson, www.paia.com/vocodwrk.htm

5. Kraftwerk info, http://sun1.bham.ac.uk/busbykg/kraftwerk/FAQ/miscellaneous.html#vocoder

 

 

 

 


Schematics / Connection information

 

 

Fig. 3: CS5360 Connections (ADC)

Page 8 CS5360 Appendix A


Fig. 4: CS4334 Connections (DAC)

Page 10 CS4334 Appendix B

 

 

 

Chip Settings: ADC

Pin 1 (High-Pass Filter defeat) – connected to a low logic level to enable the high-pass filter.

Pin 2 – Overflow.  Unused, so connected to ground through a 47kOhm resistor.

Pin 10 – Connected to ground through a 47kOhm resistor (ignored).

Pin 11 – Peak Update.  Tied to ground to disable feature.

Pins 19, 20 – Both connected to logic level low to select data format 0.

 

Chip Settings: DAC

Pin 2 – Digital De-Emphasis is turned on.

Pins 3, 4 – The incoming ratio of MCLK/LRCLK puts the DAC in master mode.  It then provides its own SCLK and runs in 16 bit per channel mode.

 


Index to Test Cases / Verification

ADC Interface

Two different sdata sequences were tested.  When lrclk = ‘1’ outputA and outputB are generated.  OutputA and OutputB correspond to the sdata (7 downto 0) and sdata (40 downto 32), respectively.

DAC Interface

1. The binary values for 1 through 9 are converted to serial representations.

2. Hexadecimal values (shown in hex for easy conversion to binary) FB through FF are converted to their serial representations.

Circular Buffer

The integer value 3 is written to the buffer. The buffer is then read from twice.  Next, the integer value 2 is written to the buffer.  Lastly, it is read from three times.  The values retrieved from the buffer are shown to be correct.

Convolver

1.      All values in both buffers are simulated to be ‘1.’  This should 1 to the sum 128 times.

2.      All values in buffer A are 1, all values in B are 3.  This will repeatedly add 3 to the sum.

3.      This is a two’s compliment test.  Buffer A contains all –3’s, buffer B contains all 2’s.

4.      Buffer B contains all 2’s (for simplicity) and buffer B contains values from 0 incrementing by 1 for each value (as if values 0, 1, 2, 3, etc. were received in that order).

 

 FIR Unit

This test simulates a full clock cycle, and the beginning of a second.  Two values are ‘received’ from the ADC on channels A and B: 2 and 3, respectively.  On the beginning of the next cycle, a 3 and a 2 are received.  This means that the circular buffers A and B contain {2, 0, 0, …} and {3, 0, 0, …}, respectively for the first cycle, and {2 ,3 ,0 ,…} and {3, 2, 0, …} respectively for the second.  The output is then observed.


ADC Interface Design Verification and Testing

Design

Description

The project includes a 24-Bit Crystal Semiconductors Stereo A/D (CS5360).  This component had to be programmed and tested to correctly output the data.  This ADC takes two analogue audio inputs and outputs a single serial data stream in the I2S format. The ADC takes a Master Clock (mclk).  In Master Mode (the chosen mode of operation), the ADC then generates a left/right clock (lrclk) and a serial data clock (sclk).  Internal dividers will divide MCLK by 4 to generate a sclk, which is 64x Fs (the sampling frequency), and by 256 to generate lrclk, which runs Fs.  The chosen sampling frequency was set to 44.1kHz so as to let the convolver finish its processing once per sampling clock cycle.  This sampling frequency was chosen to accommodate the processing time required in the filtering unit.  From the specification sheets, this corresponds to an mclk frequency of 11.2896MHz.  Unfortunately, it is not be possible to generate this clock rate using a clock divider.  However, testing revealed that the convolver contains a design flaw that makes it slower than it could be.  This is discussed in the FIR unit design verification and testing section.

Clock divider

For testing, the mclk has to be set by dividing the Altera clock by 2.  The code includes a clock_divider process that generates this mclk.

Storing sdata into two parallel 8-bit outputs

The main serial output from the ADC (sdata) has to be converted to two parallel outputs: one for each of the left and right inputs.  To achieve this, the process interface_sclk latches sdata into a shift register (called “sr”) 64 bits wide, bit by bit.  This effectively stores all incoming data from one lrclk cycle into a register.  This incoming data includes 24 bits for the left channel, 8 bits of “peak signal level detection,” then another 24+8 bits. Another process called interface_lrclk stores bits 55 to 63 and 23 to 31 of the shift register (sr) to outputA and outputB, respectively.  This is for the case where the chosen data width for internal processing is 8 bits (chosen to reduce the required number of logic cells in the design).  The MSB of the left input arrives first.  The data is shifted “left” into the register until all data is received.  This register is big-endian (MSB first).

 

The timing analyzer shows that the longest delay between the last received sdata bit (latched by a rising edge on sclk) and the time when the parallel outputs are latched (called outputA and outputB) is 14ns, which is negligible. 

 

The test results indicate that the ADC interface is currently fully functional.

 

Testing

 

Clock divider

The clock halving process was tested, and a waveform is included.

ADC

Shown below are the periods of the clocks used in testing:

 

Clock = 1/(25.175MHz) = 39.72ns

MCLK = clock*2 = 79.44ns

Sclk = 354.4ns

Lrclk = sclk*32 = 11340.8ns

 

The waveform test cases are annotated.


Digital-to-Analogue Converter Interface Design Verification and Testing

Design

 

The DAC requires a master clock (mclk) running at 11.2896MHz, a clock (“lrclk”) running at 44.1KHz to determine output to the left or right channel, and a clock (“sclk”) running at 1.536MHz for the serial input.  In the chosen mode of operation, the mclk runs at 256X the sampling rate, and output data is taken at 16 bits per channel.  The sclk will run at 32X (16+16) the sampling rate.

 

The input data stream will be 8 bits wide.  A flag (“latchData”) of type boolean will assert to “true” on the falling edge of sclk and lrclk changes to zero for output to the left channel.  At the next falling edge of sclk, the data will latch onto the 32-bit shift register.  This register accommodates all 32 bits coming in from the DAC  The flag will be asserted to “false” and the data will shift one bit left and concatenate a zero.  The most significant bit from the shift register will output to sdata, which is the input to the DAC.  This continues until lrclk becomes high where there will be no data being latched or output to the right channel.  The process of latching and outputting the serial data starts again at the next falling edges of lrclk and sclk.  The timing diagram for the DAC (CS4334) is attached.  Once all clocking issues are resolved (discussed in ADC interface section), the same mclk, sclk, and lrclk will be used for both the ADC and DAC.

 

The time taken to latch the data is around 14ns, which is negligible.

 

The test cases indicate that the DAC interface is currently fully functional, but practical considerations discussed in the Testing section below indicate a potential timing issue to be observed.

 

Testing

 

 

The left-right clock (lrclk) is set to a period of 22.7us (44.1KHz).  The serial clock is set to a period of 708.6ns (1.4112MHz).  The falling edges of the lrclk and sclk occur at the same time.  In practice, there may be a small offset.  This may or may not be significant (as will be explained shortly).

 

Consistent new data coming in at 44.1KHz is expected, but not required.  As long as the data present on the parallel data input is valid on the falling edge of lrclk (according to the datasheet, lrclk low means the start of new “left” data).  The testing values used are 0 to 256 (looping).  For each data input, sdata shows the input data stream in serial binary form.  The rising edges of sclk arrive at the middle of each bit, as required by the specifications of the DAC.  At this point, this code is assumed to work.  However, one issue may come into play once this is running in hardware.  In the attached code for the DAC, the lrclk signal is read on a falling edge of sclk.  However, the lrclk may be transitioning at this point.  This will have to be tested on an oscilloscope.


Circular Buffer Design Verification and Testing

Design

The circular buffer uses the lpm_ram_dq megafunction from MAX+PLUS II.  It is a simple LIFO (Last In, First Out) buffer, and is implemented using two address signals (a read address and a write address.  As long as data can be written to the circular buffer and then read back in LIFO order, it is functioning properly.

 

The critical path is from the time a command is issued (read or write) and the time the data is written or becomes available.  Using a state machine to perform the necessary operations may not be the fastest way of implementing this buffer, as the read operations could perhaps be sped up, but it is easier to time the steps this way.  The current maximum speed of the buffer (the read speed) is 1 value read per 3 25.175MHz clock cycles.  In other words, it takes about 120ns to read one value, or 15,253ns to read 128 values.

 

The circular buffer tested positively and is currently assumed to be fully functional.

 

Testing

 

The test case described in the test case index is explained in detail on the waveform. 


Convolver Design Verification and Testing

Design

The convolver is designed to perform discrete convolution on two signals of a specified number of samples.  It is designed to work with the aforementioned circular buffer.  Once it is triggered to start by setting its “start” signal to high externally, it will read in data from two circular buffers the specified number of times (in this case, 128 times).  Once it has finished, it sets its “done” signal to high, signifying that its output data is valid.  From the calculations of the circular buffer design verification section, The speed calculation in the previous section for retrieving 128 values from the circular buffer corresponds to approximately 66kHz.  Even accounting for setup and data retrieval, this is more than enough to accommodate a 48kHz sampling frequency.

 

The test cases indicate that the convolver is functioning properly.

 

Testing

The convolver performs its function properly.  The math was tested using many test cases.  The tests are described on the waveform plots.


FIR Unit Design Verification and Testing

Design

The FIR unit simply writes new data to the circular buffers when available from the ADC.  This is triggered by the “lrclk” signal.  Once the writing is finished, the FIR unit triggers the convolver.  This is repeated for each cycle of lrclk.

 

Writing to the circular buffer takes four cycles of the 25.175MHz clock, or 160ns.  This time is not a factor, as the convolution takes much longer, and determines the overall speed of this device.

 

Testing

The FIR unit seems to function properly over short periods of time.  The actual resulting “sound” of the system is still unknown, as listening tests will be the final factor in deciding whether success was achieved.

 


Index for Test Benches

 

DAC Interfacing

The DAC interface was tested using Mentor Graphics’ test bench capability.