Professional Documents
Culture Documents
Idin Motedayen-Aval
Senior Applications Engineer
MathWorks
Idin.motedayen-aval@mathworks.com
2
Modeling a 4G LTE System in MATLAB
Part 1:
Modeling & simulation
4
4G LTE and LTE Advanced
Distinguishing Features
Motivation
– Very high capacity & throughput
– Support for video streaming, web browsing, VoIP, mobile apps
A true global standard
– Contributions from all across globe
– Deployed in AMER, EMEA, APLA
5
4G LTE and LTE Advanced
Distinguishing Features
A true broadband mobile standard
– From 2 Mbps (UMTS)
– To 100 Mbps (LTE)
– To 1 Gbps (LTE Advanced)
6
How is this remarkable advance possible?
7
What MATLAB users care about LTE?
Academics
– Researchers contributing to future standards
– Professors
– Students
Practitioners
– System Engineers
– Software designers
– Implementers of wireless systems
Challenge in interaction and cooperation between these
two groups
MATLAB is their common language
8
Challenges:
From specification to implementation
9
Where does MATLAB fit in addressing these
challenges?
MATLAB and Communications
System Toolbox are ideal for LTE
algorithm and system design
MATLAB and Simulink provide an
environment for dynamic & large
scale simulations
Accelerate simulation with a
variety of options in MATLAB
Connect system design to
implementation with
– C and HDL code generation
– Hardware-in-the-loop verification
10
Communications System Toolbox
Over 100 algorithms for
– Modulation, Interleaving, Channels, Source Coding
– Error Coding and Correction
– MIMO, Equalizers, Synchronization
– Sources and Sinks, SDR hardware
11
4G LTE and LTE Advanced
14
Modeling and Simulation
MIMO OFDMA
Adaptation
of everything
16
LTE Physical layer model in MATLAB
Turbo Channel
Coding
MIMO OFDMA
17
LTE Physical layer model in MATLAB
>> Open LTE system model
Turbo Channel
Coding
MIMO OFDMA
18
Overview of Turbo Coding
Performance: Approach
channel capacity (Shannon
bound)
Evolution of convolutional
coding
Based on an iterative
decoding scheme
19
MATLAB Demo
=comm.ConvolutionalEncoder(
= comm.ViterbiDecoder(…
„InputFormat‟, „Hard‟,…
20
MATLAB Demo
= comm.QPSKDemodulator(
„DecisionMethod‟,‟Log-Likelihood ratio‟
=comm.ViterbiDecoder…
„InputFormat‟, „Soft‟,…
21
MATLAB Demo
= comm.TurboEncoder
= comm.QPSKDemodulator(
„DecisionMethod‟,‟Log-Likelihood ratio‟
= comm.TurboDecoder(…
„NumIterations‟, 6,…
22
DL-SCH transport channel processing
a0 , a1 ,..., a A 1
Transport block
CRC attachment
b0 , b1 ,..., bB 1
Channel coding
Rate matching
Code block
concatenation
f 0 , f1 ,..., f G 1
a0 , a1 ,..., a A 1
Transport block
CRC attachment
Turbo Channel
b0 , b1 ,..., bB 1 Coding
MATLAB Function block
Code block segmentation
Code block CRC attachment
Channel coding
Rate matching
Code block
concatenation
f 0 , f1 ,..., f G 1
24
OFDM Overview
25
OFDM & Multi-path Fading
H(ω)
Frequency-selective fading
*ℎ2 , 𝑑2 }
G(ω)H(ω)
Multi-path
1
*ℎ0 , 𝑑0 }
ω
𝑁
*ℎ1 , 𝑑1 } y(n) = 𝑛=0 ℎ𝑛 x( 𝑛 − 𝑑𝑛 )
𝑌(𝜔) = 𝐻 𝜔 𝑋(𝜔) ω
Frequency-domain equalization If G(ω𝑘 ) ≈ 𝐻 −1 (ω𝑘 ) G(ω𝑘 ) Y(ω𝑘 ) ≈ 𝑋(ω𝑘 )
26
How Does LTE Implement OFDM?
…
Frequency
Nmax=2048
Interpolate
vertically
(Frequency)
Resource
element
Pilots
Resource
block
Interpolate
horizontally (Time)
Resource
grid
…
0.5 1 1.5 2
Time (msec)
27
How to Implement LTE OFDM in MATLAB
Depending on
Channel Bandwidth
switch
prmLTEPDSCH.Nrb = 6*numRb + mod(v+vsh, 6) + 1;
Transmitter:
Case 25, N=512; Place pilots in regular intervals
Set Frequency-domain
FFT size
Case 100, N=2048;
= mean([hp(:,1,1,n) hp(:,3,1,n)])
= mean([hp(k,2,1,:) hp(k,4,1,:)])
X=ifft(tmp,N,1); Receiver:
Estimate channel by
Create OFDM signal interpolating in time &
frequency
28
MIMO Overview
h2,1
H= h1,2
ℎ11 ℎ12 ℎ13 ℎ14
X Y
ℎ21 ℎ22 ℎ23 ℎ24
ℎ31 ℎ32 ℎ33 ℎ34
ℎ41 ℎ42 ℎ43 ℎ44
h4,4
Channel
Multiple Input Multiple Output
29
Where is MIMO being used?
30
Space-Time Block Codes (STBC)
31
Spatial Multiplexing
𝑌 = 𝐻𝑋 + 𝑛
32
MIMO-OFDM overview Y=𝐻∗𝑋+𝑛
𝐻 = 𝑈𝐷𝑉 𝐻
To avoid singularity:
1. Precode input with pre-selected V
Time 𝑡𝑛 2. Transmit over antennas based on Rank
33
Adaptive MIMO:
Closed-loop Pre-coding and Layer Mapping
Base station
Layer
Precoding(*) OFDM
Mapping
Channel Rank
Estimation
Rank Indicator
Precoder Matrix
Precoder Matrix Indicator Estimation mobile
34
Adaptive MIMO in MATLAB
In Receiver:
Detect V = Rank of the H Matrix V=
= Number of layers prmLTEPDSCH.numLayers;
Switch V
35
Cell-Specific Reference Signal Mapping
R0 R0
l0 l6 l0 l6
R0 R0 R1 R1
Two antenna ports
R0 R0 R1 R1
Not used for transmission on this antenna port
4 CSR, 4 nulls /slot /RB
=> 8 CSR /152 RE
R0 R0 R1 R1
Reference symbols on this antenna port
R0 R0 R1 R1
l0 l6 l0 l6 l0 l6 l0 l6
R0 R0 R1 R1 R2 R3
Varies per antenna port:
Four antenna ports
– Adaptive modulation
QPSK, 16QAM, 64QAM
– Adaptive coding
Coding rates from (1/13) to (12/13)
– Adaptive MIMO
2x1, 2x2, …,4x2,…, 4x4, 8x8
– Adaptive bandwidth
Up to 100 MHz (LTE-A)
37
LTE Physical layer model in MATLAB
Turbo Channel
Coding
MIMO OFDMA
Adaptation
of everything
38
Put it all together …
39
References
• Standard documents – 3GPP link
• 3GPP TS 36.{201, 211, 212, 213, 101, 104, 141}, Release 10.0.0, (2010-12).
• 3GPP TS 36.{201, 211, 212, 213, 101, 104}, Release 9.0.0, (2009-12).
• Books
• Dahlman, E.; Parkvall, S.; Skold, J., “4G LTE/LTE-Advanced for Mobile Broadband”, Elsevier,
2011.
• Agilent Technologies, “LTE and the evolution to 4G Wireless: Design and measurement
challenges”, Agilent, 2009.
• Selected papers
• Min Zhang; Shafi, M.; Smith, P.J.; Dmochowski, P.A., “Precoding Performance with Codebook
Feedback in a MIMO-OFDM System”, Communications (ICC), 2011 IEEE International
Conference on, pp. 1-6.
• Simonsson, A.; Qian, Y.; Ostergaard, J., “LTE Downlink 2X2 MIMO with Realistic CSI: Overview
and Performance Evaluation”, 2010 IEEE WCNC, pp. 1-6.
40
Summary
41
Modeling a 4G LTE System in MATLAB
Part 2:
Simulation acceleration
43
MATLAB is quite fast
System
Objects
>> Demo
Parallel commacceleration
User’s Code Computing
MATLAB to C
GPU
processing
45
Parallel Simulation Runs
Worker
TOOLBOXES
Worker Worker
BLOCKSETS
Worker
Time Time
>> Demo 46
Summary
47
Simulation acceleration options in MATLAB
System
Objects
Parallel
User’s Code Computing
MATLAB to C
GPU
processing
48
What is a Graphics Processing Unit (GPU)
49
Why would you want to use a GPU?
50
Options for Targeting GPUs
Greater Control
Ease of Use
51
Data Transfer between MATLAB and GPU
52
GPU Processing with
Communications System Toolbox
GPU System objects
Alternative implementation
comm.gpu.TurboDecoder
for many System objects
comm.gpu.ViterbiDecoder
take advantage of GPU
comm.gpu.LDPCDecoder
processing
comm.gpu.PSKDemodulator
Use Parallel Computing comm.gpu.AWGNChannel
Toolbox to execute many
communications algorithms
directly on the GPU
Easy-to-use syntax
Dramatically accelerate
simulations
53
Example: Turbo Coding
Impressive coding gain
High computational complexity
Bit-error rate performance as a function of number of
iterations
= comm.TurboDecoder(…
„NumIterations‟, numIter,…
54
Acceleration with GPU System objects
=
= comm.TurboDecoder(…
comm.gpu.TurboDecoder(…
„NumIterations‟,
„NumIterations‟, N,…
N,…
=
= comm.AWGNChannel(…
comm.gpu.AWGNChannel(…
55
Key Operations in Turbo Coding Function
CPU GPU Version 1
ber = zeros(3,1); %initialize BER output ber = zeros(3,1); %initialize BER output
%% Processing loop %% Processing loop
while ( ber(1) < MaxNumErrs && ber(2) < MaxNumBits) while ( ber(1) < MaxNumErrs && ber(2) < MaxNumBits)
data = randn(blkLength, 1)>0.5; data = randn(blkLength, 1)>0.5;
% Encode random data bits % Encode random data bits
yEnc = step(hTEnc, data); yEnc = step(hTEnc, data);
%Modulate, Add noise to real bipolar data %Modulate, Add noise to real bipolar data
modout = 1-2*yEnc; modout = 1-2*yEnc;
rData = step(hAWGN, modout); rData = step(hAWGN, modout);
% Convert to log-likelihood ratios for decoding % Convert to log-likelihood ratios for decoding
llrData = (-2/noiseVar).*rData; llrData = (-2/noiseVar).*rData;
% Turbo Decode % Turbo Decode
decData = step(hTDec, llrData); decData = step(hTDec, llrData);
% Calculate errors % Calculate errors
ber = step(hBER, data, decData); ber = step(hBER, data, decData);
end end
56
Profile results in Turbo Coding Function
CPU GPU Version 1
<0.01 ber = zeros(3,1); %initialize BER output <0.01 ber = zeros(3,1); %initialize BER output
%% Processing loop %% Processing loop
while ( ber(1) < MaxNumErrs && ber(2) < MaxNumBits) while ( ber(1) < MaxNumErrs && ber(2) < MaxNumBits)
0.30 data = randn(blkLength, 1)>0.5; 0.28 data = randn(blkLength, 1)>0.5;
% Encode random data bits % Encode random data bits
2.33 yEnc = step(hTEnc, data); 2.38 yEnc = step(hTEnc, data);
%Modulate, Add noise to real bipolar data %Modulate, Add noise to real bipolar data
0.05 modout = 1-2*yEnc; 0.05 modout = 1-2*yEnc;
1.50 rData = step(hAWGN, modout); 1.45 rData = step(hAWGN, modout);
% Convert to log-likelihood ratios for decoding % Convert to log-likelihood ratios for decoding
0.03 llrData = (-2/noiseVar).*rData; 0.04 llrData = (-2/noiseVar).*rData;
% Turbo Decode % Turbo Decode
330.54 decData = step(hTDec, llrData); 98.18 decData = step(hTDec, llrData);
% Calculate errors % Calculate errors
0.17 ber = step(hBER, data, decData); 0.17 ber = step(hBER, data, decData);
end end
57
Key Operations in Turbo Coding Function
CPU GPU Version 2
58
Profile results in Turbo Coding Function
CPU GPU Version 2
59
Things to note when targeting GPU
60
Acceleration Strategies Applied in MATLAB
Technology /
Option Product
1. Best Practices in Programming
MATLAB, Toolboxes,
• Vectorization & pre-allocation
System Toolboxes
• Environment tools. (i.e. Profiler, Code Analyzer)
2. Better Algorithms
• Ideal environment for algorithm exploration MATLAB, Toolboxes,
• Rich set of functionality (e.g. System objects) System Toolboxes
61
Summary
62
Modeling a 4G LTE System in MATLAB
Part 3: Path to implementation (C and HDL)
Advanced
channel coding
MIMO OFDM
Adapt
Everything
64
Why Engineers translate MATLAB to C today?
65
Automatic Translation of MATLAB to C
e t
ra
i te
Algorithm Design and
Code Generation in
verify
MATLAB a cce /
lerate
66
MATLAB Language Support for
Code Generation
visualization
variable-sized data
Java
struct functions
malloc
sparse numeric
global
System objects
nested functions complex arrays
fixed-point
classes persistent
graphics
67
Supported MATLAB Language
Features and Functions
Broad set of language features and functions/system
objects supported for code generation.
• Matrix operations • Complex numbers • Arithmetic, relational, • MATLAB functions and sub-functions
• N-dimensional arrays • Integer math and • Variable length argument lists
• Subscripting • Double/single-precision logical operators • Function handles
• Frames • Fixed-point arithmetic • Program control
• Persistent variables • Characters (if, for, while, switch ) Supported algorithms
• Global variables • Structures • > 400 MATLAB operators and
• Numeric classes functions
• Variable-sized data • > 200 System objects for
• System objects • Signal processing
• Communications
• Computer vision
68
Path to implementation
69
MATLAB to Hardware
We are going
Customized interfaces to Memory to focus on
Memory
peripherals Memory
this use case
today
High-speed communication Bridge
interfaces to other
processors
Analog I/O
FPGA ARM
Finite state machines, Digital I/O
digital logic, timing and
memory control
DSP
High speed, highly parallel DSP
Algorithms
DSP Algorithms
71
Separate Views of DSP Implementation
Timing and Control Logic Analog Models Hardware Architecture Functional Simulation
Back Annotation
Implement Design
Map
Hardware Specification
Test Stimulus
Place & Route Hardware
72
What we will learn today
MATLAB to Hardware
73
OFDM Transmitter
74
MATLAB to Hardware
ifft(x, 2048, 1)
Issue #1
– „x‟ is 2048x4 matrix
– MATLAB does 2048-pt FFT along first dimension
– Output is also 2048x4
– Cannot process samples this way in hardware!
– Serialize design
Issue #2
– MATLAB does double-precision floating-point arithmetic
– Floating point is expensive in hardware (power and area)
– Convert to fixed-point
75
HDL Workflow
Continuous Verification
Floating Point
Model Elaboration Model
– Develop Hardware Friendly Architecture in Simulink
– Convert to Fixed-Point
Determine Word Length Model
Determine Binary Point Location Elaboration
Implement Design
– Generate HDL code using Simulink HDL Coder Implement
– Import Custom and Vendor IP Code Generation
Verification
– Software co-simulation with HDL simulator
Verification
– Hardware co-simulation
78
Divide and conquer
Save simulation data to use in development
79
MATLAB-based FFT
Can be done
Resources
– 120 LUTs (1%)
– 32 Slices (1%)
– 0 DSP48s
80
Re-implement using Simulink blocks
compare against original code
81
Convert to fixed-point
compare against original code
82
What you just saw
Simulink Fixed-Point to
model fixed-point data types
– Word lengths
– Fraction lengths
Fixed-Point Tool
– monitoring signal
min/max, overflow
– optimization of
data types
83
Use original testbench to optimize settings
84
Analyze BER to determine word length
Anything beyond
8 bits is “good
enough”
85
Recall
ifft(x, 2048, 1)
Issue #1
– „x‟ is 2048x4 matrix
– MATLAB does 2048-pt FFT along first dimension
– Output is also 2048x4
– Cannot process samples this way in hardware!
– Serialize design
Issue #2
– MATLAB does double-precision floating-point arithmetic
– Floating point is expensive in hardware (power and area)
– Convert to fixed-point
86
Serial & Fixed-point
“HDL ready”
87
Automatically Generate HDL Code
Simulink HDL Coder
88
What You Just Saw - Workflow Advisor
Program FPGA
89
What You Just Saw – Generated HDL Code
Readable, Portable
HDL Code
90
LTE Frame Structure (FDD)
0.5 ms
#0 #1 #2 #3
….. #19
10ms
1 Frame = 10ms
10 sub-frames per frame
2 slots per sub-frame (1 slot = .5ms)
7 OFDM symbols per slot
– 2048 subcarriers in our simulation
– IFFT output sample time
0.5𝑚𝑠
7 = 3.4877 × 10−8 𝑠 𝐎𝐑 28.672𝑀𝐻𝑧
2048
92
Review: Automatic HDL Code Generation
93
FPGA Prototyping
Shorter iteration cycles MATLAB® and Simulink®
System and Algorithm Design
– Automatic HDL code generation
– Integrated HDL verification
Behavioral Simulation
Timing Simulation
– Resource utilization Place & Route
– Validation models
FPGA Hardware
94
HDL Coder
Generate VHDL and Verilog Code for FPGA and ASIC designs
Algorithm-to-HDL traceability
95
HDL Verifier
Verify VHDL and Verilog code using cosimulation and FPGAs
New:
MATLAB Simulink FPGA Hardware-in-the Loop Verification
HDL
Verifier
96
HDL Workflow
Continuous Verification
Floating Point
Model Elaboration Model
– Develop Hardware Friendly Architecture
– Convert to Fixed-Point
Determine Word Length Model
Determine Binary Point Location Elaboration
Implement Design
– Generate HDL code using HDL Coder Implement
– Import Custom and Vendor IP Code Generation
Verification
– Software co-simulation with HDL simulator
– Hardware co-simulation Verification
97
Summary
98
Thank You
Q&A
99