Prelim e Lrm
-
Upload
luis-eduardo-rodriguez -
Category
Documents
-
view
225 -
download
0
Transcript of Prelim e Lrm
-
7/31/2019 Prelim e Lrm
1/453
e LanguageReference Manual
Preliminary
-
7/31/2019 Prelim e Lrm
2/453
Legal Notice
Copyright 1998-2002 Verisity Design, Inc. All rights reserved. The contents of this
document constitute valuable proprietary and confidential property of Verisity Design, Inc.
Trademarks
Verisity is a trademark of Verisity Ltd or its subsidiaries (Verisity), registered in the
United States and other jurisdictions. The Verisity logo, eVC, Invisible Specman, Lintrpt,
Pure IP, Specman, Specman Elite, Specview, SureCov, SureLint, SureSight, and
Verification Advisor are trademarks of Verisity Design, Inc. All other trademarks are the
exclusive property of their respective owners.
Confidentiality Notice
No part of this information product may be reproduced, transmitted, or translated in any
form or by any means, electronic, mechanical, manual, optical, or otherwise without prior
written permission from Verisity Design, Inc.
Information in this product is subject to change without notice and does not represent a
commitment on the part of Verisity. The information contained herein is the proprietary
and confidential information of Verisity or its licensors, and is supplied subject to, and may
be used only by Verisitys customers in accordance with, a written agreement between
Verisity and its customers. Except as may be explicitly set forth in such agreement,
Verisity does not make, and expressly disclaims, any representations or warranties as to the
completeness, accuracy, or usefulness of the information contained in this document.
Verisity does not warrant that use of such information will not infringe any third party
rights, nor does Verisity assume any liability for damages or costs of any kind that may
result from use of such information.
Restricted Rights Legend
Use, duplication, or disclosure by the Government is subject to restrictions as set forth in
subparagraphs (c)(1)(ii) of the Rights in Technical Data and Computer Software clause at
DFARS 252.227-7013.
Destination Control Statement
All technical data contained in this product is subject to the export control laws of the
United States of America. Disclosure to nationals of other countries contrary to United
States law is prohibited. It is the readers responsibility to determine the applicable
regulations and to comply with them.
-
7/31/2019 Prelim e Lrm
3/453
e Language Reference Manual Preliminary i
Table of Contents
1 About This Book . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-1
1.1 Conventions in This Book . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-2
1.2 Syntax Notation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .1-3
2 e Basics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-1
2.1 Lexical Conventions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .2-2
2.1.1 File Structure . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .2-2
2.1.2 Code Segments . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-2
2.1.3 Comments and White Space . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-3
2.1.4 Literals and Constants . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-4
2.1.4.1 Unsized Numbers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .2-4
2.1.4.2 Sized Numbers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .2-5
2.1.4.3 Predefined Constants . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-6
2.1.4.4 Literal String . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-6
2.1.4.5 Literal Character . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .2-7
2.1.5 Names and Keywords . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .2-8
2.1.5.1 Legal e Names . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-8
2.1.5.2 e Keywords . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-8
2.2 Syntactic Elements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .2-10
2.2.1 Statements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .2-10
2.2.2 Struct Members . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-122.2.3 Actions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .2-13
2.2.3.1 Creating or Modifying Variables . . . . . . . . . . . . . . . . . . 2-14
2.2.3.2 Executing Actions Conditionally . . . . . . . . . . . . . . . . . . 2-15
2.2.3.3 Executing Actions Iteratively . . . . . . . . . . . . . . . . . . . . . 2-15
2.2.3.4 Controlling Program Flow . . . . . . . . . . . . . . . . . . . . . . .2-16
-
7/31/2019 Prelim e Lrm
4/453
Table of Contents
ii Preliminary e Language Reference Manual
2.2.3.5 Invoking Methods and Routines . . . . . . . . . . . . . . . . . . .2-16
2.2.3.6 Performing Time-Consuming Actions . . . . . . . . . . . . . . 2-17
2.2.3.7 Detecting and Handling Errors . . . . . . . . . . . . . . . . . . . .2-18
2.2.4 Expressions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-18
2.3 Struct Hierarchy and Name Resolution . . . . . . . . . . . . . . . . . . . . . . . . . .2-192.3.1 Struct Hierarchy . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-19
2.3.2 Referencing e Entities . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .2-20
2.3.2.1 Structs and Fields . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .2-20
2.3.2.2 Method and Routine Names . . . . . . . . . . . . . . . . . . . . . . 2-22
2.3.2.3 Enumerated Type Values . . . . . . . . . . . . . . . . . . . . . . . .2-23
2.3.3 Implicit Variables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .2-24
2.3.3.1 it . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .2-24
2.3.3.2 me . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .2-25
2.3.3.3 result . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .2-26
2.3.3.4 index . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .2-26
2.3.4 Name Resolution Rules . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-26
2.3.4.1 Names that Include a Path . . . . . . . . . . . . . . . . . . . . . . . . 2-27
2.3.4.2 Names that Do Not Include a Path . . . . . . . . . . . . . . . . . 2-28
2.4 Operator Precedence . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .2-29
2.5 Bitwise Operators . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .2-31
2.5.1 ~ . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-31
2.5.2 & | . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .2-33
2.5.3 >> . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .2-39
2.6.5 now . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-40
2.7 Arithmetic Operators . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .2-42
2.7.1 Unary + - . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-42
2.7.2 + - * / % . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-43
2.8 Comparison Operators . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .2-452.8.1 < >= . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .2-45
2.8.2 == != . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .2-46
2.8.3 === !== . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .2-48
2.8.4 ~ !~ . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-51
-
7/31/2019 Prelim e Lrm
5/453
Table of Contents
e Language Reference Manual Preliminary iii
2.8.5 in . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-52
2.9 String Matching . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .2-54
2.10 Extraction and Concatenation Operators . . . . . . . . . . . . . . . . . . . . . . . . .2-56
2.10.1 [ ] . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .2-56
2.10.2 [ : ] . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .2-58
2.10.3 [ .. ] . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .2-61
2.10.4 { ; } . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .2-63
2.10.5 %{} . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .2-64
2.11 Scalar Modifiers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-66
2.11.1 [ range,...] . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .2-66
2.11.2 (bits | bytes : width-exp) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-67
2.12 Parentheses . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-68
2.12.1 list.list-method() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-69
2.13 Special-Purpose Operators . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .2-71
2.13.1 is [not] a . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-71
2.13.2 new . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .2-73
2.13.3 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .2-75
2.13.4 ' . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .2-77
2.13.5 ? : . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .2-78
3 Data Types . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-1
3.1 Overview of e Data Types . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-1
3.1.1 e Data Types . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .3-2
3.1.1.1 Scalar Types . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-2
3.1.1.2 Scalar Subtypes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .3-3
3.1.1.3 Enumerated Scalar Types . . . . . . . . . . . . . . . . . . . . . . . . . 3-5
3.1.1.4 Struct Types . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-6
3.1.1.5 Struct Subtypes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .3-7
3.1.1.6 List Types . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-11
3.1.1.7 The String Type . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .3-13
3.1.2 Untyped Expressions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-13
3.1.3 Assignment Rules . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .3-16
3.1.3.1 What is an Assignment?. . . . . . . . . . . . . . . . . . . . . . . . . .3-16
3.1.3.2 Assignment to Different but Compatible Types . . . . . . .3-18
3.1.4 Precision Rules for Operations . . . . . . . . . . . . . . . . . . . . . . . . . .3-21
3.1.4.1 Expected Type . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .3-21
3.1.4.2 Operand Type. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .3-21
-
7/31/2019 Prelim e Lrm
6/453
Table of Contents
iv Preliminary e Language Reference Manual
3.1.5 Automatic Type Casting . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-22
3.2 Defining and Extending Scalar Types . . . . . . . . . . . . . . . . . . . . . . . . . . .3-24
3.2.1 type enumerated scalar . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .3-24
3.2.2 type scalar subtype . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-26
3.2.3 type sized scalar . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-28
3.2.4 extend type . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-30
4 Structs, Fields and Subtypes . . . . . . . . . . . . . . . . . . . . . 4-1
4.1 Structs Overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .4-2
4.2 Defining Structs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .4-3
4.2.1 struct . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-3
4.3 Extending Structs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .4-7
4.3.1 extend type . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-74.4 Extending Subtypes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .4-10
4.5 Defining Fields . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .4-12
4.5.1 field . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-12
4.6 Defining List Fields . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .4-15
4.6.1 list of . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-15
4.7 Creating Subtypes with When . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-17
4.7.1 when . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-17
4.8 Defining Methods in Subtypes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .4-20
4.9 Defining Attributes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .4-21
4.9.1 attribute field . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-22
5 Units . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-1
5.1 Units Overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .5-1
5.1.1 HDL Paths and Units . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .5-3
5.1.2 Limitations on Units . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-4
5.2 Defining Units and Fields of Type Unit . . . . . . . . . . . . . . . . . . . . . . . . . .5-4
5.2.1 unit . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .5-5
5.2.2 field: unit-type is instance . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .5-95.2.3 field: unit-type . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .5-11
5.2.4 field: list of unit instances . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .5-13
5.2.5 field: list of unit-type . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-15
-
7/31/2019 Prelim e Lrm
7/453
Table of Contents
e Language Reference Manual Preliminary v
6 Methods . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-1
6.1 Defining and Extending Methods . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .6-2
6.1.1 method is [inline] . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .6-2
6.1.2 method @event is . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .6-56.1.3 method [@event] is also | first | only | inline only . . . . . . . . . . . .6-9
6.1.4 method [@event] is undefined | empty . . . . . . . . . . . . 6-15
6.2 Invoking Methods . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-18
6.2.1 tcm() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .6-19
6.2.2 start tcm() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .6-21
6.2.3 method() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .6-23
6.2.4 compute method() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .6-25
6.2.5 return . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .6-27
6.3 Parameter Passing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-30
6.3.1 Scalar Parameter Passing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .6-31
6.3.2 Compound Parameter Passing . . . . . . . . . . . . . . . . . . . 6-31
6.3.3 Notes on Passing by Reference . . . . . . . . . . . . . . . . . . .6-32
7 Creating and Modifying e Variables . . . . . . . . . . . . . . . . 7-1
7.1 About e Variables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .7-1
7.2 var . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-2
7.3 = . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-4
7.4 op= . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-6
8 Control Flow Actions . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8-1
8.1 Conditional Actions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .8-1
8.1.1 if then else . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8-2
8.1.2 case labeled-case-item . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8-3
8.1.3 case bool-case-item . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8-5
8.2 Iterative Actions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .8-7
8.2.1 while . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .8-8
8.2.2 repeat until . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .8-108.2.3 for each in . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .8-11
8.2.4 for from to . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .8-14
8.2.5 for . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .8-15
8.3 File Iteration Actions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .8-17
-
7/31/2019 Prelim e Lrm
8/453
Table of Contents
vi Preliminary e Language Reference Manual
8.3.1 for each line in file . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .8-17
8.3.2 for each file matching . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .8-18
8.4 Actions for Controlling the Program Flow . . . . . . . . . . . . . . . . . . . . . . .8-20
8.4.1 break . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .8-20
8.4.2 continue . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .8-21
9 Checks and Error Handling . . . . . . . . . . . . . . . . . . . . . . . 9-1
9.1 Handling DUT Errors . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9-1
9.1.1 check that . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .9-2
9.1.2 dut_error() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9-3
9.1.3 dut_error_struct . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .9-4
9.1.4 set_check() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .9-8
9.2 Handling User Errors . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .9-10
9.2.1 warning() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .9-10
9.2.2 error() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9-11
9.2.3 fatal() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9-13
9.2.4 try . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .9-14
9.3 Handling Programming Errors . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .9-16
9.3.1 assert . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9-16
10 Constraints . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10-1
10.1 Basic Concepts of Constraints . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10-1
10.1.1 Order of Evaluation of Soft Constraints . . . . . . . . . . . . . . . . . . . 10-2
10.1.2 Constraining Lists . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .10-2
10.1.2.1 List Size . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .10-3
10.1.2.2 List Item . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10-3
10.1.2.3 Multiple List Items. . . . . . . . . . . . . . . . . . . . . . . . . . . . . .10-3
10.1.2.4 List of Structs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10-3
10.1.2.5 Multiple Lists . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10-3
10.1.3 Constraining Bit Slices . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .10-4
10.1.3.1 Bit Slice Constraints and Signed Entities . . . . . . . . . . . .10-5
10.1.3.2 Bit Slice Constraints and Soft Constraints. . . . . . . . . . . .10-610.2 Defining Constraints . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .10-6
10.2.1 keep . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .10-7
10.2.2 keep struct-list.is_all_iterations() . . . . . . . . . . . . . . . . . . . . . . .10-9
10.2.3 keep for each . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .10-11
-
7/31/2019 Prelim e Lrm
9/453
Table of Contents
e Language Reference Manual Preliminary vii
10.2.4 keep soft . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .10-13
10.2.5 keep soft select . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10-15
10.2.6 keep item.reset_soft() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .10-18
10.2.7 constraint-bool-exp . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10-20
10.2.8 constraint-item . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10-23
11 Events . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11-1
11.1 Events Overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11-1
11.1.1 Causes of Events . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11-3
11.1.2 Scope of Events . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11-3
11.2 Events and Expects . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .11-4
11.2.1 event . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11-4
11.2.2 expect . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .11-611.2.3 assume . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .11-8
11.3 Sampling Events Overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .11-9
11.4 Predefined Events Overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .11-11
11.4.1 General Predefined Events . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11-11
12 Temporal Expressions . . . . . . . . . . . . . . . . . . . . . . . . . . 12-1
12.1 Temporal Expressions Overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .12-1
12.1.1 Temporal Sequences . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12-3
12.1.2 Success of a Temporal Expression . . . . . . . . . . . . . . . . . . . . . . .12-312.1.2.1 Notation in Temporals Graphics for Success or Failure .12-4
12.1.3 How Context Determines Evaluation Points . . . . . . . . . . . . . . .12-5
12.1.4 Using Verilog Objects in Temporal Expressions . . . . . . . . . . . .12-6
12.1.5 Selected Applications of Temporal Expressions . . . . . . . . . . . .12-7
12.1.5.1 Handling Overlapping Transactions . . . . . . . . . . . . . . . . 12-7
12.1.5.2 Restricting TE Matches . . . . . . . . . . . . . . . . . . . . . . . . . . 12-7
12.1.6 Forms for Common Temporal Expressions . . . . . . . . . . . . . . . .12-8
12.1.6.1 Examples of Sequence Expressions . . . . . . . . . . . . . . . . 12-8
12.1.6.2 Examples of Behavioral Rule Checks . . . . . . . . . . . . . . . 12-912.2 Temporal Operators and Constructs . . . . . . . . . . . . . . . . . . . . . . . . . . .12-11
12.2.1 Precedence of Temporal Operators . . . . . . . . . . . . . . . . . . . . .12-11
12.2.2 fail . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .12-12
12.2.3 and . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12-14
-
7/31/2019 Prelim e Lrm
10/453
Table of Contents
viii Preliminary e Language Reference Manual
12.2.4 or . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .12-15
12.2.5 { exp ; exp } . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12-17
12.2.6 eventually . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .12-19
12.2.7 [num] . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .12-20
12.2.8 [ exp..exp ] . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .12-22
12.2.9 ~[ exp..exp ] . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12-24
12.2.10 => . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12-27
12.2.11 @unary event operator . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .12-28
12.2.12 @ binary sampling operator . . . . . . . . . . . . . . . . . . . . . . . . . . .12-29
12.2.13 cycle . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .12-31
12.2.14 true(exp) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .12-32
12.2.15 change(exp), fall(exp), rise(exp) . . . . . . . . . . . . . . . . . . . . . . .12-33
12.2.16 exec . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12-36
12.3 Special Support for Model Checking . . . . . . . . . . . . . . . . . . . . . . . . . .12-37
12.3.1 Existential Path Quantifier . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12-37
12.3.2 exists(+) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .12-37
13 Time-Consuming Actions . . . . . . . . . . . . . . . . . . . . . . . 13-1
13.1 Synchronization Actions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .13-1
13.1.1 sync . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .13-2
13.1.2 wait . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .13-4
13.2 Concurrency Actions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .13-6
13.2.1 all of . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13-7
13.2.2 first of . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .13-8
14 Coverage Constructs . . . . . . . . . . . . . . . . . . . . . . . . . . . 14-1
14.1 Defining Coverage Groups . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .14-1
14.1.1 cover . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14-1
14.2 Defining Basic Coverage Items . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .14-7
14.2.1 item . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14-7
14.3 Defining Cross Coverage Items . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .14-18
14.3.1 cross . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14-18
14.4 Defining Transition Coverage Items . . . . . . . . . . . . . . . . . . . . . . . . . . .14-23
14.4.1 transition . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14-23
14.5 Extending Coverage Groups . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .14-26
14.5.1 cover is also . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14-26
-
7/31/2019 Prelim e Lrm
11/453
Table of Contents
e Language Reference Manual Preliminary ix
15 Simulation-Related Constructs . . . . . . . . . . . . . . . . . . . 15-1
15.1 Verilog Statements or Unit Members . . . . . . . . . . . . . . . . . . . . . . . . . . .15-1
15.1.1 verilog code . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15-2
15.1.2 verilog function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15-315.1.3 verilog import . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .15-5
15.1.4 verilog task . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .15-7
15.1.5 verilog time . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .15-9
15.1.6 verilog variable reg | wire . . . . . . . . . . . . . . . . . . . . . . . . . . . . .15-10
15.1.7 verilog variable memory . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .15-12
15.2 VHDL Statements and Unit Members . . . . . . . . . . . . . . . . . . . . . . . . .15-13
15.2.1 vhdl code . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .15-13
15.2.2 vhdl driver . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .15-15
15.2.3 vhdl function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .15-1715.2.4 vhdl procedure . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15-20
15.2.5 vhdl time . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .15-23
15.3 Simulation-Related Actions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .15-24
15.3.1 force . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .15-24
15.3.2 release . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .15-26
15.4 Simulation-Related Expressions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .15-27
15.4.1 'HDL-pathname' . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .15-28
16 Packing and Unpacking . . . . . . . . . . . . . . . . . . . . . . . 16-1
16.1 Basic Packing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .16-2
16.1.1 A Simple Example of Packing . . . . . . . . . . . . . . . . . . . . . . . . . .16-3
16.1.2 A Simple Example of Unpacking . . . . . . . . . . . . . . . . . . . . . . . .16-5
16.1.3 Packing and Unpacking Scalar Expressions . . . . . . . . . . . . . . . .16-6
16.1.4 Packing and Unpacking Strings . . . . . . . . . . . . . . . . . . . . . . . . . 16-8
16.1.5 Packing and Unpacking Structs . . . . . . . . . . . . . . . . . . . . . . . . . 16-9
16.1.6 Packing and Unpacking Lists . . . . . . . . . . . . . . . . . . . . . . . . . .16-10
16.2 Advanced Packing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .16-12
16.2.1 Using the Predefined pack_options Instances . . . . . . . . . . . . . 16-13
16.2.1.1 packing.low . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .16-13
16.2.1.2 packing.low_big_endian . . . . . . . . . . . . . . . . . . . . . . . .16-14
16.2.1.3 packing.high . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .16-15
16.2.1.4 packing.high_big_endian . . . . . . . . . . . . . . . . . . . . . . .16-16
-
7/31/2019 Prelim e Lrm
12/453
Table of Contents
x Preliminary e Language Reference Manual
16.2.1.5 packing.network . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .16-17
16.2.1.6 packing.global_default . . . . . . . . . . . . . . . . . . . . . . . . . 16-18
16.2.2 Customizing Pack Options . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16-19
16.2.2.1 reverse_fields . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16-19
16.2.2.2 reverse_list_items . . . . . . . . . . . . . . . . . . . . . . . . . . .16-2016.2.2.3 scalar_reorder . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .16-21
16.2.2.4 final_reorder . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .16-22
16.2.3 Customizing Packing for a Particular Struct . . . . . . . . . . . . . .16-23
16.2.4 Bit Slice Operator and Packing . . . . . . . . . . . . . . . . . . . . . . . .16-23
16.2.5 Implicit Packing and Unpacking . . . . . . . . . . . . . . . . . . . .16-24
17 Preprocessor Directives . . . . . . . . . . . . . . . . . . . . . . . . 17-1
17.1 define . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17-2
17.2 #ifdef, #ifndef . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17-4
18 Importing e Files . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18-1
18.1 import . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18-1
Index
-
7/31/2019 Prelim e Lrm
13/453
e Language Reference Manual Preliminary 1-1
1 About This BookThe e language is an object-oriented programming language. Although e can be used to
create any general-purpose software program, it has been designed to facilitate the
verification of electronic designs. The verification-specific constructs that distinguish efrom other object-oriented languages such as C++ include:
Constructs to define legal values for data items (constraints)
Constructs to describe sequences over time (temporal constructs)
Constructs to support concurrency (multi-threaded execution)
Constructs to support connectivity (bit-level access)
The e language also is designed to reduce the effort required to write tests and to make the
high-level intent of the test readily apparent. In contrast to other object-oriented
programming languages, es unique extensibility lets you modify multiple data objects in a
single, separate test file that is layered on top of the base verification environment. This
extensibility feature allows you to address systemic, test-specific concerns that are not
localized to a single data objects boundaries in a way that does not sacrifice modularity or
readability.
The e Language Reference Manual provides detailed information on the e programminglanguage.
For information on es built-in (predefined) methods and routines, refer to e Libraries.
-
7/31/2019 Prelim e Lrm
14/453
About This Book Conventions in This Book
1-2 Preliminary e Language Reference Manual
1.1 Conventions in This Book
This manual uses visual cues to help you locate and interpret information easily. These
cues are explained in Table 1-1.
Table 1-1 Document Conventions
Visual Cue Represents
courier The Courier font indicates e or HDL code. For example, the
following line indicates e code:
keep opcode in [ADD, ADDI];
bold The bold font is used in descriptive text to indicate keywords. For
example, the following sentence contains the keyword keep:
Use the keep construct to define legal values for data items.
The bold font is used in syntax descriptions to indicate text that must
be typed exactly as it appears. For example, in the following
sentence thekeywords keepandreset_soft, as well as theperiod
and the parentheses must be typed as they appear:
keep item.reset_soft()
italic The italic font represents user-defined variables that you must
provide. For example, the following line instructs you to typekeep as it appears, and then specify a Boolean expression:
keep constraint-bool-exp
[ ] square
brackets
Square brackets indicate optional parameters. For example, in the
following construct the keywords list of are optional:
var name: [list of] type
[ ] bold brackets Bold square brackets are required. For example, in the following
construct you must type the bold square brackets as they appear:
extend enum-type-name: [name,]
-
7/31/2019 Prelim e Lrm
15/453
Syntax Notation About This Book
e Language Reference Manual Preliminary 1-3
1.2 Syntax Notation
Each construct section starts with the syntax for the construct. The syntax shows the
construct, any arguments it accepts with their types, and the constructs return type if it has
one.
When using the construct, terms in bold in the syntax are to be entered exactly as shown.
Terms in italics are to be replaced by terms of your own. The argument types and the
construct return type are for information only and are not entered.
For example, the syntax notation for the predefined pseudo-method named list.first() onpage 3-33 in e Libraries is
list.first(exp: bool): list-type
This is what the notation means:
The bold .first and the parentheses must be entered exactly.
The parts in italics, list and exp, must be replaced by a list name and an expression.
: bool indicates that the expression must be a Boolean expression.
: list-type means that the pseudo-method returns an item of the list element type.
An example of a call to the list.first() pseudo-method is shown below, where numbers is
a list of integer items and my_number is an integer. The pseudo-method returns the first
integer in the list greater than 5:
my_number = numbers.first(it > 5)
construct, An item, followed by a separator (usually a comma or a semicolon)
and an ellipsis is an abbreviation for a list of elements of thespecified type. For example, the following line means you can type
a list of zero or more names separated by commas.
extend enum-type-name: [name,]
| The | character indicates alternative syntax or parameters. For
example, the following line indicates that either the bits or bytes
keyword should be used:
type scalar-type (bits | bytes: num)
Table 1-1 Document Conventions (continued)
Visual Cue Represents
http://../e_lib/list_pseudomethods.pdfhttp://../e_lib/list_pseudomethods.pdfhttp://../e_lib/list_pseudomethods.pdfhttp://../e_lib/list_pseudomethods.pdfhttp://../e_lib/list_pseudomethods.pdf -
7/31/2019 Prelim e Lrm
16/453
About This Book Syntax Notation
1-4 Preliminary e Language Reference Manual
-
7/31/2019 Prelim e Lrm
17/453
e Language Reference Manual Preliminary 2-1
2 e BasicsThis chapter describes the structure of an e program, starting with the organization of
e code into one or more files and the four categories ofe constructs, and ending with a
description of the struct hierarchy. This chapter also describes the e operators. It contains
the following sections:
Lexical Conventions on page 2-2
Syntactic Elements on page 2-10
Struct Hierarchy and Name Resolution on page 2-19
Operator Precedence on page 2-29
Bitwise Operators on page 2-31
Boolean Operators on page 2-36
Arithmetic Operators on page 2-42
Comparison Operators on page 2-45
Extraction and Concatenation Operators on page 2-56
Scalar Modifiers on page 2-66
Parentheses on page 2-68
Special-Purpose Operators on page 2-71
-
7/31/2019 Prelim e Lrm
18/453
e Basics Lexical Conventions
2-2 Preliminary e Language Reference Manual
See Also
Chapter 12, Temporal Expressions
Chapter 3, Data Types
Chapter 4, Predefined Routines in e Libraries
2.1 Lexical Conventions
The following sections describe the lexical conventions ofe:
File Structure on page 2-2
Code Segments on page 2-2
Comments and White Space on page 2-3
Literals and Constants on page 2-4
Names and Keywords on page 2-8
2.1.1 File Structure
e code can be organized in multiple files. File names must be legal e names. The default
file extension is .e. e code files are sometimes referred to as modules. Each module
contains at least one code segment and can also contain comments.
See Also
Names and Keywords on page 2-8
Code Segments on page 2-2
Comments and White Space on page 2-3
2.1.2 Code Segments
A code segment is enclosed with a begin-code marker . Both
the begin-code and the end-code markers must be placed at the beginning of a line (left
most), with no other text on that same line (no code and no comments). For example, the
following three lines of code form a code segment:
-
7/31/2019 Prelim e Lrm
19/453
Comments and White Space e Basics
e Language Reference Manual Preliminary 2-3
'>
Several code segments can appear in one file. Each code segment consists of one or more
statements.
See Also
Comments and White Space on page 2-3
Statements on page 2-10
2.1.3 Comments and White Space
e files begin as a comment which ends when the first begin-code marker and the begin-code
-
7/31/2019 Prelim e Lrm
20/453
e Basics Literals and Constants
2-4 Preliminary e Language Reference Manual
2.1.4 Literals and Constants
Literals are numeric, character and string values specified literally in e. Operators can be
applied to literals to create compound expressions. The following categories of literals and
constants are supported in e:
Unsized Numbers on page 2-4
Sized Numbers on page 2-5
Predefined Constants on page 2-6
Literal String on page 2-6
Literal Character on page 2-7
2.1.4.1 Unsized NumbersUnsized numbers are always positive and zero-extended unless preceded by a hyphen.
Decimal constants are treated as signed integers and have a default size of 32 bits. Binary,
hex, and octal constants are treated as unsigned integers, unless preceded by a hyphen to
indicate a negative number, and have a default size of 32 bits. If the number cannot be
represented in 32 bits then it is represented as an unbounded integer. See Unbounded
Integers on page 3-4 for more information.
The notations shown in Table 2-1 can be used to represent unsized numbers.
Table 2-1 Representing Unsized Numbers in Expressions
Notation Legal Characters Examples
Decimal integer Any combination of 0-9 possibly preceded
by a hyphen - for negative numbers. An
underscore (_) can be added anywhere in
the number for readability.
12, 55_32, -764
Binary integer Any combination of 0-1 preceded by 0b.
An underscore (_) can be added anywhere
in the number for readability.
0b100111,
0b1100_0101
Hexadecimal integer Any combination of 0-9 and a-f preceded
by 0x. An underscore (_) can be added
anywhere in the number for readability.
0xff,
0x99_aa_bb_cc
-
7/31/2019 Prelim e Lrm
21/453
Literals and Constants e Basics
e Language Reference Manual Preliminary 2-5
See Also
Literals and Constants on page 2-4
2.1.4.2 Sized Numbers
A sized number is a notation that defines a literal with a specific size in bits. The syntax is
as follows:
width-number' (b|o|d|h|x) value-number
The width number is a decimal integer specifying the width of the literal in bits. The value
number is the value of the literal and can be specified in one of four radixes, as shown in
Table 2-2.
Note If the value number is more than the specified size in bits, its mostsignificant bits are ignored. If the value number is less that the specified size, it is
padded by zeros.
Octal integer Any combination of 0-7 preceded by 0o.
An underscore (_) can be added anywherein the number for readability.
0o66_123
K (kilo: multiply by
1024)
A decimal integer followed by a K or k.
For example, 32K = 32768.
32K, 32k, 128k
M (mega:multiply by
1024*1024)
A decimal integer followed by an M or m.
For example, 2m = 2097152.
1m, 4m, 4M
Table 2-2 Radix Specification Characters
Radix Represented By Example
Binary A leading 'b or 'B 8'b11001010
Octal A leading 'o or 'O 6'o45
Decimal A leading 'd or 'D 16'd63453
Hexadecimal A leading 'h or 'H or 'x or 'X 32'h12ffab04
Table 2-1 Representing Unsized Numbers in Expressions (continued)
Notation Legal Characters Examples
-
7/31/2019 Prelim e Lrm
22/453
e Basics Literals and Constants
2-6 Preliminary e Language Reference Manual
See Also
Literals and Constants on page 2-4
2.1.4.3 Predefined Constants
A set of constants is predefined in e, as shown in Table 2-3.
See Also
Literals and Constants on page 2-4
2.1.4.4 Literal String
A literal string is a sequence of zero or more ASCII characters enclosed by double quotes
(" ").
The special escape sequences shown in Table 2-4 are allowed.
Table 2-3 Predefined Constants
Constant Description
TRUE For Boolean variables and expressions.
FALSE For Boolean variables and expressions.
NULL For structs, specifies a NULL pointer. For character strings, specifiesan empty string.
UNDEF UNDEF indicates NONE where an index is expected.
MAX_INT Represents the largest 32-bit int (231 -1)
MIN_INT Represents the smallest 32-bit int (-231).
MAX_UINT Represents the largest 32-bit uint (232-1).
Table 2-4 Escape Sequences in Strings
Escape Sequence Meaning
\n New-line
-
7/31/2019 Prelim e Lrm
23/453
Literals and Constants e Basics
e Language Reference Manual Preliminary 2-7
Example
This example shows escape sequences used in strings.
extend sys {
m() is {
var header: string =
"Name\tSize in Bytes\n----\t-------------\n";
var p: packet = new;
var pn: string = p.type().name;
var ps: uint = p.type().size_in_bytes;
outf("%s%s\t%d", header, pn, ps);
};
};
See Also
Literals and Constants on page 2-4
2.1.4.5 Literal Character
A literal character is a single ASCII character, enclosed in quotation marks and preceded
by 0c. This expression evaluates to the integer value that represents this character. For
example, the literal character shown below is the single ASCII character a and evaluates
to 0x0061.
var u: uint(bytes:2) = 0c"a"
Note Literal characters can only be assigned to integers or unsigned integerswithout explicit casting.
\t Tab
\f Form-feed
\" Quote
\\ Backslash
\r Carriage-return
Table 2-4 Escape Sequences in Strings (continued)
Escape Sequence Meaning
-
7/31/2019 Prelim e Lrm
24/453
e Basics Names and Keywords
2-8 Preliminary e Language Reference Manual
See Also
Literals and Constants on page 2-4
2.1.5 Names and KeywordsThe following sections describe the legal syntax for names and macros:
Legal e Names on page 2-8
e Keywords on page 2-8
2.1.5.1 Legal e Names
User-defined names in e code consist of a case-sensitive combination of any length of the
characters A-Z, a-z, 0-9, and underscore. They must begin with a letter. Names beginning
with an underscore have a special meaning in e and are not recommended for general use.
Names beginning with a number are not allowed.
The syntax of an e module name (a file name) is the same as the syntax of UNIX file
names, with the following exceptions:
@ and ~ are not allowed as the first character of a file name.
[, ], {, } are not allowed in file names.
Only one . is allowed in a file name.
Note Many ASCII characters are not handled correctly by some UNIXcommands when used in file names. These characters include control characters,
spaces, and characters reserved for command line parsing, such as -, |, and
-
7/31/2019 Prelim e Lrm
25/453
Names and Keywords e Basics
e Language Reference Manual Preliminary 2-9
cross cvl call cvl callback cvl method cycle
default define delay detach do
down to dut_error each edges else
emit event exec expect extend
fail fall file first of for
force from gen global hdl pathname
if #ifdef #ifndef in index
int is a is also is c routine is empty
is first is inline is instance is not a is not empty
is only is undefined item keep keeping
key like line list of matching
me nand new nor not
not in now nxor on only
or others pass prev print
range ranges release repeat return
reverse rise routine select session
soft start state machine step struct
string sync sys that then
time to transition true try
type uint unit until using
var verilog code verilog function verilog import verilog simulator
verilog task verilog time verilog timescale verilog trace verilog variable
vhdl code vhdl driver vhdl function vhdl procedure vhdl driver
vhdl simulator vhdl time when while with
within
-
7/31/2019 Prelim e Lrm
26/453
e Basics Syntactic Elements
2-10 Preliminary e Language Reference Manual
2.2 Syntactic Elements
Every e construct belongs to a construct category that determines how the construct can be
used. There are four categories ofe constructs:
The syntax hierarchy roughly corresponds to the level of indentation shown below:
statements
struct members
actions
expressions
See Also
Statements on page 2-10
Struct Members on page 2-12
Actions on page 2-13
Expressions on page 2-18
2.2.1 StatementsStatements are the top-level syntactic constructs of the e language and perform the
functions related to extending the e language and interface with the simulator.
Statements Statements are top-level constructs and are valid within thebegin-code markers. See Statements on
page 2-10 for a list and brief description ofe statements.
Struct members Struct members are second-level constructs and are valid
only within a struct definition. See Struct Members on
page 2-12 for a list and brief description ofe struct members.
Actions Actions are third-level constructs and are valid only when
associated with a struct member, such as a method or an
event. See Actions on page 2-13 for a list and brief
description ofe actions.
Expressions Expressions are lower-level constructs that can be used only
within another e construct. See Expressions on page 2-18
for a list and brief description ofe expressions.
-
7/31/2019 Prelim e Lrm
27/453
Statements e Basics
e Language Reference Manual Preliminary 2-11
Statements are valid within the begin-code markers. They can extend
over several lines and are separated by semicolons. For example, the following code
segment has two statements:
In general, statements can appear in any order. However, within a given e module, import
statements must appear before any other statements. No statements other than
preprocessor directives or defines (#ifdef, #ifndef, define, define as, define as computed)
can precede import statements.
Here is the complete list ofe statements:
struct on page 4-3 Defines a new data structure.
type Defines an enumerated data type or scalar subtype.
See type enumerated scalar on page 3-24, type
scalar subtype on page 3-26, or type sized scalar on
page 3-28
extend Modifies a previously defined struct or type. See
extend type on page 4-7 or extend type on page 3-30
unit on page 5-5 Defines a data structure associated with an HDL
component or block.
#ifdef, #ifndefon page 17-4 Used together with define statements to place
conditions on the e parser.import on page 18-1 Reads in an e file.
verilog import on page 15-5 Reads in Verilog macro definitions from a file.
verilog code on page 15-2 Writes Verilog code to the stubs file, which is used to
interface e programs with a Verilog simulator.
verilog time on page 15-9 Specifies Verilog simulator time resolution.
verilog variable reg | wire on
page 15-10
Specifies a Verilog register or wire that you want to
drive from e.
verilog variable memory on
page 15-12
Specifies a Verilog memory that you want to access
from e.
verilog function on page 15-3 Specifies a Verilog function that you want to call
from e.
verilog task on page 15-7 Specifies a Verilog task that you want to call from e.
-
7/31/2019 Prelim e Lrm
28/453
e Basics Struct Members
2-12 Preliminary e Language Reference Manual
See Also
Struct Members on page 2-12
Actions on page 2-13
Expressions on page 2-18
2.2.2 Struct Members
Struct member declarations are second-level syntactic constructs of the e language that
associate the entities of various kinds with the enclosing struct.
Struct members can only appear inside a struct type definition statement (see struct on
page 4-3). They can extend over several lines and are separated by semicolons. For
example, the following struct packet has two struct members, len and data:
vhdl code on page 15-13 Writes VHDL code to the stubs file, which is used to
interface e programs with a VHDL simulator.
vhdl driver on page 15-15 Used to drive a VHDL signal continuously via the
resolution function.
vhdl function on page 15-17 Declares a VHDL function defined in a VHDLpackage.
vhdl procedure on page 15-20 Declares a VHDL procedure defined in a VHDL
package.
vhdl time on page 15-23 Specifies VHDL simulator time resolution.
-
7/31/2019 Prelim e Lrm
29/453
Actions e Basics
e Language Reference Manual Preliminary 2-13
A struct can contain multiple struct members of any type in any order. Here is a brief
description ofe struct members:
See Also
Defining Fields on page 4-12
Defining and Extending Methods on page 6-2
Creating Subtypes with When on page 4-17
Defining Constraints on page 10-6
Defining Coverage Groups on page 14-1
2.2.3 Actions
e actions are lower-level procedural constructs that can be used in combination to
manipulate the fields of a struct or exchange data with the DUT.
Actions can extend over several lines and are separated by semicolons. An action block is
a list of actions separated by semicolons and enclosed in curly brackets, { }.
Actions must be associated with a struct member, specifically a method or an event, or
issued interactively as commands at the command line. Here is an example of an action (aninvocation of a method, transmit()) associated with an event, xmit_ready. Another
action, out() is associated with the transmit() method.
-
7/31/2019 Prelim e Lrm
30/453
e Basics Actions
2-14 Preliminary e Language Reference Manual
on xmit_ready {transmit();};
transmit() is {
out("transmitting packet...");
};
};
'>
The following sections describe the e actions:
Creating or Modifying Variables on page 2-14
Executing Actions Conditionally on page 2-15
Executing Actions Iteratively on page 2-15
Controlling Program Flow on page 2-16
Invoking Methods and Routines on page 2-16
Performing Time-Consuming Actions on page 2-17
Detecting and Handling Errors on page 2-18
2.2.3.1 Creating or Modifying Variables
See Also
Executing Actions Conditionally on page 2-15
Executing Actions Iteratively on page 2-15
Controlling Program Flow on page 2-16
Invoking Methods and Routines on page 2-16
Performing Time-Consuming Actions on page 2-17
var on page 7-2 Defines a local variable.
= on page 7-4 Assigns or samples values of fields, local variables, or HDL
objects.
op= on page 7-6 Performs a complex assignment (such as add and assign, or
shift and assign) of a field, local variable, or HDL object.
force on page 15-24 Forces a Verilog net or wire to a specified value, over-riding
the value from driven from the DUT.
release on page 15-26 Releases the Verilog net or wire that was previously forced.
-
7/31/2019 Prelim e Lrm
31/453
Actions e Basics
e Language Reference Manual Preliminary 2-15
Detecting and Handling Errors on page 2-18
2.2.3.2 Executing Actions Conditionally
See Also
Creating or Modifying Variables on page 2-14
Executing Actions Iteratively on page 2-15
Controlling Program Flow on page 2-16
Invoking Methods and Routines on page 2-16
Performing Time-Consuming Actions on page 2-17
Detecting and Handling Errors on page 2-18
2.2.3.3 Executing Actions Iteratively
if then else on page 8-2 Executes an action block if a condition is met and a different
action block if it is not.
case labeled-case-item
on page 8-3
Executes one action block out of multiple action blocks
depending on the value of a single expression.
case bool-case-item on
page 8-5
Evaluates a list of Boolean expressions and executes the
action block associated with the first expression that is true.
while on page 8-8 Executes an action block repeatedly until a Boolean
expression becomes FALSE.
repeat until on
page 8-10
Executes an action block repeatedly until a Boolean
expression becomes TRUE.
for each in on
page 8-11
For each item in a list that is a specified type, executes an
action block.
for from to on
page 8-14
Executes an action block for a specified number of times.
for on page 8-15 Executes an action block for a specified number of times.
for each line in file on
page 8-17
Executes an action block for each line in a file.
for each file matching
on page 8-18
Executes an action block for each file in the search path.
-
7/31/2019 Prelim e Lrm
32/453
e Basics Actions
2-16 Preliminary e Language Reference Manual
See Also
Creating or Modifying Variables on page 2-14
Executing Actions Conditionally on page 2-15
Controlling Program Flow on page 2-16
Invoking Methods and Routines on page 2-16
Performing Time-Consuming Actions on page 2-17
Detecting and Handling Errors on page 2-18
2.2.3.4 Controlling Program Flow
See Also
Creating or Modifying Variables on page 2-14
Executing Actions Conditionally on page 2-15
Executing Actions Iteratively on page 2-15
Invoking Methods and Routines on page 2-16
Performing Time-Consuming Actions on page 2-17
Detecting and Handling Errors on page 2-18
2.2.3.5 Invoking Methods and Routines
break on page 8-20 Breaks the execution of the enclosing loop.
continue on page 8-21 Stops execution of the enclosing loop and continues with the
next iteration of the same loop.
method() on page 6-23 Calls a regular method.
tcm() on page 6-19 Calls a TCM.
start tcm() on
page 6-21
Launches a TCM as a new thread (a parallel process).
-
7/31/2019 Prelim e Lrm
33/453
Actions e Basics
e Language Reference Manual Preliminary 2-17
See Also
Creating or Modifying Variables on page 2-14
Executing Actions Conditionally on page 2-15
Executing Actions Iteratively on page 2-15
Controlling Program Flow on page 2-16
Performing Time-Consuming Actions on page 2-17
Detecting and Handling Errors on page 2-18
2.2.3.6 Performing Time-Consuming Actions
See Also
Creating or Modifying Variables on page 2-14
routine() onpage 4-142
in e Libraries
Calls an e predefined routine.
compute method() on
page 6-25
Calls a value-returning method without using the value
returned.
return on page 6-27 Returns immediately from the current method to the methodthat called it.
sync on page 13-2 Suspends execution of the current TCM until the temporal
expression succeeds.
wait on page 13-4 Suspends execution of the current time-consuming method
until a given temporal expression succeeds.
all ofon page 13-7 Executes multiple action blocks concurrently, as separate
branches of a fork. The action following the all ofaction is
reached only when all branches of the all ofhave been fully
executed.
first ofon page 13-8 Executes multiple action blocks concurrently, as separate
branches of a fork. The action following the first ofaction is
reached when any of the branches in the first ofhas been
fully executed.
state machine onpage 5-2 in e Libraries
Defines a state machine.
http://../e_lib/predefined_routines.pdfhttp://../e_lib/predefined_routines.pdfhttp://../e_lib/state_machines.pdfhttp://../e_lib/state_machines.pdfhttp://../e_lib/state_machines.pdfhttp://../e_lib/state_machines.pdfhttp://../e_lib/state_machines.pdfhttp://../e_lib/predefined_routines.pdf -
7/31/2019 Prelim e Lrm
34/453
e Basics Expressions
2-18 Preliminary e Language Reference Manual
Executing Actions Conditionally on page 2-15
Executing Actions Iteratively on page 2-15
Controlling Program Flow on page 2-16
Invoking Methods and Routines on page 2-16
Detecting and Handling Errors on page 2-18
2.2.3.7 Detecting and Handling Errors
See Also
Creating or Modifying Variables on page 2-14
Executing Actions Conditionally on page 2-15
Executing Actions Iteratively on page 2-15
Controlling Program Flow on page 2-16
Invoking Methods and Routines on page 2-16
Performing Time-Consuming Actions on page 2-17
2.2.4 Expressions
Expressions are constructs that combine operands and operators to represent a value. The
resulting value is a function of the values of the operands and the semantic meaning of the
operators.
check that on page 9-2 Checks the DUT for correct data values.
dut_error() on
page 9-3
Defines a DUT error message string.
assert on page 9-16 Issues an error message if a specified Boolean expression isnot true.
warning() on page 9-10 Issues a warning message.
error() on page 9-11 Issues an error message when a user error is detected.
fatal() on page 9-13 Issues an error message, halts all activities, and exits
immediately.
try on page 9-14 Catches errors and exceptions.
-
7/31/2019 Prelim e Lrm
35/453
Struct Hierarchy and Name Resolution e Basics
e Language Reference Manual Preliminary 2-19
A few e expressions, such as expressions that restrict the range of valid values of a
variable, must evaluate to constants at compile time. More typically, expressions are
evaluated at run time, resolved to a value of some type, and assigned to a variable or field
of that type. Strict type checking in e is enforced.
Each expression must contain at least one operand, which can be:
A literal value
A constant
An e entity, such as a method, field, list, or struct
An HDL entity, such as a signal
A compound expression applies one or more operators to one or more operands.
See Also
Chapter 3, Data Types
2.3 Struct Hierarchy and Name Resolution
The following sections explain the struct hierarchy of an e program and how to reference
entities within the program:
Struct Hierarchy on page 2-19
Referencing e Entities on page 2-20
Implicit Variables on page 2-24
Name Resolution Rules on page 2-26
2.3.1 Struct Hierarchy
Because structs can be instantiated as the fields of other structs, a typical e program has
many levels of hierarchy. Every e program contains several predefined structs as well as
user-defined structs.
The predefined struct global is the root of all e structs. global contains predefined structs
that act as libraries of predefined functionality and are directly accessible from any
location in an e program.
It is highly recommended that you do not extend the global struct. Instead, you should
extend the sys struct to add user-defined structs or units.
-
7/31/2019 Prelim e Lrm
36/453
e Basics Referencing e Entities
2-20 Preliminary e Language Reference Manual
Figure 2-1 shows the partial hierarchy of a typical e program. The predefined structs are
shown in bold.
Figure 2-1 Diagram of Struct Hierarchy
2.3.2 Referencing e Entities
The following sections describe how to reference e entities:
Structs and Fields on page 2-20
Method and Routine Names on page 2-22
Enumerated Type Values on page 2-23
2.3.2.1 Structs and Fields
Any user-defined struct can be instantiated as a field of the sys struct or of another struct.
Thus every instantiated struct and its fields have a place in the struct hierarchy and their
names include a path reflecting that place.
The keep constraints in the following example show the use of paths to identify the fields
u and kind:
-
7/31/2019 Prelim e Lrm
37/453
Referencing e Entities e Basics
e Language Reference Manual Preliminary 2-21
keep ctrl.init_command.kind == RD;
};
struct ctrl_stub {
init_command: ctrl_cmd;
};
struct simplex {
kind: [TX, RX];
cell: cell;
};
struct port_stub {
sender: TX simplex;
listener: RX simplex;
};
struct cell {
u: uint;
};
struct ctrl_cmd {
kind: [RD, WR];addr: int;
};
extend sys {
switch : switch;
};
'>
Notes
The name of the global struct can be omitted from the path to a field or a struct.
The name of the enclosing struct is not included in the path if the current struct is theenclosing struct. For example, prefixing the name port.sender.cell.u in the example
above with the name of the enclosing struct, switch, is not legal.
In certain contexts, you can use the implicit variables me or it in the path to refer to theenclosing struct. For example, prefixing the name port.sender.cell.u in the example
above with me is legal. See Implicit Variables on page 2-24 for more information.
A special syntaxis required toreferencestructsubtypesandfieldsunderstructsubtypes.This syntax is described in Struct Subtypes on page 3-7.
See Also
Struct Subtypes on page 3-7
Implicit Variables on page 2-24
-
7/31/2019 Prelim e Lrm
38/453
e Basics Referencing e Entities
2-22 Preliminary e Language Reference Manual
. on page 2-75
2.3.2.2 Method and Routine Names
The names of all methods and routines must be followed immediately by parentheses both
when you define the method and when you call it.
The predefined methods of any struct, such as init() or quit(), and all user-defined methods
are associated with a particular struct. Thus, like structs and fields, every user-defined
method has a place in the struct hierarchy and its name includes a path reflecting that place.
The example below illustrates the names used to call user-defined and predefined methods.
Some predefined methods, such as the methods used to manipulate lists, are
pseudo-methods. They are not associated with a particular struct. These methods are called
by appending their name to the expression that you want to manipulate. Here is an example
of how to call the list pseudo-method .size():
-
7/31/2019 Prelim e Lrm
39/453
Referencing e Entities e Basics
e Language Reference Manual Preliminary 2-23
User-defined routines, like predefined routines, are associated with the global struct. You
can omit global from the path when the context is unambiguous. See Name Resolution
Rules on page 2-26 for more information.
See Also
Invoking Methods and Routines on page 2-16
2.3.2.3 Enumerated Type Values
Names for enumerated type values must be unique within each type. For example, defining
a type as my_type: [a, a, b] is not legal because the name a is not unique.
However, the same name can be used in more than one enumerated type. For example, the
following two enumerated types define the same value names:
type destination: [a, b, c, d];type source: [a, b, c, d];
To refer to an enumerated type value in a struct where no values are shared between the
enumerated types, you can use just the value name. In structs where more than one
enumerated field can have the same value, you must use the following syntax to refer to the
value when the type is not clear from the context:
value'field_name
In the following keep constraint, it is clear that the type of dest is destination, so you
can use just the value name b:
type destination: [a, b, c, d];
type source: [a, b, c, d];
struct packet {
dest: destination;
keep me.dest == b;
However, because the type of the variable tmp below is not specified, it is necessary to
use the full name for the enumerated type value destination'b:
m() is {
var tmp := destination'b;
};
See Also
Enumerated Scalar Types on page 3-5
-
7/31/2019 Prelim e Lrm
40/453
e Basics Implicit Variables
2-24 Preliminary e Language Reference Manual
2.3.3 Implicit Variables
Many e constructs create implicit variables. The scope of these implicit variables is the
construct that creates them. Two of these implicit variables, me and it, are used in
pathnames when referencing e entities.
This section describes the implicit variables:
it on page 2-24
me on page 2-25
result on page 2-26
index on page 2-26
Note With the exception ofresult, it is illegal to assign values to implicit
variables.
2.3.3.1 it
The constructs that create the implicit variable it are:
list pseudo-methods
for each
gen...keeping
keep for each
keep .is_all_iterations()
new with
list with key declaration
The implicit variable it always refers to the current item.
Wherever it.fieldcan be used, the shorthand notation .fieldcan be used in its place. For
example, it.len can be abbreviated to .len, with a leading dot. A typical use ofit is to referto each item in a list within a loop.
for each in sys.packets{
it.len = 5;
.good = TRUE;
};
-
7/31/2019 Prelim e Lrm
41/453
-
7/31/2019 Prelim e Lrm
42/453
e Basics Name Resolution Rules
2-26 Preliminary e Language Reference Manual
2.3.3.3 result
The result variable returns a value of the methods return type. If no return action is
encountered, result is returned by default. The following method returns the sum of a
and b:
sum(a: int, b: int): int is {
result = a + b;
};
See Also
Implicit Variables on page 2-24
2.3.3.4 index
The constructs that create the implicit variable index are:
list pseudo-methods
for each
keep for each
The index variable holds the current index of the item referred to by it. The scope of the
index variable is limited to the action block.
The following loop assigns 5 to the len field of every item in the packets list and also
assigns the index value of each item to its id field.
for each in packets do {
packets[index].len = 5;
.id = index;
};
See Also
Implicit Variables on page 2-24
2.3.4 Name Resolution Rules
The following sections describe how e names are resolved, depending on whether the
names include a path or not.
Names that Include a Path on page 2-27
-
7/31/2019 Prelim e Lrm
43/453
Name Resolution Rules e Basics
e Language Reference Manual Preliminary 2-27
Names that Do Not Include a Path on page 2-28
2.3.4.1 Names that Include a Path
If a name includes a path, an entity of that name must exist at the specified scope. In the
following example, the names sys.b.u or .u in the keep constraints cannot be resolved.All other names can be resolved.
Note If the path begins with a period (.), the path is assumed to begin with theimplicit variable it.
See Also
Names that Do Not Include a Path on page 2-28
-
7/31/2019 Prelim e Lrm
44/453
e Basics Name Resolution Rules
2-28 Preliminary e Language Reference Manual
2.3.4.2 Names that Do Not Include a Path
If a name does not include a path, the following checks are performed, in order. If a check
identifies the named object, the subsequent checks are not performed.
1. Check whether the name is a macro. If there are two macro definitions, choose the mostrecent one.
2. Check whether the name is one of the predefined constants. There cannot be two
identical predefined constants.
3. Check whether the name is an enumerated type. There cannot be two identical
enumerated types.
4. Check whether the name identifies a variable used in the current action block. If not,
and if the action is nested, check whether the name identifies a variable in the enclosing
action block. If not, this search continues from the immediately enclosing action block
outwards to the boundary of the method.
5. Check whether the name identifies a member of the current struct:
Iftheexpressionisinsideastructdefinition,thecurrentstructistheenclosingstruct.
If the expression is inside a method, the current struct is the struct to which themethod belongs.
6. Check whether the name identifies a member of the global struct.
7. If the name is still unresolved, issue an error message.
Note Macros, predefined constants, and enumerated types have global scope,which means they can be seen from anywhere within an e program. For that
reason, their names must be unique:
No user-defined constant can have the same name as a predefined e constant(Predefined Constants on page 2-6).
Notwoenumeratedtypescanhavethesame enum-type-name(DefiningandExtendingScalar Types on page 3-24).
See Also
Names that Include a Path on page 2-27
-
7/31/2019 Prelim e Lrm
45/453
Operator Precedence e Basics
e Language Reference Manual Preliminary 2-29
2.4 Operator Precedence
The following table summarizes all e operators in order of precedence. The precedence is
the same as in the C language, with the exception of operators that do not exist in C. To
change the order of computation, place parentheses around the expression that should be
computed first.
Table 2-5 Operators in Order of Precedence
Operator Operation Type
[ ] on page 2-56 List indexing (subscripting)
[ .. ] on page 2-61 List slicing
[ : ] on page 2-58 Bit slicing (selection)
f() Method and routine calls (see Invoking Methods and Routineson
page 2-16)
. on page 2-75 Field selection
~ on page 2-31,
! (not) on
page 2-36
Bitwise not, Boolean not
{ ; } on page 2-63 List concatenation
%{} onpage 2-64
Bit concatenation
Unary + - on
page 2-42
Unary plus, minus
*, /, % Binary multiply, divide, modulus (see + - * / % on page 2-43)
+, - Binary add and subtract (see + - * / % on page 2-43)
>> = on
page 2-45
Comparison
is [not] a on
page 2-71
Subtype identification
-
7/31/2019 Prelim e Lrm
46/453
e Basics Operator Precedence
2-30 Preliminary e Language Reference Manual
Note Everyoperation in e is performed within the context of types and is carriedout either with 32-bit precision or unbounded precision.
See Also
Chapter 3, Data Types for information on theprecision of operations andassignmentrules
== != on
page 2-46
Equality, inequality
=== !== on
page 2-48
Verilog four-state comparison
~ !~ onpage 2-51 String matching
in on page 2-52 Range list operator
& Bitwise and (see & | ^ on page 2-33)
| Bitwise or (see & | ^ on page 2-33)
^ Bitwise xor (see & | ^ on page 2-33)
&& (and) on
page 2-37
Boolean and
|| (or) on
page 2-38
Boolean or
=> on page 2-39 Boolean implication
? : on page 2-78 Conditional operator (a ? b : c means if a then b else c)
Table 2-5 Operators in Order of Precedence (continued)
Operator Operation Type
-
7/31/2019 Prelim e Lrm
47/453
Bitwise Operators e Basics
e Language Reference Manual Preliminary 2-31
2.5 Bitwise Operators
The following sections describe the e bitwise operators:
See Also
bitwise_op() on page 4-23 in e Libraries
2.5.1 ~
Purpose
Unary bitwise negation
Category
Expression
Syntax
~exp
Syntax example:
print ~x using hex;
Parameter
~ on page 2-31 The bitwise unary negation operator changes each 0 bit to 1
and each 1 bit to 0 in a single expression.& | ^ on page 2-33 The binary bitwise AND, OR, and XOR operators compare
each bit in one expression with the corresponding bit in a
second expression to calculate the result.
>>
-
7/31/2019 Prelim e Lrm
48/453
e Basics ~
2-32 Preliminary e Language Reference Manual
Description
Sets each 1 bit of an expression to 0 and each 0 bits to 1. Each bit of the result
expression is the opposite of the same bit in the original expression.
Example 1
This example shows the effect of the ~ operator on a 32-bit integer.
m() is {
var x : int = 0xff;
print ~x using hex;
};
Example 2
This example shows the effect of the ~ operator on a 2-bit integer.
m() is {
var x : uint (bits:2) = 2;
print ~x using bin;
};
Example 3
This example shows the effect of the ~ operator on an untyped expression.
When the type and bit size of an HDL signal cannot be determined from the context,the expression is automatically cast as an unsigned 32-bit integer.
m() is {
print 'top.clk';
print ~'top.clk';
print (~'top.clk')[0:0];
};
See Also
'HDL-pathname' on page 15-28
Scalar Types on page 3-2
Untyped Expressions on page 3-13
-
7/31/2019 Prelim e Lrm
49/453
& | ^ e Basics
e Language Reference Manual Preliminary 2-33
2.5.2 & | ^
Purpose
Binary bitwise operations
Category
Expression
Syntax
exp1 operator exp2
Syntax example:
print (x & y);
Parameters
Description
Performs an AND, OR, or XOR of both operands, bit by bit.
Example 1
m() is {
var x: uint = 0xff03;
var y: uint = 0x70f6;print (x & y);
};
Example 2
m() is {
exp1, exp2 A numeric expression or an HDL pathname.
operatoris one of the following:
& Performs an AND operation.
| Performs an OR operation.
^ Performs an XOR operation.
-
7/31/2019 Prelim e Lrm
50/453
e Basics >> > > 4);
-
7/31/2019 Prelim e Lrm
51/453
>> > 4);
var y: uint = 0x8fff0011;
outf("%b\n", y >> 4);
};
Example 2
m() is {
'top.a' = 0x8fff0011;
outf("%x\n", 'top.a' Performs a shift-right operation.
exp2 A numeric expression.
-
7/31/2019 Prelim e Lrm
52/453
e Basics Boolean Operators
2-36 Preliminary e Language Reference Manual
See Also
'HDL-pathname' on page 15-28
Scalar Types on page 3-2
2.6 Boolean Operators
The following sections describe the e Boolean operators:
2.6.1 ! (not)
PurposeBoolean not operation
Category
Expression
Syntax
!exp
not exp
Syntax example:
out(!(3 > 2));
! (not) on page 2-36 Returns TRUE when an expression evaluates to FALSE,
and vice versa.
&& (and) on page 2-37 Returns TRUE if two expressions are both TRUE.
|| (or) on page 2-38 Returns TRUE if one of two expressions is TRUE.
=> on page 2-39 Returns TRUE when the first expression of two
expressions is FALSE, or when both expressions are
TRUE.
now on page 2-40 Returns TRUE if an event has occurred in the current
cycle.
-
7/31/2019 Prelim e Lrm
53/453
&& (and) e Basics
e Language Reference Manual Preliminary 2-37
Parameters
Description
Returns FALSE when the expression evaluates to TRUE (not equal to 0) and returns
TRUE when the expression evaluates to FALSE (0).
Example
m() is {
'top.a' = 3;
out(!('top.a' > 2));
out(not FALSE);
};
See Also
'HDL-pathname' on page 15-28
Scalar Types on page 3-2
2.6.2 && (and)
Purpose
Boolean and
Category
Expression
Syntax
exp1 && exp2
exp1 and exp2
Syntax example:
if (2 > 1) and (3 > 2) then {
out("3 > 2 > 1");
exp A Boolean expression or an HDL pathname.
-
7/31/2019 Prelim e Lrm
54/453
e Basics || (or)
2-38 Preliminary e Language Reference Manual
};
Parameters
Description
Returns TRUE if both expressions evaluate to TRUE; otherwise, returns FALSE.
Example
m() is {
'top.a' = 3;
'top.b' = 2;
if ('top.b' > 1) and ('top.a' > 2) then {
out("'top.a' > 'top.b' > 1");
};
};
See Also
'HDL-pathname' on page 15-28
Scalar Types on page 3-2
2.6.3 || (or)
Purpose
Boolean or
Category
Expression
Syntax
exp1 || exp2
exp1 or exp2
Syntax example:
exp1, exp2 A Boolean expression or an HDL pathname.
-
7/31/2019 Prelim e Lrm
55/453
=> e Basics
e Language Reference Manual Preliminary 2-39
if FALSE || ('top.a' > 1) then {
out("'top.a' > 1");
};
Parameters
Description
Returns TRUE if one or both expressions evaluate to TRUE; otherwise, returns
FALSE.
Example
m() is {
'top.a' = 3;
if FALSE || ('top.a' > 1) then {
out("'top.a' > 1");
};
};
See Also
'HDL-pathname' on page 15-28
Scalar Types on page 3-2
2.6.4 =>
Purpose
Boolean implication
Category
Expression
Syntax
exp1 => exp2
exp1, exp2 A Boolean expression or an HDL pathname.
-
7/31/2019 Prelim e Lrm
56/453
e Basics now
2-40 Preliminary e Language Reference Manual
Syntax example:
out((2 > 1) => (3 > 2));
Parameters
Description
The expression returns TRUE when the first expression is FALSE, or when the second
expression is TRUE. This construct is the same as:
(not exp1) or (exp2)
Example
m() is {
out((2 > 1) => (3 > 2));
out((1 > 2) => (3 > 2));
out((2 > 1) => (2 > 3));
};
See Also
constraint-bool-exp on page 10-20
Scalar Types on page 3-2
2.6.5 now
Purpose
Boolean event check
CategoryBoolean expression
Syntax
now @event-name
exp1, exp2 A Boolean expression.
-
7/31/2019 Prelim e Lrm
57/453
now e Basics
e Language Reference Manual Preliminary 2-41
Syntax example:
if now @sys.tx_set then {out("sys.tx_set occurred");};
Parameter
Description
Evaluates to TRUE if the event occurs before the now expression is encountered, in
the same cycle in which the now expression is encountered.
However, if the event is consumed later during the same cycle, the now expression
changes to FALSE. This means that the event can be missed, if it succeeds after the
expression is encountered.
Example 1
In the following, the sys.tx_set event is checked when the ifaction is encountered. If
the sys.tx_set event has already occurred, in the same sys.clk cycle, the out() routine
is called.
struct pkt {
event clk is @sys.any;
tcm_exa()@clk is {
if now @sys.tx_set then {out("sys.tx_set occurred");};
};run() is also {
start tcm_exa();
};
};
See Also
Chapter 11, Events
Scalar Types on page 3-2