Transcription of SYSTEMVERILOG FOR VERIFICATION
1 SYSTEMVERILOG FOR VERIFICATION . A Guide to Learning the Testbench Language Features SYSTEMVERILOG FOR VERIFICATION . A Guide to Learning the Testbench Language Features CHRIS SPEAR. Synopsys, Inc. 13. Chris Spear Synopsys, Inc. 377 Simarano Drive Marlboro, MA 01752. SYSTEMVERILOG for VERIFICATION : A Guide to Learning the Testbench Language Features Library of Congress Control Number: 2006926262. ISBN-10: 0-387-27036-1 e-ISBN-10: 0-387-27038-8. ISBN-13: 9780387270364 e-ISBN-13: 9780387270388. Printed on acid-free paper. 2006 Springer Science+Business Media, LLC.
2 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 known 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.
3 Printed in the United States of America. 9 8 7 6 5 4 3 2 1. This book is dedicated to my wonderful wife Laura, whose patience during this project was invaluable, and my children, Allie and Tyler, who kept me laughing. Contents List of Examples xi List of Figures xxi List of Tables xxiii Foreword xxv Preface xxvii Acknowledgments xxxiii 1. VERIFICATION GUIDELINES 1. Introduction 1. The VERIFICATION Process 2. The VERIFICATION Plan 4. The VERIFICATION Methodology manual 4. Basic Testbench Functionality 5. Directed Testing 5. Methodology Basics 7. Constrained-Random Stimulus 8.
4 What Should You Randomize? 10. Functional Coverage 13. Testbench Components 15. Layered Testbench 16. Building a Layered Testbench 22. Simulation Environment Phases 23. Maximum Code Reuse 24. Testbench Performance 24. Conclusion 25. 2. DATA TYPES 27. Introduction 27. Built-in Data Types 27. viii SYSTEMVERILOG for VERIFICATION Fixed-Size Arrays 29. Dynamic Arrays 34. Queues 36. Associative Arrays 37. Linked Lists 39. Array Methods 40. Choosing a Storage Type 42. Creating New Types with typedef 45. Creating User-Defined Structures 46. Enumerated Types 47.
5 Constants 51. Strings 51. Expression Width 52. Net Types 53. Conclusion 53. 3. PROCEDURAL STATEMENTS AND ROUTINES 55. Introduction 55. Procedural Statements 55. Tasks, Functions, and Void Functions 56. Task and Function Overview 57. Routine Arguments 57. Returning from a Routine 62. Local Data Storage 62. Time Values 64. Conclusion 65. 4. BASIC OOP 67. Introduction 67. Think of Nouns, not Verbs 67. Your First Class 68. Where to Define a Class 69. OOP Terminology 69. Creating New Objects 70. Object Deallocation 74. Using Objects 76. Static Variables vs.
6 Global Variables 76. Class Routines 78. Defining Routines Outside of the Class 79. Scoping Rules 81. Using One Class Inside Another 85. Understanding Dynamic Objects 87. Copying Objects 91. Public vs. Private 95. Contents ix Straying Off Course 96. Building a Testbench 96. Conclusion 97. 5. CONNECTING THE TESTBENCH AND DESIGN 99. Introduction 99. Separating the Testbench and Design 99. The Interface Construct 102. Stimulus Timing 108. Interface Driving and Sampling 114. Connecting It All Together 121. Top-Level Scope 121. Program Module Interactions 123.
7 SYSTEMVERILOG Assertions 124. The Four-Port ATM Router 126. Conclusion 134. 6. RANDOMIZATION 135. Introduction 135. What to Randomize 136. Randomization in SYSTEMVERILOG 138. Constraint Details 141. Solution Probabilities 149. Controlling Multiple Constraint Blocks 154. Valid Constraints 154. In-line Constraints 155. The pre_randomize and post_randomize Functions 156. Constraints Tips and Techniques 158. Common Randomization Problems 164. Iterative and Array Constraints 165. Atomic Stimulus Generation vs. Scenario Generation 172. Random Control 175.
8 Random Generators 177. Random Device Configuration 180. Conclusion 182. 7. THREADS AND INTERPROCESS COMMUNICATION 183. Introduction 183. Working with Threads 184. Interprocess Communication 194. Events 195. Semaphores 199. Mailboxes 201. Building a Testbench with Threads and IPC 210. x SYSTEMVERILOG for VERIFICATION Conclusion 214. 8. ADVANCED OOP AND GUIDELINES 215. Introduction 215. Introduction to Inheritance 216. Factory Patterns 221. Type Casting and Virtual Methods 225. Composition, Inheritance, and Alternatives 228. Copying an Object 233.
9 Callbacks 236. Conclusion 240. 9. FUNCTIONAL COVERAGE 241. Introduction 241. Coverage Types 243. Functional Coverage Strategies 246. Simple Functional Coverage Example 248. Anatomy of a Cover Group 251. Triggering a Cover Group 253. Data Sampling 256. Cross Coverage 265. Coverage Options 272. Parameterized Cover Groups 274. Analyzing Coverage Data 275. Measuring Coverage Statistics During Simulation 276. Conclusion 277. 10. ADVANCED INTERFACES 279. Introduction 279. Virtual Interfaces with the ATM Router 279. Connecting to Multiple Design Configurations 284.
10 Procedural Code in an Interface 290. Conclusion 294. References 295. Index 297. xi List of Examples Example 1-1 Driving the APB pins 17. Example 1-2 A task to drive the APB pins 18. Example 1-3 Low-level Verilog test 18. Example 1-4 Basic transactor code 22. Example 2-1 Using the logic type 28. Example 2-2 Signed data types 28. Example 2-3 Checking for four-state values 29. Example 2-4 Declaring fixed-size arrays 29. Example 2-5 Declaring and using multidimensional arrays 29. Example 2-6 Unpacked array declarations 30. Example 2-7 Initializing an array 30.