Fixed some warnings from coverity

This commit is contained in:
mariusmonton 2020-04-10 16:43:22 +02:00
parent 9796130cb5
commit 5d30416955
6 changed files with 41 additions and 20 deletions

7
.gitignore vendored
View File

@ -38,3 +38,10 @@ helper.ods
*.swp
RISCV_TLM
dump
.project
.cproject
.settings
doc/Drawings.odg
doc/html
env.sh
gh-md-toc

View File

@ -1,6 +1,6 @@
/*!
\file Registers.h
\brief Basic register file implementation
\brief Basic register file
\author Màrius Montón
\date August 2018
*/

View File

@ -1558,7 +1558,7 @@ bool Execute::M_MUL(Instruction &inst) {
multiplier = regs->getValue(rs1);
multiplicand = regs->getValue(rs2);
result = multiplier * multiplicand;
result = (int64_t) multiplier * multiplicand;
result = result & 0x00000000FFFFFFFF;
regs->setValue(rd, result);

View File

@ -29,6 +29,10 @@ Memory::Memory(sc_module_name name, bool use_file): sc_module(name)
memory_offset = 0;
program_counter = 0;
//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") {
/* Extended segment address */
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") {
/* Start segment address */
uint32_t code_segment;
code_segment = stol(line.substr(9,4), nullptr, 16) * 16; /* ? */
program_counter = stol(line.substr(13,4), nullptr, 16);
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") {
/* Start segment address */
memory_offset = stol(line.substr(9,4), nullptr, 16) << 16;
extended_address = 0;
cout << "04 address set to 0x" << hex << extended_address << endl;
cout << "04 offset set to 0x" << hex << memory_offset << endl;
cout << "04 address set to 0x" << hex << extended_address << dec << endl;
cout << "04 offset set to 0x" << hex << memory_offset << dec << endl;
} else if (line.substr(7,2) == "05") {
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;
}
}
}

View File

@ -1,3 +1,10 @@
/*!
\file Registers.cpp
\brief Basic register file implementation
\author Màrius Montón
\date August 2018
*/
#include "Registers.h"
Registers::Registers() {
@ -58,7 +65,7 @@ void Registers::dump(void) {
cout << " x30 (t5): " << right << setw(11) << register_bank[30];
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;
}

View File

@ -64,24 +64,27 @@ void Trace::xtermKill( const char *mess ) {
void Trace::xtermSetup(void) {
ptMaster = open("/dev/ptmx", O_RDWR);
grantpt( ptMaster );
if (ptMaster != -1) {
grantpt( ptMaster );
unlockpt( ptMaster );
unlockpt( ptMaster );
char *ptSlaveName = ptsname( ptMaster );
ptSlave = open( ptSlaveName, O_RDWR ); // In and out are the same
char *ptSlaveName = ptsname( ptMaster );
ptSlave = open( ptSlaveName, O_RDWR ); // In and out are the same
struct termios termInfo;
tcgetattr( ptSlave, &termInfo );
struct termios termInfo;
tcgetattr( ptSlave, &termInfo );
termInfo.c_lflag &= ~ECHO;
termInfo.c_lflag &= ~ICANON;
tcsetattr( ptSlave, TCSADRAIN, &termInfo );
termInfo.c_lflag &= ~ECHO;
termInfo.c_lflag &= ~ICANON;
tcsetattr( ptSlave, TCSADRAIN, &termInfo );
xtermPid = fork();
xtermPid = fork();
if (xtermPid == 0) {
xtermLaunch( ptSlaveName );
if (xtermPid == 0) {
xtermLaunch( ptSlaveName );
}
}
}