blob: e0473aa584afbd052782915f0bf5188ee2e3c154 [file] [log] [blame]
Zane Shelley871adec2019-07-30 11:01:39 -05001#pragma once
Zane Shelleyfd3f9cc2019-07-29 15:02:24 -05002
Zane Shelley52cb1a92019-08-21 14:38:31 -05003#include <hei_includes.hpp>
4#include <util/hei_bit_string.hpp>
5
Zane Shelley871adec2019-07-30 11:01:39 -05006namespace libhei
Zane Shelleyfd3f9cc2019-07-29 15:02:24 -05007{
8
Zane Shelleyfd3f9cc2019-07-29 15:02:24 -05009/**
Zane Shelley65ed96a2019-10-14 13:06:11 -050010@brief An abstract class for register objects.
Paul Greenwood701fcc12019-08-15 19:29:31 -050011
12Purpose: Register is an abstract base class for real and virtual registers.
13A few examples of these registers are; HardwareRegister, ConstantRegister,
14NotRegister, and AndRegister. As a base class of register types, Register
15creates a place where these registers can be put together like logical
16building blocks. For example, Register makes this possible:
17
Paul Greenwooddc47e0a2019-11-01 16:22:57 -050018Register * mask1 = new ConstantRegister(0xffff000000000000);
19Register * mask2 = new ConstantRegister(0xffffffff00000000);
20Register * fir_mask = new AndRegister(mask1, mask2);
Zane Shelley53efc352019-10-03 21:46:39 -050021const BitString * bs = fir_mask->getBitString(chip);
Paul Greenwood701fcc12019-08-15 19:29:31 -050022
23The getBitString function (defined by each register) provides access to
24the BitString that manages each register's data. In this example bs will
Paul Greenwooddc47e0a2019-11-01 16:22:57 -050025contain the result of mask1 & mask2.
Paul Greenwood701fcc12019-08-15 19:29:31 -050026*/
27class Register
Zane Shelleyfd3f9cc2019-07-29 15:02:24 -050028{
Zane Shelley4de8ff82020-05-14 15:39:01 -050029 public: // Aliases
30 using Ptr = std::shared_ptr<Register>;
31 using ConstPtr = std::shared_ptr<const Register>;
32
Paul Greenwood701fcc12019-08-15 19:29:31 -050033 public:
Zane Shelley65ed96a2019-10-14 13:06:11 -050034 /** @brief Pure virtual destructor. */
35 virtual ~Register() = 0;
Zane Shelleyfd3f9cc2019-07-29 15:02:24 -050036
Paul Greenwood701fcc12019-08-15 19:29:31 -050037 /**
Zane Shelley53efc352019-10-03 21:46:39 -050038 * @brief Provides access to the value of this register.
39 * @param i_chip Indicates which chip to access for this register.
40 * @return A BitString containing the value of this register.
41 */
Zane Shelleyfe27b652019-10-28 11:33:07 -050042 virtual const BitString* getBitString(const Chip& i_chip) const = 0;
Zane Shelleyb0559b92019-12-05 22:18:20 -060043
44 /** @return The size (in bytes) of this register. */
45 virtual size_t getSize() const = 0;
Zane Shelleyfd3f9cc2019-07-29 15:02:24 -050046};
47
Zane Shelley65ed96a2019-10-14 13:06:11 -050048// Pure virtual destructor must be defined.
49inline Register::~Register() {}
50
Zane Shelley83da2452019-10-25 15:45:34 -050051} // end namespace libhei