System C
System C
1 • C++
• OOP 2 SystemC 3 TLM
DIFFERENCE BETWEEN C AND C++
C C++
• C Supports Procedural Program • C++ is known as hybrid language,
because it support both procedural and
OOP
• As C doesn’t support the OOPS concept , • C++ has support for polymorphism,
so it has no support for polymorphism, encapsulation and inheritance as it is an
encapsulation and inheritance OOPS language
Encapsulation Abstraction
Object Polymorphism
10
CLASSIC CLASS EXAMPLE
11
ACCESS SPECIFIERS
12
CLASS EXAMPLE
13
ACCESS SPECIFIERS
Private Members
Public Members
14
ACCESS SPECIFIERS (CONTINUED)
15
USING CONST WITH MEMBER FUNCTIONS
16
DEFINING A MEMBER FUNCTION
17
GLOBAL FUNCTIONS
• Functions that are not part of a class, that is, do not have the Class::name
notation, are global. This is what we have done up to this point.
18
ACCESSORS AND MUTATORS
19
DEFINING AN INSTANCE OF A CLASS
20
DERIVED ATTRIBUTES
21
POINTERS TO OBJECTS
22
DYNAMICALLY ALLOCATING OBJECTS
Rectangle *r1;
r1 = new Rectangle();
• This allocates a rectangle and returns a pointer to it. Then:
r1->setWidth(12.4);
23
PRIVATE MEMBERS
24
PRIVATE MEMBERS
25
SEPARATING SPECIFICATION FROM IMPLEMENTATION
• Place class declaration in a header file that serves as the class specification
file. Name the file ClassName.h, for example, Rectangle.h
• Place member function definitions in ClassName.cpp, for example,
Rectangle.cpp File should #include the class specification file
• Programs that use the class must #include the class specification file, and
be compiled and linked with the member function definitions
26
INLINE MEMBER FUNCTIONS
27
TRADEOFFS – INLINE VS. REGULAR MEMBER FUNCTIONS
• Code for an inline function is copied into program in place of call – larger
executable program, but no function call overhead, hence faster execution
28
CONSTRUCTORS
29
DEFAULT CONSTRUCTORS
30
PASSING ARGUMENTS TO CONSTRUCTORS
31
PASSING ARGUMENTS TO CONSTRUCTORS
32
MORE ABOUT DEFAULT CONSTRUCTORS
• When all of a class's constructors require arguments, then the class has NO
default constructor
• When this is the case, you must pass the required arguments to the constructor
when creating an object
34
DESTRUCTORS
35
CONSTRUCTORS, DESTRUCTORS,
AND DYNAMICALLY ALLOCATED OBJECTS
• When an object is dynamically allocated with the new operator, its constructor
executes:
36
OVERLOADING CONSTRUCTORS
37
ONLY ONE DEFAULT CONSTRUCTOR AND ONE
DESTRUCTOR
• Do not provide more than one default constructor for a class: one that
takes no arguments and one that has default arguments for all
parameters
Square();
Square(int = 0); // will not compile
39
USING PRIVATE MEMBER FUNCTIONS
40
ARRAYS OF OBJECTS
41
ARRAYS OF OBJECTS
Rectangle rArray[3]={Rectangle(2.1,3.2),
Rectangle(4.1, 9.9),
Rectangle(11.2, 31.4)};
42
ARRAYS OF OBJECTS
• It isn't necessary to call the same constructor for each object in an array:
Rectangle rArray[3]={Rectangle(2.1,3.2),
Rectangle(),
Rectangle(11.2, 31.4)};
43
ACCESSING OBJECTS IN AN ARRAY
44
THE UNIFIED MODELING LANGUAGE
45
UML CLASS DIAGRAM
46
EXAMPLE: A RECTANGLE CLASS
class Rectangle
{
private:
double width;
double length;
public:
bool setWidth(double);
bool setLength(double);
double getWidth() const;
double getLength() const;
double getArea() const;
};
47
UML ACCESS SPECIFICATION NOTATION
48
UML DATA TYPE NOTATION
- width : double
- length : double
49
UML PARAMETER TYPE NOTATION
+setWidth(w : double)
50
UML FUNCTION RETURN TYPE NOTATION
51
THE RECTANGLE CLASS
52
SHOWING CONSTRUCTORS AND DESTRUCTORS
Constructors
Destructor
53
2. SYSTEMC
FEATURES OF SYSTEMC
• MODULES (STRUCTURE)
• PORTS (STRUCTURE)
• PROCESSES (COMPUTATION, CONCURRENCY)
• CHANNELS (COMMUNICATION)
• INTERFACES (COMMUNICATION REFINEMENT)
• EVENTS (TIME, SCHEDULING,
SYNCHRONIZATION)
• DATA TYPES (HARDWARE, FIXED POINT)
ARCHITECTURE OF SYSTEMC
TYPICAL USE CASE: VIRTUAL PLATFORM
SYSTEMC DATA TYPES
WHAT IS SYSTEMC USED FOR?
•VIRTUAL PLATFORM
•SOFTWARE DEVELOPMENT
•HIGH-LEVEL SYNTHESIS
•USED BY
Introduction to SystemC
•Core Concepts and Syntax
•Data
•Modules and connectivity
•Processes & Events
•Channels and Interfaces
•Ports
•Bus Modeling
•Odds and Ends
LIMITED PRECISION INTEGER
SC_INT
LOGIC AND VECTOR TYPES
SC_MODULE
SC_MODULE OR SC_MODULE?
SEPARATE HEADER FILE
PORT BINDING
SUMMARY OF FILES
KINDS OF PROCESS
SC_METHOD EXAMPLE
SC_THREAD EXAMPLE
REFERENCES
•IEEE 1666
standards.ieee.org/getieee/1666/download/
1666-2011.pdf
•On-line tutorials
www.doulos.com/knowhow/systemc