280 likes | 297 Views
The e Language. Meir Ovadia. Tel-Aviv university 05-28, 2004. Agenda. The e language Syntax and Semantic Examples of usage Comparing to AspectJ e as predicate classes language Conclusions. Tel-Aviv University. About us. We are Verisity ( www.verisity.com )
E N D
The e Language Meir Ovadia Tel-Aviv university 05-28, 2004
Agenda • The e language • Syntax and Semantic • Examples of usage • Comparing to AspectJ • e as predicate classes language • Conclusions Tel-Aviv university Tel-Aviv University
About us • We are Verisity (www.verisity.com) • We deal in functional verification: • Verification of: chips, boards, boxes • DUT simulated e.g. in VHDL / Verilog • Main product: Specman Elite • Language: e Tel-Aviv university Tel-Aviv University
Verifying a DUT using Specman Tel-Aviv university Tel-Aviv University
The e language • A lexically-scoped, single-inheritance, general-purpose AO language • constructs: • Constraints • Coverage definitions • Parallelism • Temporal constructs • Bit-access • sequences Tel-Aviv university Tel-Aviv University
The e language • Compilation and interpretation • No pre-processor • Aspects (modules) can loaded/compiled on top of existing environment Tel-Aviv university Tel-Aviv University
Syntax: struct declaration // env.e struct packet {i : int; j : int; keep i < j + 1; keep j in [1..5]; foo() is { out(“I’m in foo”); }; }; Tel-Aviv university Tel-Aviv University
// special.e import env.e; extend packet {keep j == 3; foo() is also { print j; }; }; Syntax: Struct extension Tel-Aviv university Tel-Aviv University
// cell.e import env.e; struct cell like packet { header: list of bit;keepsoft header.size() == 56; foo() is first { header[0..31] = pack(NULL,j); }; }; Syntax: Inheritance Tel-Aviv university Tel-Aviv University
Semantic: struct’s layers • Each struct declaration or extension called ‘struct layer’ • Each layer encapsulate behavior (and data) • Collections of layers (from different struct) called aspect. • The struct layer’s order is the load order Tel-Aviv university Tel-Aviv University
Aspect: example //display.e importenv.e; extend dog{ display()is{ …}; }; extendpoodle{ display()is only {…};}; extendcat{display()is{…};}; extendsnake{ display()is{…};}; extendpacket{ display()is{…};}; Tel-Aviv university Tel-Aviv University
Semantic: Method’s layers • Each method declaration or extension called ‘method layer’ • Method can declared by • undefined (i.e. run time error) • empty • is • Method can extended by • is also (add new layer after existing behavior) • is first (add new layer before existing behavior) • is only (new layer override existing behavior) Tel-Aviv university Tel-Aviv University
Method layers: example struct A { do(): int is empty; do(): int is also {out(1); return 0;}; }; struct B like A { do(): int is only { out(3); return 10;};}; struct C like A {do(): int is first { out(4);};}; extend A { do(): int is also { out(5);}; extend B { do(): int is also { out(6);}; result = a.do() := 1,5 (result := 0) result = b.do() := 3,5,6 (result := 10) result = c.do() := 4,1,5 (result := 0) extend dog { display() is { …}; }; extend poodle { display() is only {…};}; extend cat { display() is {…};}; extend snake { display() is {…};}; extend packet { display() is {…};}; Tel-Aviv university Tel-Aviv University
Encapsulation in e • Packages (like in Java) • Types namespace (like in Java) • Access control • Public for all packages • Private to one package • Private to one struct (i.e. for all layers including descendants layers) • Private to only one layer • Friend Tel-Aviv university Tel-Aviv University
Monitoring • Logging <‘ //logging.e importenv.e; extend packet{ foo()isalso{ log(…);}; doo()isalso{ log(…);}; goo()isalso { log(…);}; }; ‘> Tel-Aviv university Tel-Aviv University
Monitoring (cont.) • Tracing – Specman has trace package build in. • Profiling –e has profiler as part of the language. (same as other languages has garbage collector). • Code style – use the reflection. Tel-Aviv university Tel-Aviv University
Linting • Forcing access to fields only via setters and getters <‘ //point.e importenv.e; extend Point { layer privatex: int; layer privatey: int; public setX(val: int)is{ x = val;}; publicsetY(val: int)is{ y = val;}; publicgetX(): intis{returnx;}; publicgetY(): intis{ returny;}; }; ‘> Tel-Aviv university Tel-Aviv University
Aspect encapsulation //eat.e packageeating; importenv.e; extend Animal { eat()is undefined; }; extendMammal { eat()is only{…};}; extendDog { eat()isalso{…};}; extendFowl { eat()isonly{…};}; extendLoveBird { eat()isfirst{…};}; Tel-Aviv university Tel-Aviv University
Patches • Very easy to send a patch to customers <‘ extend my_struct { foo() is only {….}; div(i: int; j: int) is first { if (j == 0) { error(…); }; }; }; ‘> Tel-Aviv university
Testing • Each test extend the core environment and modify it. <‘ //Test2.e extend packet { keep kind == error; send() is only { … }; check() is only {…}; }; ‘> <‘ //Test1.e extend packet { keep data.size() == 50; send() is first { data[0] = data[5] }; check() is also {…}; }; ‘> Tel-Aviv university
Predicate Classes • Similar to Craig Chambers’ Predicate Class • Useful for specifying multiple, almost-orthogonal dimensions. • Metamorphism • No need to explicitly enumerate all combinations • Security and factory. Tel-Aviv university Tel-Aviv University
Predicate classes: Example type color_t : [red, green, blue]; type size_t : [big, small]; extend packet { color : color_t; size : size_t; when red packet { keep data.size() == 40;}; when green small packet { show() is also {…};}; when green packet { foo() is { …};}; when big packet { ….}; when red big packet {…}; }; Tel-Aviv university Tel-Aviv University
Local optimization // opt.e importenv.e; extend Algorithm { keep cond => kind == opt; }; extend opt Algorithm { calc() is only { …}; }; Tel-Aviv university
Disadvantage of e • Private language (private BNF) • No abstract classes • Small users community (comparing to C++) • Java has some advantages on e. (like Jbuilder or databases packages) Tel-Aviv university Tel-Aviv University
Advantage of e • Powerful AOP but yet no new concepts • Easy to manage • Easy to collect struct layers • Easy to collect method layer (by declare order or run time order) • Easy to debug (break on layer or on all layers) • Aspect can loaded on top of compiled env’ • Good performance (method layer equal to method call) • Many commercial tools use e (as AO language) • Not break the OOP encapsulation Tel-Aviv university Tel-Aviv University
Conclusion • AO is not a keyword to mess oriented • AOP can not replace good modeling • Someday in the future someone will write NEW open source AOP language and it will looks like e (same ideas). • We need do declare “how to model problems using AOP?” Tel-Aviv university Tel-Aviv University
Other issues related to e • The e parser (backtracking) • The temporal language in e • The constraint solver in e • The ‘define as’ and ‘define as computed’ • Ports to any simulator • The eCel • Bit slice algorithms Tel-Aviv university
Thank you Tel-Aviv university Tel-Aviv University