HDL Implementation of a Controller Area Network Node
Total Page:16
File Type:pdf, Size:1020Kb
Rowan University Rowan Digital Works Theses and Dissertations 12-31-2003 HDL implementation of a controller area network node Anthony Richard Marino Rowan University Follow this and additional works at: https://rdw.rowan.edu/etd Part of the Electrical and Computer Engineering Commons Recommended Citation Marino, Anthony Richard, "HDL implementation of a controller area network node" (2003). Theses and Dissertations. 1341. https://rdw.rowan.edu/etd/1341 This Thesis is brought to you for free and open access by Rowan Digital Works. It has been accepted for inclusion in Theses and Dissertations by an authorized administrator of Rowan Digital Works. For more information, please contact [email protected]. HDL Implementation of a Controller Area Network Node by Anthony Richard Marino A Thesis Submitted to the Graduate Faculty in Partial Fulfillment of the Requirements for the Degree of MASTER OF SCIENCE Department: Electrical and Computer Engineering Major: Engineering (Electrical Engineering) Approved: Members of the Committee In Charge of Major Work For the Major Department For the College Rowan University Glassboro, New Jersey 2003 ii TABLE OF CONTENTS List of Figures ................................................................................. vi List of Tables .............................................................................................. ............. viii Abstract........................................ ....................................................................................... x Acknowledgements................................................ ............................................................ xi Chapter 1: Introduction ........................................ .................................................. 1 1.1 In-V ehicle N etw orks ........................................ ............................................... 1.1.1 In-Vehicle Network Classifications......................... ....................................... 2 1.1.1.1 Class A Networks .............................................. ..................... 3 1.1.1.2 C lass B N etw orks ............................................................................................. 3 1.1.1.3 Class C Networks ............................................................................................ 3 1.2.1 Current In-Vehicle Networks ..................................................... 4 1.2.1.1 On Board Diagnostics (OBD) ........................................... .......... 4 1.2.1.2 Local Interconnect Network (LIN) ............................................. 5 1.2.1.3 Media-Oriented Systems Transport (MOST)...................................................6 1.2.1.4 Controller Area Network (CAN)......................................................................7 1.3 Potential Law Enforcement Applications ........................................ ............. 8 1.4 Selecting an In-V ehicle Netw ork................................................................................ 10 1.4.1 Selecting the Appropriate Network for the Application ....................................... 11 1.5 Current CAN Implementations .................................................................................. 14 1.6 Statem ent of the Problem ........................................ ................................................ 15 1.7 Scope and Organization of Thesis ............................................................................ 16 Chapter 2: B ackground ..................................................................................................... 17 2.1 Data Communications Reference Model ........................................ ..... 18 2.2 CA N A rchitecture ....................................................................................................... 20 2.2.1 CAN Data Link Layer ............................................. 20 2.2.1.1 Bus Arbitration ................................................... ....................................... 20 2.2.1.2 F ram e F orm ats................................................................................................ 22 2.2.1.2.1 Data Frame .................................................. 23 2.2.1.2.2 R em ote Fram e .......................................................................................... 28 2.2.1.2.3 Error Frame ..................................................... 29 2.2.1.2.4 Overload Frame ......................................................... 30 2.2.1.3 Error Detection and Handling ............................................. 30 2.2.2 CAN Physical Layer .................................................................................. 32 2.2.2.1 B it T iming ..................................................................................................... 32 2.2.2.2 Physical Signaling .................................................................................... 34 2.2.2.3 Physical Transmission Medium ............................................. 36 2.2.3 C AN A pplication Layer........................................................................................ 40 Chapter 3: Approach ............................................................ .......................... 42 iii 3.1 CAN M odule Specification......................................................................................... 43 3.2 CAN Protocol Controller ............................................................................................ 44 3.2.1 Bit Tim ing Logic .................................................................................................. 46 3.2.2 Transmit and Receive Registers ................................................ 49 3.2.3 Bit Stream Processor ............................................................................................ 49 3.2.3.1 Fram e Generator............................................................................................. 50 3.2.3.2 Bit Stuffing and D e-stuffing........................................................................... 50 3.2.3.3 Cyclic Redundancy Check ............................................................................. 51 3.2.3.4 M essage Filtering.......................................................................................... 52 3.2.4 M essage Buffer ..................................................................................................... 53 3.2.5 Error M anagem ent Logic...................................................................................... 54 3.3 FPGA Im plem entation ........................................ ...................................... ...... 57 3.3.1 FPG A w ith CAN A pplied to Light Control.......................................................... 58 3.3.1.1 CAN D ata Fram e Coding............................................................................... 60 3.3.1.2 Transm itting and Receiving a CAN Fram e................................... ............ 63 3.3.1.2.1 Controlling the CAN Functions ............................................................... 64 Chapter 4: Results ............................................................................................................. 69 4.1 Synthesis ................................................................................................................... 69 4.2 Sim ulation ................................................. ...................... ..................................... 70 4.3 Two CA N N ode N etw ork Im plem entation................................................................. 77 4.3.1 Configuration and Initialization............................................................................ 77 4.3.2 M essage Transm ission......................................................................................... 81 4.3.3 M essage Reception ............................................................................................. 83 Chapter 5: Conclusions ..................................................................................................... 86 5.1 Sum m ary of A ccom plishm ents ............................................. .......... 87 5.2 Recom m endations for Future W ork............................................................................ 90 5.2.1 Durability of CA N ................................................................ ...................... 90 5.2.2 Integrity of CAN ................................................................. ................ 91 5.2.3 Com patibility of CAN ......................................................................................... 92 5.2.4 Sustainability of CA N ......................................................................................... 93 R eferences......................................................................................................................... 96 Appendix A: HD L Code ................................................................................................... 99 A.1: Top Level H DL Code ............................................................................................ 99 A .2: BTL HD L Code................................................................................................... 110 A .3: BSP H D L Code ................................................................................................. 116 A.4: CRC H D L Code................................................................................................... 149 A .5: A CF HD L Code..................................................................................................