Documente Academic
Documente Profesional
Documente Cultură
ALDEC Webinar
Created and Presented by
Jerry Kaczynski,
ALDEC Research Engineer
Rev. 1.0
Agenda
Introduction: Raising Abstraction Level
Benefits of Encapsulation
Why We Need Inheritance
That Mysterious Polymorphism
Decoding Dynamic Dispatch
Summary/Q&A
www.aldec.com
Introduction:
www.aldec.com
www.aldec.com
Abstraction in HDLs
Classical Hardware Description Languages (HDLs) VHDL and Verilog
www.aldec.com
BENEFITS OF ENCAPSULATION
www.aldec.com
Old Style
Classical languages (BASIC, C, Verilog, VHDL) abstract control and data
separately:
www.aldec.com
To use protected type, you have to declare shared variable of that type.
To do anything with shared variable, you use notation
similar to accessing record fields:
shared_variable_name.member_name.
Note:
This feature is available in the language since 2002 version.
www.aldec.com
10
www.aldec.com
11
Is it enough?
Protected type approach to bundling data and functions works pretty
well, but there is some room for improvements
To enhance existing protected type, you have to modify
its source code: reuse is not flexible enough.
www.aldec.com
12
Class
Object
13
www.aldec.com
module top;
timeprecision 100ps;
timeunit 1ns;
import oop::*;
Base_Counter my_counter = new;
initial begin
$display($stime, my_counter.show);
#10 my_counter.clear;
$display($stime, my_counter.show);
repeat(10) begin
#10 my_counter.count;
$display($stime, my_counter.show);
end
end
endmodule
14
Encapsulation?
One of the main reasons to use classes and objects is
to achieve encapsulation:
15
Introducing UML
Universal Modeling Language (UML) is a popular graphical
representation of classes and their relationships.
16
Improving Reuse:
17
Smart Reuse
Lets say that we want to add load functionality to our Base_Counter
class.
18
Inheritance
We can use inheritance to create new class (called derived class or child
class) based on original class (called base class or parent class).
Inheritance creates is-a relationship: new class objects are also old
class objects and can replace them in the program code.
Only changes to the old class contents are listed in the new
class box: everything else is inherited.
19
module top;
timeprecision 100ps;
timeunit 1ns;
import oop::*;
Load_Counter my_counter = new;
initial begin
$display($stime, my_counter.show);
#10 my_counter.clear;
$display($stime, my_counter.show);
repeat(5) begin
#10 my_counter.count;
$display($stime, my_counter.show);
end
#10 my_counter.load(777);
$display($stime, my_counter.show);
end
endmodule
endpackage
www.aldec.com
20
Lets say that we want to crate newer class that still has
load functionality, but is also parameterized with maximal
count value.
www.aldec.com
21
endpackage
www.aldec.com
22
www.aldec.com
23
24
Manipulating Handles
All examples of code we have seen so far were calling class constructor
www.aldec.com
25
www.aldec.com
26
Virtual Methods
You can declare methods as virtual.
When you override virtual method in a child class, implementation
created for that class will stick with the object no matter what is the type
of the handle!
www.aldec.com
27
www.aldec.com
28
www.aldec.com
29
KERNEL:
KERNEL:
KERNEL:
KERNEL:
KERNEL:
KERNEL:
KERNEL:
KERNEL:
KERNEL:
KERNEL:
KERNEL:
KERNEL:
www.aldec.com
30
31
www.aldec.com
32
Dynamic Dispatch
In addition to dynamic memory allocation for objects, simulators
have to deal with runtime binding of method calls to proper
implementations.
Of course this handling is slower than regular method calls thats why
methods are not virtual by default.
www.aldec.com
33
Level Modeling (TLM) let you create very powerful, yet extremely
flexible verification environments.
You probably heard about OVM or UVM
they are such environments!
Now you should have a little easier task
of understanding them.
www.aldec.com
34
SUMMING UP
www.aldec.com
35
Tools Used
All pieces of code presented in this webinar (VHDL and SystemVerilog)
Java-based Violet UML Editor runs on any platform and is ideal solution for
beginners not familiar with UML. All UML diagrams in this presentation were
created in Violet. To download it, google VioletUML.
UMLet is a slightly more advanced UML editor. Google its name to download it.
Popular multi-platform graphing tool Dia (http://dia-installer.de/) can create
UML diagrams, too.
Although there are tools that can generate C++ or Java code from the UML
diagrams, none of them can generate SystemVerilog code
www.aldec.com
36
Conclusion
Feel free to contact ALDEC if you need more info about EDA-related topics
and our design creation and verification tools.
ALDEC Website:
Telephone
USA
Canada:
Europe:
Japan:
India:
China:
Taiwan:
Israel:
http://www.aldec.com
+1-702-990-4400
+1-613-867-8600
+33-6-80-32-60-56
+81-3-5312-1791
+91-80-32551030
+86-21-6875-20-30
+886-2-26599119 ext. 950
+972-52-2573422
Download:
Recorded webinars
White papers
Trial versions of our tools
www.aldec.com
E-mail
sales@aldec.com
sales@aldec.com
sales-eu@aldec.com
sales-jp@aldec.com
sales-sa@aldec.com
info@aldec.com.cn
sales-tw@aldec.com
sales-il@aldec.com