Attention une mise à jour du serveur va être effectuée le lundi 17 mai entre 13h et 13h30. Cette mise à jour va générer une interruption du service de quelques minutes.

Commit b9096f9c authored by logan's avatar logan

Riscv-compliance(signature output/makefile/linker/...)+debugging...

Riscv-compliance(signature output/makefile/linker/...)+debugging print+BasicSimulator Elf File modif
parent 3d8761dc
Pipeline #203618 failed with stages
in 51 seconds
......@@ -8,20 +8,24 @@
class BasicSimulator : public Simulator {
unsigned heapAddress;
// Signature address when doing compliance tests
ac_int<32, false>*begin_signature, *end_signature;
ac_int<32, false>*im, *dm;
FILE* inputFile;
FILE* outputFile;
FILE* traceFile;
FILE* signatureFile;
public:
BasicSimulator(const char* binaryFile, std::vector<std::string>, const char* inFile, const char* outFile,
const char* tFile);
const char* tFile, const char* sFile);
~BasicSimulator();
protected:
void printCycle();
void printEnd(){};
void printEnd();
void extend(){};
// Functions for memory accesses
......
......@@ -16,7 +16,7 @@ public:
doCycle(core, 0);
solveSyscall();
extend();
printCycle();
//printCycle();
}
printEnd();
}
......
......@@ -3,6 +3,7 @@
#include <stdio.h>
#include <stdlib.h>
#include <sys/stat.h>
#include <sys/time.h>
#include <unistd.h>
......@@ -11,8 +12,10 @@
#include "core.h"
#include "elfFile.h"
#define DEBUG 0
BasicSimulator::BasicSimulator(const char* binaryFile, std::vector<std::string> args, const char* inFile,
const char* outFile, const char* tFile)
const char* outFile, const char* tFile, const char* sFile)
{
char* coreAsChar = (char*)&core;
......@@ -23,7 +26,7 @@ BasicSimulator::BasicSimulator(const char* binaryFile, std::vector<std::string>
// core.im = new SimpleMemory<4>(im);
// core.dm = new SimpleMemory<4>(dm);
core.im = new CacheMemory<4, 16, 64>(new SimpleMemory<4>(im), false);
core.dm = new CacheMemory<4, 16, 64>(new SimpleMemory<4>(dm), false);
......@@ -32,23 +35,32 @@ BasicSimulator::BasicSimulator(const char* binaryFile, std::vector<std::string>
inputFile = stdin;
outputFile = stdout;
traceFile = stderr;
signatureFile = NULL;
if (inFile)
inputFile = fopen(inFile, "rb");
if (outFile)
outputFile = fopen(outFile, "wb");
if (tFile)
traceFile = fopen(tFile, "wb");
if(sFile)
signatureFile = fopen(sFile, "wb");
begin_signature = new ac_int<32, false>;
end_signature = new ac_int<32, false>;
//****************************************************************************
// Populate memory using ELF file
ElfFile elfFile(binaryFile);
for(auto const &section : *elfFile.sectionTable){
if(section->address != 0 && section->getName() != ".text"){
if(section->address != 0 && section->getName() != ".text" && section->getName() != ".text.init"){
unsigned char* sectionContent = section->getSectionCode();
for (unsigned byteNumber = 0; byteNumber < section->size; byteNumber++)
for (unsigned byteNumber = 0; byteNumber < section->size; byteNumber++){
if(DEBUG){
// printf("Load Instructions in Memory : %x\n", (section->address + byteNumber));
}
this->stb(section->address + byteNumber, sectionContent[byteNumber]);
}
// We update the size of the heap
if (section->address + section->size > heapAddress)
......@@ -56,16 +68,23 @@ BasicSimulator::BasicSimulator(const char* binaryFile, std::vector<std::string>
free(sectionContent);
}
if (section->getName() == ".text") {
if (section->getName() == ".text" || section->getName() == ".text.init") {
unsigned char* sectionContent = section->getSectionCode();
for (unsigned int byteNumber = 0; byteNumber < section->size; byteNumber++) {
// Write the instruction byte in Instruction Memory using Little Endian
if(DEBUG){
// printf(" Load Instructions in I-Memory : %x\n", (section->address + byteNumber));
}
im[(section->address + byteNumber) / 4].set_slc(((section->address + byteNumber) % 4) * 8,
ac_int<8, false>(sectionContent[byteNumber]));
}
free(sectionContent);
}
}
if(DEBUG){
printf("Populate Instruction Memory done.\n");
}
//****************************************************************************
// Looking for start symbol
......@@ -74,9 +93,18 @@ BasicSimulator::BasicSimulator(const char* binaryFile, std::vector<std::string>
const char* name = (const char*)&(sectionContent[symbol->name]);
if (strcmp(name, "_start") == 0)
core.pc = symbol->offset;
if (signatureFile != NULL){
if (strcmp(name, "begin_signature") == 0)
*begin_signature = symbol->offset;
else if (strcmp(name, "end_signature") == 0)
*end_signature = symbol->offset;
}
}
free(sectionContent);
if(DEBUG){
printf("Start Symbol Reading done.\n");
}
//****************************************************************************
// Adding command line arguments on the stack
unsigned int argc = args.size();
......@@ -101,6 +129,11 @@ BasicSimulator::BasicSimulator(const char* binaryFile, std::vector<std::string>
oneCharIndex++;
currentPlaceStrings += oneCharIndex;
}
if(DEBUG){
printf("Populate Data Memory done.\n");
}
core.regFile[2] = STACK_INIT;
}
......@@ -116,7 +149,7 @@ BasicSimulator::~BasicSimulator()
void BasicSimulator::printCycle()
{
if (!core.stallSignals[0] && 0) {
if (!core.stallSignals[0]) {
if (!core.stallSignals[0] && !core.stallIm && !core.stallDm) {
printf("Debug trace : %x ", (unsigned int)core.ftoDC.pc);
......@@ -130,6 +163,30 @@ void BasicSimulator::printCycle()
}
}
void BasicSimulator::printEnd()
{
/*
RISCV-COMPLIANCE Ending Routine to get the signature
stored between begin_signature and end_signature.
*/
if(signatureFile != NULL){
ac_int<32, false> wordNumber;
ac_int<32, false> addr_offset = 4;
ac_int<32, false> begin_offset = ((*begin_signature)%4); // correct address alignement
if(DEBUG){
printf("BEGIN/END_SIGNATURE: %x/%x (%x)", (unsigned int)(*begin_signature), (unsigned int)(*end_signature), (unsigned int)begin_offset);
}
//memory read
for (wordNumber = *begin_signature - begin_offset; wordNumber < *end_signature - begin_offset; wordNumber+=addr_offset)
{
fprintf(signatureFile, "%08x\n", (unsigned int)this->ldw(wordNumber));
}
}
}
// Function for handling memory accesses
void BasicSimulator::stb(ac_int<32, false> addr, ac_int<8, true> value)
......
......@@ -506,6 +506,7 @@ void forwardUnit(ac_int<5, false> decodeRs1, bool decodeUseRs1, ac_int<5, false>
void doCycle(struct Core& core, // Core containing all values
bool globalStall)
{
// printf("PC : %x\n", core.pc);
bool localStall = globalStall;
core.stallSignals[0] = 0;
......@@ -665,7 +666,7 @@ void doCore(bool globalStall, ac_int<32, false> imData[1 << 24], ac_int<32, fals
IncompleteMemory<4> imInterface = IncompleteMemory<4>(imData);
IncompleteMemory<4> dmInterface = IncompleteMemory<4>(dmData);
// CacheMemory dmCache = CacheMemory(&dmInterface, false);
CacheMemory<4, 16, 64> dmCache = CacheMemory<4, 16, 64>(&dmInterface, false);
core.im = &imInterface;
core.dm = &dmInterface;
......
......@@ -27,11 +27,11 @@ char needToFixEndianness = 0;
ElfFile::ElfFile(const char* pathToElfFile)
{
this->pathToElfFile = pathToElfFile;
this->elfFile = fopen(pathToElfFile, "r+");
if (this->elfFile == NULL) {
printf("Failing to open %s\n exiting...\n", pathToElfFile);
printf("[Comet Simulator] Failing to open %s\nexiting...\n", pathToElfFile);
exit(-1);
}
......@@ -48,7 +48,7 @@ ElfFile::ElfFile(const char* pathToElfFile)
else if (eident[EI_CLASS] == ELFCLASS64)
this->is32Bits = 0;
else {
fprintf(stderr, "Error while reading ELF file header, cannot handle this "
fprintf(stderr, "[Comet Simulator] Error while reading ELF file header, cannot handle this "
"type of ELF file...\n");
exit(-1);
}
......@@ -138,10 +138,11 @@ ElfFile::ElfFile(const char* pathToElfFile)
if (DEBUG)
for (unsigned int sectionNumber = 0; sectionNumber < tableSize; sectionNumber++) {
printf("(%u / %lu) ", sectionNumber, tableSize);
ElfSection* sect = this->sectionTable->at(sectionNumber);
printf("Section is at %x, of size %x\n", sect->offset, sect->size);
printf("Section %x is at %x (%x), of size %x\n", sect->nameIndex, sect->offset, sect->address, sect->size);
}
//*************************************************************************************
// Location of the String table containing every name
......@@ -199,6 +200,10 @@ ElfFile::ElfFile(const char* pathToElfFile)
break;
}
}
if(DEBUG){
printf("ELF FILE reading done.\n");
}
}
ElfFile::~ElfFile()
......
......@@ -11,16 +11,18 @@ int main(int argc, char** argv)
std::string inputFile;
std::string outputFile;
std::string traceFile;
std::string signatureFile;
std::vector<std::string> benchArgs, pargs;
CLI::App app{"Comet RISC-V Simulator"};
app.add_option("-f,--file", binaryFile, "Specifies the RISC-V program binary file (elf)")->required();
app.add_option("-i,--input", inputFile,
"Specifies the input file (used as standard input of the "
"runing program)");
"running program)");
app.add_option("-o,--output", outputFile, "Specifies the output file (standard output of the running program)");
app.add_option("-t,--trace-file", traceFile, "Specifies trace file for simulator output");
app.add_option("-a,--program-args", pargs, "Specifies command line arguments for the binary program");
app.add_option("-s,--signature-output", signatureFile, "Specifies signature file for testing purposes");
CLI11_PARSE(app, argc, argv);
......@@ -28,7 +30,7 @@ int main(int argc, char** argv)
benchArgs.push_back(binaryFile);
for (auto a : pargs)
benchArgs.push_back(a);
BasicSimulator sim(binaryFile.c_str(), benchArgs, inputFile.c_str(), outputFile.c_str(), traceFile.c_str());
BasicSimulator sim(binaryFile.c_str(), benchArgs, inputFile.c_str(), outputFile.c_str(), traceFile.c_str(), signatureFile.c_str());
sim.run();
......
File added
This diff is collapsed.
File added
This diff is collapsed.
No preview for this file type
.file "dct.c"
.option nopic
.attribute arch, "rv32i2p0"
.attribute unaligned_access, 0
.attribute stack_align, 16
.text
.align 2
.globl fast_fixed_dct8x8
.hidden fast_fixed_dct8x8
.type fast_fixed_dct8x8, @function
fast_fixed_dct8x8:
addi sp,sp,-560
sw ra,556(sp)
sw s0,552(sp)
addi s0,sp,560
sw a0,-548(s0)
sw a1,-552(s0)
sw zero,-20(s0)
j .L2
.L5:
sw zero,-24(s0)
j .L3
.L4:
lw a5,-20(s0)
slli a5,a5,4
lw a4,-548(s0)
add a4,a4,a5
lw a5,-24(s0)
slli a5,a5,1
add a5,a4,a5
lh a5,0(a5)
mv a3,a5
lw a5,-20(s0)
slli a4,a5,3
lw a5,-24(s0)
add a5,a4,a5
slli a5,a5,2
addi a4,s0,-16
add a5,a4,a5
sw a3,-264(a5)
lw a5,-24(s0)
addi a5,a5,1
sw a5,-24(s0)
.L3:
lw a4,-24(s0)
li a5,7
ble a4,a5,.L4
lw a5,-20(s0)
addi a5,a5,1
sw a5,-20(s0)
.L2:
lw a4,-20(s0)
li a5,7
ble a4,a5,.L5
sw zero,-20(s0)
j .L6
.L7:
addi a4,s0,-280
lw a5,-20(s0)
slli a5,a5,5
add a3,a4,a5
addi a4,s0,-536
lw a5,-20(s0)
slli a5,a5,5
add a5,a4,a5
mv a1,a5
mv a0,a3
call fast_fixed_dct8
lw a5,-20(s0)
addi a5,a5,1
sw a5,-20(s0)
.L6:
lw a4,-20(s0)
li a5,7
ble a4,a5,.L7
sw zero,-20(s0)
j .L8
.L11:
sw zero,-24(s0)
j .L9
.L10:
lw a5,-24(s0)
slli a4,a5,3
lw a5,-20(s0)
add a5,a4,a5
slli a5,a5,2
addi a4,s0,-16
add a5,a4,a5
lw a4,-520(a5)
lw a5,-20(s0)
slli a3,a5,3
lw a5,-24(s0)
add a5,a3,a5
slli a5,a5,2
addi a3,s0,-16
add a5,a3,a5
sw a4,-264(a5)
lw a5,-24(s0)
addi a5,a5,1
sw a5,-24(s0)
.L9:
lw a4,-24(s0)
li a5,7
ble a4,a5,.L10
lw a5,-20(s0)
addi a5,a5,1
sw a5,-20(s0)
.L8:
lw a4,-20(s0)
li a5,7
ble a4,a5,.L11
sw zero,-20(s0)
j .L12
.L13:
addi a4,s0,-280
lw a5,-20(s0)
slli a5,a5,5
add a3,a4,a5
addi a4,s0,-536
lw a5,-20(s0)
slli a5,a5,5
add a5,a4,a5
mv a1,a5
mv a0,a3
call fast_fixed_dct8
lw a5,-20(s0)
addi a5,a5,1
sw a5,-20(s0)
.L12:
lw a4,-20(s0)
li a5,7
ble a4,a5,.L13
sw zero,-20(s0)
j .L14
.L17:
sw zero,-24(s0)
j .L15
.L16:
lw a5,-24(s0)
slli a4,a5,3
lw a5,-20(s0)
add a5,a4,a5
slli a5,a5,2
addi a4,s0,-16
add a5,a4,a5
lw a2,-520(a5)
lw a5,-20(s0)
slli a5,a5,4
lw a4,-552(s0)
add a3,a4,a5
slli a4,a2,16
srai a4,a4,16
lw a5,-24(s0)
slli a5,a5,1
add a5,a3,a5
sh a4,0(a5)
lw a5,-24(s0)
addi a5,a5,1
sw a5,-24(s0)
.L15:
lw a4,-24(s0)
li a5,7
ble a4,a5,.L16
lw a5,-20(s0)
addi a5,a5,1
sw a5,-20(s0)
.L14:
lw a4,-20(s0)
li a5,7
ble a4,a5,.L17
nop
nop
lw ra,556(sp)
lw s0,552(sp)
addi sp,sp,560
jr ra
.size fast_fixed_dct8x8, .-fast_fixed_dct8x8
.align 2
.globl fast_fixed_dct8
.hidden fast_fixed_dct8
.type fast_fixed_dct8, @function
fast_fixed_dct8:
addi sp,sp,-112
sw s0,108(sp)
addi s0,sp,112
sw a0,-100(s0)
sw a1,-104(s0)
sw zero,-20(s0)
j .L19
.L20:
lw a5,-20(s0)
slli a5,a5,2
lw a4,-100(s0)
add a5,a4,a5
lw a4,0(a5)
li a3,7
lw a5,-20(s0)
sub a5,a3,a5
slli a5,a5,2
lw a3,-100(s0)
add a5,a3,a5
lw a5,0(a5)
add a4,a4,a5
lw a5,-20(s0)
slli a5,a5,2
addi a3,s0,-16
add a5,a3,a5
sw a4,-36(a5)
lw a5,-20(s0)
addi a5,a5,1
sw a5,-20(s0)
.L19:
lw a4,-20(s0)
li a5,3
ble a4,a5,.L20
li a5,4
sw a5,-20(s0)
j .L21
.L22:
li a4,7
lw a5,-20(s0)
sub a5,a4,a5
slli a5,a5,2
lw a4,-100(s0)
add a5,a4,a5
lw a4,0(a5)
lw a5,-20(s0)
slli a5,a5,2
lw a3,-100(s0)
add a5,a3,a5
lw a5,0(a5)
sub a4,a4,a5
lw a5,-20(s0)
slli a5,a5,2
addi a3,s0,-16
add a5,a3,a5
sw a4,-36(a5)
lw a5,-20(s0)
addi a5,a5,1
sw a5,-20(s0)
.L21:
lw a4,-20(s0)
li a5,7
ble a4,a5,.L22
lw a4,-52(s0)
lw a5,-40(s0)
add a5,a4,a5
sw a5,-84(s0)
lw a4,-48(s0)
lw a5,-44(s0)
add a5,a4,a5
sw a5,-80(s0)
lw a4,-48(s0)
lw a5,-44(s0)
sub a5,a4,a5
sw a5,-76(s0)
lw a4,-52(s0)
lw a5,-40(s0)
sub a5,a4,a5
sw a5,-72(s0)
lw a5,-36(s0)
sw a5,-68(s0)
lw a4,-28(s0)
lw a5,-32(s0)
sub a3,a4,a5
mv a4,a3
slli a5,a4,1
mv a4,a5
add a4,a4,a3
slli a5,a4,4
sub a5,a5,a4
slli a5,a5,2
add a5,a5,a3
slli a5,a5,6
add a5,a5,a3
slli a5,a5,1
srai a5,a5,15
sw a5,-64(s0)
lw a3,-32(s0)
mv a4,a3
slli a5,a4,1
mv a4,a5
add a4,a4,a3
slli a5,a4,4
sub a5,a5,a4
slli a5,a5,2
add a5,a5,a3
slli a5,a5,6
add a5,a5,a3
slli a5,a5,2
srai a5,a5,15
sw a5,-60(s0)
lw a5,-24(s0)
sw a5,-56(s0)
lw a4,-84(s0)
lw a5,-80(s0)
add a3,a4,a5
mv a4,a3
slli a5,a4,1
mv a4,a5
add a4,a4,a3
slli a5,a4,4
sub a5,a5,a4
slli a5,a5,2
add a5,a5,a3
slli a5,a5,6
add a5,a5,a3
slli a5,a5,1
srai a5,a5,15
sw a5,-52(s0)
lw a4,-84(s0)
lw a5,-80(s0)
sub a3,a4,a5
mv a4,a3
slli a5,a4,1