Skip to content

File instr_auipc.h

File List > projects > simtix > src > simtix > sm > instr_auipc.h

Go to the documentation of this file

#pragma once

#include <cstdint>

#include "sm/instr.h"
#include "sm/thread.h"
#include "sm/warp.h"

namespace simtix {

class InstrAuipc : public Instr {
 public:
  using Op = void (InstrAuipc::*)();

  // Implementation of Instr's virtual methods
  void Decode() override;

  void Issue() override;

  void OperandCollect() override;

  void Execute() override;

  void Commit() override;

  void Reset() override;

  void Assign(const Instr *other) override;

  bool CanIssue() const override;

  bool CanExecute() const override { return true; }

  bool CanCommit() const override { return executed_; }

  bool CanRetire() const override { return committed_; }

  // Helper functions
  static inline int64_t DecodeImmItype(uint32_t iword) {
    return (int32_t(iword) >> 12);
  }

  static inline int64_t DecodePC(uint64_t wpc) { return (int64_t(wpc)); }

 protected:
  InstrAuipc(Warp *warp, uint32_t iword, uint64_t wpc);

  void Reinitialize(Warp *warp, uint32_t iword, uint64_t wpc) override;

  int64_t imm_ = 0;
  int64_t pc_ = 0;
  Op op_ = nullptr;
  bool executed_ = false;
  bool committed_ = false;

  // Register data
  int64_t rd_data_;

 private:
  // Operations defined in this Opcode
  void auipc_() { rd_data_ = (imm_ << 12) + pc_; }

  // Make InstrPool friend so that they can call our protected constructor
  template <class InstrType>
  friend class InstrPool;
};

}  // namespace simtix