Professional Documents
Culture Documents
-⊕P
iP bv 1 = (1010011)
6 PPP J
]
P J
u = (11101) r - r - -r J b v = (11 01 10 01 00 10 11)
³³ ^
³ ³³
-⊕)
³ bv 2 = (1101001)
c v 1 = (1000)
c v 2 = (1100)
u1 = (10) s ¡- s s
¢
¢ Z
¢
u2 = (11) s¢ - s - s Z
~⊕ c v = (0001)
Z
- 3
µ
¡
¡
¡
.. - v1
u1 .. - .
. - vj
ui -
.. Convolutional encoder ..
. .
uk -
- vn
2.
k
(1) (2) (k) (k)
X
v j = u1 ∗ g j + u2 ∗ g j + · · · + uk ∗ g j = ui ∗ g j ,
i=1
(i)
where ∗ is the convolutional operation and gj is the impulse
response of the ith input sequence with the response to the jth
output.
(i)
3. g j can be found by stimulating the encoder with the discrete
impulse (1, 0, 0, . . .) at the ith input and by observing the jth
output when all other inputs are fed the zero sequence
(0, 0, 0, . . .).
4. The impulse responses are called generator sequences of the
encoder.
-⊕P
iP bv 1 = (1010011)
6 PPP J
]
P J
u = (11101) r - r - -r J b v = (11 01 10 01 00 10 11)
³ ³³ ^
³
³³
-⊕) bv 2 = (1101001)
c v 1 = (1000)
c v 2 = (1100)
u1 = (10) s ¡- s s
¢
¢ Z
¢
u2 = (11) s¢ - s - s Z
~⊕ c v = (0001)
Z
- 3
µ
¡
¡
¡
(2)
g3 = 3 (octal)
v = u · G,
(i)
7. The element gj,ℓ , for i ∈ [1, k] and j ∈ [1, n], are the impulse
-⊕P
iP bv 1 = (1010011)
6 PPP J
]
P J
u = (11101) r - r - -r J b v = (11 01 10 01 00 10 11)
³³ ^
³ ³³
-⊕)
³ bv 2 = (1101001)
v = u·G
11 10 11
11 10 11
= (1, 1, 1, 0, 1) ·
11 10 11
11 10 11
11 10 11
= (11, 01, 10, 01, 00, 10, 11)
c v 1 = (1000)
c v 2 = (1100)
u1 = (10) s ¡¢- s s
¢ Z
¢
u2 = (11) s¢ - s - s Z
~⊕ c v = (0001)
Z
- 3
µ
¡
¡
¡
(1) (2)
(octal), g 3 = 2 (octal), g 3 = 3 (octal)
v = u·G
100 001 000
010 001 001
= (11, 01) ·
100 001 000
010 001 001
= (110, 010, 000, 001)
where
-⊕P
iP bv 1 = (1010011)
6 PPP J
]
P J
u = (11101) r - r - -r J b v = (11 01 10 01 00 10 11)
³³ ^
³ ³³
-⊕)
³ bv 2 = (1101001)
c v 1 = (1000)
c v 2 = (1100)
u1 = (10) s ¡- s s
¢
¢ Z
¢
u2 = (11) s¢ - s - s Z
~⊕ c v = (0001)
Z
- 3
µ
¡
¡
¡
Termination
1. The effective code rate, Reffective , is defined as the average
number of input bits carried by an output bit.
2. In practice, the input sequences are with finite length.
3. In order to terminate a convolutional code, some bits are
appended onto the information sequence such that the shift
registers return to the zero.
4. Each of the k input sequences of length L bits is padded with m
zeros, and these k input sequences jointly induce n(L + m)
output bits.
5. The effective rate of the terminated convolutional code is now
kL L
Reffective = =R ,
n(L + m) L+m
L
where L+m is called the fractional rate loss.
6. When L is large, Reffective ≈ R.
7. All examples presented are terminated convolutional codes.
Truncation
1. The second option to terminate a convolutional code is to stop
for t > L no matter what contents of shift registers have.
2. The effective code rate is still R.
3. The generator matrix is clipped after the Lth column:
G G1 · · · Gm
0
G0 G1 ··· Gm
.. ..
. .
Gc[L] = G0 Gm ,
..
..
. .
G0 G1
G0
-⊕P
iP b v 1 = (10100)
6 PPP J
]
P J
u = (11101) r - r - -r J b v = (11 01 10 01 00)
³³ ^
³ ³³
-⊕)
³ b v 2 = (11010)
v = u · Gc[5]
11 10 11
11 10 11
= (1, 1, 1, 0, 1) ·
11 10 11
11 10
11
= (11, 01, 10, 01, 00)
c v 1 = (10)
c v 2 = (11)
u1 = (10) s ¡- s s
¢
¢ Z
¢
u2 = (11) s¢ - s - s Z
~⊕ c v = (00)
Z
- 3
µ
¡
¡
¡
v = u · Gc[2]
100 001
010 001
= (11, 01) ·
100
010
= (110, 010)
Tail Biting
1. The third possible method to generate finite code sequences is
called tail biting.
2. Tail biting is to start the convolutional encoder in the same
contents of all shift registers (state) where it will stop after the
input of L information blocks.
3. Equal protection of all information bits of the entire information
sequences is possible.
4. The effective rate of the code is still R.
5. The generator matrix has to be clipped after the Lth column and
manipulated as follows:
G0 G1 ··· Gm
G0 G1 ··· Gm
.. ..
. .
c
G̃[L] =
G0 Gm ,
.. ..
. .
Gm
. ..
..
. G0 G1
G1 · · · Gm G0
c
where G̃[L] is an (k · L) × (n · L) matrix.
-⊕P
iP b v 1 = (10100)
6 PPP J
]
P J
u = (11101) r - r - -r J b v = (11 01 10 01 00)
³³ ^
³ ³³
-⊕)
³ b v 2 = (11010)
c
v = u · G̃[5]
11 10 11
11 10 11
= (1, 1, 1, 0, 1) ·
11 10 11
11 11 10
10 11 11
= (01, 10, 10, 01, 00)
c v 1 = (10)
c v 2 = (11)
u1 = (10) s ¡- s s
¢
¢ Z
¢
u2 = (11) s¢ - s - s Z
~⊕ c v = (00)
Z
- 3
µ
¡
¡
¡
c
v = u· G̃[2]
100 001
010 001
= (11, 01) ·
001 100
001 010
= (111, 010)
- b v 1 = (111)
J
]
J
r-⊕ xr- r - -r Jb v = (11 10 11)
u = (111) 6 ^
⊕?
¾ r
-⊕? b v = (101) 2
xt = ut + xt−1 + xt−2
v2,t = xt + xt−2 .
v1,t = ut
v2,t + v2,t−1 + v2,t−2 = ut + ut−2
9.
= (1 + D + D2 1 + D2 )
t σt σ t+1 v1 v2
0 00 10 1 1
1 10 01 1 0
2 01 00 1 1
State Diagram
1. A convolutional encoder can be treated as a finite state machine.
2. The contents of the shift registers represent the states. The
output of a code block v t at time t depends on the current state
σ t and the information block ut .
3. Each change of state σ t → σ t+1 is associated with the input of
an information block and the output of a code block.
4. The state diagram is obtained by drawing a graph. In this graph,
nodes are possible states and the state transitions are labelled
with the appropriate inputs and outputs (ut /v t ). In this course
we only consider the convolutional encoder with state diagrams
that do not have parallel transitions.
5. The state of the encoder can be expressed as k-tuple of the
memory values:
S = (σ 0 , σ 1 , . . . , σ t , . . .),
-⊕P
iP bv 1 = (1010011)
6 PPP J
]
P J
u = (11101) r - r - -r J b v = (11 01 10 01 00 10 11)
³ ³³ ^
³
³³
-⊕) bv 2 = (1101001)
10
1/11 1/01
01
0/11 0/01
si 10 si 10 si 10 si
3 3 3 3
¡ A01 ¡ A01 ¡ A01 ¡ A01
¡ ¡ ¡ ¡
01A 01A 01A A
¡
01
¡ ¡ ¡
si
1 1 A
si 1 A
si 1 A
si 1 A
si
10 A 10 A 10 A 10 A
¢ @ ¢ @ ¡ @ ¡¢ @ ¡¢ @
10
¢
¢ @¢ 00 ¡ @A¢ 00 ¡ @A¢ 00 ¡ @A¢ @A
¢ ¢@si¡ ¢@A i ¡ ¢@A i ¡ ¢@A i @A i
2 11 s2 11 s2 11 s2 11 s2 11
¢ ¢ @ ¢ @ ¢ @ ¢ @ @
Origin ¢ ¢ ¢@ ¢@ ¢@ Terminal
@ @
node11i¢ 00 11i ¢ 00 11i ¢ 00@ 11i¢ 00@ 11i¢ 00@ i 00@ i 00@node
s0 s0 s0 s0 s0 s0 s0 si
0
level 0 1 2 3 4 5 6 7
Path Enumerators
2 10
W W
1 1 W W
00 11
2 01
W W
00
2
W
X 1
10
W
1 W W
11
X 2
X 3
01
W
2
W
00
X1 = X3 + W 2
X2 = W X1 + W X2
X3 = W X1 + W X2
and
T (W ) = W 2 X3 .
Systematic Matrix
1. An important subclass of convolutional codes is the systematic
codes, in which k out of n output sequences retain the values of
the k input sequences. In other words, these outputs are directly
connected to the k inputs in the encoder.
2. A generator matrix of a systematic code has the following
structure:
1 G1,k+1 (D) · · · G1,n (D)
.. ..
1 . .
G(D) =
..
.
1 Gk,k+1 (D) Gk,n (D)
= (I k | R(D)),
-⊕ b v1
6 J]
J
r - r - r - -r Jb v
u
^
-⊕? -⊕? -⊕? b v 2
4. Since w ≤ p, we have Rm ≤ Rp .
5. w can not be too small in order to assure that Rp ≤ 1.
2. Let
1 0 0 0 0 1
P =
1 1 1 1 1 0
5.
11 01 01 01 01 10 11 01 01 01 01 10 11 01
11 10 11
11 10 11
11 10 11
11 10 11
11 10 11
11 10 11
11 10 11
11 10 11
11 10 11
11 10 11
11 10 11
11 10 11
References
[1] M. Bossert, Channel Coding for Telecommunications. New York,
NY: John Wiley and Sons, 1999.
Hari Palaiyanur
May 13, 2005
1 Introduction
Error control codes are a way of combatting uncertainty in the transmission
of information from one point to another. Information theory shows the exis-
tence of codes that allow for arbitrarily reliable communication when the rate
of transmission is less than the channel capacity. However, it doesn’t provide
schemes that are practical to achieve this. Error control coding strives to find
codes that provide for good performance in terms of error probability, but also
low complexity in encoding and decoding.
The first major class of codes designed for this purpose was linear block
codes, having been invented in the late 1940’s and early 1950’s. Linear block
codes take a fixed number, k, of input symbols and encode them into a larger,
fixed number, n, of output symbols in some linear fashion. Some of the major
classes of linear block codes we have discussed in class are Hamming codes,
Reed-Muller codes, BCH codes and Reed-Solomon codes. Each of these codes
introduces redundancy into a sequence of input symbols in a controlled manner
to improve the resistance of the transmitted codewords to noise. However, each
block has no dependence on other blocks.
Convolutional codes were first introduced in the mid-1950’s as an alternative
to block codes. At each time step, a convolutional code takes k input symbols
and encodes them into n output symbols. However, we allow for each block to
depend on other blocks of k inputs in a manner that can be implemented as
a finite state machine. We will assume that each block is allowed to depend
only on previous blocks of inputs, and not future blocks of inputs. The use
of memory in convolutional codes makes the code structure more complicated
than a block code and increases complexity in the encoder by the use of shift
registers storing previous inputs, but the additional structure has advantages in
decoding.
A convolutional code can be represented by a trellis. The trellis describes
the codewords of the code as paths through a directed graph. If we weight the
edges of this trellis with log-likelihoods, then maximum-likelihood decoding can
1
A property of MVG_OMALLOOR
be viewed as the problem of finding the shortest path from the root or start
of the trellis to the end. Maximum likelihood (ML) decoding of convolutional
codes is accomplished in this manner through the well known Viterbi Algorithm
[1].
While the Viterbi Algorithm provides the optimal solution, it may not be
practical to implement for certain code parameters. Sequential decoding algo-
rithms, such as the Stack Algorithm and Fano Algorithm can be useful in some
cases where the Viterbi algorithm is not practical.
The performance criteria we use when evaluating these various algorithms
will be probability of error. In an unterminated convolutional code used over a
noisy channel, the probability of error will tend to 1, so instead we will focus
on the probability of error per unit time in most cases.
The purpose of this project was to become familiar with several decoding
procedures and then evaluate their performance in terms of this probability of
error per unit time for randomly generated convolutional codes. In this process,
roughly speaking, we come across results concerning convolutional codes using
ML decoding, block codes derived from terminated convolutional codes using
ML decoding, and convolutional codes using sequential decoding. (The code
itself doesn’t use the decoding process, but the probability of error depends
both on the code and the decoding process chosen.) We will mostly cover
results, but since my personal goal for the project was to become familiar with
proof techniques used for ML decoding analysis, we give a few detailed proofs
of theorems. The main sources from which these results are drawn are Forney’s
papers on ML decoding [2] and sequential decoding [3] and Zigangirov’s book
[4] on convolutional codes. For a quick, general introduction to convolutional
codes, Lin and Costello’s textbook[5] is useful.
2
A property of MVG_OMALLOOR
previous time and the present time. So for this code, q = 2, k = 1, M = 2 and
n = 2.
00
00
11
01
0 00 11
10
···
00
10 01
1 11
01
10
10
In general, at time zero, there is only the root node, at time 1, there are M
nodes, at time 2, there are M 2 nodes and so on. Now we note that we have
required the convolutional code encoder to be implemented with a finite state
machine. Eventually there is a depth in the tree when the number of nodes at
that depth exceeds the number of possible states in the encoder. At this depth
and afterwards, the tree contains redundant information about the encoder.
This is because we again require that future outputs depend only on the state
and future inputs. Hence, all we really need to keep track of for purposes of
knowing the output of the encoder is the state of the encoder at each time. The
code trellis is formed from the code tree by merging nodes corresponding to the
same encoder state.
Figure 2 shows the trellis for the example in Figure 1. As can be seen,
there are two possible states, corresponding to the fact that the present output
depends on the previous input as well as the present input. Define νi to be the
memory of the ith input inPthe convolutional encoder. Also, define the overall
k
constraint length as ν0 = i=1 νi . We only consider νi = ν so that ν0 = kν,
because in general, it is harder to prove results about convolutional codes in
which the memories of the inputs are different. We define the state at time t
to be St = (Xt−1 , Xt−2 , . . . , Xt−ν ) where Xt is the k-tuple of inputs at time
t. After time ν, each state in the trellis has M predecessors and M successors.
3
A property of MVG_OMALLOOR
The M successors of any given state all have the same M predecessors.
10 10
S1
11 11 11
···
01 01
00 00 00
S0
Next, we note that a block code can be thought of as a trivial block code
with no memory. Also, we can form a block code from a convolutional code by
terminating it at some time τ . In such a terminated convolutional code, there
are a total of K = kτ input symbols and N = nτ output symbols. Sometimes,
in terminated convolutional codes, it is necessary to end all input sequences with
a particular length ν sequence to ’clear’ the states of the encoder. In this case,
the terminated convolutional code has M0 = M τ −ν total codewords. Below we
define the rates of a convolutional code and a terminated convolutional code as
r and R respectively. Finally, we note that we can still use a trellis to describe
a terminated convolutional code.
ln M
r =
n
ν
θ ,
τ
1
R = ln M0
N
= r(1 − θ)
4
A property of MVG_OMALLOOR
matrix pjl = P r(zi = j|yi = l). Inherent in this notation is the assumption that
the channel is time-invariant.
yi Discrete Memoryless zi
Channel
Γ(y) , − ln P r(z|y)
ŷ = arg maxy∈C L(y)
= arg miny∈C Γ(y)
Sometimes, a tie will occur in choosing ŷ, in which case we can pick one of
the best choices randomly or deterministically. Also, we note that Γ is actually
the negative log-likelihood, but we will refer to it freely as the log-likelihood.
The Viterbi Algorithm allows us to find this optimal codeword efficiently.
To do this we first note that,
Γ(y) = − ln P r(z|y)
N
X
= − ln P r(zi |yi )
i=1
Xτ nt
X
= − ln P r(zi |yi )
t=1 i=n(t−1)+1
The total log-likelihood for a potential codeword is the sum of the log-
likelihoods of each branch of the codeword. So in the code trellis, we can label
each branch with the log-likelihood of channel outputs on that branch. Now, as
we go through the trellis for each codeword, we add up these ’lengths’ along the
way until we go from the start to the end. The problem of finding the optimal
codeword for ML decoding now becomes the problem of finding the shortest
path through the trellis. The Viterbi Algorithm provides a way to do this and
it is summarized below.
5
A property of MVG_OMALLOOR
2. For each node at time t + 1 find, for each of its predecessors, the sum
of the predecessor’s length with the length of the branch connecting the
predecessor at time t with the node at time t + 1. Assign the minimum
of these sums as the ’length’ of the node, and label the node with the
shortest path to it from the root. If there is a tie, choose one of the paths
randomly.
3. If t = τ , stop. The decoded codeword is the shortest path from the root
to a node at time τ . If t is not τ , go to step 2.
6
A property of MVG_OMALLOOR
Theorem 1 Over the ensemble of random (M, ν, n) trellis codes using ML de-
coding,
X·X 1
¸1+ρ
1+ρ
E0 (ρ) = − ln pl pjl
j l
E0 (ρr )
and 0 ≤ ρ ≤ 1 and ρ < ρr , where ρr is related to r by r = ρr .
Since this bound is an average over all codes in the ensemble, it is true
for at least one code in the ensemble. Assuming for the moment that the
theorem is true, we can quickly prove a corollary about block codes derived
from convolutional codes.
7
A property of MVG_OMALLOOR
where the indices on the brackets indicate restriction of the paths to within
those times. Now define
· ¸t+κ
0 P r(z|y0 )
Γ(y ) , ln
P r(z|y) t
· X ¸ρ
Tt (α, ρ) , exp[αΓ(y0 )] 0 ≤ α, 0 ≤ ρ ≤ 1
y0 ∈St
where the expectation is taken over all randomness in the codes and the channel.
Next, we need to bound the number of paths that can diverge at time t and
re-merge at time t + κ. Hence we are interested in the number of possible error
events in the configuration, as Forney calls it, of paths that diverge at time t
and re-merge at time t + κ. Define Ctκ to be the set of all possible error events
starting at time t and ending at time t + κ. Figure 4 shows a typical element
of Ctκ along with the correct path. Since the last ν time steps’ inputs must be
the same as those of the correct path to re-merge with it, a bound on the size
8
A property of MVG_OMALLOOR
Lemma 1
· ¸
E Ttκ (α, ρ) ≤ |Ctκ |ρ exp[−nκE0 (ρ)] 0≤ρ≤1
time t time t + κ
9
A property of MVG_OMALLOOR
Hence, Theorem 1 says that the probability or error per unit time is exponen-
tially decreasing in constraint length. This shows explicitly that the increased
complexity in the structure of the code helps in decoding of the code.
A few more bounds on error probability for ML decoding are stated before
we move on to sequential decoding algorithms.
Theorem 2 For any probability vector on channel inputs p and any ² > 0,
there exists a block code of length N and rate R with block error probability,
P r(E), so that
P r(E) ≤ K1 N exp[−N (E(R) − ²)]
where E(R) = max0≤ρ≤1 E0 (ρ) − ρR.
The random block coding error exponent, E(R), is known to be tight for
rates close to channel capacity. The proof of Theorem 2 also uses terminated
convolutional codes. Interestingly, Theorem 2 says that one can get an optimal
block code from an appropriately terminated convolutional code.
The last sample result concerns bounded delay decoding of convolutional
codes.
P r(Ea ) ≤ exp[−nκE(r)]
where E(r) is the block code exponent evaluated at the rate of the convolutional
code.
10
A property of MVG_OMALLOOR
This result comes essentially from the proof of the channel coding theorem
with block codes. An incorrect symbol decision at time t would lead the Viterbi
decoder on a path which is statistically independent of the correct path, and so
the analysis of Gallager[6] can be used, with the block length equal to nκ.
11
A property of MVG_OMALLOOR
P r(Et ) ≤ K exp[−nνρr]
where K is a constant independent of ν.
The proof of this result is similar to the proof of Theorem 1, with an ad-
justment of the quantity Tt being bounded. By the properties of Gallager’s
function E0 , if 0 ≤ ρr ≤ 1, then E0 (1) = Rcomp ≤ r ≤ C and as ρ goes to ρr ,
we have asymptotically the same result in Theorem 1 as in this theorem about
sequential decoding. That is, for the high rate region, sequential decoding is
asymptotically as good as ML decoding.
The last result stated is one about the random variable of computation.
Theorem 5 Let C be the number of computations performed by any sequential
decoder. Then P [C > L] ' L−ρ where ρ is a parameter that depends on both
the channel and the rate of the code. That is, the distribution of the random
variable of computation is lower bounded by a Pareto distribution.
The impact of this theorem, proved by Jacobs and Berlekamp[7], is that there
always exists a moment of computation that is infinite. Hence, there is some
unavoidable probability that the sequential decoder will perform extremely long
searches and run into a buffer overflow in a real system.
12
A property of MVG_OMALLOOR
8 Conclusion
In this survey paper, we first described a convolutional code as a directed graph
called a trellis, or a tree code. Then, we looked at the problem of ML decoding
over DMC channels and the Viterbi Algorithm as a solution to this problem. We
stated some results about probability of error per unit time for random trellis
codes and gave one detailed proof. We stated the result that one can get an
optimum block code from a properly terminated convolutional code. Then we
explained sequential decoding, the Stack Algorithm, and a few variants. Finally,
we stated a few results about sequential decoders, namely that for certain rates
they can be as ’good’ as ML decoders, and that they are always ’bad’ in the
sense that there exist moments of the random variable of computation that are
infinite.
I would like to thank Professor Anantharam for giving me and the rest of
the class the opportunity in the project to look into an area of coding theory in
depth when we didn’t have time to cover it in class.
13
A property of MVG_OMALLOOR
References
[1] A.J. Viterbi, “Error Bounds for Convolutional Codes and an Asymptot-
ically Optimum Decoding Algorithm,” IEEE Trans. Information Theory,
IT-13:260-69, April 1967
[2] G.D. Forney Jr., “Convolutional Codes II: Maximum Likelihood Decoding,”
Information and Control, 25:222-66, July 1974.
[3] G.D. Forney Jr., “Convolutional Codes III: Sequential Decoding,” Infor-
mation and Control, 25:267-97, July 1974.
14
A property of MVG_OMALLOOR
Warning : Use at your own risk ! These notes have not been sufficiently carefully screened.
1 Convolutional Codes
1.1 Introduction
Suggested reference for convolutional codes : “Fundamentals of Convolutional Coding” by Rolf
Johannesson and Kamil Zigangirov, IEEE Press, 1999.
An encoder for a binary block code takes a block of information bits and converts it into a block
of transmitted bits (a codeword). A binary convolutional encoder takes a stream of information
bits and converts it into a stream of transmitted bits, using a shift register bank. Redundancy for
recovery from channel errors is provided by transmitting more bits per unit time than the number
of information bits per unit time. Maximum likelihood decoding can be done using the Viterbi
algorithm; other decoding algorithms such as SOVA (soft output Viterbi algorithm) and the BCJR
algorithm are also commonly used. In practice the information stream is of finite duration and one
typically appends a few termination bits to the input stream to bring the shift register bank back
to the all zeros state, so that the convolutional code is in effect used as a very long block code.
Often convolutional codes are used as inner codes with burst error correcting block codes as
outer codes to form concatenated codes. Errors in Viterbi-like decoding algorithms for convolutional
codes tend to occur in bursts because they result from taking a wrong path in a trellis. The burst
error correcting capability of the outer code is used to recover from such burst error patterns in
the decoding of the inner code. See Section 15.6 on pp. 760 -761 of the text of Lin and Costello
(2nd edition) for a short discussion of this idea.
Definition 1 Let ( )
∞
X
i
F ((D)) = xi D : xi ∈ F, r ∈ Z
i=r
The D is a formal place holder to represent one step of delay. With addition and multiplication
defined in the obvious way F ((D)) becomes a field. Because the Laurent series are finite to the left,
multiplication is well defined (as then we don’t have to sum an infinite number of terms). All the
1
A property of MVG_OMALLOOR
axioms of a field are easy to check except the existence of a multiplicative inverse. A multiplicative
inverse can be constructed explicitly by “long division”.
Definition 2 Let (∞ )
X
F [[D]] = xi D i : xi ∈ F, r ≥ 0
i=r
With addition and multiplication defined in the obvious way F [[D]] is a ring (in a ring, as
opposed to a field, we do not require the existence of a multiplicative identity and we do not
requrie the existence of multiplicative inverses for nonzero elements).
Definition 3 Let ( )
d
X
i
F [D] = xi D : xi ∈ F, 0 ≤ r ≤ d < ∞
i=r
With addition and multiplication defined in the obvious way F [D] is a ring.
Definition 4 Let
p(D)
F (D) = : p(D), q(D) ∈ F [D]
q(D)
be the set of binary rational functions.
With addition and multiplication defined in the obvious way F (D) is a field.
Note that we have
F [D] ⊂ F (D) ⊂ F ((D))
and
F [D] ⊂ F [[D]] ⊂ F ((D)).
Definition 5 Let
τ : F k ((D)) → F n ((D))
defined by
τ (x(D)) = x(D)G(D)
where G(D) ∈ F (D)k×n (k × n matrices of rational functions) and G(D) has rank k. G(D) is
called a transfer function.
Definition 7 A rate R = k/n convolutional code is the image of a rate R convolution mapping.
2
A property of MVG_OMALLOOR
Given a k × n transfer function G(D) and x(D) ∈ F k ((D)), then y(D) = x(D)G(D) ∈ F n ((D))
is the code sequence corresponding to the input sequence x(D).
Definition 8 Given x(D) ∈ F ((D)), its delay del(x(D)) is the smallest r for which xr = 1.
Definition 11 G(D) ∈ F (D)k×n is called realizable if each of its elements is realizable. Such a
G(D) is called a generator matrix.
Definition 12 A generator matrix (a transfer function matrix that is realizable) is called delay
free if at least one of its elements is delay free.
Theorem 1 Any convolutional code C ⊆ F n ((D)) is the image of a convolutional mapping with a
transfer function matrix that is a delay free generator matrix.
Proof: Suppose C is the image of F k ((D)) under the mapping corresponding to G(D) ∈ F (D)k×n .
Write
G(D) = [gij (D)]k×n
where gij (D) = pij (D)/qij (D). Now write
Ĝ(D) = D −s G(D).
Then Ĝ(D) is a delay free generator and the image of F k ((D)) under the transformation corre-
sponding to Ĝ(D) is C. 2
In general a transfer function matrix may not be realizable, so any shift register bank that
implements it would need to be noncausal. The preceding result shows that any convolutional
code has a generator matrix ( a realizable transfer function matrix), which can now be built with
a causal shift register bank. Further we can ensure that there is no “unnecessary delay” (this the
content of the delay free condition). The following result shows that we can actually even use any
convolutional code with feedforward shift register banks (i.e. no need for feedback, or, in other
words, a polynomial transfer function matrix).
Theorem 2 Any rate R = k/n convolutional code C is the image of F n ((D)) under a transfer
function matrix that is
• a generator
• delay free
• polynomial
3
A property of MVG_OMALLOOR
Proof: We already know from the previous theorem that C is the image of F k ((D)) under a
G(D) ∈ F (D)k×n that is realizable and delay free. Write
where gij (D) = pij (D)/qij (D), qij (0) = 1, 1 ≤ i ≤ k, 1 ≤ j ≤ n, and there is at least one (i, j) with
pij (0) = 1. Let q(D) = lcm({qij (D) : 1 ≤ i ≤ k, 1 ≤ j ≤ n}). Let
Ĝ(D) = q(D)G(D).
Then C is the image of F k ((D)) under Ĝ(D). Ĝ(D) is a polynomial matrix and thus realizable. Since
all the qij (0) = 1, q(0) = 1. So for the same (i, j) for which pij (0) = 1 will have q(0)pij (0)/qij (0) = 1
making Ĝ(D) delay free.
Definition 13 A rate R = k/n convolutional mapping is said to be systematic if some k of the code
sequences are exactly the k input sequences. Equivalently, after reordering the output coordinates
the corresponding transfer function matrix G(D) has the form
Every convolutional code has both systematic and non-systematic convolutional mappings that
result in the same code.
In block codes errors cannot propagate very far because of finite size blocks. This is not
necessarily the case for convolutional codes as it is possible for a “finite” error in the code sequence
to have an “infinite” error in the corresponding input sequence.
Every code has catastrophic and non-catastrophic mappings that result in that code.
Several examples relating to the definitions were discussed in class. See also the text of Lin and
Costello and the book of Johannesson and Zigangirov.
G(D) = A(D)Γ(D)B(D)
∆i (D)
γi (D) =
∆i−1 (D)
Therefore,
G(D) = A(D)Γ(D)B(D)
where A(D) and B(D) are unimodular with size k × k and n × n, respectively, and
α1 (D)
β1 (D)
.. 0
Γ(D) = .
αr (D)
βr (D)
0 0
5
A property of MVG_OMALLOOR
x(D)G(D) = 0 . . . 1 0| .{z
. . 0} B(D)
n−k
is a polynomial, so it corresponds to a sequence with finitely many 1’s. Thus we have found an
input sequence with infinitely many 1’s that is encoded as an output sequence with finitely many
1’s. This means that G(D) is catastrophic.
Definition 15 A generator matrix G(D) is called basic if it is polynomial and has a polynomial
right inverse.
Note: Any basic generator matrix is an (basic) encoding matrix. (A generator matrix G(D) is
called an encoding matrix if G(0) is invertible.)
One consequence is that decoding can be conceptually viewed as in the figure, when a basic generator
matrix is used for encoding. Namely, one can view the decoding problem in two stages as that of
first finding the most likely output sequence that explains the (noisy) observations and then using
the (feedforward) inverse of the basic encoding matrix to recover the corresponding information
sequence.
Proof: We already know that C can be described by a polynomial delay free matrix. Call it
G(D). Let G(D) = A(D)Γ(D)B(D) be the Smith form of G(D), where
Note that
G(D) = A(D) [diag(γi (D)), 1 ≤ i ≤ k] Ĝ(D)
where Ĝ(D) is the k × n matrix consisting of the k rows of B(D). Also A(D) [diag(γi (D))] is
invertible as a rational matrix. So Ĝ(D) also describes C. Further Ĝ(D) is a polynomial matrix
6
A property of MVG_OMALLOOR
e(D)
basic polynomial
generator matrix
Figure 1:
and the first k columns of B −1 (D) give a right inverse for Ĝ(D), and this is a polynomial right
inverse because B −1 (D) is polynomial.
Corollary: For any convolutional code C, any basic (i.e. polynomial with polynomial inverse)
generator matrix is non-catastrophic.
Proof : γk (D) = 1 = D 0 and use Massey-Sain, i.e. Theorem 1.
7
A property of MVG_OMALLOOR
The i-th coordinate of the information sequence (viewed as a block of k bits at any symbol interval)
will need to go into a shift register with γi blocks, the longest such shift register will have length
m, and the overall number of blocks in all the k shift registers involved will be γ.
Definition 16 A minimal basic encoding matrix is one whose overall constraint length is the small-
est among all basic encoding matrices for the same code.
Note: A convolutional code can have more than one basic encoding matrix describing it. In fact, if
a basic encoding matrix is multiplied on the left or the right by any unimodular matrix, this gives
another basic encoding matrix for the same code.
Now consider G(D), an arbitrary generator matrix for C.
" #
pij (D)
G(D) =
qij (D)
Definition 17 A minimal generator matrix for C is one whose overall constraint length γ is small-
est among all generator matrices describing C.
Theorem :
(I) A basic encoding matrix G(D) is minimal iff the 0-1 matrix of the highest degree terms in
each row is full rank. For example
" # " #
1 + D D2 D2 + D 1 0 1 1 0
G(D) = =⇒
D D3 D2 1 + D3 0 1 0 1
and this is a full rank matrix, so G(D) is a minimal basic encoding matrix for the code that
it describes.
(III) Any two minimal generator matrices have exactly the same constraint lengths up to reorder-
ing.
8
A property of MVG_OMALLOOR
For proofs of these results, see the book of Johannesson and Zigangirov.
Note : Every convolutional code has a systematic generator matrix (this is just using the
assumption that any generator matrix for the code has full rank), but there are convolutional codes
that do not have systematic polynomial generator matrices. For instance, the rate 1/2 code with
generator matrix
G(D) = [1 + D 1 + D + D 2 ] .
where Ĝ(D)−1 is a right inverse of G(D) and (H T (D))−1 is a right inverse for H T (D). The
convolutional code generated by H(D) is called the dual code of C.
The connection with the block code notion of duality was described in class. See also the book
of Johannesson and Zigangirov.
9
A property of MVG_OMALLOOR
x(1) c(1)
D D D +
c(2)
+
x(2) c(3)
D D +
Figure 2.1: Example convolutional encoder where x(i) is an input information bit
stream and c(i) is an output encoded bit stream [Wic95].
The information bits are input into shift registers and the output encoded bits are obtained
by modulo-2 addition of the input information bits and the contents of the shift registers.
The connections to the modulo-2 adders were developed heuristically with no algebraic or
combinatorial foundation.
where k is the number of parallel input information bits and n is the number of parallel
output encoded bits at one time interval. The constraint length K for a convolutional code
is defined as
K = m+1 (2.2)
where m is the maximum number of stages (memory size) in any shift register. The shift
registers store the state information of the convolutional encoder and the constraint length
relates the number of bits upon which the output depends. For the convolutional encoder
shown in Figure 2.1, the code rate r=2/3, the maximum memory size m=3, and the
constraint length K=4.
A convolutional code can become very complicated with various code rates and
constraint lengths. As a result, a simple convolutional code will be used to describe the
code properties as shown in Figure 2.2.
c(1)
x(1)
D D
c(2)
Figure 2.2: Convolutional encoder with k=1, n=2, r=1/2, m=2, and K=3.
0 0
0 0
0 0 1 1
1 0
1 1
0 1
0 0 0
1 1
1 0
0 0
1 1
0 1
0 1
1 0
0 0
1 1
1 1
1 0
1 0
0 0
0 1
1 1
1 1
1 0 1
0 0
0 1
0 1
1 0
1 0
t= 0 t= 1 t= 2 t= 3 t= 4
Figure 2.3: Tree diagram representation of the encoder in Figure 2.2 for four input
bit intervals.
In the tree diagram, a solid line represents input information bit 0 and a dashed line
represents input information bit 1. The corresponding output encoded bits are shown on
the branches of the tree. An input information sequence defines a specific path through
the tree diagram from left to right. For example, the input information sequence
x={1011} produces the output encoded sequence c={11, 10, 00, 01}. Each input
information bit corresponds to branching either upward (for input information bit 0) or
downward (for input information bit 1) at a tree node.
10
1/11 1/01
0/00 0/10
00 11
1/00 1/10
0/11 0/01
01
In the state diagram, the state information of the encoder is shown in the circles. Each
new input information bit causes a transition from one state to another. The path
information between the states, denoted as x/c, represents input information bit x and
output encoded bits c. It is customary to begin convolutional encoding from the all zero
state. For example, the input information sequence x={1011} (begin from the all zero
state) leads to the state transition sequence s={10, 01, 10, 11} and produces the output
encoded sequence c={11, 10, 00, 01}. Figure 2.5 shows the path taken through the state
diagram for the given example.
10
1/11 1/01
0/00 0/10
00 11
1/00 1/10
0/11 0/01
01
Figure 2.5: The state transitions (path) for input information sequence {1011}.
LEGEND
00 0/00 00 States
1/11 0/11 00
01 01
1/00 01
0/10
10 10
1/01 0/01
10
11 11
1/10 11
i i+1 0 1 2 3 4 Time
Time
Figure 2.6: Trellis diagram representation of the encoder in Figure 2.2 for four
input bit intervals.
Figure 2.7 shows the trellis path for the state transitions in Figure 2.5.
00
01 1/11
0/10
1/00
10
1/01
11
0 1 2 3 4 Time
Figure 2.7: Trellis path for the state transitions in Figure 2.5.
Sj
1/00
1/00
Si 0/00
Si
1/00
Sk
BPSK
x Convolutional c Modulator
Encoder c=0 -> send -1
c=1 -> send +1
Noise Channel
r Soft-Decision
y Convolutional BPSK
Decoder Hard-Decision Demodulator
r=rout rin
rin<=0 -> rout=0
rin>0 -> rout=1
x Convolutional c r Viterbi y
Channel
Encoder Decoder
Noise
For a rate r convolutional code, the encoder inputs k bits in parallel and outputs n
bits in parallel at each time step. The input sequence is denoted as
x=(x0(1), x0(2), ..., x0(k), x1(1), ..., x1(k), xL+m-1(1), ..., xL+m-1(k)) (2.3)
and the coded sequence is denoted as
c=(c0(1), c0(2), ..., c0(n), c1(1), ..., c1(n), cL+m-1(1), ..., cL+m-1(n)) (2.4)
where L denotes the length of input information sequence and m denotes the maximum
length of the shift registers. Additional m zero bits are required at the tail of the
information sequence to take the convolutional encoder back to the all-zero state. It is
required that the encoder start and end at the all-zero state. The subscript denotes the
time index while the superscript denotes the bit within a particular input k-bit or output n-
bit block. The received and estimated sequences r and y can be described similarly as
r=( r0(1), r0(2), ..., r0(n), r1(1), ..., r1(n), rL+m-1(1), ..., rL+m-1(n)) (2.5)
and
y=(y0(1), y0(2), ..., y0(n), y1(1), ..., y1(n), yL+m-1(1), ..., yL+m-1(n)). (2.6)
L + m −1 n
= ∏ ∏ p(ri( j) | yi( j) ) [Wic95] (2.8)
i = 0 j=1
This equation is called the likelihood function of y given that r is received [Vit71]. The
estimate that maximizes p(r|y) also maximizes log p(r|y) because logarithms are
monotonically increasing functions. Thus, a log likelihood function can be defined as
L + m −1 n
log p(r| y) = ∑ ∑ log p(ri( j) | yi( j) ) [Wic95] (2.9)
i = 0 j=1
For an easier manipulation of the summations over the log function, a bit metric is
defined. The bit metric is defined as
M (ri ( j ) | yi( j ) ) = a[log p(ri ( j ) | yi( j ) ) + b] [Wic95] (2.10)
where a and b are chosen such that the bit metric is a small positive integer [Wic95].
The values a and b are defined for binary symmetric channel (BSC) or hard-decision
decoding. Figure 2.11 shows a BSC.
1-p
0 0
p
Transmitted Received
Bit p Bit
1-p
1 1
Figure 2.11: The binary symmetric channel model, where p is the crossover
probability.
For BSC, a and b can be chosen in two distinct ways. For the conventional way,
they can be chosen as
1
a= [Wic95] (2.11)
log p − log(1 − p)
and
b = − log(1 − p) [Wic95] (2.12)
The resulting bit metric is then
1
M (ri ( j ) | yi( j ) ) = [log p(ri ( j ) | yi( j ) ) − log(1 − p)] (2.13)
[log p − log(1 − p)]
From the BSC model, it is clear that p(ri ( j ) | yi( j ) ) can only take on values p and 1-p.
Table 2.1 shows the resulting bit metric.
This bit metric shows the cost of receiving and decoding bits. For example, if the
decoded bit yi( j ) = 0 and the received bit ri ( j ) = 0 , then the cost M (ri ( j ) | yi( j ) ) = 0.
However, if the decoded bit yi( j ) = 0 and the received bit ri ( j ) = 1, then the cost
M (ri ( j ) | yi( j ) ) = 1. As it can be seen, this is related to the Hamming distance and is
known as the Hamming distance metric. Thus, the Viterbi algorithm chooses the code
sequence y through the trellis that has the smallest cost/Hamming distance relative to the
received sequence r.
For this case, the Viterbi algorithm chooses the code sequence y through the trellis that
has the largest cost/Hamming distance relative to the received sequence r. Furthermore,
for an arbitrary channel (not necessarily BSC), the values a and b are found on a trial-and-
error basis to obtain an acceptable bit metric.
From the bit metric, a path metric is defined. The path metric is defined as
L + m −1 n
M(r| y) = ∑ ∑ M(ri( j) | yi( j) ) [Wic95] (2.17)
i = 0 j=1
and indicates the total cost of estimating the received bit sequence r with the decoded bit
sequence y in the trellis diagram. Furthermore, the kth branch metric is defined as
n
M (rk | y k ) = ∑ M (rk( j ) | y k( j ) ) [Wic95] (2.18)
j =1
The kth branch metric indicates the cost of choosing a branch from the trellis diagram.
The kth partial path metric indicates the cost of choosing a partially decoded bit sequence
y up to time index k.
The Viterbi algorithm utilizes the trellis diagram to compute the path metrics.
Each state (node) in the trellis diagram is assigned a value, the partial path metric. The
partial path metric is determined from state s = 0 at time t = 0 to a particular state s = k at
time t ≥ 0. At each state, the “best” partial path metric is chosen from the paths
terminated at that state [Wic95]. The “best” partial path metric may be either the larger
or smaller metric, depending whether a and b are chosen conventionally or alternatively.
The selected metric represents the survivor path and the remaining metrics represent the
nonsurvivor paths. The survivor paths are stored while the nonsurvivor paths are
discarded in the trellis diagram. The Viterbi algorithm selects the single survivor path
left at the end of the process as the ML path. Trace-back of the ML path on the trellis
diagram would then provide the ML decoded sequence.
LEGEND
S ta te s S ta te s
0 /0 0
0 0 0 0
1 /1 1 0 /1 1
0 1 0 1
1 /0 0
0 /1 0
1 0 1 0
1 /0 1 0 /0 1
1 1 1 1
1 /1 0
i i+ 1
T im e
Figure 2.12: The state transition diagram (trellis legend) of the example
convolutional encoder.
The state transition diagram shows the estimated information and coded bits along the
branches (needed for the decoding process). HDVA decoding chooses the ML path
through the trellis as shown in Figure 2.13. The chosen partial path (accumulated) metric
for this example is the smallest Hamming distance and are shown in the figure for every
node. The bold partial path metrics correspond to the ML path. Survivor paths are
represented by bold solid lines and competing paths are represented by simple solid lines.
For metric “ties”, the first branch is always chosen.
TRELLIS DIAGRAM
States
0 1 2 2 3 3 4 1
00
TIE
01 1 3 1 TIE 4 1
10
1 2 1 3 1
3 3 3 4
11 TIE TIE
0 1 2 3 4 5 6 7
Time
From the trellis diagram in Figure 2.13, the estimated code sequence is y={11, 10, 00, 10,
00, 10, 11} which is the code sequence c. Utilizing the state transition diagram in
Figure 2.12, the estimated information sequence is x’={1010100}.
2
log πNo (2.24)
−1 L+ m−1 n ( j) 2 ( L + m)n
= ∑ ∑ [ri − 2ri yi Eb + yi Eb ] −
No i = 0 j=1
( j) ( j) ( j) 2
2
log πNo (2.25)
where yi( j )2 = 1
L + m −1 n ( j) ( j)
= C1 ∑0 ∑1 ri yi + C 2 (2.26)
i= j=
where C1 and C2 are all terms not a function of y
= C1 (r • y) + C2 (2.27)
From this, it is seen that the bit metric can be defined as
M (ri ( j ) | yi( j ) ) = ri ( j ) yi( j ) (2.28)
The soft-decision Viterbi algorithm (SDVA2) can be implemented as follows:
Sk,t is the state in the trellis diagram that corresponds to state Sk at time t. Every
state in the trellis is assigned a value denoted V(Sk,t).
1. (a) Initialize time t = 0.
(b) Initial V(S0,0) = 0 and all other V(Sk,t) = -∞.
2. (a) Set time t = t+1.
(b) Compute the partial path metrics for all paths going to state Sk at time t.
n
First, find the tth branch metric M (rt | y t ) = ∑ M (rt( j ) | y t( j ) ) . This is calculated
j =1
n
from the correlation of ri ( j ) and yi( j ) , ∑r
j =1
i
( j)
yi( j ) . Second, compute the tth partial
t
path metric Mt (r| y) = ∑ M(ri | y i ) . This is calculated from
i =0
V(S k,t-1 ) + M (rt | y t ) .
3. (a) Set V(Sk,t) to the “best” partial path metric going to state Sk at time t. The
“best” partial path metric is the partial path metric with the largest value.
(b) If there is a tie for the “best” partial path metric, then any one of the tied
partial path metric may be chosen.
4. Store the “best” partial path metric and its associated survivor bit and state paths.
5. If t < L+m-1, return to Step 2.
Generally with soft-decision decoding, approximately 2 dB of coding gain over hard-
decision decoding can be obtained in Gaussian channels.
of obtaining the transfer function and other related performance measures are described
below.
1/00=NJ
1/11=NJD2 0/11=JD 2
Sa 00 Sb 10 Sc 01 Se 00
0/10=JD
1/01=NJD 0/01=JD
Sd 11
1/10=NJD
Figure 2.14: The modified state diagram of Figure 2.4 where Sa is the start state and
Se is the end state.
Nodal equations are obtained for all the states except for the start state in Figure 2.14.
These results are
Sb = NJD 2 S a + NJS c
S c = JDS b + JDS d
S d = NJDSb + NJDS d
S e = JD 2 S c
number of bit errors in the decoded sequence. Usually, these error probabilities are
defined using the Chernoff Bounds and are derived in [Pro95], [Rhe89], [Wic95].
For hard-decision decoding, the first event error and bit error probabilities are
defined as
Pe < T ( D, N , J )| D = 4 p (1− p ) , N =1, J =1 (2.32)
and
dT ( D, N , J )
Pb < (2.33)
dN D = 4 p (1− p ) , N =1, J =1
where
2rE b
p = Q (2.34)
No
and
∞
1
Q ( x) = ∫ e − u / 2 du
2
(2.35)
x 2π
For soft-decision decoding, the first event error and bit error probabilities are
defined as
Pe < T ( D, N , J )| D = e − rEb / N o , N =1, J =1 (2.36)
and
dT ( D, N , J )
Pb < (2.37)
dN D = e − rE b / N o , N =1, J =1
Two other factors also determine the performance of the Viterbi decoder. They
are commonly referred to as the decoding depth and the degree of quantization of the
received signal.
1.0 Prologue:
Convolutional codes, why should complicate our lives with them
People use to send voice waveforms in electrical form over a twisted pair of wires. These tel-
ephone voice signals had a bandwidth of 4KHz. If the channel polluted the signal with a bit of
noise, the only thing that happened was that the conversation got a bit noisier. As technology de-
veloped, we digitized the voice signals at 8000 samples per second (twice the highest frequency to
prevent aliasing) and transmitted the bits. If noise corrupted a few bits, the corresponding sample
value(s) would be slightly wrong or very wrong depending on whether the bad bits were near the
most-significant-bit or least-significant-bit. The conversation sounded noisier, but were still dis-
cernible. Someone saying “cat” will not be thought to have said “dog,” and probably would not
even be thought to have said “caught.”
When people started to send data files rather than voice, corrupted bits became more impor-
tant. Even one wrong bit could prevent a program from running properly. Say the noise in a chan-
nel was low enough for the probability of a bad bit to be 1x10-9 i.e. the chances of a bit being
correct is 0.999999999 (nine 9’s). The chances of 1000 bits being all correct is 0.999999 (six 9’s)
and the chances of 106 bits being all correct is 0.999 (three 9’s). A 1 megabyte file (8x106 bits) has
almost a 1% chance of being corrupted. The reliability of the channel had to be improved.
The probability of error can be reduced by transmitting more bits than needed to represent
the information being sent, and convolving each bit with neighbouring bits so that if one transmit-
ted bit got corrupted, enough information is carried by the neighbouring bits to estimate what the
corrupted bit was. This approach of transforming a number of information bits into a larger
number of transmitted bits is called channel coding, and the particular approach of convolving the
bits to distribute the information is referred to as convolution coding. The ratio of information bits
to transmitted bits is the code rate (less than 1) and the number of information bits over which the
convolution takes place is the constraint length.
For example, suppose you channel encod-
ed a message using a convolution code. Suppose Convolution
00101101 channel
you transmitted 2 bits for every information bit encoder
a b
(code rate=0.5) and used a constraint length of 3.
Then the coder would send out 16 bits for every
11 10 00 01 01 00
8 bits of input, and each output pair would de-
pend on the present and the past 2 input bits
(constraint length =3). The output would come a 3 bits in the input stream generate 2 bits
out at twice the input speed. in the output stream.
b Take the most recent of these input bits
Since information about each input bit is plus one new input bit and generate the
spread out over 6 transmitted bits, one can usual- next 2 output bits.
ly reconstruct the correct input even with several Thus each input bit effects 6 output bits.
transmission errors. FIGURE 1
The need for coding is very important in the use of cellular phones. In this case, the “chan-
nel” is the propagation of radio waves between your cell phone and the base station. Just by turn-
ing your head while talking on the phone, you could suddenly block out a large portion of the
transmitted signal. If you tried to keep your head still, a passing bus could change the pattern of
bouncing radio waves arriving at your phone so that they add destructively, again giving a poor
signal. In both cases, the SNR suddenly drops deeply and the bit error rate goes up dramatically.
So the cellular environment is extremely unreliable. If you didn’t have lots of redundancy in the
transmitted bits to boost reliability, chances are that digital cell phones would not be the success
they are today. As an example, the first digital cell system, Digital Advance Mobile Phone Service
(D-AMPS) used convolution coding of rate 1/2 (i.e. double the information bit rate) and constraint
length of 6. Current CDMA-based cell phones use spread-spectrum to combat the unreliably of the
air interface, but still use convolution coding of rate 1/2 in the downlink and 1/3 in the uplink (con-
straint length 9). What CDMA is, is not part of this lab. You can ask the TA if you are curious.
XOR Output z1
MUX Double
Shift register speed
Input information x(n) x(n-1) x(n-2) 0 output
Todays Yester- Day z
bit stream x days before 1
bit yester-
bit days bit
clock
This is a convolution encoder of code rate 1/2 This means there are two output bits for each
input bit. Here the output bits are transmitted one after another, two per clock cycle.
The output z1 = x(n)⊕ x(n-1)⊕x(n-2).
Here x(n) is the present input bit, x(n-1) was the previous (yesterdays) bit, etc.
The output z2= x(n)⊕ x(n-2).
The input connections to the XORs can be written as binary vectors [1 1 1] and [1 0 1] are known
as the generating vectors or generating polynomials for the code.
11
Then add the transitions to the diagram. Make the S1 0 S1
0/
0 input
them all go from states @ t=n to states @ t=n+1. Thus the 1 /0
self loop at state S0 in the state graph becomes the horizon- 0 /1
0
1/
tal line from S0@t=n to S0 @t=n+1 in the trellis diagram. S2 S2
01
The complete trellis diagram extends past t=1 to as FIGURE 4 1
0 /0
many time steps as are needed. 1/10
S3 S3
Suppose the encoder is reset to state S0=00, and the t=n t=n+1
input is 1,0,1,1,0,0. By following the trellis one sees that
the output is 11 10 00 01 01 11. Also it passes through
states S0, S1, S2, S1, S3, S2 ending in S0 @ t=6.
FIGURE 5
More Complete Trellis Diagram
11
11
11
11
S1 0 S1 0 S1 S1 0 S1 0 S1 0 S1
0/
0/
0/
0/
0
0/
0/
1 /0 1 /0 1/0 1 /0 1 /0 1 /0
0 /1 0 /1 0 /1 0 /1 0/1 0 /1
0 0 0 0 0 0
1/
1/
1/
1/
1/
S2 S2 S2
1/
S2 S2 S2 S2
01
0
01
01
01
1
1 1 1 1 1
0/0 0 /0 0 /0 0 /0 0 /0 0 /0
1
S3 1/10 S3 1/10 S3 1/10 S3 1/10 S3 1/10 1/10
S3 S3
t=0 t=1 t=2 t=3 t=4 t=5 t=6
Clock cycle 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
input bit
end
endmodule
For the constraint length 3 system, you must have the test bench automatically compare your
answer with the result you obtained from your student number.
1. Write a finite-state machine encoder for the constraint length 3 system.
always @( state or x)
nxtstate= {state[2:0],x};
···
always @(posedge clk or posedge reset)
···
state <=nxtstate
2. Write a shift-register based encoder for the constraint length 4 system (Sect 2.3 prob 2).
Generating vectors [1101] and [1111].
always @(posedge clk or posedge reset)
···
state <=state<< 1; // Left shift 1 position
state[0] <= x; // Overwrite the zero shifted in on the previous line.
3. Write a synchronous test bench so the other two modules can be simulated.
a) Compare the result for the data 1 1 0 1 0 0 1 0 1 1 0 0 0 0
Ans: Constraint length 3 encoded data-
11,01,01,00,10,11,11,10,00,01,01,11,00,00,00,00.
Ans: Constraint length 4 encoded data-
11,00,10,01,00,01,00,11,10,11,10,10,11,00,00,00,00,
0
/0
/0
/0
/0
/
S1 S S S
/
S
11
11
11
S
11
11
/1 1
11
/1 1 00 /1 1 /1 1 /1 1 /1 1
00 00 00 00 00
10 10 10 10/ 10 10
/0 /0 /0 0 /0 /0
01
01
01
01
01
S2 S2 S2
01
S2 S2 S2 S2
/1
/1
/1
/1
/1
1
/0 /0 /0 /0 0 /0
01 01 01 01 01/ 01
S3 10/1 S3 10/1 S3 10/1 S3 10/1 S3 10/1 10/1
S3 S3
t=0 t=1 t=2 t=3 t=4 t=5 t=6
01
S2 S2 S2
1
Suppose the first four received bits have an error
so instead of 11 01, one receives 11 11. On the trellis
in Fig. 8, there are two choices leaving state S0, one for S3 S3 S3
input 11 0 and the other for input 00 2 . The number in t=0 t=1 t=2
the box is the Hamming distance between the received Instead of input/output (i.e. 11/1)
Þ
input and the bits for the transition. It is clear one we now show input Hamming distance
should make the transition from S0 S1.
The next input has an error. Note there are no 11 or 00 paths leaving state S1. Both possible
paths, 10 or 01, are at Hamming distance 1. At this time either transition looks equally likely, but
wait!
00 2 S0 00 0 00 1
S0 S0 S0 S0 S0 S0
11 0 11 1 11
0
0
S1 S1 S1 1 S1 0 S1
11
1 S1 S1
11
11
00 00 00
10 10 10 10
1 1 0 1
01
01
S2 S2 S2
01
S2 S2 S2 S2
1
1
0 10 1
Outputs 01
is 0 S3 S3 S3 S3 10 0 S3 10 1 S3
is 1 t=1 t=2 t=3 t=4 t=5 t=6
At t=2, if one starts from S3, then h=0 for the path to state S2. However if one starts from S2
one has h=1 for either the path to S0 or to S1.
Thus at t=1 the proper path was not obvious, at t=2, the choice is clearer. We will chose a path
through the trellis based on the path Hamming distance or path metric, which is the sum of the
Hamming distances as one steps along a path through the trellis.
Figure 10 shows how the Hamming distances sum as one goes down various paths through
the trellis diagram. At t=5, one path has a total distance of 1 from the input data. The others have
FIGURE 10
00 2 S0 1+ 1+ 0 3 1
S0 S0 S0 S0 S0
0 3 1
+1
1
S1 S1 S1 0 1
1 S1
Hamming distance
0 + S1 4 1 S1
1+ 1+ 4
1 1+ 1
Lowest path
1+ 0
S2 S2 S2 S 1 S2 S2
+0 2
1
1 1+
1
+1
S3 S3 S3 S3 S3 3 0 S3
t=1 t=2 t=3 t=4 t=5
The sum of the Hamming distances is shown like 1 + 1 + 0 until this gets too messy.
Then the sum, and the distance for the current step, are shown in a hexagon and a box like 2 1
3.1.2 Metrics
A metric is a measure of something. The more general name for what we called the Ham-
ming distance is branch metric, and for the path Hamming distance is path metric. One does not
have to use the the Hamming distance as a measure. In decoders where the input is an analog sig-
nal, the distance between the actual and expected voltage may be measured, and the sum of the
squares of the errors might be used for the branch metric.
References:
Bernard Sklar, Digital Communications Fundamentals and Applications.
B.P.Lathe, Modern Digital and Analog Communication Systems, Holt, Rinehart & Winston, 1989
Prof. Ian Marsland, http://www.sce.carleton.ca/courses/94554/
Click on "Convolutional Codes." You will need Ghostview (gv) to read the Postscript file.
S2 S2 S2
1
error
Received 11 01
input 01→11
Going out to t=3
The paths temporarily double to 8
S0 00 2 S0 002 4 S 00 1 5 S0
0 11 There are two paths to each node.
11 0 11 1 5
0 2 One has a larger path distance.
2
1 The larger “H” path can never be
S1 S1 S1 11 1 2 S1
10 the most likely path, hence we will
1 001
1 0 erase it.
01 2 6
01
S2 S2 S2 S2
0
1
1
0 1
2
01
S3 S3 S3 10 2 3 S3
t=0 t=1 t=2 t=3 FIGURE 12
FIGURE 13
Here just the path Hamming distances Here the unneeded paths are eliminated.
are shown so it is easy to see which paths This is all important information up to
should be erased. to t=3.
Rec’d 11 error error
01→11 01 11 01
01 →11
2 4 5 2
S0 S0 S0 S0 S0 S0 S0 S0
0 5 2 0 2
S1 S1 S1 S1 S1 S1 S1 S1
2 2
1 1
6
S2 S2 S2 1
S2 S2 S2 S2 1 S2
1
1
3 2
S3 S3 S3 S3 S3 S3 S3 S3
t=0 t=1 t=2 t=3 t=0 t=1 t=2 t=3
FIGURE 14
error 2nd error
Rec’d 11 01→11 01 00→01 Entering t=4,
input
00 Eight paths are created temporarily
A A A A 11 1 3 S0
0 2 1 Again at each node, only the
2 3 2
lowest path Hamming-
1 distance path can be part of the
S1 S1 S1 S110 2 11 S
2 0 1 2 1 most likely path so four of the eight
1 0 paths will again be eliminated.
01 4
S2 S2 S2 The second error has made
0
1 S2 2 S2
four paths, all with equal chances
1
0
01 of being the most-likely path.
2
2
S3 S3 S3 S3 10 2 4 S3 (four paths with 2 )
But see what happens next.
t=0 t=1 t=2 t=3 t=4
FIGURE 15
error
Rec’d 11 01→11 01 2nd error
input 00→01 10
Entering t=5
S0 S0 S0 S0 S0 00 1 3 S0 Eight new paths are
0 11 1
2 2 2 3 created, keep the four
3
lowest H ones enter-
S1 S1 S1 1 ing each state
2
S1 S1 11 1 3 S1
2 001 Since two paths
1 0
01 0 2 have the same H
S2 S2 S2 1 S2 S2 S2 as they enter S1,
2
1 we have no way
2 2 4 of choosing a
4
2 01 better path.
2
S3 S3 S3 S3 S3 10 0 2 S3
Pick one randomly;
Þ
t=0 t=1 t=2 t=3 t=4 t=5 Here we choose
There are two most likely paths the one S0 S1.
Note path dies out.
(with H=2). Down from four at t=4
1
3
1
1
4
2
01
2
S3 S3 S3 S3 S3 2 S3 10 1 3 S3
t=0 t=1 t=2 t=3 t=4 t=5 t=6 FIGURE 16
error FIGURE 17
Rec’d 11 2nd error
input 01→11 01 00→01 10 11 11
S0 S0 S0 S0 S0 3 S0 S0 100 2 4 S0
0 10
2 2 2 3 3 2 2 3
S1 S1 S1 S1 S1 S1 S1 0
2
11 2 5 S1
2
1 0010
2 01 1 4
S2 S2 S2 S2 S2 S2 S2 S2
1
1 2 3
1 4
1
2 01
2
S3 S3 S3 S3 S3 3 S3 S3 10 1 4 S32
t=0 t=1 t=2 t=3 t=5 t=4
t=6 t=7
Entering t=7: The one best path is getting fairly clear.
The most likely path ends at S1 and a close second at S0. The paths to S2 and S3 have H= 4
2
S2 S2 S2 S2 S2 S2 S2 S2 S2
4
Common path
S3 S3 S3 S3 S3 S3 S3 S3 S3
t=0 t=1 t=2 t=3 t=4 t=5 t=6 t=7 t=8
Entering t=8: One can be fairly sure the best path at t=8 ends at state S2.
Follow the path back from
S0<-S1<-S3.<-S2<-S1<-S2<-S0<-S1<-S2
Also follow the paths back from S0, S1 and S3.
No matter what state you start in at t=8, all paths come togethe when you get back to t=1.
From the solid (for “0”)and dashed (for 1) lines along the path one can decode
the probable original message as 11010010 (travelling t=0 to t=8).
As illustrated above, the Viterbi decoder can decode a convolution code in the presence of
some errors.
If two branches entering a state have equal “H,” then the code is unable to tell if one path is
more likely than another. Pick one path at random.
The circuit to add H+h, compare H+h on the two paths, H0 0/00 h00
S0 S0 H0
and select the smaller path metric, is called the add-compare- 1/1
11
1
h
select circuit. h1
1
11
H1 S1 S1 H 1
0/
0
Problem Prolog: Using the algorithm 0h 0
1/00/1
A typical step in the trellis decoder is shown. 0h
10
1/
H2 S2 S2 H 2
01
1. Problem
a) Starting at t=8 with an input of 00, as in Figure
Input = 00 FIGURE 20
20, calculate and fill in the values of hij and
hence the Hkfor t=9. h00=
H0=4 S0 S0 H0=
b) Write pseudocode to calculate the branch Ham- h1
ming metrics for each step. 1=
H1=4 S1 S1 H1=
=
Let the two input bits In[1:0] be y, x.
11
=
h
Let the Hamming metrics associated with the h 00h
10 =
eight trellis edges for this step be h00, h01, etc.
h 01
H2=2 S2 S2 H2=
=
Calculate these metrics using a case statement:
=
case ({y, x}) h 01
2'b00 : begin h00=0; ... h11=2; end H3=4 S3 h10= S3 H3=
2'b01 : ...
t=8 t=9
2. Problem:
a) Starting at t=9, using the Hk from Prob 1, Input =10 FIGURE 21
step a) and input 10, calculate and fill in Fig-
ure 21. h00=
H0= S0 S0 H0=5
b) Use Boolean algebra to calculate them as 2-
bit binary numbers. i.e 2=10, 1=01 and 0=00. H1= S1 S1 H1=
Use reg /*wire*/ [1:0] h00, h01, h10, h11;
Example:
H2= S2 S2 H2=
h00[1] = y&x ; h00[0] = y^x;
H3= h10=
S3 S3 H3=
3. Problem t=9 t=10
a) Start at t=10, with input 11 and use the FIGURE 22
Input =11
H k from Prob. 2, step a). Let the new
H k at t=11 be written with a prime i.e.
H 0' H1' H2' and H3'. Fill in Figure 22 but
H0= S0 S0 H0'= H2 + h11 = 2
put in an expression, as well as a
number, for each Hk' . This has already H1= S1 S1 H1'=
been done for H 0'. h1
Only the better path is written here. 0=
H2= S2 S2 H2'=
b) Write pseudocode to update the Hk in
=
going from step t=n to step t=n+1. h 01
H3= S3 S3 H3'=
Use if statements to calculate the Hk' to
be associated with the four states at t=10 t=11
t=n+1. Use H0nxt instead of H0' since
Verilog cannot handle primes.
if (H 0+h00 < H2+h11) begin H0nxt= H 0+h00; end else ...
c) The flip-flop procedure.
Write a procedure to clock the flip-flops and replace the old Hs with the new ones.
Combinational logic in parts 2 and 3 calculated the D inputs for the flip-flops. For example:-
always @(posedge clk
H0 <= H0nxt ....
Don’t put combinational logic in a flip-flop procedure, and don’t forget a reset.
4. Problem: When is the output correct?
Experience has shown that all backward paths converge into one if one traces them back 4
or 5 times the constraint length. Using the paths in Figure 18, you will find that if one traces
back far enough it does not matter which path one follows.
a) Take a copy of Figure 18. Start at t=8; start at each state in turn and colour backwards until
you reach t=0 or until you hit previous colouring. At what time (t=?) do the paths all con-
verge?
5. Problem: When is the output correct?
Look at Figure 14 in which the ending time is t=4.
Test encoder decoder
a) Using data available at t=4 could you say, with confi- Bench
dence, what the original data bit was between t=0 and
t=1? Why not? original data bit
encoded, 2 bits for 1
b) Take a copy of Figure 17. Start at t=7; start at each decoded output, back to 1 bit.
state in turn and colour backwards until you reach t=0
or until you hit previous colouring. At what time (t=?) do the paths all converge?
c) Follow the trellis backwards, and from the information in the trellis find the most probable
original data. Write out the message in the correct order with the earliest (t=0) bit on the left.
6. Problem: Finding the original data from the state.
a) The states can be placed in two sets, even and odd.
If one is in an even state (S0 or S2), what was the original data in the previous step?
If one is in an even state (S1 or S3), what was the original data in the previous step?
Write pseudocode to send out the proper output bit based on the state during the trace back.
reg [1:0] state
if (state is odd) output= ... // Make this more exact.
7. Problem: Use Figure 23 only.
a) If the decoder was in state S2 at t=3, what was the original data (before encoding) between
t=2 and t=3? (The obvious answer is right.)
If it was in state S0 at t=3, what was the original data between t=2 and t=3?
If it was in state S1 at t=3, what was the original data between t=2 and t=3?
If it was in state S3 at t=3, what was the original data between t=2 and t=3?
orig. data FIGURE 23
Trellis Diagram with no signal knowledge superimposed
is 0
is 1 S0 S0 S0 S0 S0 S0 S0
S1 S1 S1 S1 S1 S1 S1
S2 ? S2 S2 S2 S2 S2 S2
S3 S3 S3 S3 S3 S3 S3
t=2 t=3 t=4 t=5 t=6 t=7 t=8
S0 S0 S0 S0 S0 S0 S0 S0 4 S
0
4
S1 S1 S1 S1 S1 S1 S1 S1 S1
2
S2 S2 S2 S2 S2 S2 S2 S2 S2
4
S3 S3 S3 S3 S3 S3 S3 S3 S3
t=0 t=1 t=2 t=3 t=4 t=5 t=6 t=7 t=8
Figure 23 shows a trellis decoder only. It gives no information about the data. Figure 24
shows paths, but when you trace back to the area between t=2 and t=3 you cannot tell from
the figure what the data was. However the those who did questions Prob: 6 or 7 can tell you.
Figure 25 is the same as Figure 23 except some little parallelograms have been drawn asso-
ciated with each state in each time step.
Fill a minimum of information in each parallelogram. This information would allow your
lab partner two to back-trace knowing that H 2 had the minimum path Hamming metric at
t=8. Thus by looking only at Figure 25 and starting at state S2 at time t=8, one should be
able to tell what the original bit was between t=2 and t=3. You may establish some conven-
tions like a 1 in the state S2 box means.... However they must be independent of the data.
a) Using Figure 25, fill in the boxes at t=3 if you have not done so already, so that one can de-
termine the original data bits between t=2 and t=3, and also between t=1 and t=2.
You should hand in the filled in Figure 25 and your list of conventions.
FIGURE 25
Trellis Diagram on which you will superimpose signal knowledge
S0 S0 S0 S0 S0 S0 S0
S1 S1 S1 S1 S1 S1 S1
S2 ? S2 S2 S2 S2 S2 S2
S3 S3 S3 S3 S3 S3 S3
t=2 t=3 t=4 t=5 t=6 t=7 t=8
b) How many bits per step must be stored to allow for backtracking and extraction of the orig-
inal data?
9. Problem: In communications latency is the term for the time difference between the time
the input signal was received and the output signal is sent out. Throughput is the number of
input signals that can pe processed per second. The point of this problem is to show it does
not matter how long it takes to decode the data as long as you can keep up with the input.
c) If a decoder had to wait until all paths converged before it had confidence it could send out a
correct output, what would the latency be in clock cycles?
There are two answers for c):
(i) What latency was needed for the data stream as shown in Figure 18 and 17?
(ii) What was the latency, mentioned earlier in these notes, that experience has shown gives
the most likely bit for almost all cases?
d) If the decoder delays the signal by 12 to 15 clock cycles, latency, would anyone care assum-
ing:
• The signal was a digitized phone conversation?
• The signal was a www page?
• The signal was a digital TV signal?
e) If the decoder could not take in the next input until it had spent 12 or 15 clock cycles
processing the previous data, throughput, would this matter?
S1 S1 S1 S1 S1 S1 S1 S1 S1
2 2
1 10
2 4
01 0 2
S2 S2 S2 S2 S2 S2 S2 S2 S2
1
1 2
On best path 3
4
2
S3 S3 S3 S3 S3 2 S3 3 S3 4 S3 S3
t=0 t=1 t=2 t=3 t=4 t=5 t=6 t=7 t=8
One may not be sure which data bit is best at t=2. However if one traces the paths forward
from t=2, only two paths survives to t=8, and one has a much smaller H.
However if one goes back to t=2 and travels ahead in time, only paths that start at S3 or S2
make it all the way to t=8. The others die out. Only the path from S3 has H=2 at t=8, thus we are
fairly sure the edge from S3 at t=2 to S2 at t=3 is on the most likely path and the original data be-
tween these two clock edges was 0 (a solid line is 0, a broken line is 1).
This illustrates why we waited six cycles here before sending out the output. At time t=8, we
can be somewhat confident that the “0” data at t=2 is the most likely. In general one would wait
twice that time to be very sure.
odd state.
FIGURE 27
Rec’d 11 10 00 01 01 00 00
input
S0 2 2 S0 1 1 S0 0 1 S 1 2 S0 1 3 S0 0 3 S0
0
0 0 1 2 2 2 1 3 1 3 2 2
0 1 3 2 3 5
S1 0 S1 1 S1 2 S1 1 S1 1 S1 2 S1
2
2
1
2
0 0 1
3
1
3
0 0
1 0 1 2 2 1
1 0 2 2 4 4
S2 S2 S2 S2 S2 S2 S2
1
1 3 2 2 0 3
1 2
1 0 0 1
1
4
0
S3 1 1 S3 0 1 S3 1S3 2 22 S3 S3
1 2 3 S3 4
t=0 t=1 t=3 t=2 t=4 t=5 t=6
Trellis path for a pre-encoding data stream of 1011011... The surviving paths are shown
with heavy lines. The paths that die out have light lines. The results for t=7 were left as an
exercise.
FIGURE 28
Rec’d 11 10 00 01 01 00
input 01
↓ ↑ ↑ ↑ ↑ ↓ ↑
S0 S0 1 S0 1 S0 2 S0 3 S S0 3 S0
0
0 2
0 ↑ 1 ↑ ↓ 2 ↑ 3 ↑ ↓ 3 ↑
S1 S1 S1 S1 S1 S1 S1 S1
0 0
1 ↑ 0 ↑ 2 ↑ 2 ↑ ↓ ↓ 2 ↑
S2 S2 S2 S2 S2 S2 S2 S2
0 3
↑ ↓ ↑ ↑ ↑ ↓ ↑
0
2
1
2
S3 S3 1 3S S3 S3 S3 3
S 3 S 3
t=0 t=1 t=2 t=3 t=4 t=5 t=6 t=7
A data bit is stored at each trellis state to show which path to take during a backwards trace.
FIGURE 29
Rec’d 11 10 00 01 01 00
input 01
↓ ↑ ↑ ↑ ↑ ↓ ↑
S0 S0 S0 S0 S0 S0 S0 S0
↑ ↑ ↓ ↑ ↑ ↓ ↑
S1 S1 S1 S1 S1 S1 S1 S1
↑ ↑ ↑ ↑ ↓ ↓ ↑
S2 S2 S2 S2 S2 S2 S2 S2
↑ ↓ ↑ ↑ ↑ ↓ ↑
S3 S3 S3 S3 S3 S3 S3 S3
t=0 t=1 t=2 t=3 t=4 t=5 t=6 t=7
The survivor paths with the excess straw removed.
Then going from J to 2J represents a left shift, and shifting in an x of 0. Going J to 2J+1 rep-
resents a left shift including shifting x=1 into the flip flops.
+2
+2
J=1 J=1 J=1 start at state J=0. Knowing that one is in
J/2
J=1
J/2
J=
state J allows the two paths to be calculated
J=
↑ ↓ ↓ ↑ on the fly.
J=2 J=2 J=2 J=2
/ 2+
2 ↓
J
↑ J= ↑ ↓ ↑
J=3 J=3 J=3 J=3
t=4 t=5 t=6 t=7
This will be slow because the throughput will be 1/17 of the input symbol rate (a symbol
here is two-bits).
Figure 32 shows one way to do the Verilog design. The top modules only collect signals and
pass them on to the lower level modules. When an ASIC is built the arguments for the top module
are the pins of the ASIC. If this circuity was to all be built on one chip, one would put on a top-
top or wrapper module where the shaded box is to define the pins.
The error generator is used for testing. To test the circuit, connect the encoder to the decoder
through the error generator, and see if the dataOut equals the dataIn. Under normal (not test) oper-
ation, the encoder would need an output lead to the outside world and the decoder would need an
input lead from outside.
To keep the data rate high, the complete two-bit symbol comes in serially in one clock cycle.
This is immediately converted to two parallel bits, both lasting one clock cycle.
• Second, there are two ways to pass parameters in Verilog. Which one works for synthesis?
d) Considerable emphasis will be given to testing. One simple test is a loopback test where the
output is sent back to the input and the two compared. Other thing you can do to your circuit
to aid testing will be considered later.
e) The Error Generator block is necessary if you want to simulate to the error correction prop-
erties. First it will be done as a test bench so it is only useful during simulation. Later you
might consider making it part of the loopback test so it can be used for testing in the field.
What to do for the lab
1. Draw a block diagram somewhat like that of Figure 32. 1However make it bigger and show
the arguments passed to all modules. If a module will be over a page of code, try to divide it.
2. Write Verilog for the Decoder Top Module and Encoder Top Module (already done?)
3. Design a serial to parallel module. The serial_in signal changes at twice the clock rate. Let
the serial_in bits be labelled s, e, r, i, a, l ...
Decide how these bits will come out of a transparent-high latch.See the latch_sig below.
You will probably use a transparent latch and two flip-flops in the module.
clk
serial_in serial_in s e r i a l
or serial_in_err
1D
C1 latch_sig s
1D Transparent- ConvSig[1] s r
C1 high latch ConvSig[2] e i
1D
C1 FIGURE 33
Waveforms for serial to parallel
Write the Verilog code for the serial to parallel module.
How do you write a latch in Verilog? Hints, see Figure 37.
4. Write the Add-Compare-Select module. (See Exercise 2.)
5. Modify the Test Bench to handle the decoder // send in a new x every clock cycle
and the encoder. This should include a loop- always @(posedge clk)
back test which compares the dataIn (x on the begin
right) with dataOut. if (I==9) $finish;
You will have a delay (latency) between dataIn x<= #1 data[I];
and dataOut. At the start dataOut will be the bit if(I>latncy) y<=#1 data[I-latncy];
corresponding to the present lowest H (path I<=I+1;
Hamming metric) so the latency will be only end
that of the serial-to-parallel converter. Later assign err=(y!=dataOut) FIGURE 34
you will want to add a latency of 4 to 5 times
the constraint length.
1. We like originality in block diagrams as long as you can give a reason for changes.