ebook img

Hardware Verification with C++: A Practitioner’s Handbook PDF

351 Pages·2006·1.713 MB·English
Save to my drive
Quick download
Download
Most books are stored in the elastic cloud where traffic is expensive. For this reason, we have a limit on daily download.

Preview Hardware Verification with C++: A Practitioner’s Handbook

HARDWARE VERIFICATION WITH C++ A Practitioner’s Handbook HARDWARE VERIFICATION WITH C++ A Practitioner’s Handbook MIKE MINTZ ROBERT EKENDAHL 1 3 Cover art from the original painting “Every other now and then” by John E. Bannon, johnebannon.com Mike Mintz Robert Ekendahl Hardware Verification with C++: A Practitioner’s Handbook Library of Congress Control Number: 2006928441 ISBN 0-387-25543-5 e-ISBN 0-387-36254-1 ISBN 9780387255439 Printed on acid-free paper. (cid:164) 2006 Springer Science+Business Media, LLC All rights reserved. This work may not be translated or copied in whole or in part without the written permission of the publisher (Springer Science+Business Media, LLC, 233 Spring Street, New York, NY 10013, USA), except for brief excerpts in connection with reviews or scholarly analysis. Use in connection with any form of information storage and retrieval, electronic adaptation, computer software, or by similar or dissimilar methodology now know or hereafter developed is forbidden. The use in this publication of trade names, trademarks, service marks and similar terms, even if they are not identified as such, is not to be taken as an expression of opinion as to whether or not they are subject to proprietary rights. Printed in the United States of America. 9 8 7 6 5 4 3 2 1 springer.com For Joan, Alan, and Brian. Thanks for your patience. Mike For Chantal. Thanks for your understanding, love, and active support. And to Newton. For many missed walks. Robert Contents Preface. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xix Acknowledgments. . . . . . . . . . . . . . . . . . . . . . . . . xxi Chapter 1: Introduction . . . . . . . . . . . . . . . . . .1 Background . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3 What is Functional Verification?. . . . . . . . . . . . . . . . . 4 Why Focus on C++? . . . . . . . . . . . . . . . . . . . . . . . . . 4 A Tour of the Handbook. . . . . . . . . . . . . . . . . . . . . . 5 For Further Reading . . . . . . . . . . . . . . . . . . . . . . . . 6 Part I: C++ and Verification (The Why and How). . . . . . . . . . . . . . . . . . . .7 Chapter 2: Why C++? . . . . . . . . . . . . . . . . . . . . .9 Overview. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10 C++: A Good Verification Language. . . . . . . . . . . . . . 11 A Look at Hardware-Verification Languages. . . . . . . . 13 Randomization. . . . . . . . . . . . . . . . . . . . . . . . . . 13 Coverage. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14 Object-oriented support . . . . . . . . . . . . . . . . . . . 14 Main Benefits of Using C++ . . . . . . . . . . . . . . . . . . . 15 Hardware Verification with C++: A Practitioner’s Handbook (cid:122)(cid:3)(cid:122)(cid:3)(cid:122)(cid:3)(cid:122)(cid:3)(cid:122)(cid:3)(cid:122)(cid:3)(cid:122)(cid:3) Contents Other Benefits of Using C++ . . . . . . . . . . . . . . . . . . 16 Drawbacks of Using C++ . . . . . . . . . . . . . . . . . . . . . 17 For Further Reading . . . . . . . . . . . . . . . . . . . . . . . 17 Chapter 3: OOP, C++, and Verification . . . .19 Overview. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20 The Evolution of OOP and C++. . . . . . . . . . . . . . . . . 21 Assembly programming: The early days. . . . . . . . . . 21 Procedural languages: The next big step. . . . . . . . . 21 OOP: Inheritance for functionality. . . . . . . . . . . . . 22 OOP: Inheritance for interface . . . . . . . . . . . . . . . 24 OOP: Templates. . . . . . . . . . . . . . . . . . . . . . . . . 24 C++: The standard template library . . . . . . . . . . . . 25 The Evolution of Functional Verification . . . . . . . . . . 25 Verification through inspection . . . . . . . . . . . . . . . 25 Verification through randomness. . . . . . . . . . . . . . 26 The emergence of hardware verification languages . . . . . . . . . . . . . . 27 OOP: A current trend in hardware verification languages . . . . . . . . . . . . . . 27 OOP: Problems with the current approach. . . . . . . . 28 OOP: A possible next step . . . . . . . . . . . . . . . . . . 28 OOP Using C++ . . . . . . . . . . . . . . . . . . . . . . . . . . . 29 Data abstraction through classes . . . . . . . . . . . . . . 29 A DMA descriptor example . . . . . . . . . . . . . . . . . 29 Access control . . . . . . . . . . . . . . . . . . . . . . . . . 31 Constructors and destructors . . . . . . . . . . . . . . . 32 Member methods and variables. . . . . . . . . . . . . . 33 Operator overloading . . . . . . . . . . . . . . . . . . . . 34 Inheritance for functionality. . . . . . . . . . . . . . . . . 34 Inheritance for interface . . . . . . . . . . . . . . . . . . . 36 Templating . . . . . . . . . . . . . . . . . . . . . . . . . . . . 38 A word about user-defined templates. . . . . . . . . . 39 Namespaces. . . . . . . . . . . . . . . . . . . . . . . . . . . . 39 viii (cid:122)(cid:3)(cid:122)(cid:3)(cid:122)(cid:3)(cid:122)(cid:3)(cid:122)(cid:3)(cid:122)(cid:3)(cid:122) Hardware Verification with C++ Summary. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 41 For Further Reading . . . . . . . . . . . . . . . . . . . . . . . 41 Chapter 4: A Layered Approach . . . . . . . . . . .43 Overview. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 44 A Whiteboard Drawing. . . . . . . . . . . . . . . . . . . . . . 46 An “ends-in” approach. . . . . . . . . . . . . . . . . . . . . 47 Refining the whiteboard blocks. . . . . . . . . . . . . . . 47 The “Common-Currency” Components . . . . . . . . . . . 48 The Interface Layer in Detail. . . . . . . . . . . . . . . . . . 49 The wire layer . . . . . . . . . . . . . . . . . . . . . . . . . . 50 The agent layer . . . . . . . . . . . . . . . . . . . . . . . . . 52 The transaction layer . . . . . . . . . . . . . . . . . . . . . 53 The Top-Layer Components . . . . . . . . . . . . . . . . . . 54 What is a Test?. . . . . . . . . . . . . . . . . . . . . . . . . . . 56 The Test Component. . . . . . . . . . . . . . . . . . . . . . . 58 The Test Irritator . . . . . . . . . . . . . . . . . . . . . . . . . 60 A Complete Test. . . . . . . . . . . . . . . . . . . . . . . . . . 61 Summary. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 63 For Further Reading . . . . . . . . . . . . . . . . . . . . . . . 63 Part II: An Open-Source Environment with C++ . . . . . .65 Chapter 5: Teal Basics . . . . . . . . . . . . . . . . . . .67 Overview. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 68 What Teal provides. . . . . . . . . . . . . . . . . . . . . . . 68 Teal’s similarity to HDLs . . . . . . . . . . . . . . . . . . . 69 A tiny but complete example . . . . . . . . . . . . . . . . 69 Teal’s Main Components. . . . . . . . . . . . . . . . . . . . . 71 Using Teal. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 73 Initialization . . . . . . . . . . . . . . . . . . . . . . . . . . . 73 Your C++ test. . . . . . . . . . . . . . . . . . . . . . . . . . . 74 Registers. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 74 A Practitioner’s Handbook (cid:122)(cid:3)(cid:122)(cid:3)(cid:122)(cid:3)(cid:122)(cid:3)(cid:122)(cid:3)(cid:122)(cid:3)(cid:122) ix Contents Creating registers. . . . . . . . . . . . . . . . . . . . . . . 74 Working with a reg or vreg . . . . . . . . . . . . . . . . . . 75 Logging Output. . . . . . . . . . . . . . . . . . . . . . . . . . . 76 Using Test Parameters. . . . . . . . . . . . . . . . . . . . . . 79 Accessing Memory. . . . . . . . . . . . . . . . . . . . . . . . . 81 A memory note example . . . . . . . . . . . . . . . . . . . 82 Constrained Random Numbers. . . . . . . . . . . . . . . . . 84 Required initialization. . . . . . . . . . . . . . . . . . . . . 84 Using random numbers. . . . . . . . . . . . . . . . . . . . . 84 Working with Simulation Events and Concurrency . . . . 86 Summary. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 88 For Further Reading . . . . . . . . . . . . . . . . . . . . . . . 88 Chapter 6: Truss: A Standard Verification Framework . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .91 Overview. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 92 General Considerations . . . . . . . . . . . . . . . . . . . . . 93 Using a language other than C++ . . . . . . . . . . . . . . 93 Keeping it simple . . . . . . . . . . . . . . . . . . . . . . . . 94 Major Classes and Their Roles . . . . . . . . . . . . . . . . . 95 Key test algorithm: The “dance”. . . . . . . . . . . . . . 96 The verification_component Abstract Base Class. . . . . 99 Detailed Responsibilities of the Major Components. . . . . . . . . . . . . . . . . . . .100 The testbench class. . . . . . . . . . . . . . . . . . . . . . .101 Watchdog timer . . . . . . . . . . . . . . . . . . . . . . . . .102 Test class . . . . . . . . . . . . . . . . . . . . . . . . . . . . .102 Test Component and Irritator Classes . . . . . . . . . . . .106 The test component abstract base class . . . . . . . . .106 An AHB example. . . . . . . . . . . . . . . . . . . . . . . . .108 Test-component housekeeping functionality . . . . . .109 The irritator abstract base class . . . . . . . . . . . . . .110 Using the irritator. . . . . . . . . . . . . . . . . . . . . . .112 Summary. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .113 x (cid:122)(cid:3)(cid:122)(cid:3)(cid:122)(cid:3)(cid:122)(cid:3)(cid:122)(cid:3)(cid:122)(cid:3)(cid:122) Hardware Verification with C++ Chapter 7: Truss Flow . . . . . . . . . . . . . . . . . . . .115 Overview. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .116 About verification_top.cpp. . . . . . . . . . . . . . . . . . .116 The Test Component Dance . . . . . . . . . . . . . . . . . .119 The Irritator Dance . . . . . . . . . . . . . . . . . . . . . . . .121 Compiling and Running Tests. . . . . . . . . . . . . . . . . .122 Truss run script . . . . . . . . . . . . . . . . . . . . . . . . .123 Switches. . . . . . . . . . . . . . . . . . . . . . . . . . . . .124 The Truss makefile . . . . . . . . . . . . . . . . . . . . . . .125 The First Test: A Directed Test . . . . . . . . . . . . . . . .125 The Second Test: Adding Channels and Random Parameters . . . . . . . . .127 The channel classes. . . . . . . . . . . . . . . . . . . . . . .128 Building the second test. . . . . . . . . . . . . . . . . . . .129 Building the second test’s test_component . . . . . . .132 Adjusting the second test’s parameters . . . . . . . . .134 The Remaining Tests: Mix-and-Match Test Components . . . . . . . . . . . . . . .136 Summary. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .137 Chapter 8: Truss Example . . . . . . . . . . . . . . . .139 Overview. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .140 Directory Structure. . . . . . . . . . . . . . . . . . . . . . . .140 Theory of Operation . . . . . . . . . . . . . . . . . . . . . . .142 Running the Simple ALU Example. . . . . . . . . . . . . . .144 Points of Interest . . . . . . . . . . . . . . . . . . . . . . . . .144 Power-on Reset . . . . . . . . . . . . . . . . . . . . . . . . . .145 Driver and Monitor Protocol . . . . . . . . . . . . . . . . . .146 The alu_test_component . . . . . . . . . . . . . . . . . . . .147 Checking the Chip. . . . . . . . . . . . . . . . . . . . . . . . .147 Completing the Test . . . . . . . . . . . . . . . . . . . . . . .149 Summary. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .150 A Practitioner’s Handbook (cid:122)(cid:3)(cid:122)(cid:3)(cid:122)(cid:3)(cid:122)(cid:3)(cid:122)(cid:3)(cid:122)(cid:3)(cid:122) xi

See more

The list of books you might like

Most books are stored in the elastic cloud where traffic is expensive. For this reason, we have a limit on daily download.