Quantization

advertisement
Quantization
Digital representations of analog signals are in the
form of bits. These bits are taken from an analog-todigital converter, processed and then put to a digitalto-analog converter.
bits
x
A/D
Filtering
D/A
bits
y
What is the number of bits needed per sample to
accurately represent the analog signal?
With B bits, we can represent 2B different values.
For example, if B=3, we can have eight different
values corresponding to 000, 001, 010, 011, 100,
101, 110, 111.
The 2B values can correspond to volts, millivolts,
multiplies of 0.25 volts, etc.
Example: Suppose we had B=3 bits corresponding
to a number which is equal to the voltage of a signal
(at some point in time). The 23=8 different voltage
levels are 0V, 1V, 2V, 3V, 4V, 5V, 6V and 7V.
A digital-to-analog converter would convert 000 to
0V, 001 to 1V, etc.
An analog-to-digital converter would convert an input
signal at 0V to 000. An input of 1V would be
converted to 001; an input of 2V would be converted
to 010, etc.
Suppose the input signal to an analog-to-digital
converter were 1.5V. Would this voltage be
converted to 001 or 010? The answer depends
upon the type of quantization used by the analogto-digital converter.
If the type of quantization is truncation, then all
values from 1.0V up to but not including 2.0V are
converted to 001.
If the type of quantization is rounding, then all
values from 0.5V up to but not including 1.5V are
converted to 001. Values of from 1.5V up to but not
including 2.5V are converted to 010.
Let ^
x be the quantized version of x. While x can
take on any value, x^ can only take on discrete
values corresponding to the output of a digital-toanalog converter such as 1.0, 2.0, 3.0 (volts).
If we cascade an analog-to-digital converter with a
digital-to-analog converter we will get a quantizer
^
that converts x to x.
x
A/D
000, 001, …
D/A
x^
^ are shown on the
The relationships between x and x
following graphs.
x^
Truncation
111
7
110
6
101
5
100
4
011
3
010
2
001
1
000
1
x
2
3
4
5
6
7
8
x^
Rounding
7
6
5
4
3
2
1
x
1
2
3
4
5
6
7
8
Negative values can also be represented digitally.
There are two common formats: sign magnitude
and two’s complement.
In sign magnitude format, the most significant bit is
a sign bit:1 is negative, 0 is positive.
In two’s complement format, positive numbers are
like normal positive numbers. Negative numbers are
wrapped backwards: -1 is 111, -2 is 110, etc.
Shown on the following graphs are signed
quantization levels and values for truncation and
rounding quantization, and sign magnitude and two’s
complement formats.
x^
Truncation,
Sign Magnitude
011
010
001
000
101
110
111
x
x^
Truncation,
Two’s Complement
011
010
001
000
111
110
101
100
x
x^
Rounding,
Sign Magnitude
011
010
001
000
101
110
111
x
x^
Rounding,
Two’s Complement
011
010
001
000
111
110
101
100
x
In all of the previous quantization examples, the step
size was one (1). The step size could be 0.5, 0.25,
etc. Let D be the step size, also known as the
quantization interval.
For truncation quantization, the quantization
error is between 0 and D.
For rounding quantization, the quantization error
is between -D/2 and +D/2.
The ratio of the maximum signal magnitude to the
quantization interval is a measure of the fidelity of
the digitized sample. Let us see if we can relate this
ratio to a more common ratio called the signal-tonoise ratio (SNR).
Let A be the maximum magnitude of a signal. The
ratio of the maximum magnitude to the quantization
interval is A/D.
The signal-to-noise ratio is a ratio of powers. The
power in a signal is related to its distribution.
If the signal is uniformly distributed between –A
and A, the distribution looks like this:
px(x)
x
-A
A
In many cases, we can assume that the distribution
of the quantization error, e, is uniform:
Truncation
pe(e)
e
D
In many cases, we can assume that the distribution
of the quantization error, e, is uniform:
Rounding
pe(e)
e
-D/2
D/2
The power may be obtained from a distribution by
integrating the product of the distribution with x2 or
e2.
Px   x p x ( x)dx
2
1
 x
dx
A
2A
3
2
2A
A


.
3(2 A) 3
A
2
For truncation quantization we have
Pe   e pe (e) de
2
D
1
  e de
0
D
3
2
(D )
D

 .
3( D ) 3
2
For rounding quantization we have
Pe   e pe (e) de
2
D/2
1
  e de
D / 2
D
3
2
2( D / 2)
D

 .
3( D )
12
2
We can now calculate the signal-to-noise ratio for a
uniformly distributed signal with truncation and
rounding quantization:
Px
SNR 
Pe
SNRTruncation 
A2
3
D2
3
 A
 
D
2
SNRRounding 
A2
3
D2
12
 A
 4 
D
2
Exercise: If we use B-bit quantization (with 2B
quantization levels), express the signal-to-noise ratio
in dB [=10 log (power ratio)] in terms of B for both
truncation and rounding quantization. (In both
cases, 2A/D = 2B.)
Download