Skip to content

File base.h

File List > fu > lsu > base.h

Go to the documentation of this file

#pragma once

#include <simtix/mem.h>
#include <simtix/param.h>

#include <cstdint>
#include <string>

#include "sm/fu/base.h"

namespace simtix {

// Class: BaseLoadStoreUnit
//   Basic load/store unit. Load store unit is modeled as a function unit,
//   i.e., provides Put/Get interface.
class BaseLoadStoreUnit : public BaseFunctionUnit {
 public:
  using Payload = mem::MemoryInterface::Payload;
  using OnResp = mem::MemoryInterface::OnResp;
  using RespStatus = mem::MemoryInterface::RespStatus;

  explicit BaseLoadStoreUnit(const std::string &name,
                             const ArchParam &p = kDefaultArchParam)
      : BaseFunctionUnit() {}

  // Function: AttachDMem
  //   Attach the memory port to this <BaseLoadStoreUnit>.
  //
  // Parameter:
  //   dmem_port - The data memory interface.
  virtual void AttachDMem(mem::MemoryInterface *dmem_port) {
    dmem_port_ = dmem_port;
  }

  // Function: PushWriteRequest
  //   Push a write request to the memory port.
  virtual void PushWriteRequest(uint32_t tid, Payload payload,
                                OnResp on_resp) = 0;

  // Function: PushReadRequest
  //   Push a read request to the memory port.
  virtual void PushReadRequest(uint32_t tid, Payload payload,
                               OnResp on_resp) = 0;

 protected:
  mem::MemoryInterface *dmem_port_ = nullptr;
};

}  // namespace simtix