mirror of
https://github.com/vortexgpgpu/vortex.git
synced 2025-04-24 05:47:35 -04:00
Fix ifdef for 32 bit, add make commands for rtl
This commit is contained in:
parent
864349d812
commit
0887db4e05
7 changed files with 179 additions and 87 deletions
8
Makefile
8
Makefile
|
@ -19,4 +19,10 @@ clean-all:
|
|||
$(MAKE) -C sim clean
|
||||
$(MAKE) -C kernel clean
|
||||
$(MAKE) -C runtime clean
|
||||
$(MAKE) -C tests clean-all
|
||||
$(MAKE) -C tests clean-all
|
||||
|
||||
crtlsim:
|
||||
$(MAKE) -C sim clean
|
||||
|
||||
brtlsim:
|
||||
$(MAKE) -C sim
|
||||
|
|
|
@ -9,162 +9,168 @@
|
|||
#include "verilated_vpi.h"
|
||||
#include "VX_config.h"
|
||||
|
||||
#ifndef MODE_64_BIT
|
||||
#define INT_LEN int
|
||||
#else
|
||||
#define INT_LEN long int
|
||||
#endif
|
||||
|
||||
extern "C" {
|
||||
void dpi_fadd(bool enable, long int a, long int b, const svBitVecVal* frm, long int* result, svBitVecVal* fflags);
|
||||
void dpi_fsub(bool enable, long int a, long int b, const svBitVecVal* frm, long int* result, svBitVecVal* fflags);
|
||||
void dpi_fmul(bool enable, long int a, long int b, const svBitVecVal* frm, long int* result, svBitVecVal* fflags);
|
||||
void dpi_fmadd(bool enable, long int a, long int b, int c, const svBitVecVal* frm, long int* result, svBitVecVal* fflags);
|
||||
void dpi_fmsub(bool enable, long int a, long int b, int c, const svBitVecVal* frm, long int* result, svBitVecVal* fflags);
|
||||
void dpi_fnmadd(bool enable, long int a, long int b, int c, const svBitVecVal* frm, long int* result, svBitVecVal* fflags);
|
||||
void dpi_fnmsub(bool enable, long int a, long int b, int c, const svBitVecVal* frm, long int* result, svBitVecVal* fflags);
|
||||
void dpi_fadd(bool enable, INT_LEN a, INT_LEN b, const svBitVecVal* frm, INT_LEN* result, svBitVecVal* fflags);
|
||||
void dpi_fsub(bool enable, INT_LEN a, INT_LEN b, const svBitVecVal* frm, INT_LEN* result, svBitVecVal* fflags);
|
||||
void dpi_fmul(bool enable, INT_LEN a, INT_LEN b, const svBitVecVal* frm, INT_LEN* result, svBitVecVal* fflags);
|
||||
void dpi_fmadd(bool enable, INT_LEN a, INT_LEN b, int c, const svBitVecVal* frm, INT_LEN* result, svBitVecVal* fflags);
|
||||
void dpi_fmsub(bool enable, INT_LEN a, INT_LEN b, int c, const svBitVecVal* frm, INT_LEN* result, svBitVecVal* fflags);
|
||||
void dpi_fnmadd(bool enable, INT_LEN a, INT_LEN b, int c, const svBitVecVal* frm, INT_LEN* result, svBitVecVal* fflags);
|
||||
void dpi_fnmsub(bool enable, INT_LEN a, INT_LEN b, int c, const svBitVecVal* frm, INT_LEN* result, svBitVecVal* fflags);
|
||||
|
||||
void dpi_fdiv(bool enable, long int a, long int b, const svBitVecVal* frm, long int* result, svBitVecVal* fflags);
|
||||
void dpi_fsqrt(bool enable, int a, const svBitVecVal* frm, long int* result, svBitVecVal* fflags);
|
||||
void dpi_fdiv(bool enable, INT_LEN a, INT_LEN b, const svBitVecVal* frm, INT_LEN* result, svBitVecVal* fflags);
|
||||
void dpi_fsqrt(bool enable, int a, const svBitVecVal* frm, INT_LEN* result, svBitVecVal* fflags);
|
||||
|
||||
void dpi_ftoi(bool enable, int a, const svBitVecVal* frm, long int* result, svBitVecVal* fflags);
|
||||
void dpi_ftou(bool enable, int a, const svBitVecVal* frm, long int* result, svBitVecVal* fflags);
|
||||
void dpi_itof(bool enable, int a, const svBitVecVal* frm, long int* result, svBitVecVal* fflags);
|
||||
void dpi_utof(bool enable, int a, const svBitVecVal* frm, long int* result, svBitVecVal* fflags);
|
||||
void dpi_ftoi(bool enable, int a, const svBitVecVal* frm, INT_LEN* result, svBitVecVal* fflags);
|
||||
void dpi_ftou(bool enable, int a, const svBitVecVal* frm, INT_LEN* result, svBitVecVal* fflags);
|
||||
void dpi_itof(bool enable, int a, const svBitVecVal* frm, INT_LEN* result, svBitVecVal* fflags);
|
||||
void dpi_utof(bool enable, int a, const svBitVecVal* frm, INT_LEN* result, svBitVecVal* fflags);
|
||||
|
||||
void dpi_fclss(bool enable, long int a, long long int* result);
|
||||
void dpi_fsgnj(bool enable, long int a, long int b, long int* result);
|
||||
void dpi_fsgnjn(bool enable, long int a, long int b, long int* result);
|
||||
void dpi_fsgnjx(bool enable, long int a, long int b, long int* result);
|
||||
void dpi_fclss(bool enable, INT_LEN a, long INT_LEN* result);
|
||||
void dpi_fsgnj(bool enable, INT_LEN a, INT_LEN b, INT_LEN* result);
|
||||
void dpi_fsgnjn(bool enable, INT_LEN a, INT_LEN b, INT_LEN* result);
|
||||
void dpi_fsgnjx(bool enable, INT_LEN a, INT_LEN b, INT_LEN* result);
|
||||
|
||||
void dpi_flt(bool enable, long int a, long int b, long int* result, svBitVecVal* fflags);
|
||||
void dpi_fle(bool enable, long int a, long int b, long int* result, svBitVecVal* fflags);
|
||||
void dpi_feq(bool enable, long int a, long int b, long int* result, svBitVecVal* fflags);
|
||||
void dpi_fmin(bool enable, long int a, long int b, long int* result, svBitVecVal* fflags);
|
||||
void dpi_fmax(bool enable, long int a, long int b, long int* result, svBitVecVal* fflags);
|
||||
void dpi_flt(bool enable, INT_LEN a, INT_LEN b, INT_LEN* result, svBitVecVal* fflags);
|
||||
void dpi_fle(bool enable, INT_LEN a, INT_LEN b, INT_LEN* result, svBitVecVal* fflags);
|
||||
void dpi_feq(bool enable, INT_LEN a, INT_LEN b, INT_LEN* result, svBitVecVal* fflags);
|
||||
void dpi_fmin(bool enable, INT_LEN a, INT_LEN b, INT_LEN* result, svBitVecVal* fflags);
|
||||
void dpi_fmax(bool enable, INT_LEN a, INT_LEN b, INT_LEN* result, svBitVecVal* fflags);
|
||||
}
|
||||
|
||||
void dpi_fadd(bool enable, long int a, long int b, const svBitVecVal* frm, long int* result, svBitVecVal* fflags) {
|
||||
void dpi_fadd(bool enable, INT_LEN a, INT_LEN b, const svBitVecVal* frm, INT_LEN* result, svBitVecVal* fflags) {
|
||||
if (!enable)
|
||||
return;
|
||||
*result = rv_fadd_s(a, b, (*frm & 0x7), fflags);
|
||||
}
|
||||
|
||||
void dpi_fsub(bool enable, long int a, long int b, const svBitVecVal* frm, long int* result, svBitVecVal* fflags) {
|
||||
void dpi_fsub(bool enable, INT_LEN a, INT_LEN b, const svBitVecVal* frm, INT_LEN* result, svBitVecVal* fflags) {
|
||||
if (!enable)
|
||||
return;
|
||||
*result = rv_fsub_s(a, b, (*frm & 0x7), fflags);
|
||||
}
|
||||
|
||||
void dpi_fmul(bool enable, long int a, long int b, const svBitVecVal* frm, long int* result, svBitVecVal* fflags) {
|
||||
void dpi_fmul(bool enable, INT_LEN a, INT_LEN b, const svBitVecVal* frm, INT_LEN* result, svBitVecVal* fflags) {
|
||||
if (!enable)
|
||||
return;
|
||||
*result = rv_fmul_s(a, b, (*frm & 0x7), fflags);
|
||||
}
|
||||
|
||||
void dpi_fmadd(bool enable, long int a, long int b, int c, const svBitVecVal* frm, long int* result, svBitVecVal* fflags) {
|
||||
void dpi_fmadd(bool enable, INT_LEN a, INT_LEN b, int c, const svBitVecVal* frm, INT_LEN* result, svBitVecVal* fflags) {
|
||||
if (!enable)
|
||||
return;
|
||||
*result = rv_fmadd_s(a, b, c, (*frm & 0x7), fflags);
|
||||
}
|
||||
|
||||
void dpi_fmsub(bool enable, long int a, long int b, int c, const svBitVecVal* frm, long int* result, svBitVecVal* fflags) {
|
||||
void dpi_fmsub(bool enable, INT_LEN a, INT_LEN b, int c, const svBitVecVal* frm, INT_LEN* result, svBitVecVal* fflags) {
|
||||
if (!enable)
|
||||
return;
|
||||
*result = rv_fmsub_s(a, b, c, (*frm & 0x7), fflags);
|
||||
}
|
||||
|
||||
void dpi_fnmadd(bool enable, long int a, long int b, int c, const svBitVecVal* frm, long int* result, svBitVecVal* fflags) {
|
||||
void dpi_fnmadd(bool enable, INT_LEN a, INT_LEN b, int c, const svBitVecVal* frm, INT_LEN* result, svBitVecVal* fflags) {
|
||||
if (!enable)
|
||||
return;
|
||||
*result = rv_fnmadd_s(a, b, c, (*frm & 0x7), fflags);
|
||||
}
|
||||
|
||||
void dpi_fnmsub(bool enable, long int a, long int b, int c, const svBitVecVal* frm, long int* result, svBitVecVal* fflags) {
|
||||
void dpi_fnmsub(bool enable, INT_LEN a, INT_LEN b, int c, const svBitVecVal* frm, INT_LEN* result, svBitVecVal* fflags) {
|
||||
if (!enable)
|
||||
return;
|
||||
*result = rv_fnmsub_s(a, b, c, (*frm & 0x7), fflags);
|
||||
}
|
||||
|
||||
void dpi_fdiv(bool enable, long int a, long int b, const svBitVecVal* frm, long int* result, svBitVecVal* fflags) {
|
||||
void dpi_fdiv(bool enable, INT_LEN a, INT_LEN b, const svBitVecVal* frm, INT_LEN* result, svBitVecVal* fflags) {
|
||||
if (!enable)
|
||||
return;
|
||||
*result = rv_fdiv_s(a, b, (*frm & 0x7), fflags);
|
||||
}
|
||||
|
||||
void dpi_fsqrt(bool enable, int a, const svBitVecVal* frm, long int* result, svBitVecVal* fflags) {
|
||||
void dpi_fsqrt(bool enable, int a, const svBitVecVal* frm, INT_LEN* result, svBitVecVal* fflags) {
|
||||
if (!enable)
|
||||
return;
|
||||
*result = rv_fsqrt_s(a, (*frm & 0x7), fflags);
|
||||
}
|
||||
|
||||
void dpi_ftoi(bool enable, int a, const svBitVecVal* frm, long int* result, svBitVecVal* fflags) {
|
||||
void dpi_ftoi(bool enable, int a, const svBitVecVal* frm, INT_LEN* result, svBitVecVal* fflags) {
|
||||
if (!enable)
|
||||
return;
|
||||
*result = rv_ftoi_s(a, (*frm & 0x7), fflags);
|
||||
}
|
||||
|
||||
void dpi_ftou(bool enable, int a, const svBitVecVal* frm, long int* result, svBitVecVal* fflags) {
|
||||
void dpi_ftou(bool enable, int a, const svBitVecVal* frm, INT_LEN* result, svBitVecVal* fflags) {
|
||||
if (!enable)
|
||||
return;
|
||||
*result = rv_ftou_s(a, (*frm & 0x7), fflags);
|
||||
}
|
||||
|
||||
void dpi_itof(bool enable, int a, const svBitVecVal* frm, long int* result, svBitVecVal* fflags) {
|
||||
void dpi_itof(bool enable, int a, const svBitVecVal* frm, INT_LEN* result, svBitVecVal* fflags) {
|
||||
if (!enable)
|
||||
return;
|
||||
*result = rv_itof_s(a, (*frm & 0x7), fflags);
|
||||
}
|
||||
|
||||
void dpi_utof(bool enable, int a, const svBitVecVal* frm, long int* result, svBitVecVal* fflags) {
|
||||
void dpi_utof(bool enable, int a, const svBitVecVal* frm, INT_LEN* result, svBitVecVal* fflags) {
|
||||
if (!enable)
|
||||
return;
|
||||
*result = rv_utof_s(a, (*frm & 0x7), fflags);
|
||||
}
|
||||
|
||||
void dpi_flt(bool enable, long int a, long int b, long int* result, svBitVecVal* fflags) {
|
||||
void dpi_flt(bool enable, INT_LEN a, INT_LEN b, INT_LEN* result, svBitVecVal* fflags) {
|
||||
if (!enable)
|
||||
return;
|
||||
*result = rv_flt_s(a, b, fflags);
|
||||
}
|
||||
|
||||
void dpi_fle(bool enable, long int a, long int b, long int* result, svBitVecVal* fflags) {
|
||||
void dpi_fle(bool enable, INT_LEN a, INT_LEN b, INT_LEN* result, svBitVecVal* fflags) {
|
||||
if (!enable)
|
||||
return;
|
||||
*result = rv_fle_s(a, b, fflags);
|
||||
}
|
||||
|
||||
void dpi_feq(bool enable, long int a, long int b, long int* result, svBitVecVal* fflags) {
|
||||
void dpi_feq(bool enable, INT_LEN a, INT_LEN b, INT_LEN* result, svBitVecVal* fflags) {
|
||||
if (!enable)
|
||||
return;
|
||||
*result = rv_feq_s(a, b, fflags);
|
||||
}
|
||||
|
||||
void dpi_fmin(bool enable, long int a, long int b, long int* result, svBitVecVal* fflags) {
|
||||
void dpi_fmin(bool enable, INT_LEN a, INT_LEN b, INT_LEN* result, svBitVecVal* fflags) {
|
||||
if (!enable)
|
||||
return;
|
||||
*result = rv_fmin_s(a, b, fflags);
|
||||
}
|
||||
|
||||
void dpi_fmax(bool enable, long int a, long int b, long int* result, svBitVecVal* fflags) {
|
||||
void dpi_fmax(bool enable, INT_LEN a, INT_LEN b, INT_LEN* result, svBitVecVal* fflags) {
|
||||
if (!enable)
|
||||
return;
|
||||
*result = rv_fmax_s(a, b, fflags);
|
||||
}
|
||||
|
||||
void dpi_fclss(bool enable, long int a, long long int* result) {
|
||||
void dpi_fclss(bool enable, INT_LEN a, long INT_LEN* result) {
|
||||
if (!enable)
|
||||
return;
|
||||
*result = rv_fclss_s(a);
|
||||
}
|
||||
|
||||
void dpi_fsgnj(bool enable, long int a, long int b, long int* result) {
|
||||
void dpi_fsgnj(bool enable, INT_LEN a, INT_LEN b, INT_LEN* result) {
|
||||
if (!enable)
|
||||
return;
|
||||
*result = rv_fsgnj_s(a, b);
|
||||
}
|
||||
|
||||
void dpi_fsgnjn(bool enable, long int a, long int b, long int* result) {
|
||||
void dpi_fsgnjn(bool enable, INT_LEN a, INT_LEN b, INT_LEN* result) {
|
||||
if (!enable)
|
||||
return;
|
||||
*result = rv_fsgnjn_s(a, b);
|
||||
}
|
||||
|
||||
void dpi_fsgnjx(bool enable, long int a, long int b, long int* result) {
|
||||
void dpi_fsgnjx(bool enable, INT_LEN a, INT_LEN b, INT_LEN* result) {
|
||||
if (!enable)
|
||||
return;
|
||||
*result = rv_fsgnjx_s(a, b);
|
||||
|
|
|
@ -1,31 +1,39 @@
|
|||
`include "VX_config.vh"
|
||||
|
||||
`ifndef FLOAT_DPI
|
||||
`define FLOAT_DPI
|
||||
|
||||
import "DPI-C" function void dpi_fadd(input logic enable, input longint a, input longint b, input bit[2:0] frm, output longint result, output bit[4:0] fflags);
|
||||
import "DPI-C" function void dpi_fsub(input logic enable, input longint a, input longint b, input bit[2:0] frm, output longint result, output bit[4:0] fflags);
|
||||
import "DPI-C" function void dpi_fmul(input logic enable, input longint a, input longint b, input bit[2:0] frm, output longint result, output bit[4:0] fflags);
|
||||
import "DPI-C" function void dpi_fmadd(input logic enable, input longint a, input longint b, input longint c, input bit[2:0] frm, output longint result, output bit[4:0] fflags);
|
||||
import "DPI-C" function void dpi_fmsub(input logic enable, input longint a, input longint b, input longint c, input bit[2:0] frm, output longint result, output bit[4:0] fflags);
|
||||
import "DPI-C" function void dpi_fnmadd(input logic enable, input longint a, input longint b, input longint c, input bit[2:0] frm, output longint result, output bit[4:0] fflags);
|
||||
import "DPI-C" function void dpi_fnmsub(input logic enable, input longint a, input longint b, input longint c, input bit[2:0] frm, output longint result, output bit[4:0] fflags);
|
||||
`ifdef MODE_32_BIT
|
||||
`define INT_LEN int
|
||||
`else
|
||||
`define INT_LEN longint
|
||||
`endif
|
||||
|
||||
import "DPI-C" function void dpi_fdiv(input logic enable, input longint a, input longint b, input bit[2:0] frm, output longint result, output bit[4:0] fflags);
|
||||
import "DPI-C" function void dpi_fsqrt(input logic enable, input longint a, input bit[2:0] frm, output longint result, output bit[4:0] fflags);
|
||||
import "DPI-C" function void dpi_fadd(input logic enable, input `INT_LEN a, input `INT_LEN b, input bit[2:0] frm, output `INT_LEN result, output bit[4:0] fflags);
|
||||
import "DPI-C" function void dpi_fsub(input logic enable, input `INT_LEN a, input `INT_LEN b, input bit[2:0] frm, output `INT_LEN result, output bit[4:0] fflags);
|
||||
import "DPI-C" function void dpi_fmul(input logic enable, input `INT_LEN a, input `INT_LEN b, input bit[2:0] frm, output `INT_LEN result, output bit[4:0] fflags);
|
||||
import "DPI-C" function void dpi_fmadd(input logic enable, input `INT_LEN a, input `INT_LEN b, input `INT_LEN c, input bit[2:0] frm, output `INT_LEN result, output bit[4:0] fflags);
|
||||
import "DPI-C" function void dpi_fmsub(input logic enable, input `INT_LEN a, input `INT_LEN b, input `INT_LEN c, input bit[2:0] frm, output `INT_LEN result, output bit[4:0] fflags);
|
||||
import "DPI-C" function void dpi_fnmadd(input logic enable, input `INT_LEN a, input `INT_LEN b, input `INT_LEN c, input bit[2:0] frm, output `INT_LEN result, output bit[4:0] fflags);
|
||||
import "DPI-C" function void dpi_fnmsub(input logic enable, input `INT_LEN a, input `INT_LEN b, input `INT_LEN c, input bit[2:0] frm, output `INT_LEN result, output bit[4:0] fflags);
|
||||
|
||||
import "DPI-C" function void dpi_ftoi(input logic enable, input longint a, input bit[2:0] frm, output longint result, output bit[4:0] fflags);
|
||||
import "DPI-C" function void dpi_ftou(input logic enable, input longint a, input bit[2:0] frm, output longint result, output bit[4:0] fflags);
|
||||
import "DPI-C" function void dpi_itof(input logic enable, input longint a, input bit[2:0] frm, output longint result, output bit[4:0] fflags);
|
||||
import "DPI-C" function void dpi_utof(input logic enable, input longint a, input bit[2:0] frm, output longint result, output bit[4:0] fflags);
|
||||
import "DPI-C" function void dpi_fdiv(input logic enable, input `INT_LEN a, input `INT_LEN b, input bit[2:0] frm, output `INT_LEN result, output bit[4:0] fflags);
|
||||
import "DPI-C" function void dpi_fsqrt(input logic enable, input `INT_LEN a, input bit[2:0] frm, output `INT_LEN result, output bit[4:0] fflags);
|
||||
|
||||
import "DPI-C" function void dpi_fclss(input logic enable, input longint a, output longint result);
|
||||
import "DPI-C" function void dpi_fsgnj(input logic enable, input longint a, input longint b, output longint result);
|
||||
import "DPI-C" function void dpi_fsgnjn(input logic enable, input longint a, input longint b, output longint result);
|
||||
import "DPI-C" function void dpi_fsgnjx(input logic enable, input longint a, input longint b, output longint result);
|
||||
import "DPI-C" function void dpi_ftoi(input logic enable, input `INT_LEN a, input bit[2:0] frm, output `INT_LEN result, output bit[4:0] fflags);
|
||||
import "DPI-C" function void dpi_ftou(input logic enable, input `INT_LEN a, input bit[2:0] frm, output `INT_LEN result, output bit[4:0] fflags);
|
||||
import "DPI-C" function void dpi_itof(input logic enable, input `INT_LEN a, input bit[2:0] frm, output `INT_LEN result, output bit[4:0] fflags);
|
||||
import "DPI-C" function void dpi_utof(input logic enable, input `INT_LEN a, input bit[2:0] frm, output `INT_LEN result, output bit[4:0] fflags);
|
||||
|
||||
import "DPI-C" function void dpi_flt(input logic enable, input longint a, input longint b, output longint result, output bit[4:0] fflags);
|
||||
import "DPI-C" function void dpi_fle(input logic enable, input longint a, input longint b, output longint result, output bit[4:0] fflags);
|
||||
import "DPI-C" function void dpi_feq(input logic enable, input longint a, input longint b, output longint result, output bit[4:0] fflags);
|
||||
import "DPI-C" function void dpi_fmin(input logic enable, input longint a, input longint b, output longint result, output bit[4:0] fflags);
|
||||
import "DPI-C" function void dpi_fmax(input logic enable, input longint a, input longint b, output longint result, output bit[4:0] fflags);
|
||||
import "DPI-C" function void dpi_fclss(input logic enable, input `INT_LEN a, output `INT_LEN result);
|
||||
import "DPI-C" function void dpi_fsgnj(input logic enable, input `INT_LEN a, input `INT_LEN b, output `INT_LEN result);
|
||||
import "DPI-C" function void dpi_fsgnjn(input logic enable, input `INT_LEN a, input `INT_LEN b, output `INT_LEN result);
|
||||
import "DPI-C" function void dpi_fsgnjx(input logic enable, input `INT_LEN a, input `INT_LEN b, output `INT_LEN result);
|
||||
|
||||
import "DPI-C" function void dpi_flt(input logic enable, input `INT_LEN a, input `INT_LEN b, output `INT_LEN result, output bit[4:0] fflags);
|
||||
import "DPI-C" function void dpi_fle(input logic enable, input `INT_LEN a, input `INT_LEN b, output `INT_LEN result, output bit[4:0] fflags);
|
||||
import "DPI-C" function void dpi_feq(input logic enable, input `INT_LEN a, input `INT_LEN b, output `INT_LEN result, output bit[4:0] fflags);
|
||||
import "DPI-C" function void dpi_fmin(input logic enable, input `INT_LEN a, input `INT_LEN b, output `INT_LEN result, output bit[4:0] fflags);
|
||||
import "DPI-C" function void dpi_fmax(input logic enable, input `INT_LEN a, input `INT_LEN b, output `INT_LEN result, output bit[4:0] fflags);
|
||||
|
||||
`endif
|
||||
|
|
|
@ -4,17 +4,25 @@
|
|||
#include <vector>
|
||||
#include <mutex>
|
||||
#include <iostream>
|
||||
|
||||
#include "svdpi.h"
|
||||
#include "verilated_vpi.h"
|
||||
#include "VX_config.h"
|
||||
|
||||
#ifndef MODE_64_BIT
|
||||
#define INT_LEN int
|
||||
#else
|
||||
#define INT_LEN long int
|
||||
#endif
|
||||
|
||||
#ifndef DEBUG_LEVEL
|
||||
#define DEBUG_LEVEL 3
|
||||
#endif
|
||||
|
||||
|
||||
extern "C" {
|
||||
void dpi_imul(bool enable, long int a, long int b, bool is_signed_a, bool is_signed_b, long int* resultl, long int* resulth);
|
||||
void dpi_idiv(bool enable, long int a, long int b, bool is_signed, long int* quotient, long int* remainder);
|
||||
void dpi_imul(bool enable, INT_LEN a, INT_LEN b, bool is_signed_a, bool is_signed_b, INT_LEN* resultl, INT_LEN* resulth);
|
||||
void dpi_idiv(bool enable, INT_LEN a, INT_LEN b, bool is_signed, INT_LEN* quotient, INT_LEN* remainder);
|
||||
|
||||
int dpi_register();
|
||||
void dpi_assert(int inst, bool cond, int delay);
|
||||
|
@ -98,7 +106,33 @@ void dpi_assert(int inst, bool cond, int delay) {
|
|||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
#ifndef MODE_64_BIT
|
||||
void dpi_imul(bool enable, int a, int b, bool is_signed_a, bool is_signed_b, int* resultl, int* resulth) {
|
||||
if (!enable)
|
||||
return;
|
||||
|
||||
uint64_t first = *(uint32_t*)&a;
|
||||
uint64_t second = *(uint32_t*)&b;
|
||||
|
||||
if (is_signed_a && (first & 0x80000000)) {
|
||||
first |= 0xFFFFFFFF00000000;
|
||||
}
|
||||
|
||||
if (is_signed_b && (second & 0x80000000)) {
|
||||
second |= 0xFFFFFFFF00000000;
|
||||
}
|
||||
|
||||
uint64_t result;
|
||||
if (is_signed_a || is_signed_b) {
|
||||
result = (int64_t)first * (int64_t)second;
|
||||
} else {
|
||||
result = first * second;
|
||||
}
|
||||
|
||||
*resultl = result & 0xFFFFFFFF;
|
||||
*resulth = (result >> 32) & 0xFFFFFFFF;
|
||||
}
|
||||
#else
|
||||
void umul64wide (uint64_t a, uint64_t b, uint64_t *hi, uint64_t *lo)
|
||||
{
|
||||
uint64_t a_lo = (uint64_t)(uint32_t)a;
|
||||
|
@ -116,14 +150,12 @@ void umul64wide (uint64_t a, uint64_t b, uint64_t *hi, uint64_t *lo)
|
|||
*lo = p0 + (p1 << 32) + (p2 << 32);
|
||||
*hi = p3 + (p1 >> 32) + (p2 >> 32) + cy;
|
||||
}
|
||||
|
||||
|
||||
void dpi_imul(bool enable, long int a, long int b, bool is_signed_a, bool is_signed_b, long int* resultl, long int* resulth) {
|
||||
void dpi_imul(bool enable, INT_LEN a, INT_LEN b, bool is_signed_a, bool is_signed_b, INT_LEN* resultl, INT_LEN* resulth) {
|
||||
if (!enable)
|
||||
return;
|
||||
|
||||
uint64_t first = *(long int*)&a;
|
||||
uint64_t second = *(long int*)&b;
|
||||
uint64_t first = *(INT_LEN*)&a;
|
||||
uint64_t second = *(INT_LEN*)&b;
|
||||
|
||||
umul64wide (a, b, (uint64_t *)resulth, (uint64_t *)resultl);
|
||||
|
||||
|
@ -148,13 +180,44 @@ void dpi_imul(bool enable, long int a, long int b, bool is_signed_a, bool is_sig
|
|||
*resultl = result & 0xFFFFFFFF;
|
||||
*resulth = (result >> 32) & 0xFFFFFFFF;*/
|
||||
}
|
||||
#endif
|
||||
|
||||
void dpi_idiv(bool enable, long int a, long int b, bool is_signed, long int* quotient, long int* remainder) {
|
||||
#ifdef MODE_32_BIT
|
||||
void dpi_idiv(bool enable, int a, int b, bool is_signed, int* quotient, int* remainder) {
|
||||
if (!enable)
|
||||
return;
|
||||
|
||||
uint64_t dividen = *(long int*)&a;
|
||||
uint64_t divisor = *(long int*)&b;
|
||||
uint32_t dividen = *(uint32_t*)&a;
|
||||
uint32_t divisor = *(uint32_t*)&b;
|
||||
|
||||
if (is_signed) {
|
||||
if (b == 0) {
|
||||
*quotient = -1;
|
||||
*remainder = dividen;
|
||||
} else if (dividen == 0x80000000 && divisor == 0xffffffff) {
|
||||
*remainder = 0;
|
||||
*quotient = dividen;
|
||||
} else {
|
||||
*quotient = (int32_t)dividen / (int32_t)divisor;
|
||||
*remainder = (int32_t)dividen % (int32_t)divisor;
|
||||
}
|
||||
} else {
|
||||
if (b == 0) {
|
||||
*quotient = -1;
|
||||
*remainder = dividen;
|
||||
} else {
|
||||
*quotient = dividen / divisor;
|
||||
*remainder = dividen % divisor;
|
||||
}
|
||||
}
|
||||
}
|
||||
#else
|
||||
void dpi_idiv(bool enable, INT_LEN a, INT_LEN b, bool is_signed, INT_LEN* quotient, INT_LEN* remainder) {
|
||||
if (!enable)
|
||||
return;
|
||||
|
||||
uint64_t dividen = *(INT_LEN*)&a;
|
||||
uint64_t divisor = *(INT_LEN*)&b;
|
||||
|
||||
if (is_signed) {
|
||||
if (b == 0) {
|
||||
|
@ -178,6 +241,7 @@ void dpi_idiv(bool enable, long int a, long int b, bool is_signed, long int* quo
|
|||
}
|
||||
dpi_trace(1, "DIV - %d %lld %lld %lld %lld %lld %lld\n",is_signed , a, b, dividen, divisor, *quotient, *remainder);
|
||||
}
|
||||
#endif
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
|
|
@ -1,8 +1,15 @@
|
|||
`include "VX_config.vh"
|
||||
`ifndef UTIL_DPI
|
||||
`define UTIL_DPI
|
||||
|
||||
import "DPI-C" function void dpi_imul(input logic enable, input longint a, input longint b, input logic is_signed_a, input logic is_signed_b, output longint resultl, output longint resulth);
|
||||
import "DPI-C" function void dpi_idiv(input logic enable, input longint a, input longint b, input logic is_signed, output longint quotient, output longint remainder);
|
||||
`ifdef MODE_32_BIT
|
||||
`define INT_LEN int
|
||||
`else
|
||||
`define INT_LEN longint
|
||||
`endif
|
||||
|
||||
import "DPI-C" function void dpi_imul(input logic enable, input `INT_LEN a, input `INT_LEN b, input logic is_signed_a, input logic is_signed_b, output `INT_LEN resultl, output `INT_LEN resulth);
|
||||
import "DPI-C" function void dpi_idiv(input logic enable, input `INT_LEN a, input `INT_LEN b, input logic is_signed, output `INT_LEN quotient, output `INT_LEN remainder);
|
||||
|
||||
import "DPI-C" function int dpi_register();
|
||||
import "DPI-C" function void dpi_assert(int inst, input logic cond, input int delay);
|
||||
|
|
|
@ -20,11 +20,12 @@
|
|||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
// comment out the top or bottom two lines to switch between 64 and 32 bit mode
|
||||
// 64 bit by default. If you want 32 bit, compile with XLEN=32
|
||||
`ifndef XLEN
|
||||
`define XLEN 64
|
||||
`define MODE_64_BIT 1
|
||||
// `define XLEN 32
|
||||
// `define MODE_32_BIT 1
|
||||
`else
|
||||
`define MODE_`XLEN_BIT 1
|
||||
`endif
|
||||
|
||||
// Disable MULDIV, FPU, and TEX units since irrelevant to RV64I instructions
|
||||
|
|
|
@ -62,9 +62,9 @@ module VX_muldiv (
|
|||
|
||||
for (genvar i = 0; i < `NUM_THREADS; ++i) begin
|
||||
wire [`XLEN-1:0] mul_resultl, mul_resulth;
|
||||
wire [`XLEN-1:0] alu_in1_dpi = is_mulw ? (alu_in1[i] & 64'hFFFFFFFF) : alu_in1[i];
|
||||
wire [`XLEN-1:0] alu_in2_dpi = is_mulw ? (alu_in2[i] & 64'hFFFFFFFF) : alu_in2[i];
|
||||
always @(*) begin
|
||||
wire [`XLEN-1:0] alu_in1_dpi = is_mulw ? (alu_in1[i] & `XLEN'hFFFFFFFF) : alu_in1[i];
|
||||
wire [`XLEN-1:0] alu_in2_dpi = is_mulw ? (alu_in2[i] & `XLEN'hFFFFFFFF) : alu_in2[i];
|
||||
always @(*) begin
|
||||
dpi_imul (mul_fire_in, alu_in1_dpi, alu_in2_dpi, is_signed_mul_a, is_signed_mul_b, mul_resultl, mul_resulth);
|
||||
end
|
||||
assign mul_result_tmp[i] = is_mulh_in ? mul_resulth : (is_mulw ? `XLEN'($signed(mul_resultl[31:0])) : mul_resultl);
|
||||
|
@ -151,9 +151,9 @@ module VX_muldiv (
|
|||
wire div_fire_in = div_valid_in && div_ready_in;
|
||||
for (genvar i = 0; i < `NUM_THREADS; ++i) begin
|
||||
wire [`XLEN-1:0] div_quotient, div_remainder;
|
||||
wire [`XLEN-1:0] alu_in1_dpi = is_divuw ? (alu_in1[i] & 64'hFFFFFFFF) : (is_divw ? `XLEN'($signed(alu_in1[i][31:0])): alu_in1[i]);
|
||||
wire [`XLEN-1:0] alu_in2_dpi = is_divuw ? (alu_in2[i] & 64'hFFFFFFFF) : (is_divw ? `XLEN'($signed(alu_in2[i][31:0])): alu_in2[i]);
|
||||
always @(*) begin
|
||||
wire [`XLEN-1:0] alu_in1_dpi = is_divuw ? (alu_in1[i] & `XLEN'hFFFFFFFF) : (is_divw ? `XLEN'($signed(alu_in1[i][31:0])): alu_in1[i]);
|
||||
wire [`XLEN-1:0] alu_in2_dpi = is_divuw ? (alu_in2[i] & `XLEN'hFFFFFFFF) : (is_divw ? `XLEN'($signed(alu_in2[i][31:0])): alu_in2[i]);
|
||||
always @(*) begin
|
||||
dpi_idiv (div_fire_in, alu_in1_dpi, alu_in2_dpi, is_signed_div, div_quotient, div_remainder);
|
||||
end
|
||||
wire [`XLEN-1:0] div_quotient_out = (is_divuw | is_divw) ? `XLEN'($signed(div_quotient[31:0])) : div_quotient;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue