Fixed some warnings from coverity
This commit is contained in:
parent
9796130cb5
commit
5d30416955
|
@ -38,3 +38,10 @@ helper.ods
|
||||||
*.swp
|
*.swp
|
||||||
RISCV_TLM
|
RISCV_TLM
|
||||||
dump
|
dump
|
||||||
|
.project
|
||||||
|
.cproject
|
||||||
|
.settings
|
||||||
|
doc/Drawings.odg
|
||||||
|
doc/html
|
||||||
|
env.sh
|
||||||
|
gh-md-toc
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
/*!
|
/*!
|
||||||
\file Registers.h
|
\file Registers.h
|
||||||
\brief Basic register file implementation
|
\brief Basic register file
|
||||||
\author Màrius Montón
|
\author Màrius Montón
|
||||||
\date August 2018
|
\date August 2018
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -1558,7 +1558,7 @@ bool Execute::M_MUL(Instruction &inst) {
|
||||||
multiplier = regs->getValue(rs1);
|
multiplier = regs->getValue(rs1);
|
||||||
multiplicand = regs->getValue(rs2);
|
multiplicand = regs->getValue(rs2);
|
||||||
|
|
||||||
result = multiplier * multiplicand;
|
result = (int64_t) multiplier * multiplicand;
|
||||||
result = result & 0x00000000FFFFFFFF;
|
result = result & 0x00000000FFFFFFFF;
|
||||||
regs->setValue(rd, result);
|
regs->setValue(rd, result);
|
||||||
|
|
||||||
|
|
|
@ -29,6 +29,10 @@ Memory::Memory(sc_module_name name, bool use_file): sc_module(name)
|
||||||
memory_offset = 0;
|
memory_offset = 0;
|
||||||
program_counter = 0;
|
program_counter = 0;
|
||||||
//memset(mem, 0, SIZE*sizeof(uint8_t));
|
//memset(mem, 0, SIZE*sizeof(uint8_t));
|
||||||
|
//
|
||||||
|
mem = new uint8_t[SIZE];
|
||||||
|
log = Log::getInstance();
|
||||||
|
log->SC_log(Log::INFO) << "Memory instantiated wihtout file" << endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -160,23 +164,23 @@ void Memory::readHexFile(string filename) {
|
||||||
} else if (line.substr(7,2) == "02") {
|
} else if (line.substr(7,2) == "02") {
|
||||||
/* Extended segment address */
|
/* Extended segment address */
|
||||||
extended_address = stol(line.substr(9,4), nullptr, 16) * 16;
|
extended_address = stol(line.substr(9,4), nullptr, 16) * 16;
|
||||||
cout << "02 extended address 0x" << hex << extended_address << endl;
|
cout << "02 extended address 0x" << hex << extended_address << dec << endl;
|
||||||
} else if (line.substr(7,2) == "03") {
|
} else if (line.substr(7,2) == "03") {
|
||||||
/* Start segment address */
|
/* Start segment address */
|
||||||
uint32_t code_segment;
|
uint32_t code_segment;
|
||||||
code_segment = stol(line.substr(9,4), nullptr, 16) * 16; /* ? */
|
code_segment = stol(line.substr(9,4), nullptr, 16) * 16; /* ? */
|
||||||
program_counter = stol(line.substr(13,4), nullptr, 16);
|
program_counter = stol(line.substr(13,4), nullptr, 16);
|
||||||
program_counter = program_counter + code_segment;
|
program_counter = program_counter + code_segment;
|
||||||
cout << "03 PC set to 0x" << hex << program_counter << endl;
|
cout << "03 PC set to 0x" << hex << program_counter << dec << endl;
|
||||||
} else if (line.substr(7,2) == "04") {
|
} else if (line.substr(7,2) == "04") {
|
||||||
/* Start segment address */
|
/* Start segment address */
|
||||||
memory_offset = stol(line.substr(9,4), nullptr, 16) << 16;
|
memory_offset = stol(line.substr(9,4), nullptr, 16) << 16;
|
||||||
extended_address = 0;
|
extended_address = 0;
|
||||||
cout << "04 address set to 0x" << hex << extended_address << endl;
|
cout << "04 address set to 0x" << hex << extended_address << dec << endl;
|
||||||
cout << "04 offset set to 0x" << hex << memory_offset << endl;
|
cout << "04 offset set to 0x" << hex << memory_offset << dec << endl;
|
||||||
} else if (line.substr(7,2) == "05") {
|
} else if (line.substr(7,2) == "05") {
|
||||||
program_counter = stol(line.substr(9,8), nullptr, 16);
|
program_counter = stol(line.substr(9,8), nullptr, 16);
|
||||||
cout << "05 PC set to 0x" << hex << program_counter << endl;
|
cout << "05 PC set to 0x" << hex << program_counter << dec << endl;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,3 +1,10 @@
|
||||||
|
/*!
|
||||||
|
\file Registers.cpp
|
||||||
|
\brief Basic register file implementation
|
||||||
|
\author Màrius Montón
|
||||||
|
\date August 2018
|
||||||
|
*/
|
||||||
|
|
||||||
#include "Registers.h"
|
#include "Registers.h"
|
||||||
|
|
||||||
Registers::Registers() {
|
Registers::Registers() {
|
||||||
|
@ -58,7 +65,7 @@ void Registers::dump(void) {
|
||||||
cout << " x30 (t5): " << right << setw(11) << register_bank[30];
|
cout << " x30 (t5): " << right << setw(11) << register_bank[30];
|
||||||
cout << " x31 (t6): " << right << setw(11) << register_bank[31] << endl;
|
cout << " x31 (t6): " << right << setw(11) << register_bank[31] << endl;
|
||||||
|
|
||||||
cout << "PC: 0x" << hex << register_PC << endl;
|
cout << "PC: 0x" << hex << register_PC << dec << endl;
|
||||||
cout << "************************************" << endl;
|
cout << "************************************" << endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -64,6 +64,8 @@ void Trace::xtermKill( const char *mess ) {
|
||||||
|
|
||||||
void Trace::xtermSetup(void) {
|
void Trace::xtermSetup(void) {
|
||||||
ptMaster = open("/dev/ptmx", O_RDWR);
|
ptMaster = open("/dev/ptmx", O_RDWR);
|
||||||
|
|
||||||
|
if (ptMaster != -1) {
|
||||||
grantpt( ptMaster );
|
grantpt( ptMaster );
|
||||||
|
|
||||||
unlockpt( ptMaster );
|
unlockpt( ptMaster );
|
||||||
|
@ -83,6 +85,7 @@ void Trace::xtermSetup(void) {
|
||||||
if (xtermPid == 0) {
|
if (xtermPid == 0) {
|
||||||
xtermLaunch( ptSlaveName );
|
xtermLaunch( ptSlaveName );
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
SC_HAS_PROCESS(Trace);
|
SC_HAS_PROCESS(Trace);
|
||||||
|
|
Loading…
Reference in New Issue