00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019 #ifndef SAMPA_FIFO_H
00020 #define SAMPA_FIFO_H
00021
00022 #include "sampa/core/object.h"
00023
00024 namespace Sampa {
00025
00035 class Fifo : public Object {
00036 public:
00037 Fifo(const Name& name);
00038 bool is_empty() const { return m_size == 0; }
00039 bool is_full() const { return m_size == get_capacity(); }
00040 short peek() const { return m_rd_ptr & m_depth_mask; }
00041 short pop() { short rd = m_rd_ptr; m_rd_ptr = (m_rd_ptr+1) & m_depth_mask; m_size--; return rd; }
00042 short push() { short wr = m_wr_ptr; m_wr_ptr = (m_wr_ptr+1) & m_depth_mask; m_size++; return wr; }
00043 short pushable() const { return m_size < get_capacity(); }
00044 short get_capacity() const { return m_depth_mask + 1; }
00045 short get_size() const { return m_size; }
00046
00047 private:
00048 short m_size;
00049 short m_rd_ptr;
00050 short m_wr_ptr;
00051 short m_depth_mask;
00052 SAMPA_PERSISTENT(Fifo);
00053
00054 };
00055
00064 class TraceFifo : public Object {
00065 public:
00066 TraceFifo(const Name& name);
00067 bool is_empty() const { return m_size == 0; }
00068 bool is_full() const { return m_size == get_capacity(); }
00069 short peek() const { return m_rd_ptr & m_depth_mask; }
00070 short pop();
00071 short push();
00072 short pushable() const { return m_size < get_capacity(); }
00073 short get_capacity() const { return m_depth_mask + 1; }
00074 short get_size() const { return m_size; }
00075
00076 private:
00077 short m_size;
00078 short m_rd_ptr;
00079 short m_wr_ptr;
00080 short m_depth_mask;
00081 SAMPA_PERSISTENT(TraceFifo);
00082
00083 };
00084
00085 }
00086
00087 #endif