Mintz q207

408 views

Published on

0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total views
408
On SlideShare
0
From Embeds
0
Number of Embeds
1
Actions
Shares
0
Downloads
2
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide
  • 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
  • Separates “what to do” from “who does it”
  • Mintz q207

    1. 1. Mike Mintz Co-author, Hardware Verification with C++ and Hardware Verification with SystemVerilog [email_address] OOP for Hardware Verification ̶ Demystified!
    2. 2. Overview <ul><li>Common Currency </li></ul><ul><li>Data Abstraction </li></ul><ul><li>Virtual Functions </li></ul><ul><li>Base Classes </li></ul><ul><li>Q&A </li></ul>
    3. 3. Common Currency *There is nothing new under the sun. Sub sole nihil novi est.*
    4. 4. Data Abstraction <ul><li>Procedural code has separate data structures and functions. </li></ul><ul><li>OOP moves the functions into the data structure, </li></ul><ul><li>Every possible function for that structure is now in one place. </li></ul><ul><li>This works well for a driver. </li></ul>
    5. 5. Data Abstraction – Code Details Procedural Data Abstraction struct usb_driver {wire d_plus, d_minus;} void usb_init (usb_driver * d); void usb_send_packet (usb_driver * d, int type, int* data, int length); void usb_enumerate (usb_driver * d); struct usb_driver { wire d_plus, d_minus; void init (); void send_packet (int type, int* data, int length); void enumerate (); }; begin usb_driver driver; usb_init (&driver); usb_enumerate (&driver); usb_send (&driver, 0, {0,12}, 2); end begin usb_driver driver; driver. init (); driver.enumerate (); driver.send (0, {0,12}, 2); end
    6. 6. Virtual Function <ul><li>Is a run-time function call. </li></ul><ul><li>Is the “I don’t know” function. </li></ul><ul><li>Great for separating concerns (and increasing portability). </li></ul><ul><li>This works well for a monitor. </li></ul>
    7. 7. Virtual Functions Monitor class Derived for printing struct usb_printer: public usb_monitor { virtual void packet_completed (int length, int* data) { for (int i(0); i < length; ++i) { printf (“Packet [%d]:0x%x ”, i, data[i]); } } }; Derived for checker struct usb_checker : public usb_monitor { virtual void packet_completed (int length, int* data) { checker_->check (length, data); } checker* checker_; }; Derived for channel struct usb_monitor_agent : public usb_monitor { virtual void packet_completed (int length, int* data) { channel_->put (data_packet (length, data)); } usb_channel* channel_; }; struct usb_monitor { wire d_plus, d_minus; void start_monitor_thread (); virtual void packet_completed (int length, int* data) =0; };
    8. 8. Base Class <ul><li>Is a class with one or more virtual methods. </li></ul><ul><li>Is the “follow my lead” class. </li></ul><ul><li>Sets up a framework or interface. </li></ul><ul><li>This works well for a test irritator. </li></ul>
    9. 9. Base Classes – Code Details struct irritator { virtual void out_of_reset () =0; virtual void start () =0; virtual void stop () =0; virtual void wait_for_completion () =0; }; Irritator class Derived for USB Derived for PCIE Derived for Ethernet struct usb_irritator : public irritator { virtual void out_of_reset (); virtual void start (); virtual void stop (); virtual void wait_for_completion (); }; struct pcie_irritator: public irritator { virtual void out_of_reset (); virtual void start (); virtual void stop (); virtual void wait_for_completion (); }; struct ethernet_irritator: public irritator { virtual void out_of_reset (); virtual void start (); virtual void stop (); virtual void wait_for_completion (); };
    10. 10. Using OOP – Truss Top-Level Components Source: Hardware Verification with C++, page 95, page 100 class verification_component { public: verification_component (const std::string&); virtual void randomize () = 0; virtual void time_zero_setup () = 0; virtual void out_of_reset (reset r) = 0; virtual void start () = 0; virtual void wait_for_completion () = 0; virtual void report (const std::string) = 0; };
    11. 11. The “Dance” Source: Hardware Verification with C++, page 97 Source: Hardware Verification with C++, page 117
    12. 12. The “Dance” ̶ painfully detailed Source: Hardware Verification with C++, page 120 Source: Hardware Verification with C++, page 121
    13. 13. Summary <ul><li>OOP is a little bit of syntax with a large amount of attitude. </li></ul><ul><li>Learning OOP is gradual process, with making mistakes an integral part. </li></ul><ul><li>OOP is not really that “different” – just different packaging </li></ul><ul><li>See www.trusster.com for forums, articles, code, and more. </li></ul>
    14. 14. Q & A* *shameless plug

    ×