blob: 7be76f5fe3cee6f8362bb6d01de731144befa03b [file] [log] [blame]
Zane Shelley871adec2019-07-30 11:01:39 -05001#pragma once
Zane Shelleyfd3f9cc2019-07-29 15:02:24 -05002
3/**
4 * @brief Models register.It does not contain target.
5 *
6 * This class stores the hash id and bit length of scom registers It models
7 * registers without maintaining target information. Instances of this class
8 * are shared across rule chip objects of same type.Once prd object model is
9 * built, instances of this register are saved in flyweight.These instances
10 * persist as long as prd object model survives.
11 */
12
13#include <iipscr.h>
14#include <iipbits.h>
15#include <iipMopRegisterAccess.h>
16#include <prdfTrace.H>
17
Zane Shelley871adec2019-07-30 11:01:39 -050018namespace libhei
Zane Shelleyfd3f9cc2019-07-29 15:02:24 -050019{
20
21// Forward References
22class CHIP_CLASS;
23class MopsRegisterAccess;
24class ExtensibleChip;
25
26class ScomRegister : public SCAN_COMM_REGISTER_CLASS
27{
28 public:
29
30 /**
31 * @brief constructor
32 * @param i_address address of the register
33 * @param i_bitLength bit length of register
34 * @param i_targetType target type associated with register
35 */
36 ScomRegister( uint64_t i_address, uint32_t i_bitLength,
37 TARGETING::TYPE i_targetType, AccessLevel i_access ) :
38 SCAN_COMM_REGISTER_CLASS(),
39 iv_bitLength( i_bitLength ),
40 iv_chipType( i_targetType ),
41 iv_scomAddress( i_address ),
42 iv_operationType( i_access )
43 {}
44
45 /**
46 * @brief constructor .Added this because we save object of this type in
47 * @ FlyweightS
48 */
49 ScomRegister():
50 SCAN_COMM_REGISTER_CLASS(),
51 iv_bitLength( 0 ),
52 iv_chipType( TARGETING::TYPE_NA ),
53 iv_scomAddress( 0 ),
54 iv_operationType( ACCESS_NONE )
55 {}
56
57 /**
58 * @brief Returns the pointer to bit string
59 * @param i_type attention type
60 * @return BitString * pointer to bit string
61 */
62
63 virtual const BitString * GetBitString(ATTENTION_TYPE i_type =
64 INVALID_ATTENTION_TYPE) const;
65 /**
66 * @brief Updates bit string contents associated with register
67 * @param i_bs poiner to bit string
68 * @return Nil
69 */
70
71 virtual void SetBitString(const BitString * i_bs) ;
72
73 /**
74 * @brief Returns length of the bits string associated with register
75 * @return length of bit string
76 */
77 uint32_t GetBitLength(void) const { return iv_bitLength ;}
78
79 /**
80 * @brief Directly reads from hardware register
81 * @return SUCCESS|FAIL
82 */
83 virtual uint32_t ForceRead() const;
84
85 /**
86 * @brief Returns contents of register.If entry does not exist in cache
87 * a fresh entry is created and hardware is read.
88 * @return SUCCESS|FAIL
89 */
90 virtual uint32_t Read() const;
91
92 /**
93 * @brief Writes cache contents to register.
94 * @return SUCCESS|FAIL
95 */
96 virtual uint32_t Write();
97
98 /**
99 * @brief Returns the hash id of register
100 * @return returns hash id of register
101 * @pre None
102 * @post None
103 * @note
104 */
105 virtual uint16_t GetId(void) const { return iv_shortId; };
106
107 /**
108 * @brief Sets the hash id of register
109 * @param i_id hash id of register
110 * @return Nil
111 */
112 virtual void SetId(uint16_t i_id) { iv_shortId = i_id; };
113
114 /**
115 * @brief Returns type of Target associated with register.
116 * @return Refer to function description
117 */
118 TARGETING::TYPE getChipType()const{ return iv_chipType ;} ;
119 /**
120 * @brief Returns scom address of register
121 * @return Refer to function description
122 */
123 uint64_t GetAddress( ) const {return iv_scomAddress ;};
124 /**
125 * @brief compares two ScomRegisterAccess register for equality
126 * @param i_rightRegister register to be compared against
127 * @return Returns true if registers are equal false otherwise
128 */
129 bool operator == ( const ScomRegister & i_rightRegister ) const ;
130 /**
131 * @brief defines < operation for ScomRegisterAccess
132 * @param i_rightRegister register to be compared against
133 * @return Returns false if i_rightRegisters is less and true otherwise
134 */
135 bool operator < ( const ScomRegister & i_rightRegister ) const ;
136 /**
137 * @brief defines >= operation for ScomRegisterAccess
138 * @param i_rightRegister register to be compared against
139 * @return Returns true if registers is >= i_rightRegister false
140 * otherwise
141 */
142 bool operator >= ( const ScomRegister & i_rightRegister ) const;
143
144 /** @return The register access level (see enum AccessLevel). */
145 virtual AccessLevel getAccessLevel() const { return iv_operationType; }
146
147 /** @brief Sets the register access level (see enum AccessLevel). */
148 virtual void setAccessLevel( AccessLevel i_op ) { iv_operationType = i_op; }
149
150 protected: // Functions
151
152 /**
153 * @brief copy constructor
154 * @param i_scomRegister scomRegister instance to be copied
155 */
156 ScomRegister( const SCAN_COMM_REGISTER_CLASS & i_scomRegister ):
157 SCAN_COMM_REGISTER_CLASS(),
158 iv_bitLength( i_scomRegister.GetBitLength() ),
159 iv_shortId( i_scomRegister.GetId() ),
160 iv_chipType( i_scomRegister.getChipType() ),
161 iv_scomAddress( i_scomRegister.GetAddress() ),
162 iv_operationType( i_scomRegister.getAccessLevel() )
163 {}
164
165 /**
166 * @brief Returns reference to bit string associated with register
167 * @return Refer to function description
168 */
169 virtual BitString & AccessBitString( );
170 /**
171 * @brief Gets the register read and write done by calling access
172 * function of scom accessor service.
173 * @param reference to bit string maintained in caller class
174 * @param Read or write operation
175 * @return [SUCCESS|FAIL]
176 */
177 uint32_t Access( BitString & bs,
178 MopRegisterAccess::Operation op )const;
179
180 /**
181 * @brief Returns rulechip pointer associated with the register
182 * @return Refer to function description
183 */
184 virtual ExtensibleChip * getChip() const;
185
186private: // functions
187
188 friend class CaptureData;
189
190 /** @return TRUE if entry for this register exist in this cache. */
191 bool queryCache() const;
192
193 /**
194 * @brief Reads register contents from cache.
195 * @return Reference to bit string buffer maintained in cache.
196 */
197 BitString & readCache() const;
198
199 /**
200 * @brief Deletes one or all entry in the cache
201 * @param RuleChip pointer associated with register
202 * @return Nil
203 */
204 void flushCache( ExtensibleChip *i_pChip = NULL ) const;
205
206 private: // Data
207
208 uint32_t iv_bitLength; // bit length of scom
209 uint16_t iv_shortId; // unique hash id of register
210 TARGETING::TYPE iv_chipType; // type of target associated with register
211 uint64_t iv_scomAddress; // scom address associated with regiser
212 AccessLevel iv_operationType; // Operation supported (RO, WO, or RW)
213
214};
215
Zane Shelley871adec2019-07-30 11:01:39 -0500216} // end namespace libhei
Zane Shelleyfd3f9cc2019-07-29 15:02:24 -0500217