filer::~xaxi_stream_profiler() 
{
    delete curr_event;
    curr_event = nullptr;

    delete curr_event1;
    curr_event1 = nullptr;

    reset_event_list();

    delete event_list;
}

void xaxi_stream_profiler::register_axi_stream_transaction(unsigned int id)
{
    ++total_trans;
}
void xaxi_stream_profiler::register_axi_stream_data_byte(unsigned int id, uint64_t num_bytes)
{
    total_data_bytes += num_bytes;
}
void xaxi_stream_profiler::register_axi_stream_busy_cycle(unsigned int id)
{
    ++total_busy_cycles;
}
void xaxi_stream_profiler::register_axi_stream_stall_cycle(unsigned int id)
{
    ++total_stall_cycles;
}
void xaxi_stream_profiler::register_axi_stream_starve_cycle(unsigned int id)
{
    ++total_starve_cycles;
}

void xaxi_stream_profiler::reset_event_list()
{
    if(!event_list) {
        return;
    }

    for(std::vector<axi_s_event*>::iterator itr = event_list->begin(); itr != event_list->end(); ++itr) {
        delete (*itr);
    }
    event_list->clear();
}

void xaxi_stream_profiler::simulate_single_cycle()
{
    // if curr_event non-null; update the timestamp and add to event list and reset curr_event
    ++num_cycles;
    if(curr_event) {
        // IMPORTANT NOTE: this *must* be compatible with the method of generating
        // timestamps as defined in RTProfile::getTraceTime()

        struct timespec now;
        int err;
        if ((err = clock_gettime(CLOCK_MONOTONIC, &now)) < 0)
            curr_event->host_timestamp = 0;
        else
            curr_event->host_timestamp = (uint64_t) now.tv_sec * 1000000000UL + (uint64_t) now.tv_nsec;

        curr_event->timestamp = num_cycles;
        if(curr_event->axi_s_state & AXI_S_TRANS) {
            if(curr_event1 && (curr_event1->axi_s_state & AXI_S_STARVE)) {
                curr_event1->host_timestamp = curr_event->host_timestamp;
                curr_event1->timestamp = curr_event->timestamp;
                event_list->push_back(curr_event1);
                curr_event1 = nullptr;
            }
            num_cycles = 0; 
        5PA30+d