blob: 2a5c6ef32f8237eda9f3a88e0baf81f4aeea4791 [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
18Register * fir = new HardwareRegister(REG_ADDRESS, REG_WIDTH,
Zane Shelley0d4f5622019-10-14 13:02:30 -050019 CHIP_TYPE, ACCESS_RO);
Paul Greenwood701fcc12019-08-15 19:29:31 -050020Register * mask = new ConstantRegister( 0xffffffff00000000 );
21Register * fir_mask = new AndRegister(fir, mask);
Zane Shelley53efc352019-10-03 21:46:39 -050022const BitString * bs = fir_mask->getBitString(chip);
Paul Greenwood701fcc12019-08-15 19:29:31 -050023
24The getBitString function (defined by each register) provides access to
25the BitString that manages each register's data. In this example bs will
26contain the result of fir & mask.
27*/
28class Register
Zane Shelleyfd3f9cc2019-07-29 15:02:24 -050029{
Paul Greenwood701fcc12019-08-15 19:29:31 -050030 public:
Zane Shelleyfd3f9cc2019-07-29 15:02:24 -050031
Zane Shelley65ed96a2019-10-14 13:06:11 -050032 /** @brief Pure virtual destructor. */
33 virtual ~Register() = 0;
Zane Shelleyfd3f9cc2019-07-29 15:02:24 -050034
Paul Greenwood701fcc12019-08-15 19:29:31 -050035 /**
Zane Shelley53efc352019-10-03 21:46:39 -050036 * @brief Provides access to the value of this register.
37 * @param i_chip Indicates which chip to access for this register.
38 * @return A BitString containing the value of this register.
39 */
40 virtual const BitString * getBitString( const Chip & i_chip ) const = 0;
Zane Shelleyfd3f9cc2019-07-29 15:02:24 -050041};
42
Zane Shelley65ed96a2019-10-14 13:06:11 -050043// Pure virtual destructor must be defined.
44inline Register::~Register() {}
45
Paul Greenwood701fcc12019-08-15 19:29:31 -050046}//end namespace libhei