Fix verilator

This commit is contained in:
wgulian3 2020-02-13 13:18:06 -05:00
parent 0e0ea52568
commit e662ef4134
6 changed files with 36 additions and 22 deletions

View file

@ -3,8 +3,8 @@
#define NW 8 #define NW 8
// #define CACHE_NUM_BANKS 8 #define CACHE_NUM_BANKS 8
// #define CACHE_WORDS_PER_BLOCK 4 #define CACHE_WORDS_PER_BLOCK 4
#define R_INST 51 #define R_INST 51
#define L_INST 3 #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(); mem->clear();
FILE *fp = fopen(&path[0], "r"); FILE *fp = fopen(path, "r");
if(fp == 0){ if(fp == 0){
printf("Path not found %s\n", path); printf("Path not found %s\n", path);
return;
// std::cout << path << " not found" << std::endl; // std::cout << path << " not found" << std::endl;
} }
//Preload 0x0 <-> 0x80000000 jumps //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"; // char testing[] = "../../emulator/riscv_tests/rv32ui-p-sw.hex";
Vortex v; 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); bool curr = v.simulate(testing);
if ( curr) std::cerr << GREEN << "Test Passed: " << testing << std::endl; if ( curr) std::cerr << GREEN << "Test Passed: " << testing << std::endl;

View file

@ -100,7 +100,7 @@ Vortex::~Vortex()
void Vortex::ProcessFile(void) 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) void Vortex::print_stats(bool cycle_test)
@ -206,12 +206,12 @@ bool Vortex::dbus_driver()
// printf("****************************\n"); // printf("****************************\n");
vortex->i_m_ready = 0; vortex->i_m_ready_d = 0;
for (int i = 0; i < CACHE_NUM_BANKS; i++) for (int i = 0; i < CACHE_NUM_BANKS; i++)
{ {
for (int j = 0; j < CACHE_WORDS_PER_BLOCK; j++) 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; 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++) 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); unsigned new_addr = this->refill_addr + (4*curr_e);
@ -234,23 +234,23 @@ bool Vortex::dbus_driver()
unsigned value; unsigned value;
ram.getWord(new_addr, &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); // printf("-------- (%x) i_m_readdata_d[%d][%d] (%d) = %d\n", new_addr, bank_num, offset_num, curr_e, value);
vortex->i_m_readdata[bank_num][offset_num] = value; vortex->i_m_readdata_d[bank_num][offset_num] = value;
} }
} }
else else
{ {
if (vortex->o_m_valid) if (vortex->o_m_valid_d)
{ {
// printf("Valid o_m_valid\n"); // printf("Valid o_m_valid_d\n");
if (vortex->o_m_read_or_write) if (vortex->o_m_read_or_write_d)
{ {
// printf("Valid write\n"); // printf("Valid write\n");
for (int curr_e = 0; curr_e < (CACHE_NUM_BANKS*CACHE_WORDS_PER_BLOCK); curr_e++) 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; unsigned addr_without_byte = new_addr >> 2;
@ -259,19 +259,19 @@ bool Vortex::dbus_driver()
unsigned offset_num = addr_wihtout_bank & 0x3; 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); 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) 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 // Respond next cycle
this->refill = true; 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,14 @@
COMP = ../../../../riscv-gnu-toolchain/drops/bin/riscv32-unknown-elf-gcc # To set a custom TOOLPATH, call make like this:
# TOOLPATH=../../../../riscv-gnu-toolchain/drops/bin make ...
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,linker.ld -ffreestanding -nostdlib
CC_FLAGS = -march=rv32im -mabi=ilp32 -O0 -Wl,-Bstatic,-T,../vortex_link.ld -ffreestanding -nostartfiles CC_FLAGS = -march=rv32im -mabi=ilp32 -O0 -Wl,-Bstatic,-T,../vortex_link.ld -ffreestanding -nostartfiles
DMP = ../../../../riscv-gnu-toolchain/drops/bin/riscv32-unknown-elf-objdump DMP = $(TOOLPATH)/riscv32-unknown-elf-objdump
CPY = ../../../../riscv-gnu-toolchain/drops/bin/riscv32-unknown-elf-objcopy CPY = $(TOOLPATH)/riscv32-unknown-elf-objcopy
VX_STR = ../../startup/vx_start.s VX_STR = ../../startup/vx_start.s

View file

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