Skip to content

File base.h

File List > fu > base.h

Go to the documentation of this file

#pragma once

#include <optional>

#include "sm/instr_ptr.h"

namespace simtix {

// Class: BaseFunctionUnit
//   A basic interface for a function unit.
class BaseFunctionUnit {
 public:
  virtual ~BaseFunctionUnit() = default;
  // Function: Busy
  //
  // Return:
  //   true  - If the function unit cannot accept a new InstrPtr for execution.
  //   false - Otherwise.
  virtual bool Busy() = 0;

  // Function: Put
  //
  // Parameter:
  //   instr - The <InstrPtr> to put into the function unit for execution.
  //
  // Return:
  //   true  - If the function unit accepts the instr.
  //   false - Otherwise.
  virtual bool Put(InstrPtr instr) = 0;

  // Function: Get
  //
  // Return:
  //   std::nullopt - If there is no finished instr.
  //   <InstrPtr>   - Finished instruction.
  virtual std::optional<InstrPtr> Get() = 0;
};

}  // namespace simtix