FreeCommunication 版本 4.5 已经出来了!

freeabc 2005-06-28 09:25:21
http://www.softvv.com/FreeCommunication/Download.asp

添加新功能,支持:

1。动态表情。
2。强大的邮件管理系统。(多帐户的收发)
3。多人音、视频聊天室。

希望大家多多支持,多提宝贵意见。
...全文
47 4 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
fongming 2005-06-28
  • 打赏
  • 举报
回复
up
truewill 2005-06-28
  • 打赏
  • 举报
回复
up
herman~~ 2005-06-28
  • 打赏
  • 举报
回复
帮顶一下
paranoia190 2005-06-28
  • 打赏
  • 举报
回复
幫你頂
书名: 无线通信基础 原书名: Fundamentals of Wireless Communication 原出版社: Cambridge University Press 分类: 电子电气 >> 通信 作者: David Tse, Pramod Viswanath Contents 1 Introduction 12 1.1 Book Objective . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12 1.2 Wireless Systems . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13 1.3 Book Outline . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16 2 The Wireless Channel 21 2.1 Physical Modeling for Wireless Channels . . . . . . . . . . . . . . . . . 21 2.1.1 Free space, fixed transmitting and receive antennas . . . . . . . 23 2.1.2 Free space, moving antenna . . . . . . . . . . . . . . . . . . . . 24 2.1.3 Reflecting wall, fixed antenna . . . . . . . . . . . . . . . . . . . 25 2.1.4 Reflecting wall, moving antenna . . . . . . . . . . . . . . . . . . 27 2.1.5 Reflection from a Ground Plane . . . . . . . . . . . . . . . . . . 29 2.1.6 Power Decay with Distance and Shadowing . . . . . . . . . . . . 30 2.1.7 Moving Antenna, Multiple Reflectors . . . . . . . . . . . . . . . 31 2.2 Input/Output Model of the Wireless Channel . . . . . . . . . . . . . . 32 2.2.1 The Wireless Channel as a Linear Time-Varying System . . . . 32 2.2.2 Baseband Equivalent Model . . . . . . . . . . . . . . . . . . . . 34 2.2.3 A Discrete Time Baseband Model . . . . . . . . . . . . . . . . . 37 Discussion 2.1 Degrees of Freedom . . . . . . . . . . . . . . . 40 2.2.4 Additive White Noise . . . . . . . . . . . . . . . . . . . . . . . . 41 2.3 Time and Frequency Coherence . . . . . . . . . . . . . . . . . . . . . . 42 2.3.1 Doppler Spread and Coherence Time . . . . . . . . . . . . . . . 42 2.3.2 Delay Spread and Coherence Bandwidth . . . . . . . . . . . . . 44 2.4 Statistical Channel Models . . . . . . . . . . . . . . . . . . . . . . . . . 47 2.4.1 Modeling Philosophy . . . . . . . . . . . . . . . . . . . . . . . . 47 2.4.2 Rayleigh and Rician Fading . . . . . . . . . . . . . . . . . . . . 48 2.4.3 Tap Gain Autocorrelation Function . . . . . . . . . . . . . . . . 50 Example 2.2 Clarke’s Model . . . . . . . . . . . . . . . . . . . 51 2.5 Bibliographical Notes . . . . . . . . . . . . . . . . . . . . . . . . . . . . 55 2.6 Exercises . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 56 3 Point-to-Point Communication: Detection, Diversity and Channel Uncertainty 64 3.1 Detection in a Rayleigh Fading Channel . . . . . . . . . . . . . . . . . 65 3.1.1 Noncoherent Detection . . . . . . . . . . . . . . . . . . . . . . . 65 3.1.2 Coherent Detection . . . . . . . . . . . . . . . . . . . . . . . . . 68 3.1.3 From BPSK to QPSK: Exploiting the Degrees of Freedom . . . 72 3.1.4 Diversity . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 76 3.2 Time Diversity . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 76 3.2.1 Repetition Coding . . . . . . . . . . . . . . . . . . . . . . . . . 78 3.2.2 Beyond Repetition Coding . . . . . . . . . . . . . . . . . . . . . 80 Example 3.1 Time Diversity in GSM . . . . . . . . . . . . . . 86 3.3 Antenna Diversity . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 88 3.3.1 Receive Diversity . . . . . . . . . . . . . . . . . . . . . . . . . . 89 3.3.2 Transmit Diversity: Space-Time Codes . . . . . . . . . . . . . . 90 3.3.3 MIMO: A 2 × 2 Example . . . . . . . . . . . . . . . . . . . . . . 94 3.4 Frequency Diversity . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 100 3.4.1 Basic Concept . . . . . . . . . . . . . . . . . . . . . . . . . . . . 100 3.4.2 Single-Carrier with ISI Equalization . . . . . . . . . . . . . . . . 102 3.4.3 Direct Sequence Spread Spectrum . . . . . . . . . . . . . . . . . 109 3.4.4 Orthogonal Frequency Division Multiplexing . . . . . . . . . . . 114 3.5 Impact of Channel Uncertainty . . . . . . . . . . . . . . . . . . . . . . 122 3.5.1 Noncoherent Detection for DS Spread Spectrum . . . . . . . . . 122 3.5.2 Channel Estimation . . . . . . . . . . . . . . . . . . . . . . . . . 125 3.5.3 Other Diversity Scenarios . . . . . . . . . . . . . . . . . . . . . 127 3.6 Bibliographical Notes . . . . . . . . . . . . . . . . . . . . . . . . . . . . 131 3.7 Exercises . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 132 4 Cellular Systems: Multiple Access and Interference Management 143 4.1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 143 4.2 Narrowband Cellular Systems . . . . . . . . . . . . . . . . . . . . . . . 146 4.2.1 Narrowband allocations: GSM system . . . . . . . . . . . . . . 147 4.2.2 Impact on Network and System Design . . . . . . . . . . . . . . 150 4.2.3 Impact on Frequency Reuse . . . . . . . . . . . . . . . . . . . . 151 4.3 Wideband Systems: CDMA . . . . . . . . . . . . . . . . . . . . . . . . 152 4.3.1 CDMA Uplink . . . . . . . . . . . . . . . . . . . . . . . . . . . 155 4.3.2 CDMA Downlink . . . . . . . . . . . . . . . . . . . . . . . . . . 170 4.3.3 System Issues . . . . . . . . . . . . . . . . . . . . . . . . . . . . 171 4.4 Wideband Systems: OFDM . . . . . . . . . . . . . . . . . . . . . . . . 174 4.4.1 Allocation Design Principles . . . . . . . . . . . . . . . . . . . . 174 4.4.2 Hopping Pattern . . . . . . . . . . . . . . . . . . . . . . . . . . 175 4.4.3 Signal Characteristics and Receiver Design . . . . . . . . . . . . 177 4.4.4 Sectorization . . . . . . . . . . . . . . . . . . . . . . . . . . . . 178 Example 4.1 Flash-OFDM . . . . . . . . . . . . . . . . . . . . 179 4.5 Bibliographical Notes . . . . . . . . . . . . . . . . . . . . . . . . . . . . 181 4.6 Exercises . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 182 5 Capacity of Wireless Channels 195 5.1 AWGN Channel Capacity . . . . . . . . . . . . . . . . . . . . . . . . . 196 5.1.1 Repetition Coding . . . . . . . . . . . . . . . . . . . . . . . . . 196 5.1.2 Packing Spheres . . . . . . . . . . . . . . . . . . . . . . . . . . . 197 Discussion 5.1 Capacity-Achieving AWGN Channel Codes . . 199 5.2 Resources of the AWGN Channel . . . . . . . . . . . . . . . . . . . . . 201 5.2.1 Continuous-Time AWGN Channel . . . . . . . . . . . . . . . . . 202 5.2.2 Power and Bandwidth . . . . . . . . . . . . . . . . . . . . . . . 202 Example 5.2 Bandwidth Reuse in Cellular Systems . . . . . . 205 5.3 Linear Time-Invariant Gaussian Channels . . . . . . . . . . . . . . . . 209 5.3.1 Single Input Multiple Output (SIMO) Channel . . . . . . . . . 209 5.3.2 Multiple Input Single Output (MISO) Channel . . . . . . . . . 210 5.3.3 Frequency-Selective Channel . . . . . . . . . . . . . . . . . . . . 211 5.4 Capacity of Fading Channels . . . . . . . . . . . . . . . . . . . . . . . . 217 5.4.1 Slow Fading Channel . . . . . . . . . . . . . . . . . . . . . . . . 218 5.4.2 Receive Diversity . . . . . . . . . . . . . . . . . . . . . . . . . . 221 5.4.3 Transmit Diversity . . . . . . . . . . . . . . . . . . . . . . . . . 222 5.4.4 Time and Frequency Diversity . . . . . . . . . . . . . . . . . . . 227 5.4.5 Fast Fading Channel . . . . . . . . . . . . . . . . . . . . . . . . 231 5.4.6 Transmitter Side Information . . . . . . . . . . . . . . . . . . . 236 Example 5.3 Rate Adaptation in IS-856 . . . . . . . . . . . . . 244 5.4.7 Frequency-Selective Fading Channels . . . . . . . . . . . . . . . 247 5.4.8 Summary: A Shift in Point of View . . . . . . . . . . . . . . . . 248 5.5 Bibliographical Notes . . . . . . . . . . . . . . . . . . . . . . . . . . . . 252 5.6 Exercises . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 253 6 Multiuser Capacity and Opportunistic Communication 266 6.1 Uplink AWGN Channel . . . . . . . . . . . . . . . . . . . . . . . . . . 267 6.1.1 Capacity via Successive Interference Cancellation . . . . . . . . 267 6.1.2 Comparison with Conventional CDMA . . . . . . . . . . . . . . 271 6.1.3 Comparison with Orthogonal Multiple Access . . . . . . . . . . 271 6.1.4 General K-user Uplink Capacity . . . . . . . . . . . . . . . . . . 273 6.2 Downlink AWGN Channel . . . . . . . . . . . . . . . . . . . . . . . . . 275 6.2.1 Symmetric Case: Two Capacity-Achieving Schemes . . . . . . . 276 6.2.2 General Case: Superposition Coding Achieves Capacity . . . . . 279 Discussion 6.1 SIC: Implementation Issues . . . . . . . . . . . 283 6.3 Uplink Fading Channel . . . . . . . . . . . . . . . . . . . . . . . . . . . 285 6.3.1 Slow Fading Channel . . . . . . . . . . . . . . . . . . . . . . . . 285 6.3.2 Fast Fading Channel . . . . . . . . . . . . . . . . . . . . . . . . 287 6.3.3 Full Channel Side Information . . . . . . . . . . . . . . . . . . . 289 6.4 Downlink Fading Channel . . . . . . . . . . . . . . . . . . . . . . . . . 292 6.4.1 Channel Side Information at Receiver Only . . . . . . . . . . . . 293 6.4.2 Full Channel Side Information . . . . . . . . . . . . . . . . . . . 294 6.5 Frequency-Selective Fading Channels . . . . . . . . . . . . . . . . . . . 294 6.6 Multiuser Diversity . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 295 6.6.1 Multiuser Diversity Gain . . . . . . . . . . . . . . . . . . . . . . 295 6.6.2 Multiuser versus Classical Diversity . . . . . . . . . . . . . . . . 298 6.7 Multiuser Diversity: System Aspects . . . . . . . . . . . . . . . . . . . 300 6.7.1 Fair Scheduling and Multiuser Diversity . . . . . . . . . . . . . 301 6.7.2 Channel Prediction and Feedback . . . . . . . . . . . . . . . . . 308 6.7.3 Opportunistic Beamforming using Dumb Antennas . . . . . . . 309 6.7.4 Multiuser Diversity in Multi-cell Systems . . . . . . . . . . . . . 318 6.7.5 A System View . . . . . . . . . . . . . . . . . . . . . . . . . . . 319 6.8 Bibliographical Notes . . . . . . . . . . . . . . . . . . . . . . . . . . . . 325 6.9 Exercises . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 326 7 MIMO I: Spatial Multiplexing and Channel Modeling 342 7.1 Multiplexing Capability of Deterministic MIMO Channels . . . . . . . 343 7.1.1 Capacity via Singular Value Decomposition . . . . . . . . . . . 343 7.1.2 Rank and Condition Number . . . . . . . . . . . . . . . . . . . 346 7.2 Physical Modeling of MIMO Channels . . . . . . . . . . . . . . . . . . 347 7.2.1 Line-of-Sight SIMO channel . . . . . . . . . . . . . . . . . . . . 348 7.2.2 Line-of-Sight MISO Channel . . . . . . . . . . . . . . . . . . . . 350 7.2.3 Antenna arrays with only a line-of-sight path . . . . . . . . . . 351 7.2.4 Geographically separated antennas . . . . . . . . . . . . . . . . 352 7.2.5 Line-of-sight plus one reflected path . . . . . . . . . . . . . . . . 359 7.3 Modeling of MIMO Fading Channels . . . . . . . . . . . . . . . . . . . 364 7.3.1 Basic Approach . . . . . . . . . . . . . . . . . . . . . . . . . . . 364 7.3.2 MIMO Multipath Channel . . . . . . . . . . . . . . . . . . . . . 365 7.3.3 Angular Domain Representation of Signals . . . . . . . . . . . . 367 7.3.4 Angular Domain Representation of MIMO Channels . . . . . . . 370 7.3.5 Statistical Modeling in the Angular Domain . . . . . . . . . . . 372 7.3.6 Degrees of Freedom and Diversity . . . . . . . . . . . . . . . . . 372 Example 7.1 Degrees of Freedom in Clustered Response Models 375 7.3.7 Dependency on Antenna Spacing . . . . . . . . . . . . . . . . . 380 7.3.8 I.I.D. Rayleigh Fading Model . . . . . . . . . . . . . . . . . . . 387 7.4 Bibliographical Notes . . . . . . . . . . . . . . . . . . . . . . . . . . . . 390 7.5 Exercises . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 390 8 MIMO II: Capacity and Multiplexing Architectures 393 8.1 The V-BLAST Architecture . . . . . . . . . . . . . . . . . . . . . . . . 394 8.2 Fast Fading MIMO Channel . . . . . . . . . . . . . . . . . . . . . . . . 396 8.2.1 Capacity with CSI at Receiver . . . . . . . . . . . . . . . . . . . 396 8.2.2 Performance Gains . . . . . . . . . . . . . . . . . . . . . . . . . 399 8.2.3 Full CSI . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 408 8.3 Receiver Architectures . . . . . . . . . . . . . . . . . . . . . . . . . . . 411 8.3.1 Linear Decorrelator . . . . . . . . . . . . . . . . . . . . . . . . . 411 8.3.2 Successive Cancellation . . . . . . . . . . . . . . . . . . . . . . . 417 8.3.3 Linear MMSE Receiver . . . . . . . . . . . . . . . . . . . . . . . 419 8.3.4 Information Theoretic Optimality* . . . . . . . . . . . . . . . . 427 Discussion 8.1 Connections with CDMA Multiuser Detection and ISI Equalization . . . . . . . . . . . . . . . . . . . . . . . . . . . . 429 8.4 Slow Fading MIMO Channel . . . . . . . . . . . . . . . . . . . . . . . . 431 8.5 D-BLAST: An Outage-Optimal Architecture . . . . . . . . . . . . . . . 433 8.5.1 Sub-optimality of V-BLAST . . . . . . . . . . . . . . . . . . . . 433 8.5.2 Coding Across Transmit Antennas: D-BLAST . . . . . . . . . . 435 8.5.3 Discussion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 438 8.6 Bibliographical Notes . . . . . . . . . . . . . . . . . . . . . . . . . . . . 440 8.7 Exercises . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 440 9 MIMO III: Diversity-Multiplexing Tradeoff and Universal Space-Time Codes 451 9.1 Diversity-Multiplexing Tradeoff . . . . . . . . . . . . . . . . . . . . . . 452 9.1.1 Formulation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 452 9.1.2 Scalar Rayleigh Channel . . . . . . . . . . . . . . . . . . . . . . 454 9.1.3 Parallel Rayleigh Channel . . . . . . . . . . . . . . . . . . . . . 458 9.1.4 MISO Rayleigh Channel . . . . . . . . . . . . . . . . . . . . . . 459 9.1.5 2 × 2 MIMO Rayleigh Channel . . . . . . . . . . . . . . . . . . 460 9.1.6 nt × nr MIMO i.i.d. Rayleigh Channel . . . . . . . . . . . . . . 463 9.2 Universal Code Design for Optimal Diversity-Multiplexing Tradeoff . . 467 9.2.1 QAM is Approximately Universal for Scalar Channels . . . . . . 468 9.2.2 Universal Code Design for Parallel Channels . . . . . . . . . . . 470 9.2.3 Universal Code Design for MISO Channels . . . . . . . . . . . . 477 9.2.4 Universal Code Design for MIMO Channels . . . . . . . . . . . 481 Discussion 9.1 Universal Codes in the Downlink . . . . . . . . 485 9.3 Bibliographical Notes . . . . . . . . . . . . . . . . . . . . . . . . . . . . 487 9.4 Exercises . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 488 10 MIMO IV: Multiuser Communication 497 10.1 Uplink with Multiple Receive Antennas . . . . . . . . . . . . . . . . . . 498 10.1.1 Space-Division Multiple Access . . . . . . . . . . . . . . . . . . 498 10.1.2 SDMA Capacity Region . . . . . . . . . . . . . . . . . . . . . . 500 10.1.3 System Implications . . . . . . . . . . . . . . . . . . . . . . . . 503 10.1.4 Slow Fading . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 505 10.1.5 Fast Fading . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 509 10.1.6 Multiuser Diversity Revisited . . . . . . . . . . . . . . . . . . . 512 10.2 MIMO Uplink . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 516 10.2.1 SDMA with Multiple Transmit Antennas . . . . . . . . . . . . . 517 10.2.2 System Implications . . . . . . . . . . . . . . . . . . . . . . . . 521 10.2.3 Fast Fading . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 521 10.3 Downlink with Multiple Transmit Antennas . . . . . . . . . . . . . . . 523 10.3.1 Degrees of Freedom in the Downlink . . . . . . . . . . . . . . . 523 10.3.2 Uplink-Downlink Duality and Transmit Beamforming . . . . . . 525 10.3.3 Precoding for Interference Known at Transmitter . . . . . . . . 530 10.3.4 Precoding for the downlink . . . . . . . . . . . . . . . . . . . . . 543 10.3.5 Fast Fading . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 546 10.4 MIMO Downlink . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 549 10.5 Multiple Antennas in Cellular Networks: A System View . . . . . . . . 552 10.5.1 Inter-cell Interference Management . . . . . . . . . . . . . . . . 554 10.5.2 Uplink with Multiple Receive Antennas . . . . . . . . . . . . . . 555 10.5.3 MIMO Uplink . . . . . . . . . . . . . . . . . . . . . . . . . . . . 557 10.5.4 Downlink with Multiple Receive Antennas . . . . . . . . . . . . 558 10.5.5 Downlink with Multiple Transmit Antennas . . . . . . . . . . . 559 Example 10.1 SDMA in ArrayComm Systems . . . . . . . . . 559 10.6 Bibliographical Notes . . . . . . . . . . . . . . . . . . . . . . . . . . . . 562 10.7 Exercises . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 563 A Detection and Estimation in Additive Gaussian Noise 579 A.1 Gaussian Random Variables . . . . . . . . . . . . . . . . . . . . . . . . 579 A.1.1 Scalar Real Gaussian Random Variable . . . . . . . . . . . . . . 579 A.1.2 Real Gaussian Random Vectors . . . . . . . . . . . . . . . . . . 580 A.1.3 Complex Gaussian Random Vectors . . . . . . . . . . . . . . . . 583 A.2 Detection in Gaussian Noise . . . . . . . . . . . . . . . . . . . . . . . . 586 A.2.1 Scalar Detection . . . . . . . . . . . . . . . . . . . . . . . . . . 586 A.2.2 Detection in a Vector Space . . . . . . . . . . . . . . . . . . . . 587 A.2.3 Detection in a Complex Vector Space . . . . . . . . . . . . . . . 591 A.3 Estimation in Gaussian Noise . . . . . . . . . . . . . . . . . . . . . . . 593 A.3.1 Scalar Estimation . . . . . . . . . . . . . . . . . . . . . . . . . . 593 A.3.2 Estimation in a Vector Space . . . . . . . . . . . . . . . . . . . 594 A.3.3 Estimation in a Complex Vector Space . . . . . . . . . . . . . . 595 A.4 Exercises . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 597 B Information Theory Background 599 B.1 Discrete Memoryless Channels . . . . . . . . . . . . . . . . . . . . . . . 599 Example B.1 Binary Symmetric Channel . . . . . . . . . . . . 601 Example B.2 Binary Erasure Channel . . . . . . . . . . . . . . 601 B.2 Entropy, Conditional Entropy and Mutual Information . . . . . . . . . 602 Example B.3 Binary Entropy . . . . . . . . . . . . . . . . . . 603 B.3 Noisy Channel Coding Theorem . . . . . . . . . . . . . . . . . . . . . . 605 B.3.1 Reliable Communication and Conditional Entropy . . . . . . . . 606 B.3.2 A Simple Upper Bound . . . . . . . . . . . . . . . . . . . . . . . 606 B.3.3 Achieving the Upper Bound . . . . . . . . . . . . . . . . . . . . 607 Example B.4 Binary Symmetric Channel . . . . . . . . . . . . 609 Example B.5 Binary Erasure Channel . . . . . . . . . . . . . . 609
Homage to Alain Glavieux. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xv Chapter 1. Information Theory. . . . . . . . . . . . . . . . . . . . . . . . . . . . 1 Gérard BATTAIL 1.1. Introduction: the Shannon paradigm . . . . . . . . . . . . . . . . . . . . . 1 1.2. Principal coding functions . . . . . . . . . . . . . . . . . . . . . . . . . . . 5 1.2.1. Source coding . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5 1.2.2. Channel coding . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6 1.2.3. Cryptography . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7 1.2.4. Standardization of the Shannon diagram blocks. . . . . . . . . . . . 8 1.2.5. Fundamental theorems. . . . . . . . . . . . . . . . . . . . . . . . . . . 9 1.3. Quantitative measurement of information . . . . . . . . . . . . . . . . . . 9 1.3.1. Principle . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9 1.3.2. Measurement of self-information . . . . . . . . . . . . . . . . . . . . 10 1.3.3. Entropy of a source. . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11 1.3.4. Mutual information measure . . . . . . . . . . . . . . . . . . . . . . . 12 1.3.5. Channel capacity . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14 1.3.6. Comments on the measurement of information . . . . . . . . . . . . 15 1.4. Source coding . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15 1.4.1. Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15 1.4.2. Decodability, Kraft-McMillan inequality. . . . . . . . . . . . . . . . 16 1.4.3. Demonstration of the fundamental theorem . . . . . . . . . . . . . . 17 1.4.4. Outline of optimal algorithms of source coding . . . . . . . . . . . . 18 1.5. Channel coding . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19 1.5.1. Introduction and statement of the fundamental theorem . . . . . . . 19 1.5.2. General comments . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20 1.5.3. Need for redundancy. . . . . . . . . . . . . . . . . . . . . . . . . . . . 20 1.5.4. Example of the binary symmetric channel . . . . . . . . . . . . . . . 21 1.5.4.1. Hamming’s metric . . . . . . . . . . . . . . . . . . . . . . . . . . . 21 1.5.4.2. Decoding with minimal Hamming distance . . . . . . . . . . . . 22 1.5.4.4. Gilbert-Varshamov bound. . . . . . . . . . . . . . . . . . . . . . . 24 1.5.5. A geometrical interpretation . . . . . . . . . . . . . . . . . . . . . . . 25 1.5.6. Fundamental theorem: Gallager’s proof . . . . . . . . . . . . . . . . 26 1.5.6.1. Upper bound of the probability of error. . . . . . . . . . . . . . . 27 1.5.6.2. Use of random coding . . . . . . . . . . . . . . . . . . . . . . . . . 28 1.5.6.3. Form of exponential limits . . . . . . . . . . . . . . . . . . . . . . 30 1.6. Channels with continuous noise. . . . . . . . . . . . . . . . . . . . . . . . 32 1.6.1. Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 32 1.6.2. A reference model in physical reality: the channel with Gaussian additive noise . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 32 1.6.3. Communication via a channel with additive white Gaussian noise. 35 1.6.3.1. Use of a finite alphabet, modulation. . . . . . . . . . . . . . . . . 35 1.6.3.2. Demodulation, decision margin . . . . . . . . . . . . . . . . . . . 36 1.6.4. Channel with fadings. . . . . . . . . . . . . . . . . . . . . . . . . . . . 37 1.7. Information theory and channel coding . . . . . . . . . . . . . . . . . . . 38 1.8. Bibliography . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 40 Chapter 2. Block Codes. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 41 Alain POLI 2.1. Unstructured codes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 41 2.1.1. The fundamental question of message redundancy . . . . . . . . . . 41 2.1.2. Unstructured codes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 42 2.1.2.1. Code parameters . . . . . . . . . . . . . . . . . . . . . . . . . . . . 42 2.1.2.2. Code, coding and decoding . . . . . . . . . . . . . . . . . . . . . . 43 2.1.2.3. Bounds of code parameters . . . . . . . . . . . . . . . . . . . . . . 44 2.2. Linear codes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 44 2.2.1. Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 44 2.2.2. Properties of linear codes . . . . . . . . . . . . . . . . . . . . . . . . . 44 2.2.2.1. Minimum distance and minimum weight of a code. . . . . . . . 45 2.2.2.2. Linear code base, coding . . . . . . . . . . . . . . . . . . . . . . . 45 2.2.2.3. Singleton bound. . . . . . . . . . . . . . . . . . . . . . . . . . . . . 46 2.2.3. Dual code . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 46 2.2.3.1. Reminders of the Gaussian method . . . . . . . . . . . . . . . . . 46 2.2.3.2. Lateral classes of a linear code C . . . . . . . . . . . . . . . . . . 47 2.2.3.3. Syndromes. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 48 2.2.3.4. Decoding and syndromes . . . . . . . . . . . . . . . . . . . . . . . 49 2.2.3.5. Lateral classes, syndromes and decoding. . . . . . . . . . . . . . 49 2.2.3.6. Parity check matrix and minimum code weight . . . . . . . . . . 49 2.2.3.7. Minimum distance of C and matrix H. . . . . . . . . . . . . . . . 50 2.2.4. Some linear codes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 50 2.2.5. Decoding of linear codes . . . . . . . . . . . . . . . . . . . . . . . . . 51 2.3. Finite fields. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 53 2.3.1. Basic concepts. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 53 2.3.2. Polynomial modulo calculations: quotient ring . . . . . . . . . . . . 53 2.3.3. Irreducible polynomial modulo calculations: finite field. . . . . . . 54 2.3.4. Order and the opposite of an element of F2[X]/(p(X)) . . . . . . . . 54 2.3.4.1. Order . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 55 2.3.4.2. Properties of the order . . . . . . . . . . . . . . . . . . . . . . . . . 55 2.3.4.3. Primitive elements . . . . . . . . . . . . . . . . . . . . . . . . . . . 56 2.3.4.4. Use of the primitives . . . . . . . . . . . . . . . . . . . . . . . . . . 58 2.3.4.5. How to find a primitive . . . . . . . . . . . . . . . . . . . . . . . . 58 2.3.4.6. Exponentiation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 59 2.3.5. Minimum polynomials. . . . . . . . . . . . . . . . . . . . . . . . . . . 59 2.3.6. The field of nth roots of unity . . . . . . . . . . . . . . . . . . . . . . . 60 2.3.7. Projective geometry in a finite field . . . . . . . . . . . . . . . . . . . 61 2.3.7.1. Points . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 61 2.3.7.2. Projective subspaces of order 1. . . . . . . . . . . . . . . . . . . . 61 2.3.7.3. Projective subspaces of order t . . . . . . . . . . . . . . . . . . . . 61 2.3.7.4. An example . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 61 2.3.7.5. Cyclic codes and projective geometry. . . . . . . . . . . . . . . . 62 2.4. Cyclic codes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 62 2.4.1. Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 62 2.4.2. Base, coding, dual code and code annihilator . . . . . . . . . . . . . 63 2.4.2.1. Cyclic code base . . . . . . . . . . . . . . . . . . . . . . . . . . . . 63 2.4.2.2. Coding . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 64 2.4.2.3. Annihilator and dual of a cyclic code C. . . . . . . . . . . . . . . 65 2.4.2.4. Cyclic code and error correcting capability: roots of g(X). . . . 66 2.4.2.5. The Vandermonde determinant. . . . . . . . . . . . . . . . . . . . 66 2.4.2.6. BCH theorem . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 67 2.4.3. Certain cyclic codes . . . . . . . . . . . . . . . . . . . . . . . . . . . . 68 2.4.3.1. Hamming codes. . . . . . . . . . . . . . . . . . . . . . . . . . . . . 68 2.4.3.2. BCH codes. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 69 2.4.3.3. Fire codes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 70 2.4.3.4. RM codes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 71 2.4.3.5. RS codes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 71 2.4.3.6. Codes with true distance greater than their BCH distance . . . . 71 2.4.3.7. PG-codes. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 71 2.4.3.8. QR codes. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 73 2.4.4. Existence and construction of cyclic codes. . . . . . . . . . . . . . . 74 2.4.4.1. Existence. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 74 2.4.4.2. Construction. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 75 2.4.4.3. Shortened codes and extended codes . . . . . . . . . . . . . . . . 79 2.4.4.4. Specifications . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 79 2.4.4.5. How should we look for a cyclic code?. . . . . . . . . . . . . . . 79 2.4.4.6. How should we look for a truncated cyclic code?. . . . . . . . . 81 2.4.5. Applications of cyclic codes . . . . . . . . . . . . . . . . . . . . . . . 82 2.5. Electronic circuits . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 82 2.5.1. Basic gates for error correcting codes. . . . . . . . . . . . . . . . . . 82 2.5.2. Shift registers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 83 2.5.3. Circuits for the correct codes . . . . . . . . . . . . . . . . . . . . . . . 83 2.5.3.1. Divisors. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 83 2.5.3.2. Multipliers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 84 2.5.3.3. Multiplier-divisors . . . . . . . . . . . . . . . . . . . . . . . . . . . 84 2.5.3.4. Encoder (systematic coding) . . . . . . . . . . . . . . . . . . . . . 84 2.5.3.5. Inverse calculation in Fq . . . . . . . . . . . . . . . . . . . . . . . . 85 2.5.3.6. Hsiao decoder . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 85 2.5.3.7. Meggitt decoder (natural code). . . . . . . . . . . . . . . . . . . . 86 2.5.3.8. Meggitt decoder (shortened code) . . . . . . . . . . . . . . . . . . 87 2.5.4. Polynomial representation and representation to the power of a primitive representation for a field . . . . . . . . . . . . . . . . . . . . . . 87 2.6. Decoding of cyclic codes. . . . . . . . . . . . . . . . . . . . . . . . . . . . 88 2.6.1. Meggitt decoding (trapping of bursts). . . . . . . . . . . . . . . . . . 88 2.6.1.1. The principle of trapping of bursts. . . . . . . . . . . . . . . . . . 88 2.6.1.2. Trapping in the case of natural Fire codes . . . . . . . . . . . . . 88 2.6.1.3. Trapping in the case of shortened Fire codes. . . . . . . . . . . . 89 2.6.2. Decoding by the DFT . . . . . . . . . . . . . . . . . . . . . . . . . . . 89 2.6.2.1. Definition of the DFT . . . . . . . . . . . . . . . . . . . . . . . . . 89 2.6.2.2. Some properties of the DFT. . . . . . . . . . . . . . . . . . . . . . 89 2.6.2.3. Decoding using the DFT. . . . . . . . . . . . . . . . . . . . . . . . 92 2.6.3. FG-decoding. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 94 2.6.3.1. Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 94 2.6.3.2. Solving a system of polynomial equations with several variables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 95 2.6.3.3. Two basic operations. . . . . . . . . . . . . . . . . . . . . . . . . . 96 2.6.3.4. The algorithm of B. Buchberger . . . . . . . . . . . . . . . . . . . 96 2.6.3.5. FG-decoding. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 97 2.6.4. Berlekamp-Massey decoding. . . . . . . . . . . . . . . . . . . . . . . 99 2.6.4.1. Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 99 2.6.4.2. Existence of a key equation. . . . . . . . . . . . . . . . . . . . . . 100 2.6.4.3. The solution by successive stages . . . . . . . . . . . . . . . . . . 100 2.6.4.4. Some properties of dj. . . . . . . . . . . . . . . . . . . . . . . . . . 101 2.6.4.5. Property of an optimal solution (aj(X),bj(X)) at level j . . . . . . 101 2.6.4.6. Construction of the pair (a'j+1(X),b'j+1(X)) at the j stage . . . . . 102 2.6.4.7. Construction of an optimal solution (aj+1(X),bj+1(X)) . . . . . . . 103 2.6.4.8. The algorithm . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 104 2.6.5. Majority decoding . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 105 2.6.5.1. The mechanism of decoding, and the associated code . . . . . . 105 2.6.5.2. Trapping by words of C⊥ incidents between them . . . . . . . . 106 2.6.5.3. Codes decodable in one or two stages. . . . . . . . . . . . . . . . 106 2.6.5.4. How should the digital implementation be prepared?. . . . . . . 108 2.6.6. Hard decoding, soft decoding and chase decoding . . . . . . . . . . 110 2.6.6.1. Hard decoding and soft decoding . . . . . . . . . . . . . . . . . . 110 2.6.6.2. Chase decoding . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 110 2.7. 2D codes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 111 2.7.1. Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 111 2.7.2. Product codes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 112 2.7.3. Minimum distance of 2D codes . . . . . . . . . . . . . . . . . . . . . 112 2.7.4. Practical examples of the use of 2D codes . . . . . . . . . . . . . . . 112 2.7.5. Coding . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 112 2.7.6. Decoding. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 113 2.8. Exercises on block codes. . . . . . . . . . . . . . . . . . . . . . . . . . . . 113 2.8.1. Unstructured codes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 113 2.8.2. Linear codes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 114 2.8.3. Finite bodies. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 117 2.8.4. Cyclic codes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 119 2.8.4.1. Theory . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 119 2.8.4.2. Applications . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 122 2.8.5. Exercises on circuits . . . . . . . . . . . . . . . . . . . . . . . . . . . . 123 Chapter 3. Convolutional Codes . . . . . . . . . . . . . . . . . . . . . . . . . . . 129 Alain GLAVIEUX and Sandrine VATON 3.1. Introduction. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 129 3.2. State transition diagram, trellis, tree . . . . . . . . . . . . . . . . . . . . . 135 3.3. Transfer function and distance spectrum. . . . . . . . . . . . . . . . . . . 137 3.4. Perforated convolutional codes . . . . . . . . . . . . . . . . . . . . . . . . 140 3.5. Catastrophic codes. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 142 3.6. The decoding of convolutional codes . . . . . . . . . . . . . . . . . . . . 142 3.6.1. Viterbi algorithm . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 143 3.6.1.1. The term log p(S0) . . . . . . . . . . . . . . . . . . . . . . . . . . . 144 3.6.1.2. The term log p(Sk|Sk−1) . . . . . . . . . . . . . . . . . . . . . . . . 145 3.6.1.3. The term log p(yk|Sk, Sk−1) . . . . . . . . . . . . . . . . . . . . . . . 145 3.6.1.4. Viterbi algorithm . . . . . . . . . . . . . . . . . . . . . . . . . . . . 150 3.6.1.5. Viterbi algorithm for transmissions with continuous data flow . 155 3.6.2. MAP criterion or BCJR algorithm. . . . . . . . . . . . . . . . . . . . 156 3.6.2.1. BCJR algorithm. . . . . . . . . . . . . . . . . . . . . . . . . . . . . 157 3.6.2.2. Example . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 166 3.6.3. SubMAP algorithm. . . . . . . . . . . . . . . . . . . . . . . . . . . . . 169 3.6.3.1. Propagation of the Front filter . . . . . . . . . . . . . . . . . . . . 170 3.6.3.2. Propagation of the Back filter. . . . . . . . . . . . . . . . . . . . . 171 3.6.3.3. Calculation of the ψk(s, s’) quantities . . . . . . . . . . . . . . . . 171 3.6.3.4. Calculation of the joint probability of dk and y . . . . . . . . . . 171 3.7. Performance of convolutional codes . . . . . . . . . . . . . . . . . . . . . 172 3.7.1. Channel with binary input and continuous output . . . . . . . . . . 173 3.7.1.1. Gaussian channel . . . . . . . . . . . . . . . . . . . . . . . . . . . . 174 3.7.1.2. Rayleigh channel . . . . . . . . . . . . . . . . . . . . . . . . . . . . 177 3.7.2. Channel with binary input and output . . . . . . . . . . . . . . . . . 180 3.8. Distance spectrum of convolutional codes . . . . . . . . . . . . . . . . . 182 3.9. Recursive convolution codes . . . . . . . . . . . . . . . . . . . . . . . . . 184 Chapter 4. Coded Modulations . . . . . . . . . . . . . . . . . . . . . . . . . . . . 197 Ezio BIGLIERI 4.1. Hamming distance and Euclidean distance . . . . . . . . . . . . . . . . . 197 4.2. Trellis code . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 200 4.3. Decoding . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 201 4.4. Some examples of TCM . . . . . . . . . . . . . . . . . . . . . . . . . . . . 201 4.5. Choice of a TCM diagram . . . . . . . . . . . . . . . . . . . . . . . . . . . 205 4.6. TCM representations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 207 4.7. TCM transparent to rotations . . . . . . . . . . . . . . . . . . . . . . . . . 209 4.7.1. Partitions transparent to rotations . . . . . . . . . . . . . . . . . . . . 211 4.7.2. Transparent trellis with rotations. . . . . . . . . . . . . . . . . . . . . 212 4.7.3. Transparent encoder . . . . . . . . . . . . . . . . . . . . . . . . . . . . 213 4.7.4. General considerations. . . . . . . . . . . . . . . . . . . . . . . . . . . 215 4.8. TCM error probability . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 215 4.8.1. Upper limit of the probability of an error event . . . . . . . . . . . . 215 4.8.1.1. Enumeration of error events . . . . . . . . . . . . . . . . . . . . . 217 4.8.1.2. Interpretation and symmetry . . . . . . . . . . . . . . . . . . . . . 221 4.8.1.3. Asymptotic considerations . . . . . . . . . . . . . . . . . . . . . . 223 4.8.1.4. A tighter upper bound . . . . . . . . . . . . . . . . . . . . . . . . . 223 4.8.1.5. Bit error probability . . . . . . . . . . . . . . . . . . . . . . . . . . 224 4.8.1.6. Lower bound of the probability of error . . . . . . . . . . . . . . 225 4.8.2. Examples. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 226 4.8.3. Calculation of δfree . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 228 4.9. Power spectral density . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 232 4.10. Multi-level coding . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 234 4.10.1. Block coded modulation . . . . . . . . . . . . . . . . . . . . . . . . . 235 4.10.2. Decoding of multilevel codes by stages . . . . . . . . . . . . . . . . 237 4.11. Probability of error for the BCM . . . . . . . . . . . . . . . . . . . . . . 238 4.11.1. Additive Gaussian channel . . . . . . . . . . . . . . . . . . . . . . . 239 4.11.2. Calculation of the transfer function . . . . . . . . . . . . . . . . . . 240 4.12. Coded modulations for channels with fading . . . . . . . . . . . . . . . 241 4.12.1. Modeling of channels with fading . . . . . . . . . . . . . . . . . . . 241 4.12.1.1. Delay spread . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 242 4.12.1.2. Doppler-frequency spread . . . . . . . . . . . . . . . . . . . . . . 244 4.12.1.3. Classification of channels with fading. . . . . . . . . . . . . . . 244 4.12.1.4. Examples of radio channels with fading. . . . . . . . . . . . . . 245 4.12.2. Rayleigh fading channel: Euclidean distance and Hamming distance . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 247 4.13. Bit interleaved coded modulation (BICM). . . . . . . . . . . . . . . . . 251 4.14. Bibliography . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 253 Chapter 5. Turbocodes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 255 Claude BERROU, Catherine DOUILLARD, Michel JÉZÉQUEL and Annie PICART 5.1. History of turbocodes. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 255 5.1.1. Concatenation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 256 5.1.2. Negative feedback in the decoder . . . . . . . . . . . . . . . . . . . . 256 5.1.3. Recursive systematic codes . . . . . . . . . . . . . . . . . . . . . . . . 258 5.1.4. Extrinsic information. . . . . . . . . . . . . . . . . . . . . . . . . . . . 258 5.1.5. Parallel concatenation . . . . . . . . . . . . . . . . . . . . . . . . . . . 259 5.1.6. Irregular interleaving. . . . . . . . . . . . . . . . . . . . . . . . . . . . 260 5.2. A simple and convincing illustration of the turbo effect . . . . . . . . . 260 5.3. Turbocodes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 265 5.3.1. Coding . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 265 5.3.2. The termination of constituent codes . . . . . . . . . . . . . . . . . . 272 5.3.2.1. Recursive convolutional circular codes . . . . . . . . . . . . . . . 273 5.3.3. Decoding. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 275 5.3.4. SISO decoding and extrinsic information. . . . . . . . . . . . . . . . 280 5.3.4.1. Notations. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 280 5.3.4.2. Decoding using the MAP criterion. . . . . . . . . . . . . . . . . . 281 5.3.4.3. The simplified Max-Log-MAP algorithm . . . . . . . . . . . . . 284 5.4. The permutation function. . . . . . . . . . . . . . . . . . . . . . . . . . . . 287 5.4.1. The regular permutation. . . . . . . . . . . . . . . . . . . . . . . . . . 288 5.4.2. Statistical approach. . . . . . . . . . . . . . . . . . . . . . . . . . . . . 290 5.4.3. Real permutations. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 291 5.5. m-binary turbocodes. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 297 5.5.1. m-binary RSC encoders . . . . . . . . . . . . . . . . . . . . . . . . . . 298 5.5.2. m-binary turbocodes . . . . . . . . . . . . . . . . . . . . . . . . . . . . 300 5.5.3. Double-binary turbocodes with 8 states. . . . . . . . . . . . . . . . . 302 5.5.4. Double-binary turbocodes with 16 states . . . . . . . . . . . . . . . . 303 5.6. Bibliography . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 304 Chapter 6. Block Turbocodes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 307 Ramesh PYNDIAH and Patrick ADDE 6.1. Introduction. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 307 6.2. Concatenation of block codes . . . . . . . . . . . . . . . . . . . . . . . . . 308 6.2.1. Parallel concatenation of block codes . . . . . . . . . . . . . . . . . . 309 6.2.2. Serial concatenation of block codes . . . . . . . . . . . . . . . . . . . 313 6.2.3. Properties of product codes and theoretical performances. . . . . . 318 6.3. Soft decoding of block codes . . . . . . . . . . . . . . . . . . . . . . . . . 323 6.3.1. Soft decoding of block codes . . . . . . . . . . . . . . . . . . . . . . . 324 6.3.2. Soft decoding of block codes (Chase algorithm) . . . . . . . . . . . 326 6.3.3. Decoding of block codes by the Viterbi algorithm . . . . . . . . . . 334 6.3.4. Decoding of block codes by the Hartmann and Rudolph algorithm 338 6.4. Iterative decoding of product codes . . . . . . . . . . . . . . . . . . . . . 340 6.4.1. SISO decoding of a block code. . . . . . . . . . . . . . . . . . . . . . 341 6.4.2. Implementation of the weighting algorithm . . . . . . . . . . . . . . 345 6.4.3. Iterative decoding of product codes . . . . . . . . . . . . . . . . . . . 347 6.4.4. Comparison of the performances of BTC. . . . . . . . . . . . . . . . 349 6.5. Conclusion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 367 6.6. Bibliography . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 367 Chapter 7. Block Turbocodes in a Practical Setting . . . . . . . . . . . . . . . 373 Patrick ADDE and Ramesh PYNDIAH 7.1. Introduction. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 373 7.2. Implementation of BTC: structure and complexity . . . . . . . . . . . . 373 7.2.1. Influence of integration constraints . . . . . . . . . . . . . . . . . . . 373 7.2.1.1. Quantification of data . . . . . . . . . . . . . . . . . . . . . . . . . 373 7.2.1.2. Choice of the scaling factor. . . . . . . . . . . . . . . . . . . . . . 375 7.2.2. General architecture and organization of the circuit . . . . . . . . . 376 7.2.2.1. Modular structure. . . . . . . . . . . . . . . . . . . . . . . . . . . . 376 7.2.2.2. Von Neumann architecture . . . . . . . . . . . . . . . . . . . . . . 378 7.2.3. Memorizing of data and results. . . . . . . . . . . . . . . . . . . . . . 380 7.2.3.1. Modular structure. . . . . . . . . . . . . . . . . . . . . . . . . . . . 380 7.2.3.2. Von Neumann architecture . . . . . . . . . . . . . . . . . . . . . . 381 7.2.4. Elementary decoder . . . . . . . . . . . . . . . . . . . . . . . . . . . . 384 7.2.4.1. Decoding of BCH codes with soft inputs and outputs . . . . . . 384 7.2.4.2. Functional structure and sequencing. . . . . . . . . . . . . . . . . 385 7.2.4.3. Installation of a decoder on a silicon microchip . . . . . . . . . . 388 7.2.5. High flow structure. . . . . . . . . . . . . . . . . . . . . . . . . . . . . 392 7.2.5.1. Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 392 7.2.5.2. High flow turbodecoder in a practical setting . . . . . . . . . . . 395 7.3. Flexibility of turbo block codes . . . . . . . . . . . . . . . . . . . . . . . . 397 7.4. Hybrid turbocodes. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 404 7.4.1. Construction of the code. . . . . . . . . . . . . . . . . . . . . . . . . . 404 7.4.2. Binary error rates (BER) function of the signal-to-noise ratio in a Gaussian channel . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 406 7.4.3. Variation of the size of the blocks . . . . . . . . . . . . . . . . . . . . 408 7.4.4. Variation of the total rate . . . . . . . . . . . . . . . . . . . . . . . . . 409 7.5. Multidimensional turbocodes . . . . . . . . . . . . . . . . . . . . . . . . . 409 7.6. Bibliography . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 412 List of Authors . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 415 Index . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 417
Acknowledgments xiii Introduction xv 1. Making Games the Modular Way 1 1.1 Important Programming Concepts.....................................2 1.1.1 Manager and Controller Scripts...............................2 1.1.2 Script Communication.......................................3 1.1.3 Using the Singleton Pattern in Unity...........................5 1.1.4 Inheritance.................................................6 1.1.5 Where to Now?.............................................8 2. Building the Core Game Framework 9 2.1 Controllers and Managers............................................11 2.1.1 Controllers................................................11 2.1.2 Managers.................................................11 2.2 Building the Core Framework Scripts..................................11 2.2.1 BaseGameController.cs.....................................12 2.2.1.1 Script Breakdown................................14 viii Contents 2.2.2 Scene Manager.............................................17 2.2.2.1 Script Breakdown................................17 2.2.3 ExtendedCustomMonoBehavior.cs...........................19 2.2.4 BaseUserManager.cs........................................20 2.2.4.1 Script Breakdown................................22 2.2.5 BasePlayerManager.cs.......................................22 2.2.5.1 Script Breakdown................................23 2.2.6 BaseInputController.cs......................................24 2.2.6.1 Script Breakdown................................26 3. Player Structure 29 3.1 Game-Specific Player Controller......................................31 3.2 Dealing with Input..................................................32 3.3 Player Manager.....................................................35 3.3.1 Script Breakdown..........................................36 3.4 User Data Manager (Dealing with Player Stats Such as Health, Lives, etc.)....37 3.4.1 Script Breakdown..........................................39 4. Recipes: Common Components 41 4.1 Introduction.......................................................41 4.2 The Timer Class....................................................43 4.2.1 Script Breakdown..........................................45 4.3 Spawn Scripts......................................................48 4.3.1 A Simple Spawn Controller..................................49 4.3.1.1 Script Breakdown................................52 4.3.2 Trigger Spawner...........................................56 4.3.3 Path Spawner..............................................57 4.3.3.1 Script Breakdown................................61 4.4 Set Gravity.........................................................66 4.5 Pretend Friction—Friction Simulation to Prevent Slipping Around........66 4.5.1 Script Breakdown..........................................68 4.6 Cameras. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .68 4.6.1 Third-Person Camera.......................................69 4.6.1.1 Script Breakdown................................71 4.6.2 Top-Down Camera.........................................74 4.6.2.1 Script Breakdown................................74 4.7 Input Scripts.......................................................75 4.7.1 Mouse Input...............................................75 4.7.1.1 Script Breakdown................................76 4.7.2 Single Axis Keyboard Input.................................78 4.8 Automatic Self-Destruction Script.....................................79 4.8.1 Script Breakdown..........................................79 4.9 Automatic Object Spinner............................................79 4.9.1 Script Breakdown..........................................80 ix Contents 4.10 Scene Manager.....................................................81 4.10.1 Script Breakdown..........................................82 5. Building Player Movement Controllers 85 5.1 Shoot ’Em Up Spaceship.............................................85 5.2 Humanoid Character................................................91 5.2.1 Script Breakdown..........................................96 5.3 Wheeled Vehicle...................................................106 5.3.1 Script Breakdown.........................................109 5.3.2 Wheel Alignment.........................................114 5.3.3 Script Breakdown.........................................116 6. Weapon Systems 121 6.1 Building the Scripts................................................122 6.1.1 BaseWeaponController.cs..................................122 6.1.1.1 Script Breakdown...............................127 6.1.2 BaseWeaponScript.cs......................................134 6.1.2.1 Script Breakdown...............................138 7. Recipe: Waypoints Manager 143 7.1 Waypoint System..................................................143 8. Recipe: Sound Manager 157 8.1 The Sound Controller...............................................158 8.1.1 Script Breakdown.........................................160 8.2 The Music Player...................................................163 8.2.1 Script Breakdown.........................................165 8.3 Adding Sound to the Weapons.......................................167 9. AI Manager 169 9.1 The AI State Control Script..........................................171 9.2 The Base AI Control Script. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .172 9.2.1 Script Breakdown.........................................185 9.3 Adding Weapon Control to the AI Controller..........................206 9.3.1 Script Breakdown.........................................210 10. Menus and User Interface 215 10.1 The Main Menu....................................................215 10.1.1 Script Breakdown.........................................223 10.2 In-Game User Interface.............................................231 x Contents 11. Dish: Lazer Blast Survival 233 11.1 Main Menu Scene..................................................235 11.2 Main Game Scene..................................................236 11.3 Prefabs...........................................................237 11.4 Ingredients........................................................238 11.5 Game Controller...................................................239 11.5.1 Script Breakdown.........................................243 11.6 Player Controller...................................................250 11.6.1 Script Breakdown.........................................253 11.7 Enemies..........................................................259 11.7.1 Script Breakdown.........................................260 11.8 Wave Spawning and Control........................................261 11.8.1 Script Breakdown.........................................263 11.9 Wave Properties...................................................265 11.10 Weapons and Projectiles. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ..266 11.11 User Interface.....................................................266 11.11.1 Script Breakdown.........................................267 12. Dish: Metal Vehicle Doom 271 12.1 Main Menu Scene..................................................272 12.2 Main Game Scene..................................................272 12.2.1 Prefabs...................................................275 12.3 Ingredients........................................................275 12.3.1 Game Controller..........................................276 12.3.1.1 Script Breakdown...............................282 12.3.2 Race Controller...........................................291 12.3.2.1 Script Breakdown...............................297 12.3.3 Global Race Manager......................................306 12.3.3.1 Script Breakdown...............................311 12.3.4 Vehicle/Custom Player Control.............................318 12.3.4.1 Script Breakdown...............................327 12.3.5 User Interface.............................................344 13. Dish: Making the Game Tank Battle 345 13.1 Main Game Scene..................................................347 13.2 Prefabs...........................................................349 13.3 Ingredients........................................................349 13.4 Game Controller...................................................350 13.4.1 Script Breakdown.........................................356 13.5 Battle Controller...................................................361 13.5.1 Script Breakdown.........................................363 13.6 Global Battle Manager..............................................364 13.6.1 Script Breakdown.........................................368 13.7 Players............................................................373 13.7.1 Script Breakdown.........................................382 xi Contents 13.8 AI Chasing with SetAIChaseTargetBasedOnTag.cs.....................383 13.8.1 Script Breakdown.........................................385 14. Dish: Making the Game Interstellar Paranoids 389 14.1 Main Menu.......................................................392 14.2 Game Scenes......................................................392 14.3 Prefabs...........................................................393 14.3.1 Ingredients...............................................394 14.3.2 Game Controller..........................................395 14.3.2.1 Script Breakdown...............................401 14.3.3 Player Spaceship..........................................411 14.3.3.1 Script Breakdown...............................415 14.3.4 Enemies..................................................423 14.3.4.1 Script Breakdown...............................424 14.3.5 Waypoint Follower........................................426 14.3.5.1 Script Breakdown...............................427 Final Note 429 xiii I would like to thank my wife for all the encouragement, support, and nice cups of tea. I would also like to thank my mum and dad, my brother Steve, and everyone else who knows me. Sophie cat, be nice to the boys. Sincere thanks go to the many people who positively influence my life directly or indirectly: Michelle Ashton, Brian Robbins, George Bray, Nadeem Rasool, Christian Boutin, James and Anna, Rich and Sharon, Liz and Peter, Rob Fearon (the curator of all things shiny), everyone on Twitter who RTs my babble (you know who you are, guys!), Matthew Smith (the creator of Manic Miner), David Braben, Tōru Iwatani, and anyone who made Atari games in the 1980s. I would like to thank everyone at AK Peters/CRC Press for the help and support and for publishing my work. Finally, a massive thank you goes out to you for buying this book and for wanting to do something as cool as to make games. I sincerely hope this book helps your gamemaking adventures—feel free to tell me about them on Twitter @psychicparrot or drop by my website at http://www.psychicparrot.com. Acknowledgments xv As I was starting out as a game developer, as a self-taught programmer my skills took a while to reach a level where I could achieve what I wanted. Sometimes I wanted to do things that I just didn’t have yet the technical skills to achieve. Now and again, software packages came along that could either help me in my quest to make games or even make full games for me; complete game systems such as the Shoot ’Em-Up Construction Kit (aka SEUCK) from Sensible Software, Gary Kitchen’s GameMaker, or The Quill Adventure System could bring to life the kinds of games that went way beyond anything that my limited programming skills could ever dream of building. The downside to using game creation software was that it was tailored to create games within their chosen specific genre. If I wanted to do something outside of the limitations of the software, the source code was inaccessible and there was no way to extend or modify it. When that happened, I longed for a modular code-based system that I could plug together to create different types of games but modify parts of it without having to spend a lot of time learning how the entire system internals work—building block game development that I could actually script and modify if I needed to. After completing my first book, Game Development for iOS with Unity3D, I wanted to follow up by applying a modular style of game building to Unity3D that would provide readers with a highly flexible framework to create just about any kind of game by “plugging in” the different script components. My intention was to make a more technical second book, based on C# programming, that would offer extensibility in any direction a developer might require. In essence, what you are holding in your hands right now is a cookbook Introduction xvi Introduction for game development that has a highly flexible core framework for just about any type of game. A lot of the work I put in at the start of writing this book was in designing a framework that not only made sense in the context of Unity but also could easily cope with the demands of different genres. Prerequisites You can get up and running with the required software for the grand total of zero dollars. Everything you need can be downloaded free of charge with no catches. You may want to consider an upgrade to Unity Pro at some point in the future, to take advantage of some of its advanced features, but to get started all you need to do is grab the free version from the Unity website. Unity Free or Unity Pro (available from the Unity store at http://www.unity3d.com) Unity Free is completely free for anyone or any company making less than $100,000 per year—it may be downloaded for no charge at all, and you don’t even need a credit card. It’s a really sweet deal! We are talking about a fully functional game engine, ready to make 3D or 2D games that may be sold commercially or otherwise. There are no royalties to pay, either. Unity Pro adds a whole host of professional functionality to the engine, such as render culling and profiling. If you are a company with more than $100,000 per year of turnover, you will need a Pro license, but if you find that Unity Free doesn’t pack quite enough power, you may also want to consider going Pro. You can arrange a free trial of the Pro version right from the Unity website to try before you buy. If the trial licence runs out before you feel you know enough to make a purchase, contact Unity about extending it and they are usually very friendly and helpful about it (just don’t try using a trial license for 6 months at a time, as they may just figure it out!). C# programming knowledge Again, to reiterate this very important point, this is nota book about learning how to program. You will need to know some C#, and there are a number of other books out there for that purpose, even if I have tried to make the examples as simple as possible! This book is about making games, not about learning to program. What This Book Doesn’t Cover This is not a book about programming and it is not a book about the right or wrong way to do things. We assume that the reader has some experience with the C# programming language. I am a self-taught programmer, and I understand that there may well be better ways to do things. xvii Introduction This is a book about concepts, and it is inevitable that there will be better methods for achieving some of the same goals. The techniques and concepts offered in this book are meant to provide solid foundation, not to be the final word on any subject. It is the author’s intention that, as you gain your own experiences in game development, you make your own rules and draw your own conclusions. Additional material is available from the CRC Press Web site: http://www.crcpress. com/product/isbn/9781466581401. 1 1 Making Games the Modular Way When I first started making games, I would approach development on a project-to-project basis, recoding and rebuilding everything from scratch each time. As I became a professional developer, landing a job at a game development studio making browser-based games, I was lucky enough to work with a guy who was innovating the scene. He was a master at turning out great games (both visually and gameplay-wise) very quickly. One secret to his success lay in the development of a reusable framework that could easily be refactored to use on all of his projects. His framework was set up to deal with server communication, input handling, browser communication, and UI among other things, saving an incredible amount of time in putting together all of the essentials. By reusing the framework, it allowed more time for him and his team to concentrate on great gameplay and graphics optimization, resulting in games that, at the time, blew the competition away. Of course, the structure was tailored to how he worked (he did build it, after all), and it took me a while to get to grips with his style of development; but once I did, it really opened my eyes. From then on, I used the framework for every project and even taught other programmers how to go about using it. Development time was substantially reduced, which left more time to concentrate on making better games. This book is based on a similar concept of a game-centric framework for use with many different types of games, rather than a set of different games in different styles. The overall goal of this book is to provide script-based components that you can use within that framework to make a head start with your own projects in a way that reduces recoding, repurposing, or adaptation time. 2 1. Making Games the Modular Way In terms of this book as a cookbook, think of the framework as a base soup and the scripting components as ingredients. We can mix and match script components from different games that use the same framework to make new games, and we can share several of the same core scripts in many different games. The framework takes care of the essentials, and we add a little “glue” code to pull everything together the way we want it all to work. This framework is, of course, optional, but you should spend some time familiarizing yourself with it to help understand the book. If you intend to use the components in this book for your own games, the framework may serve either as a base to build your games on or simply as a tutorial test bed for you to rip apart and see how things work. Perhaps you can develop a better framework or maybe you already have a solid framework in place. If you do, find a way to develop a cleaner, more efficient framework or even a framework that isn’t quite so efficient but works better with your own code, and do it. In this chapter, we start by examining some of the major programming concepts used in this book and look at how they affect the design decisions of the framework. 1.1 Important Programming Concepts I had been programming in C# for a fairly long time before I actually sat down and figured out some of the concepts covered in this chapter. It was not because of any particular problem or difficulty with the concepts themselves but more because I had solved the problems in a different way that meant I had no real requirement to learn anything new. For most programmers, these concepts will be second nature and perhaps something taught in school, but I did not know how important they could be. I had heard about things like inheritance, and it was something I put in the to-do list, buried somewhere under “finish the project.” Once I took the time to figure them out, they saved me a lot of time and led to much cleaner code than I would have previously pulled together. If there’s something you are unsure about, give this chapter a read-through and see whether you can work through the ideas. Hopefully, they may save some of you some time in the long run. 1.1.1 Manager and Controller Scripts I am a strong believer in manager and controller scripts. I like to try and split things out into separate areas; for example, in the Metal Vehicle Doomgame, I have race controller scripts and a global race controller script. The race controller scripts are attached to the players and track their positions on the track, waypoints, and other relevant player-specific race information. The global race controller script talks to all the race controller scripts attached to the players to determine who is winning and when the race starts or finishes. By keeping this logic separate from the other game scripts and contained in their own controller scripts, it makes it easier to migrate them from project to project. Essentially, I can take the race controller and global race controller scripts out of the game and apply them to another game, perhaps one that features a completely different type of gameplay— for example, alien characters running around a track instead of cars. As long as I apply the correct control scripts, the race logic is in place, and I can access it in the new game. In the framework that this book contains, there are individual manager and controller scripts dealing with user data, input, game functions, and user interface. We look at those in detail in Chapter 2, but as you read this chapter, you should keep in mind the idea of separated scripts dedicated to managing particular parts of the game structure. It was 3 1.1 Important Programming Concepts important to me to design scripts as standalone so that they may be used in more than one situation. For example, our weapon slot manager will not care what kind of weapon is in any of the slots. The weapon slot manager is merely an interface between the player and the weapon, taking a call to “fire” and responding to it by telling the weapon in the currently selected weapon slot to fire. What happens on the player end will not affect the slot manager just as anything that happens with the weapon itself will not affect the slot manager. It just doesn’t care as long as your code talks to it in the proper way and as long as your weapons receive commands in the proper way. It doesn’t even matter what type of object the slot manager is attached to. If you decide to attach the weapon slot manager to a car, a boat, a telegraph pole, etc., it doesn’t really matter just as long as when you want them to fire, you use the correct function in the slot manager to get it to tell a weapon to fire. Since our core game logic is controlled by manager and controller scripts, we need to be a little smart about how we piece everything together. Some manager scripts may benefit from being static and available globally (for all other scripts to access), whereas others may be better attached to other scripts. We deal with these on a case-by-case basis. To get things started, we will be looking at some of the ways that these manager scripts can communicate with each other. As a final note for the topic in this section, you may be wondering what the difference is between managers and controllers. There really isn’t all that much, and I have only chosen to differentiate for my own sanity. I see controllers as scripts that are larger global systems, such as game state control, and managers as smaller scripts applied to gameObjects, such as weapon slot management or physics control. The terms are applied loosely, so don’t worry if there appear to be inconsistencies in the application of the term in one case versus another. I’ll try my best to keep things logical, but that doesn’t mean it’ll always make sense to everyone else! 1.1.2 Script Communication An important part of our manager- and component-based structures is how our scripts are going to communicate with each other. It is inevitable that we will need to access our scripts from a multitude of other areas of the game, which means we should try to provide interfaces that make the most sense. There are several different ways of communicating between scripts and objects in Unity: 1. Direct referencing manager scripts via variables set in the editor by the Inspector window. The easiest way to have your scripts talk to each other is to have direct references to them in the form of public variables within a class. They are populated in the Unity editor with a direct link to another script. Here is an example of direct referencing: public void aScript otherScript; In the editor window, the Inspector shows the otherScript field. We drag and drop an object containing the script component that we want to talk to. Within the class, function calls are made directly on the variable, such as otherScript.DoSomething(); 4 1. Making Games the Modular Way 2. GameObject referencing using SendMessage. SendMessage is a great way to send a message to a gameObject and call a function in one of its attached scripts or components when we do not need any kind of return result. For example, SomeGameObject.SendMessage("DoSomething"); SendMessage may also take several parameters, such as setting whether or not the engine should throw an error when there is no receiver, that is, no function in any script attached to the gameObject with a name matching the one in the SendMessage call. (SendMessageOptions). You can also pass one parameter into the chosen function just as if you were passing it via a regular function call such as SomeGameObject.SendMessage("AddScore",2); SomeGameObject.SendMessage("AddScore", SendMessageOptions.RequireReceiver); SomeGameObject.SendMessage("AddScore", SendMessageOptions.DontRequireReceiver); 3. Static variables. The static variable type is useful in that it extends across the entire system; it will be accessible in every other script. This is a particularly useful behavior for a game control script, where several different scripts may want to communicate with it to do things such as add to the player’s score, lose a life, or perhaps change a level. An example declaration of a static variable might be private static GameController aController; Although static variables extend across the entire program, you can have private and public static variables. Things get a little tricky when you try to understand the differences between public and private static types—I was glad to have friends on Twitter that could explain it all to me, so let me pass on what I was told: Public static A public static variable exists everywhere in the system and may be accessed from other classes and other types of script. Imagine a situation where a player control script needs to tell the game controller script whenever a player picks up a banana. We could deal with it like this: 1. In our gamecontroller.cs game controller script, we set up a public static: public static GameController gateway; 2. When the game controller (gamecontroller.cs) runs its Start() function, it stores a reference to itself in a public static variable like this: gateway = this; 3. In any other class, we can now access the game controller by referring to its type followed by that static variable (GameController.gateway) such as GameController.gateway.GotBanana(); 5 1.1 Important Programming Concepts Private static A private static variable exists within the class it was declared and in any other instances of the same class. Other classes/types of script will not be able to access it. As a working example, try to imagine that a script named player.cs directly controls player objects in your game. They all need to tell a player manager script when something happens, so we declare the player manager as a static variable in our player.cs script like this: private static PlayerManager playerManager; The playerManager object only needs to be set up once, by a single instance of the player class, to be ready to use for all the other instances of the same class. All player.cs scripts will be able to access the same instance of the PlayerManager. 4. The singleton design pattern. In the previous part of this section, we looked at using a static variable to share a manager script across the entire game code. The biggest danger with this method is that it is possible to create multiple instances of the same script. If this happens, you may find that your player code is talking to the wrong instance of the game controller. A singletonis a commonly used design pattern that allows for only one instance of a particular class to be instantiated at a time. This pattern is ideal for our game scripts that may need to communicate (or be communicated with) across the entire game code. Note that we will be providing a static reference to the script, exactly as we did in the “Static Variables” method earlier in this section, but in implementing a singleton class, we will be adding some extra code to make sure that only one instance of our script is ever created. 1.1.3 Using the Singleton Pattern in Unity It is not too difficult to see how useful static variables can be in communication between different script objects. In the public static example cited earlier, the idea was that we had a game controller object that needed to be accessed from one or more other scripts in our game. The method shown here was demonstrated on the Unity public wiki*by a user named Emil Johansen (AngryAnt). It uses a private static variable in conjunction with a public static function. Other scripts access the public function to gain access to the private static instance of this script, which is returned via the public function so that only one instance of the object will ever exist in a scene regardless of how many components it is attached to and regardless of how many times it is instantiated. A simple singleton structure: public class MySingleton { private static MySingleton instance; public MySingleton () *http://wiki.unity3d.com/index.php/Singleton. 6 1. Making Games the Modular Way { if (instance != null) { Debug.LogError ("Cannot have two instances of singleton."); return; } instance = this; } public static MySingleton Instance { get { if (instance == null) { new MySingleton (); } return instance; } } } The singleton instance of our script may be accessed anywhere, by any script, simply with the following syntax: MySingleton.Instance.MySingletonMember; 1.1.4 Inheritance Inheritanceis a complex concept, which demands some explanation here because of its key role within the scripts provided in this book. Have a read through this section, but don’t worry if you don’t pick up inheritance right away. Once we get to the programming, it will most likely become clear. The bottom line is that inheritance is used in programming to describe a method of providing template scripts that may be overridden, or added to, by other scripts. As a metaphor, imagine a car. All cars have four wheels and an engine. The types of wheels may vary from car to car, as will the engine, so when we say “this is a car” and try to describe how our car behaves, we may also describe the engine and wheels. These relationships may be shown in a hierarchical order: Car -Wheels -Engine Now try to picture this as a C# script: Car class Wheels function Engine function 7 1.1 Important Programming Concepts
Contents WEB DYNPRO ABAP: DEVELOPMENT IN DETAIL .............................................................. 1 1 BASICS............................................................................................................................. 1 1.1 Component................................................................................................................ 2 1.2 Web Dynpro View ..................................................................................................... 3 1.2.1 UI Elements of the View ................................................................................. 5 1.2.2 Structure of the View Context......................................................................... 7 1.2.3 Data Binding ................................................................................................... 8 1.2.4 UI Element Actions....................................................................................... 10 1.2.5 Action Event Handlers.................................................................................. 12 1.3 Component Controller ............................................................................................. 15 1.3.1 Context Mapping .......................................................................................... 16 1.4 Programming Controller Methods ........................................................................... 18 1.4.1 Reference Variable WD_CONTEXT ............................................................ 19 1.4.2 Reference Variable WD_THIS and Local Controller Interface..................... 19 1.4.3 Methods of the Local Controller Interface .................................................... 20 1.4.4 Web Dynpro Runtime APIs .......................................................................... 32 1.4.5 Filling the Context......................................................................................... 34 1.4.6 Phase Model................................................................................................. 35 1.4.7 Client Implementation................................................................................... 39 1.5 Web Dynpro Window .............................................................................................. 40 1.5.1 Navigation Between Two Views................................................................... 41 1.6 Web Dynpro Application.......................................................................................... 44 1.7 URL of a Web Dynpro Application .......................................................................... 45 1.7.1 Fully Qualified Domain Names (FQDN) ....................................................... 48 1.7.2 URLs and Namespaces ............................................................................... 53 1.8 Calling a Web Dynpro Application Using Parameters ............................................ 55 2 CROSS-COMPONENT PROGRAMMING....................................................................... 55 2.1 Controllers of a Web Dynpro Component............................................................... 56 2.2 Component Usages ................................................................................................ 58 2.2.1 Component Usage without Controller Access.............................................. 59 2.2.2 Component Usage with Controller Access................................................... 62 2.2.3 Navigation Through Window Plugs .............................................................. 63 2.2.4 Cross-Component Context Mapping............................................................ 64 2.3 Working with Web Dynpro Component Interfaces.................................................. 68 2.3.1 Creating a Web Dynpro Component Interface Definition............................. 70 2.3.2 Implementing a Web Dynpro Interface Definition......................................... 71 2.3.3 Example for the Implementation of an Interface Definition .......................... 71 2.4 Working With Faceless Components...................................................................... 74 3 DYNAMIC PROGRAMMING ........................................................................................... 74 3.1 Dynamic Layout Manipulation................................................................................. 75 3.1.1 Working Dynamically with Parameter Mappings.......................................... 77 3.2 Dynamic Context Manipulation ............................................................................... 79 3.3 Working Dynamically with Component Usages ...................................................... 80 3.3.1 Dynamically Creating Component Usages .................................................. 81 3.3.2 Dynamically Embedding an Interface View.................................................. 83 3.3.3 Method Call in a Dynamically Created Component Usage.......................... 85 3.3.4 Dynamically Registering an Event Handler to an Event............................... 86 4 ADVANCED CONCEPTS................................................................................................ 86 4.1 Working with the Assistance Class ......................................................................... 87 4.2 Service Calls in a Web Dynpro Application............................................................. 88 4.2.1 Creating a Service Call................................................................................. 88 4.2.2 Using a Service Call ..................................................................................... 89 4.3 Working with Dialog Boxes ..................................................................................... 90 4.3.1 Calling Dialog Boxes of the Same Component ............................................ 91 4.3.2 Calling Dialog Boxes of a Used Component................................................ 93 4.3.3 Calling a Confirmation Dialog Box................................................................ 94 4.4 Data Binding Concepts ........................................................................................... 95 4.4.1 Data Binding of User Interface Element Properties ..................................... 95 4.4.2 Data Binding Using Index and Key............................................................... 97 4.4.3 Fixed Values of Attributes ............................................................................ 98 4.4.4 Context Change Log (Recording User Entries).......................................... 100 4.5 Input Help .............................................................................................................. 102 4.5.1 ABAP Dictionary Search Help .................................................................... 102 4.5.2 OVS Input Help........................................................................................... 104 4.5.3 Freely Programmed Input Help .................................................................. 106 4.6 Messages.............................................................................................................. 107 4.6.1 Integration of Messages in the Message Log ............................................ 110 4.7 Handling Web Icons .............................................................................................. 112 4.8 File Export ............................................................................................................. 114 4.9 Portal Integration................................................................................................... 116 4.9.1 Binding to Portal: Prerequisites .................................................................. 117 4.9.2 Integrating an Application in the Portal....................................................... 117 4.9.3 Portal Events .............................................................................................. 120 4.9.4 Portal Navigation ........................................................................................ 123 4.9.5 Work Protect Mode..................................................................................... 131 4.10 Example ................................................................................................................ 133 4.11 Integrating Forms .................................................................................................. 133 4.11.1 Integrating a PDF Form in a Web Dynpro Application ............................... 134 4.11.2 Supported Elements of the Adobe Library ................................................. 136 4.11.3 Interactive Form Use .................................................................................. 137 4.11.4 Forms with Function Module-Based Interface............................................ 137 4.12 Personalization and Configuration ........................................................................ 138 4.12.1 Component Configuration .......................................................................... 139 4.12.2 Application Configuration ........................................................................... 141 4.12.3 Personalization........................................................................................... 143 4.12.4 Delta Handling in Customization and Personalization ............................... 144 4.12.5 Notes on Working with Adjustment Data.................................................... 146 4.12.6 Configuration of an Included ALV Component........................................... 147 4.13 Modification-Free Enhancements ......................................................................... 148 4.13.1 Implementing Enhancements in a View ..................................................... 149 4.13.2 Implementing Enhancements in the Controller .......................................... 150 4.13.3 Implementing Enhancements in a Window ................................................ 151 4.14 Integration of Web Dynpro ABAP Applications in GUI Applications ..................... 151 4.15 Accessibility of a Web Dynpro Application............................................................ 153 4.16 Internationalization and Translation ...................................................................... 156 4.17 SAP List Viewer in Web Dynpro for ABAP............................................................ 158 4.17.1 Integration of the ALV in Your Application ................................................. 158 4.17.2 Managing ALV Output Areas...................................................................... 166 4.17.3 Appearance of ALV Output ........................................................................ 182 4.17.4 Predefining Standard ALV Functions ......................................................... 190 4.17.5 Functions, Interactions, and Events ........................................................... 205 4.17.6 Methods and Events of the Interface Controller......................................... 219 4.18 Screen Design Time Conversion .......................................................................... 231 4.18.1 Restrictions................................................................................................. 232 4.18.2 Transformation Rules ................................................................................. 233 4.19 Version Comparisons in Web Dynpro for ABAP................................................... 247 4.20 Quality Assurance ................................................................................................. 248 4.20.1 Web Dynpro Trace Tool ............................................................................. 248 4.20.2 ICM Tracing ................................................................................................ 250 4.20.3 HTTP Browser Tracing............................................................................... 252 4.21 System Logon ....................................................................................................... 258 4.21.1 Prerequisites............................................................................................... 261 4.21.2 Configuration Settings ................................................................................ 262 4.21.3 Password Logon Scenarios........................................................................ 265 4.21.4 User-specific Changes ............................................................................... 268 4.21.5 URL Generation in an AS-ABAP - Web Dispatcher Configuration ............ 271 4.21.6 Examples of the Logon Screen .................................................................. 280

830

社区成员

发帖
与我相关
我的任务
社区描述
Delphi 非技术区
社区管理员
  • 非技术区社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧