Program Listing for File completion_table.hpp

Return to documentation for file (completion_table.hpp)

#ifndef FELIX_COMPLETIONTABLE_H_
#define FELIX_COMPLETIONTABLE_H_

#include "ers/ers.h"

#include <limits>
#include <map>
#include <cstdint>

ERS_DECLARE_ISSUE(felix_log, completion_table_issue, issue_message, ((const std::string&)issue_message))


class CompletionTable
{
    public:
        CompletionTable();

        void push(uint32_t addr);

        int update(uint32_t addr);

        void set_last_again_addr(uint32_t addr) { m_last_again_addr = addr; }

        uint32_t get_rd() const;

        uint32_t get_count(uint32_t addr) const;

        uint32_t get_previous_rd() const;

        size_t get_entries() const;

        void inspect() const;

        bool is_empty() const;

    private:
        typedef uint32_t address_t;
        typedef uint32_t counter_t;

        address_t m_rd;
        address_t m_last_pushed_addr;
        address_t m_last_provided_addr;
        address_t m_last_again_addr{std::numeric_limits<address_t>::max()};
        std::map<address_t, counter_t> *m_current_table;
        std::map<address_t, counter_t> *m_wrap_table;
        std::map<address_t, counter_t>  m_table_a;
        std::map<address_t, counter_t>  m_table_b;
};

#endif /* FELIX_COMPLETIONTABLE_H_ */