19 #include "sc_variable.h"
20 #include "traceable.h"
23 #include <sysc/communication/sc_semaphore_if.h>
24 #include <sysc/kernel/sc_event.h>
25 #include <sysc/kernel/sc_object.h>
26 #include <sysc/kernel/sc_process_handle.h>
64 ordered_semaphore(
const char* name,
unsigned init_value = 1,
bool value_traceable =
false);
82 int wait(
unsigned priority);
89 int trywait()
override;
109 void set_capacity(
unsigned capacity);
123 const char*
kind()
const override {
return "sc_semaphore_ordered"; }
130 void trace(sc_core::sc_trace_file* tf)
const override;
186 if(queue[1].size()) {
187 if(queue[1].front() == sc_core::sc_get_current_process_handle()) {
188 queue[1].pop_front();
192 if(queue[0].front() == sc_core::sc_get_current_process_handle()) {
193 queue[0].pop_front();
202 void report_error(
const char*
id,
const char* add_msg = 0)
const;
205 sc_core::sc_event free_evt;
208 bool value_traceable =
false;
209 std::unique_ptr<scc::sc_ref_variable<int>> value_ref;
210 std::array<std::deque<sc_core::sc_process_handle>, 2> queue;
The ordered_semaphore primitive channel class.
int get_value() const override
get the value of the semaphore
unsigned get_capacity()
retrieve the initial capacity of the semaphore
int post() override
unlock (give) the semaphore
const char * kind() const override
kind of this SastemC object
bool is_trace_enabled() const override
returns of this component shall be traced
int wait() override
lock (take) the semaphore, block if not available
ordered_semaphore(unsigned init_value=1)
constructor of an un-named semaphore
interface defining a traceable component
~lock()
destructor, unlock the semaphore if still locked
void release()
unlock the semaphore
lock(scc::ordered_semaphore &sem)
lock the given semahore, wait if not free