Search the Community
Showing results for tags 'events'.
-
Hello, I have a system-under-test that can connect to one or more producers, as well as one or more consumers. I am currently writing a testbench for this system. I have a sequence of N test scenarios I would like to submit my SUT to, so I'd like phase through each in my testbench. I could instantiate N separate testbenches, but I am looking for a more elegant solution that only requires me to instantiate one testbench, and phase through the tests within it. I am looking for suggestions on how to do this. The primary concerns for me are that it should not be too difficult to understand the testing mechanism, and it should be as easy as possible to add new tests, or modify existing ones. To give this some substance, this is the solution I have design so far: class Producer : public sc_module { public: sc_event first_test_e; sc_event second_test_e; sc_mutex busy_lock; // ... void first_test() { wait(first_test_e); busy_lock.lock(); // ... busy_lock.unlock(); } void second_test() { wait(second_test_e); busy_lock.lock(); // ... busy_lock.unlock(); } }; class Consumer : public sc_module { public: sc_event first_test_e; sc_event second_test_e; sc_mutex busy_lock; // ... void first_test() { wait(first_test_e); busy_lock.lock(); // ... busy_lock.unlock(); } void second_test() { wait(second_test_e); busy_lock.lock(); // ... busy_lock.unlock(); } }; class tb_top : public sc_module { public: Producer prod_i; Consumer cons_i; // ... void top_test() { // First test starts... prod_i.first_test_e.notify(SC_ZERO_TIME); cons_i.first_test_e.notify(SC_ZERO_TIME); wait(SC_ZERO_TIME); wait(SC_ZERO_TIME); prod_i.busy_lock.lock(); cons_i.busy_lock.lock(); // First test done. prod_i.busy_lock.unlock(); cons_i.busy_lock.unlock(); // Go on to second test... // ... } }; Here, I use events owned by the producers/consumers to begin tests. I use locks to communicate to the top test thread when all producers/consumers are done. I created a rudimentary prototype for this with success. Do you have any feedback?
- 3 replies
-
- systemc2.3
- test
-
(and 2 more)
Tagged with:
-
I have recently modeled registers as simple unions to represent bitfields, for example: typedef union { struct { uint32_t ADDRESS:5; uint32_t RESERVED:26; uint32_t ENABLE:1; } b; uint32_t w; } register_type; which facilitates the access to either the complete word or a bitfield. The interesting part comes when I try to check if the register value has changed, is there a more elegant way of doing this than polling in if or while statements for each register's value? I need to do this for a lot of them so I was wondering if modeling this using sc_bv provides a built-in event I could use in a SC_METHOD sensitivity list? example: typedef union { struct { sc_bv<5> ADDRESS; sc_bv<26> RESERVED; sc_bv<1> ENABLE; } b; uint32_t w; } register_type; and then do something like: register_type Reg; ... SC_METHOD(some_method); sensitive << Reg.b.ENABLE; ... some_method(){ ... } Any pointers or ideas are greatly appreciated
- 1 reply
-
- events
- register model
-
(and 1 more)
Tagged with:
-
Hello All I am trying to understand the hierarchical events and for this I created a SystemC class which contains a sc_event object. - How I can control an event to make it hierarchical or non-hierarchical ? -What is the example use case or hierarchical events. Can anyone help me on this ? Thanks Khushi