Skip to content

Commit 1cd0c49

Browse files
committed
add const
1 parent 11e096e commit 1cd0c49

File tree

2 files changed

+8
-8
lines changed

2 files changed

+8
-8
lines changed

include/RevExt.h

+7-7
Original file line numberDiff line numberDiff line change
@@ -58,21 +58,21 @@ struct RevExt {
5858
std::string_view GetName() const { return name; }
5959

6060
/// RevExt: baseline execution function
61-
bool Execute( unsigned Inst, const RevInst& Payload, uint16_t HartID, RevRegFile* regFile );
61+
bool Execute( unsigned Inst, const RevInst& Payload, uint16_t HartID, RevRegFile* regFile ) const;
6262

6363
/// RevExt: retrieves the extension's instruction table
64-
const std::vector<RevInstEntry>& GetTable() { return table; }
64+
const std::vector<RevInstEntry>& GetTable() const { return table; }
6565

6666
/// RevExt: retrieves the extension's compressed instruction table
67-
const std::vector<RevInstEntry>& GetCTable() { return ctable; }
67+
const std::vector<RevInstEntry>& GetCTable() const { return ctable; }
6868

6969
private:
7070
// RevExt: Randomize instruction costs if randomizeCosts == true
71-
void RandomizeCosts( std::vector<RevInstEntry>& table ) {
72-
if( feature->GetRandomizeCosts() ) {
71+
void RandomizeCosts( std::vector<RevInstEntry>& table ) const {
72+
if( feature->GetRandomizeCosts() )
7373
for( auto& entry : table )
74-
entry.cost = RevRand( 1, MAX_COST );
75-
}
74+
if( entry.cost == 1 )
75+
entry.cost = RevRand( 1, MAX_COST );
7676
}
7777

7878
std::string_view const name; ///< RevExt: extension name

src/RevExt.cc

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
namespace SST::RevCPU {
1414

1515
/// Execute an instruction
16-
bool RevExt::Execute( unsigned Inst, const RevInst& payload, uint16_t HartID, RevRegFile* regFile ) {
16+
bool RevExt::Execute( unsigned Inst, const RevInst& payload, uint16_t HartID, RevRegFile* regFile ) const {
1717
bool ( *func )( RevFeature*, RevRegFile*, RevMem*, const RevInst& );
1818

1919
if( payload.compressed ) {

0 commit comments

Comments
 (0)