1. OOP for Hardware Verification
̶ Demystified!
Mike Mintz
Co-author, Hardware Verification with C++
and Hardware Verification with SystemVerilog
mike@trusster.com
www.trusster.com 1
2. Overview
• Common Currency
• Data Abstraction
• Virtual Functions
• Base Classes
• Q&A
www.trusster.com 2
3. Common Currency
Sub sole nihil novi est.*
*There is nothing new under the sun.
www.trusster.com 3
4. Data Abstraction
• Procedural code has separate data
structures and functions.
• OOP moves the functions into the
data structure,
• Every possible function for that
structure is now in one place.
• This works well for a driver.
www.trusster.com 4
5. Data Abstraction – Code Details
Procedural Data Abstraction
struct usb_driver {
struct usb_driver {wire d_plus, d_minus;}
wire d_plus, d_minus;
void usb_init (usb_driver * d);
void init ();
void usb_send_packet (usb_driver * d, void send_packet (int type, int* data,
int type, int* data, int length); int length);
void usb_enumerate (usb_driver * d); void enumerate ();
};
begin begin
usb_driver driver; usb_driver driver;
driver. init ();
usb_init (&driver);
driver.enumerate ();
usb_enumerate (&driver); driver.send (0, {0,12}, 2);
usb_send (&driver, 0, {0,12}, 2); end
end
www.trusster.com 5
6. Virtual Function
• Is a run-time function call.
• Is the “I don’t know” function.
• Great for separating concerns
(and increasing portability).
• This works well for a monitor.
www.trusster.com 6
8. Base Class
• Is a class with one or more virtual
methods.
• Is the “follow my lead” class.
• Sets up a framework or interface.
• This works well for a test irritator.
www.trusster.com 8
11. The “Dance”
Source: Hardware Verification with C++, page 97 Source: Hardware Verification with C++, page 117
www.trusster.com 11
12. The “Dance” ̶ painfully detailed
Source: Hardware Verification with C++, page 120 Source: Hardware Verification with C++, page 121
www.trusster.com 12
13. Summary
• OOP is a little bit of syntax with a
large amount of attitude.
• Learning OOP is gradual process,
with making mistakes an integral part.
• OOP is not really that “different” – just
different packaging
• See www.trusster.com for forums,
articles, code, and more.
www.trusster.com 13
Mention taken heavily from the book. Mention condensing 2 years of writing 340 pages into one hour Mention relation to Verification – bigger projects, more complicated – OOP lets us be more productive
Note that information hiding and data abstraction were techniques within an existing language. Languages either allow, support, or encourage these techniques -- Bjarne’s paper OOP has been the best technique for over 20 years
Note that information hiding and data abstraction were techniques within an existing language. Languages either allow, support, or encourage these techniques -- Bjarne’s paper OOP has been the best technique for over 20 years
Note that information hiding and data abstraction were techniques within an existing language. Languages either allow, support, or encourage these techniques -- Bjarne’s paper OOP has been the best technique for over 20 years
Separates “when to do” from “what to do”
The monitor code is now maximally reusable. Could have one that just prints, or connects to a checker, or one that connects via a channel. There is now a separation between the monitor function and what to do with the results of monitoring
Separates “what to do” from “who does it”
The monitor code is now maximally reusable. Could have one that just prints, or connects to a checker, or one that connects via a channel. There is now a separation between the monitor function and what to do with the results of monitoring
Hope this talk was useful OOP is exciting and fun stuff