Skip to content

Commit

Permalink
Finish peq integration
Browse files Browse the repository at this point in the history
  • Loading branch information
janweinstock committed Dec 6, 2023
1 parent 4d19b7a commit c5926d4
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 17 deletions.
2 changes: 1 addition & 1 deletion include/vcml.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
#include "vcml/core/thctl.h"
#include "vcml/core/systemc.h"
#include "vcml/core/range.h"
// #include "vcml/core/peq.h"
#include "vcml/core/peq.h"
#include "vcml/core/command.h"
#include "vcml/core/module.h"
#include "vcml/core/component.h"
Expand Down
28 changes: 15 additions & 13 deletions include/vcml/core/peq.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,36 +24,38 @@ class peq : public sc_object
std::multimap<sc_time, T> m_schedule;

public:
// Constructor
peq(const char* nm):
sc_object(nm),
m_event(mkstr("%s_event", basename()).c_str()),
m_schedule() {}
peq(const char* nm);
virtual ~peq() = default;
VCML_KIND(peq);

void notify(T payload, double t, sc_time_unit tu);
void notify(T payload, const sc_time& delta);
void cancel(T obj);
void notify(const T& payload, double t, sc_time_unit tu);
void notify(const T& payload, const sc_time& delta);
void cancel(const T& obj);
void wait(T& obj);

sc_event& event() { return m_event; }
};

template <typename T>
inline void peq<T>::notify(T payload, double t, sc_time_unit tu) {
inline peq<T>::peq(const char* nm):
sc_object(nm),
m_event(mkstr("%s_event", basename()).c_str()),
m_schedule() {
// nothing to do
}

template <typename T>
inline void peq<T>::notify(const T& payload, double t, sc_time_unit tu) {
notify(payload, sc_time(t, tu));
}

template <typename T>
inline void peq<T>::notify(T payload, const sc_time& delta) {
inline void peq<T>::notify(const T& payload, const sc_time& delta) {
sc_time t = sc_time_stamp() + delta;
m_schedule.emplace(t, payload);
m_event.notify(m_schedule.begin()->first - sc_time_stamp());
}

template <typename T>
inline void peq<T>::cancel(T payload) {
inline void peq<T>::cancel(const T& payload) {
if (m_schedule.empty())
return;

Expand Down
3 changes: 0 additions & 3 deletions test/core/peq.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@

#include "testing.h"

#include "vcml/core/peq.h"

class peq_test : public test_base
{
public:
Expand All @@ -23,7 +21,6 @@ class peq_test : public test_base
peq<int> queue("peq");

EXPECT_STREQ(queue.name(), "test.run.peq");
EXPECT_STREQ(queue.event().name(), "test.run.peq_event");
EXPECT_STREQ(queue.kind(), "vcml::peq");

queue.notify(2, 2.0, SC_SEC);
Expand Down

0 comments on commit c5926d4

Please sign in to comment.