Fix verilator

This commit is contained in:
wgulian3 2020-02-13 13:18:06 -05:00
parent 8318aff69f
commit 86bfa4d1e4
6 changed files with 34 additions and 22 deletions

View file

@ -3,8 +3,8 @@
#define NW 8
// #define CACHE_NUM_BANKS 8
// #define CACHE_WORDS_PER_BLOCK 4
#define CACHE_NUM_BANKS 8
#define CACHE_WORDS_PER_BLOCK 4
#define R_INST 51
#define L_INST 3

View file

@ -167,11 +167,12 @@ uint32_t hToI(char *c, uint32_t size) {
void loadHexImpl(char * path,RAM* mem) {
void loadHexImpl(const char *path, RAM* mem) {
mem->clear();
FILE *fp = fopen(&path[0], "r");
FILE *fp = fopen(path, "r");
if(fp == 0){
printf("Path not found %s\n", path);
return;
// std::cout << path << " not found" << std::endl;
}
//Preload 0x0 <-> 0x80000000 jumps

View file

@ -83,7 +83,16 @@ int main(int argc, char **argv)
// char testing[] = "../../emulator/riscv_tests/rv32ui-p-sw.hex";
Vortex v;
char testing[] = "../../kernel/vortex_test.hex";
const char *testing;
if (argc >= 2) {
testing = argv[1];
} else {
testing = "../../kernel/vortex_test.hex";
}
std::cerr << testing << std::endl;
bool curr = v.simulate(testing);
if ( curr) std::cerr << GREEN << "Test Passed: " << testing << std::endl;

View file

@ -100,7 +100,7 @@ Vortex::~Vortex()
void Vortex::ProcessFile(void)
{
loadHexImpl("../../kernel/vortex_test.hex", &this->ram);
loadHexImpl(this->instruction_file_name.c_str(), &this->ram);
}
void Vortex::print_stats(bool cycle_test)
@ -206,12 +206,12 @@ bool Vortex::dbus_driver()
// printf("****************************\n");
vortex->i_m_ready = 0;
vortex->i_m_ready_d = 0;
for (int i = 0; i < CACHE_NUM_BANKS; i++)
{
for (int j = 0; j < CACHE_WORDS_PER_BLOCK; j++)
{
vortex->i_m_readdata[i][j] = 0;
vortex->i_m_readdata_d[i][j] = 0;
}
}
@ -220,7 +220,7 @@ bool Vortex::dbus_driver()
{
this->refill = false;
vortex->i_m_ready = 1;
vortex->i_m_ready_d = 1;
for (int curr_e = 0; curr_e < (CACHE_NUM_BANKS*CACHE_WORDS_PER_BLOCK); curr_e++)
{
unsigned new_addr = this->refill_addr + (4*curr_e);
@ -234,23 +234,23 @@ bool Vortex::dbus_driver()
unsigned value;
ram.getWord(new_addr, &value);
// printf("-------- (%x) i_m_readdata[%d][%d] (%d) = %d\n", new_addr, bank_num, offset_num, curr_e, value);
vortex->i_m_readdata[bank_num][offset_num] = value;
// printf("-------- (%x) i_m_readdata_d[%d][%d] (%d) = %d\n", new_addr, bank_num, offset_num, curr_e, value);
vortex->i_m_readdata_d[bank_num][offset_num] = value;
}
}
else
{
if (vortex->o_m_valid)
if (vortex->o_m_valid_d)
{
// printf("Valid o_m_valid\n");
if (vortex->o_m_read_or_write)
// printf("Valid o_m_valid_d\n");
if (vortex->o_m_read_or_write_d)
{
// printf("Valid write\n");
for (int curr_e = 0; curr_e < (CACHE_NUM_BANKS*CACHE_WORDS_PER_BLOCK); curr_e++)
{
unsigned new_addr = vortex->o_m_evict_addr + (4*curr_e);
unsigned new_addr = vortex->o_m_evict_addr_d + (4*curr_e);
unsigned addr_without_byte = new_addr >> 2;
@ -259,19 +259,19 @@ bool Vortex::dbus_driver()
unsigned offset_num = addr_wihtout_bank & 0x3;
unsigned new_value = vortex->o_m_writedata[bank_num][offset_num];
unsigned new_value = vortex->o_m_writedata_d[bank_num][offset_num];
ram.writeWord( new_addr, &new_value);
// printf("+++++++ (%x) writeback[%d][%d] (%d) = %d\n", new_addr, bank_num, offset_num, curr_e, new_value);
// printf("+++++++ (%x) i_m_readdata[%d][%d] (%d) = %d\n", new_addr, bank_num, offset_num, curr_e, value);
// printf("+++++++ (%x) i_m_readdata_d[%d][%d] (%d) = %d\n", new_addr, bank_num, offset_num, curr_e, value);
}
}
// Respond next cycle
this->refill = true;
this->refill_addr = vortex->o_m_read_addr;
this->refill_addr = vortex->o_m_read_addr_d;
}
}

View file

@ -1,10 +1,12 @@
COMP = ~/dev/riscv-gnu-toolchain/drops/bin/riscv32-unknown-elf-gcc
TOOLPATH ?= ~/dev/riscv-gnu-toolchain/drops/bin
COMP = $(TOOLPATH)/riscv32-unknown-elf-gcc
# CC_FLAGS = -march=rv32im -mabi=ilp32 -O0 -Wl,-Bstatic,-T,linker.ld -ffreestanding -nostdlib
CC_FLAGS = -march=rv32im -mabi=ilp32 -O0 -Wl,-Bstatic,-T,../vortex_link.ld -ffreestanding -nostartfiles
DMP = ~/dev/riscv-gnu-toolchain/drops/bin/riscv32-unknown-elf-objdump
CPY = ~/dev/riscv-gnu-toolchain/drops/bin/riscv32-unknown-elf-objcopy
DMP = $(TOOLPATH)/riscv32-unknown-elf-objdump
CPY = $(TOOLPATH)/riscv32-unknown-elf-objcopy
VX_STR = ../../startup/vx_start.s

View file

@ -106,7 +106,7 @@ int main()
vx_print_mat(z, arguments.numRows, arguments.numColums);
return 0;
return 1;
}