blob: 7cc28eb9aa8a842a51d8021348955641b780cf7a [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{
Paul Greenwood701fcc12019-08-15 19:29:31 -050029 public:
Zane Shelley65ed96a2019-10-14 13:06:11 -050030 /** @brief Pure virtual destructor. */
31 virtual ~Register() = 0;
Zane Shelleyfd3f9cc2019-07-29 15:02:24 -050032
Paul Greenwood701fcc12019-08-15 19:29:31 -050033 /**
Zane Shelley53efc352019-10-03 21:46:39 -050034 * @brief Provides access to the value of this register.
35 * @param i_chip Indicates which chip to access for this register.
36 * @return A BitString containing the value of this register.
37 */
Zane Shelleyfe27b652019-10-28 11:33:07 -050038 virtual const BitString* getBitString(const Chip& i_chip) const = 0;
Zane Shelleyb0559b92019-12-05 22:18:20 -060039
40 /** @return The size (in bytes) of this register. */
41 virtual size_t getSize() const = 0;
Zane Shelleyfd3f9cc2019-07-29 15:02:24 -050042};
43
Zane Shelley65ed96a2019-10-14 13:06:11 -050044// Pure virtual destructor must be defined.
45inline Register::~Register() {}
46
Zane Shelley6722b5b2020-05-12 22:09:04 -050047/** Pointer management for Register objects. */
48using RegisterPtr = std::shared_ptr<const Register>;
49
Zane Shelley83da2452019-10-25 15:45:34 -050050} // end namespace libhei