提交 614e4334 编写于 作者: 饶先宏's avatar 饶先宏

202109070637

上级 e71b3d24
......@@ -993,6 +993,8 @@ set_global_assignment -name POWER_BOARD_THERMAL_MODEL "NONE (CONSERVATIVE)"
set_global_assignment -name PARTITION_NETLIST_TYPE SOURCE -section_id Top
set_global_assignment -name PARTITION_FITTER_PRESERVATION_LEVEL PLACEMENT_AND_ROUTING -section_id Top
set_global_assignment -name PARTITION_COLOR 16764057 -section_id Top
set_global_assignment -name VERILOG_FILE ../verilog/alu/mul32.v
set_global_assignment -name VERILOG_FILE ../verilog/alu/div32.v
set_global_assignment -name VERILOG_FILE ../verilog/altera/regfile/regfile.v
set_global_assignment -name VERILOG_FILE qsys/pllqsys/synthesis/submodules/pllqsys_altpll_0.v
set_global_assignment -name VERILOG_FILE qsys/pllqsys/synthesis/pllqsys.v
......
......@@ -3,7 +3,7 @@
// This code is generated by Terasic System Builder
//=======================================================
`define USECLOCK50__
`define USECLOCK50
module de2_riscv_v4(
//////////// CLOCK //////////
......
......@@ -3,7 +3,7 @@
#define REFFREQ 50000000
static volatile unsigned int* _uartaddr = UARTADDRESS;
static volatile unsigned int _uartstate;
static volatile unsigned int _uartstate = 0;
/*
地址 0 -- 读接收数据
......@@ -110,6 +110,39 @@ static int _d2s(char* buf, long long num)
return len;
}
static int _i2s(char* buf, int num)
{
int i;
int len;
int sign;
len = 0;
sign = 0;
if (num < 0) {
num = -num;
sign = 0;
}
if (num == 0)
buf[len++] = '0';
else {
while (num > 0) {
buf[len++] = (num % 10) + '0';
num /= 10;
}
if (sign)
buf[len++] = '-';
}
for (i = 0; i < len / 2; i++) {
int di = len - 1 - i;
char temp;
temp = buf[i];
buf[i] = buf[di];
buf[di] = temp;
}
buf[len] = 0;
return len;
}
static int _h2s(char* buf, unsigned long long num, int fixlen, char lead)
{
int i;
......@@ -270,22 +303,28 @@ static void dispmem()
char buf[256];
for (j = 0; j < 16; j++) {
_h2s(buf, startaddr, 8, '0');
_strcat(buf, " ");
_puts(buf);
//_strcat(buf, " ");
_puts(" ");
for (i = 0; i < 16; i++) {
unsigned char* disp = (unsigned char*)startaddr;
if (startaddr + i < displayaddr) {
_strcat(buf, " ");
//_strcat(buf, " ");
_puts(" ");
}
else {
char temp[8];
_h2s(temp, disp[i], 2, '0');
_strcat(temp, " ");
_strcat(buf, temp);
_puts(temp);
_puts(" ");
//_strcat(temp, " ");
//_strcat(buf, temp);
}
if (i == 7)
_strcat(buf, "- ");
_puts("-");//_strcat(buf, "- ");
}
_strcat(buf, " |");
//_strcat(buf, " |");
_puts(" |");
for (i = 0; i < 16; i++) {
unsigned char* disp = (unsigned char*)startaddr;
char temp[2];
......@@ -295,11 +334,13 @@ static void dispmem()
else {
temp[0] = '.';
}
temp[1] = 0;
_strcat(buf, temp);
//temp[1] = 0;
//_strcat(buf, temp);
_putchar(temp[0]);
}
_strcat(buf, "|\n");
_puts(buf);
_puts("|\n");
//_strcat(buf, "|\n");
//_puts(buf);
startaddr += 16;
if ( (startaddr & 0xff) == 0)
break;
......@@ -390,12 +431,16 @@ DEFINECSRGETCLEAR(clear_all_counter, 0xc40)
DEFINECSRGETCLEAR(stop_all_counter, 0xc41)
#define TESTMAD 1
#define TESTMAD 0
#define TESTSTATUS 0
#if TESTSTATUS
#define TESTMADCOUNT 11
typedef unsigned long long (*statusget)();
typedef void (*statusclear)();
statusget statusgetfuncs[10] = {
statusget statusgetfuncs[TESTMADCOUNT] = {
instrcount,
cycle,
get_counter_addsub,
get_counter_mul,
get_counter_div,
......@@ -408,8 +453,9 @@ statusget statusgetfuncs[10] = {
};
const char* statusname[10] = {
const char* statusname[TESTMADCOUNT] = {
"total : ",
"cycle : ",
"add/sub : ",
"mul : ",
"div : ",
......@@ -427,7 +473,7 @@ static void liststatus()
unsigned long long total = instrcount();
unsigned long long num;
int i;
for (i = 0; i < 10; i++) {
for (i = 0; i < TESTMADCOUNT; i++) {
_puts("\n");
_puts(statusname[i]);
num = statusgetfuncs[i]();
......@@ -440,6 +486,7 @@ static void liststatus()
}
_puts("\n\r");
}
#endif
#if TESTMAD
#define LEN 1024
......@@ -471,7 +518,7 @@ static void printhelp()
_puts(" width=1, 2 or 4\n");
}
#define TESTISA 1
#define TESTISA 0
#if TESTISA
......@@ -528,6 +575,10 @@ void testisa()
#endif
#define RATEISA 0
#define LISTSTATUS 0
int main(int argc, char* argv[])
{
volatile unsigned int* ledkey = (unsigned int*)0xF0000000;
......@@ -544,9 +595,10 @@ int main(int argc, char* argv[])
count1 = 0;
do {
char buf[256];
int rate;
rate = cycle() / (instrcount() / 100);
if (_canputchar()) {
#if RATEISA
int rate;
rate = cycle() / (instrcount() / 100);
_h2s(buf, cycle(), 8, '0');
_puts(buf);
_puts(":");
......@@ -555,6 +607,7 @@ int main(int argc, char* argv[])
_puts(":");
_d2s(buf, rate);
_puts(buf);
#endif
_puts(">>");
}
do {
......@@ -600,15 +653,17 @@ int main(int argc, char* argv[])
_puts("\n\r:");
_puts(buf);
_puts("\n\r");
if (_strncmp(buf, "help ", 4) == 0) {
if (buf[0] == 'h') {
printhelp();
}
#if LISTSTATUS
else if (buf[0] == 'c') {
clear_all_counter();
}
else if (buf[0] == 'l') {
liststatus();
}
#endif
#if TESTISA
else if (buf[0] == 't') {
testisa();
......@@ -677,7 +732,7 @@ int main(int argc, char* argv[])
_h2s(buf, addr, 8, '0');
_puts(buf);
_puts(" = ");
_d2s(buf, value);
_i2s(buf, value);
_puts(buf);
_puts("(");
_h2s(buf, value, width * 2, '0');
......
.macro DEFINECSRGET csrname, csrno
.macro DEFINECSRGET1 csrname, csrno
.global \csrname
.align 2
.type \csrname, @function
......@@ -25,9 +25,35 @@
.macro DEFINECSRGETCLEAR csrname, csrno
.endm
.macro DEFINECSRGET csrname, csrno
.endm
.text
.global __start
.type __start, @function
__start:
# Initialize global pointer
.option push
.option norelax
1:auipc gp, %pcrel_hi(__global_pointer$)
addi gp, gp, %pcrel_lo(1b)
.option pop
# Clear the bss segment
la a0, _edata
la a2, _end
sub a2, a2, a0
li a1, 0
call memset
lw a0, 0(sp) # a0 = argc
addi a1, sp, __SIZEOF_POINTER__ # a1 = argv
li a2, 0 # a2 = envp = NULL
call main
tail exit
.size __start, .-__start
DEFINECSRGET cycle, 0xc00
DEFINECSRGETCLEAR cycle_clear, 0xc00
DEFINECSRGET instrcount, 0xc02
......
/*======================================================================*/
/* Proxy kernel linker script */
/*======================================================================*/
/* This is the linker script used when building the proxy kernel. */
/*----------------------------------------------------------------------*/
/* Setup */
/*----------------------------------------------------------------------*/
/* The OUTPUT_ARCH command specifies the machine architecture where the
argument is one of the names used in the BFD library. More
specifically one of the entires in bfd/cpu-mips.c */
OUTPUT_ARCH( "riscv" )
ENTRY(_start)
/*----------------------------------------------------------------------*/
/* Sections */
/*----------------------------------------------------------------------*/
SECTIONS
{
/* text: test code section */
. = 0x00000000;
.text.init : { *(.text.init) }
. = ALIGN(0x1000);
.tohost : { *(.tohost) }
. = ALIGN(0x1000);
.text : { *(.text) }
/* data segment */
.data : { *(.data) }
.sdata : {
__global_pointer$ = . + 0x800;
*(.srodata.cst16) *(.srodata.cst8) *(.srodata.cst4) *(.srodata.cst2) *(.srodata*)
*(.sdata .sdata.* .gnu.linkonce.s.*)
}
/* bss segment */
.sbss : {
*(.sbss .sbss.* .gnu.linkonce.sb.*)
*(.scommon)
}
.bss : { *(.bss) }
/* thread-local data segment */
.tdata :
{
_tdata_begin = .;
*(.tdata)
_tdata_end = .;
}
.tbss :
{
*(.tbss)
_tbss_end = .;
}
/* End of uninitalized data segement */
_end = .;
}
int testadd()
{
int i;
int a[16] = { 822056645, -893578039, -1592839155, -208906095, 2081039957, 643924313, 1970441629, -1184321759, 2067696101, -1048444439, 307772205, 1455528369, 52281717, 686790265, 1440824509, 1678252097, };
int b[16] = { 360704632, 399278188, -1024445792, 1991759124, -1322091576, -144344388, -1237293584, -1345253020, -927493864, 1239038220, -363225792, 902074804, 579611240, -323503268, -1999054704, 1128224260, };
int c[16] = { 1182761277, -494299851, 1677682349, 1782853029, 758948381, 499579925, 733148045, 1765392517, 1140202237, 190593781, -55453587, -1937364123, 631892957, 363286997, -558230195, -1488490939, };
int a[16] = { -1515702165, -1191830961, 21877619, -842618921, 637344635, -675876257, 130494595, 1244797415, -2054081909, 632766063, 1637106067, -1738965001, 165510555, 1849687679, 818808483, 1378212359, };
int b[16] = { 1734876550, -2094331942, 582839406, 1391034178, 468300886, -394477654, 1664718142, -1104975598, -1736593626, -153085062, 25862670, 2096723682, 817434102, -1334174902, 996512478, -1515149134, };
int c[16] = { 219174385, 1008804393, 604717025, 548415257, 1105645521, -1070353911, 1795212737, 139821817, 504291761, 479681001, 1662968737, 357758681, 982944657, 515512777, 1815320961, -136936775, };
for (i = 0; i < 16; i++) {
if (a[i] + b[i] != c[i])
return i;
......@@ -13,9 +13,9 @@ int testadd()
int testsub()
{
int i;
int a[16] = { 822056645, -893578039, -1592839155, -208906095, 2081039957, 643924313, 1970441629, -1184321759, 2067696101, -1048444439, 307772205, 1455528369, 52281717, 686790265, 1440824509, 1678252097, };
int b[16] = { 360704632, 399278188, -1024445792, 1991759124, -1322091576, -144344388, -1237293584, -1345253020, -927493864, 1239038220, -363225792, 902074804, 579611240, -323503268, -1999054704, 1128224260, };
int c[16] = { 461352013, -1292856227, -568393363, 2094302077, -891835763, 788268701, -1087232083, 160931261, -1299777331, 2007484637, 670997997, 553453565, -527329523, 1010293533, -855088083, 550027837, };
int a[16] = { -1515702165, -1191830961, 21877619, -842618921, 637344635, -675876257, 130494595, 1244797415, -2054081909, 632766063, 1637106067, -1738965001, 165510555, 1849687679, 818808483, 1378212359, };
int b[16] = { 1734876550, -2094331942, 582839406, 1391034178, 468300886, -394477654, 1664718142, -1104975598, -1736593626, -153085062, 25862670, 2096723682, 817434102, -1334174902, 996512478, -1515149134, };
int c[16] = { 1044388581, 902500981, -560961787, 2061314197, 169043749, -281398603, -1534223547, -1945194283, -317488283, 785851125, 1611243397, 459278613, -651923547, -1111104715, -177703995, -1401605803, };
for (i = 0; i < 16; i++) {
if (a[i] - b[i] != c[i])
return i;
......@@ -25,9 +25,9 @@ int testsub()
int testmul()
{
int i;
int a[16] = { 822056645, -893578039, -1592839155, -208906095, 2081039957, 643924313, 1970441629, -1184321759, 2067696101, -1048444439, 307772205, 1455528369, 52281717, 686790265, 1440824509, 1678252097, };
int b[16] = { 360704632, 399278188, -1024445792, 1991759124, -1322091576, -144344388, -1237293584, -1345253020, -927493864, 1239038220, -363225792, 902074804, 579611240, -323503268, -1999054704, 1128224260, };
int c[16] = { -1940275624, -1319811892, 1205539360, -229732268, 166906216, -1906546852, 1384363056, -378103324, 1957339768, 367982572, 1727947840, -122597004, 2077215112, -712804740, 23700048, 1128609540, };
int a[16] = { -1515702165, -1191830961, 21877619, -842618921, 637344635, -675876257, 130494595, 1244797415, -2054081909, 632766063, 1637106067, -1738965001, 165510555, 1849687679, 818808483, 1378212359, };
int b[16] = { 1734876550, -2094331942, 582839406, 1391034178, 468300886, -394477654, 1664718142, -1104975598, -1736593626, -153085062, 25862670, 2096723682, 817434102, -1334174902, 996512478, -1515149134, };
int c[16] = { -1125538046, 344952902, -963879062, 992603758, -1236486318, 1012257814, 1201995450, -1061514946, 1257866658, -1744210458, 332962826, -616705522, -1891986958, 920450486, 29472602, 1563832542, };
for (i = 0; i < 16; i++) {
if (a[i] * b[i] != c[i])
return i;
......@@ -37,9 +37,9 @@ int testmul()
int testdiv()
{
int i;
int a[16] = { 822056645, -893578039, -1592839155, -208906095, 2081039957, 643924313, 1970441629, -1184321759, 2067696101, -1048444439, 307772205, 1455528369, 52281717, 686790265, 1440824509, 1678252097, };
int b[16] = { 360704632, 399278188, -1024445792, 1991759124, -1322091576, -144344388, -1237293584, -1345253020, -927493864, 1239038220, -363225792, 902074804, 579611240, -323503268, -1999054704, 1128224260, };
int c[16] = { 2, -2, 1, 0, -1, -4, -1, 0, -2, 0, 0, 1, 0, -2, 0, 1, };
int a[16] = { -1515702165, -1191830961, 21877619, -842618921, 637344635, -675876257, 130494595, 1244797415, -2054081909, 632766063, 1637106067, -1738965001, 165510555, 1849687679, 818808483, 1378212359, };
int b[16] = { 1734876550, -2094331942, 582839406, 1391034178, 468300886, -394477654, 1664718142, -1104975598, -1736593626, -153085062, 25862670, 2096723682, 817434102, -1334174902, 996512478, -1515149134, };
int c[16] = { 0, 0, 0, 0, 1, 1, 0, -1, 1, -4, 63, 0, 0, -1, 0, 0, };
for (i = 0; i < 16; i++) {
if (a[i] / b[i] != c[i])
return i;
......@@ -49,9 +49,9 @@ int testdiv()
int testmod()
{
int i;
int a[16] = { 822056645, -893578039, -1592839155, -208906095, 2081039957, 643924313, 1970441629, -1184321759, 2067696101, -1048444439, 307772205, 1455528369, 52281717, 686790265, 1440824509, 1678252097, };
int b[16] = { 360704632, 399278188, -1024445792, 1991759124, -1322091576, -144344388, -1237293584, -1345253020, -927493864, 1239038220, -363225792, 902074804, 579611240, -323503268, -1999054704, 1128224260, };
int c[16] = { 100647381, -95021663, -568393363, -208906095, 758948381, 66546761, 733148045, -1184321759, 212708373, -1048444439, 307772205, 553453565, 52281717, 39783729, 1440824509, 550027837, };
int a[16] = { -1515702165, -1191830961, 21877619, -842618921, 637344635, -675876257, 130494595, 1244797415, -2054081909, 632766063, 1637106067, -1738965001, 165510555, 1849687679, 818808483, 1378212359, };
int b[16] = { 1734876550, -2094331942, 582839406, 1391034178, 468300886, -394477654, 1664718142, -1104975598, -1736593626, -153085062, 25862670, 2096723682, 817434102, -1334174902, 996512478, -1515149134, };
int c[16] = { -1515702165, -1191830961, 21877619, -842618921, 169043749, -281398603, 130494595, 139821817, -317488283, 20425815, 7757857, -1738965001, 165510555, 515512777, 818808483, 1378212359, };
for (i = 0; i < 16; i++) {
if (a[i] % b[i] != c[i])
return i;
......@@ -61,9 +61,9 @@ int testmod()
int testaddu()
{
int i;
unsigned int a[16] = { 0xf9537b5e, 0x0c1e8982, 0x9ca542e6, 0x6fd12b8a, 0x48c5076e, 0xfec0da92, 0xaa45e8f6, 0x2d7ab69a, 0x9bcf077e, 0x44dfdfa2, 0x669b8306, 0xcaa575aa, 0xd2fa7b8e, 0xb9d498b2, 0x08cf1116, 0x8b4a68ba, };
unsigned int b[16] = { 0xb30b24a9, 0x94d78a3d, 0xd8adee11, 0xc2e1c425, 0x921ac079, 0xcda8d70d, 0x4e183be1, 0x340562f5, 0x41310049, 0x47d407dd, 0xa433adb1, 0xf47565c5, 0x82b2e419, 0x154e1cad, 0x19854381, 0x5c46cc95, };
unsigned int c[16] = { 0xac5ea007, 0xa0f613bf, 0x755330f7, 0x32b2efaf, 0xdadfc7e7, 0xcc69b19f, 0xf85e24d7, 0x6180198f, 0xdd0007c7, 0x8cb3e77f, 0x0acf30b7, 0xbf1adb6f, 0x55ad5fa7, 0xcf22b55f, 0x22545497, 0xe791354f, };
unsigned int a[16] = { 0x4a549a34, 0x7c462b38, 0xae024d7c, 0x0afa6500, 0x5d4f15c4, 0x289443c8, 0x61d5130c, 0xe8d7e790, 0x26a26554, 0x753d7058, 0x34b92c9c, 0xb170fe20, 0x3f8f88e4, 0x2fd2b0e8, 0x818f9a2c, 0x75f6a8b0, };
unsigned int b[16] = { 0x68baa027, 0xb076fd1b, 0x7b28a64f, 0x910b6fc3, 0x2b4d6d77, 0xb3c2f36b, 0xacda959f, 0x55d12813, 0xdf25bec7, 0x434dadbb, 0x17a888ef, 0xe9b42463, 0xfc809417, 0x7a642c0b, 0x6eef803f, 0x1d2164b3, };
unsigned int c[16] = { 0xb30f3a5b, 0x2cbd2853, 0x292af3cb, 0x9c05d4c3, 0x889c833b, 0xdc573733, 0x0eafa8ab, 0x3ea90fa3, 0x05c8241b, 0xb88b1e13, 0x4c61b58b, 0x9b252283, 0x3c101cfb, 0xaa36dcf3, 0xf07f1a6b, 0x93180d63, };
for (i = 0; i < 16; i++) {
if (a[i] + b[i] != c[i])
return i;
......@@ -73,9 +73,9 @@ int testaddu()
int testsubu()
{
int i;
unsigned int a[16] = { 0xf9537b5e, 0x0c1e8982, 0x9ca542e6, 0x6fd12b8a, 0x48c5076e, 0xfec0da92, 0xaa45e8f6, 0x2d7ab69a, 0x9bcf077e, 0x44dfdfa2, 0x669b8306, 0xcaa575aa, 0xd2fa7b8e, 0xb9d498b2, 0x08cf1116, 0x8b4a68ba, };
unsigned int b[16] = { 0xb30b24a9, 0x94d78a3d, 0xd8adee11, 0xc2e1c425, 0x921ac079, 0xcda8d70d, 0x4e183be1, 0x340562f5, 0x41310049, 0x47d407dd, 0xa433adb1, 0xf47565c5, 0x82b2e419, 0x154e1cad, 0x19854381, 0x5c46cc95, };
unsigned int c[16] = { 0x464856b5, 0x7746ff45, 0xc3f754d5, 0xacef6765, 0xb6aa46f5, 0x31180385, 0x5c2dad15, 0xf97553a5, 0x5a9e0735, 0xfd0bd7c5, 0xc267d555, 0xd6300fe5, 0x50479775, 0xa4867c05, 0xef49cd95, 0x2f039c25, };
unsigned int a[16] = { 0x4a549a34, 0x7c462b38, 0xae024d7c, 0x0afa6500, 0x5d4f15c4, 0x289443c8, 0x61d5130c, 0xe8d7e790, 0x26a26554, 0x753d7058, 0x34b92c9c, 0xb170fe20, 0x3f8f88e4, 0x2fd2b0e8, 0x818f9a2c, 0x75f6a8b0, };
unsigned int b[16] = { 0x68baa027, 0xb076fd1b, 0x7b28a64f, 0x910b6fc3, 0x2b4d6d77, 0xb3c2f36b, 0xacda959f, 0x55d12813, 0xdf25bec7, 0x434dadbb, 0x17a888ef, 0xe9b42463, 0xfc809417, 0x7a642c0b, 0x6eef803f, 0x1d2164b3, };
unsigned int c[16] = { 0xe199fa0d, 0xcbcf2e1d, 0x32d9a72d, 0x79eef53d, 0x3201a84d, 0x74d1505d, 0xb4fa7d6d, 0x9306bf7d, 0x477ca68d, 0x31efc29d, 0x1d10a3ad, 0xc7bcd9bd, 0x430ef4cd, 0xb56e84dd, 0x12a019ed, 0x58d543fd, };
for (i = 0; i < 16; i++) {
if (a[i] - b[i] != c[i])
return i;
......@@ -85,9 +85,9 @@ int testsubu()
int testmulu()
{
int i;
unsigned int a[16] = { 0xf9537b5e, 0x0c1e8982, 0x9ca542e6, 0x6fd12b8a, 0x48c5076e, 0xfec0da92, 0xaa45e8f6, 0x2d7ab69a, 0x9bcf077e, 0x44dfdfa2, 0x669b8306, 0xcaa575aa, 0xd2fa7b8e, 0xb9d498b2, 0x08cf1116, 0x8b4a68ba, };
unsigned int b[16] = { 0xb30b24a9, 0x94d78a3d, 0xd8adee11, 0xc2e1c425, 0x921ac079, 0xcda8d70d, 0x4e183be1, 0x340562f5, 0x41310049, 0x47d407dd, 0xa433adb1, 0xf47565c5, 0x82b2e419, 0x154e1cad, 0x19854381, 0x5c46cc95, };
unsigned int c[16] = { 0x5c7fa90e, 0xfd94d7fa, 0x50994546, 0x26daf2f2, 0xa7df02fe, 0x412bb76a, 0x8f327236, 0x5959b562, 0xdb2722ee, 0xb4897cda, 0xfb42a526, 0x07719dd2, 0xb53c88de, 0xf59aa84a, 0xa83e5e16, 0xd89f2c42, };
unsigned int a[16] = { 0x4a549a34, 0x7c462b38, 0xae024d7c, 0x0afa6500, 0x5d4f15c4, 0x289443c8, 0x61d5130c, 0xe8d7e790, 0x26a26554, 0x753d7058, 0x34b92c9c, 0xb170fe20, 0x3f8f88e4, 0x2fd2b0e8, 0x818f9a2c, 0x75f6a8b0, };
unsigned int b[16] = { 0x68baa027, 0xb076fd1b, 0x7b28a64f, 0x910b6fc3, 0x2b4d6d77, 0xb3c2f36b, 0xacda959f, 0x55d12813, 0xdf25bec7, 0x434dadbb, 0x17a888ef, 0xe9b42463, 0xfc809417, 0x7a642c0b, 0x6eef803f, 0x1d2164b3, };
unsigned int c[16] = { 0x5d0bfdec, 0xdfece6e8, 0xe0545144, 0x4585ef00, 0x83fb921c, 0xe7df2c98, 0x0fa4d074, 0xe0c4afb0, 0x60951c4c, 0xfb448848, 0xe2f385a4, 0x50eec660, 0x93091c7c, 0xef1579f8, 0x8680f0d4, 0x840cb310, };
for (i = 0; i < 16; i++) {
if (a[i] * b[i] != c[i])
return i;
......@@ -97,9 +97,9 @@ int testmulu()
int testdivu()
{
int i;
unsigned int a[16] = { 0xf9537b5e, 0x0c1e8982, 0x9ca542e6, 0x6fd12b8a, 0x48c5076e, 0xfec0da92, 0xaa45e8f6, 0x2d7ab69a, 0x9bcf077e, 0x44dfdfa2, 0x669b8306, 0xcaa575aa, 0xd2fa7b8e, 0xb9d498b2, 0x08cf1116, 0x8b4a68ba, };
unsigned int b[16] = { 0xb30b24a9, 0x94d78a3d, 0xd8adee11, 0xc2e1c425, 0x921ac079, 0xcda8d70d, 0x4e183be1, 0x340562f5, 0x41310049, 0x47d407dd, 0xa433adb1, 0xf47565c5, 0x82b2e419, 0x154e1cad, 0x19854381, 0x5c46cc95, };
unsigned int c[16] = { 0x00000001, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000001, 0x00000002, 0x00000000, 0x00000002, 0x00000000, 0x00000000, 0x00000000, 0x00000001, 0x00000008, 0x00000000, 0x00000001, };
unsigned int a[16] = { 0x4a549a34, 0x7c462b38, 0xae024d7c, 0x0afa6500, 0x5d4f15c4, 0x289443c8, 0x61d5130c, 0xe8d7e790, 0x26a26554, 0x753d7058, 0x34b92c9c, 0xb170fe20, 0x3f8f88e4, 0x2fd2b0e8, 0x818f9a2c, 0x75f6a8b0, };
unsigned int b[16] = { 0x68baa027, 0xb076fd1b, 0x7b28a64f, 0x910b6fc3, 0x2b4d6d77, 0xb3c2f36b, 0xacda959f, 0x55d12813, 0xdf25bec7, 0x434dadbb, 0x17a888ef, 0xe9b42463, 0xfc809417, 0x7a642c0b, 0x6eef803f, 0x1d2164b3, };
unsigned int c[16] = { 0x00000000, 0x00000000, 0x00000001, 0x00000000, 0x00000002, 0x00000000, 0x00000000, 0x00000002, 0x00000000, 0x00000001, 0x00000002, 0x00000000, 0x00000000, 0x00000000, 0x00000001, 0x00000004, };
for (i = 0; i < 16; i++) {
if (a[i] / b[i] != c[i])
return i;
......@@ -109,9 +109,9 @@ int testdivu()
int testmodu()
{
int i;
unsigned int a[16] = { 0xf9537b5e, 0x0c1e8982, 0x9ca542e6, 0x6fd12b8a, 0x48c5076e, 0xfec0da92, 0xaa45e8f6, 0x2d7ab69a, 0x9bcf077e, 0x44dfdfa2, 0x669b8306, 0xcaa575aa, 0xd2fa7b8e, 0xb9d498b2, 0x08cf1116, 0x8b4a68ba, };
unsigned int b[16] = { 0xb30b24a9, 0x94d78a3d, 0xd8adee11, 0xc2e1c425, 0x921ac079, 0xcda8d70d, 0x4e183be1, 0x340562f5, 0x41310049, 0x47d407dd, 0xa433adb1, 0xf47565c5, 0x82b2e419, 0x154e1cad, 0x19854381, 0x5c46cc95, };
unsigned int c[16] = { 0x464856b5, 0x0c1e8982, 0x9ca542e6, 0x6fd12b8a, 0x48c5076e, 0x31180385, 0x0e157134, 0x2d7ab69a, 0x196d06ec, 0x44dfdfa2, 0x669b8306, 0xcaa575aa, 0x50479775, 0x0f63b34a, 0x08cf1116, 0x2f039c25, };
unsigned int a[16] = { 0x4a549a34, 0x7c462b38, 0xae024d7c, 0x0afa6500, 0x5d4f15c4, 0x289443c8, 0x61d5130c, 0xe8d7e790, 0x26a26554, 0x753d7058, 0x34b92c9c, 0xb170fe20, 0x3f8f88e4, 0x2fd2b0e8, 0x818f9a2c, 0x75f6a8b0, };
unsigned int b[16] = { 0x68baa027, 0xb076fd1b, 0x7b28a64f, 0x910b6fc3, 0x2b4d6d77, 0xb3c2f36b, 0xacda959f, 0x55d12813, 0xdf25bec7, 0x434dadbb, 0x17a888ef, 0xe9b42463, 0xfc809417, 0x7a642c0b, 0x6eef803f, 0x1d2164b3, };
unsigned int c[16] = { 0x4a549a34, 0x7c462b38, 0x32d9a72d, 0x0afa6500, 0x06b43ad6, 0x289443c8, 0x61d5130c, 0x3d35976a, 0x26a26554, 0x31efc29d, 0x05681abe, 0xb170fe20, 0x3f8f88e4, 0x2fd2b0e8, 0x12a019ed, 0x017115e4, };
for (i = 0; i < 16; i++) {
if (a[i] % b[i] != c[i])
return i;
......
......@@ -8,9 +8,9 @@ ELF Header:
Type: EXEC (Executable file)
Machine: RISC-V
Version: 0x1
Entry point address: 0x8c
Entry point address: 0xf00
Start of program headers: 52 (bytes into file)
Start of section headers: 41604 (bytes into file)
Start of section headers: 22744 (bytes into file)
Flags: 0x0
Size of this header: 52 (bytes)
Size of program headers: 32 (bytes)
......@@ -22,28 +22,28 @@ ELF Header:
Section Headers:
[Nr] Name Type Addr Off Size ES Flg Lk Inf Al
[ 0] NULL 00000000 000000 000000 00 0 0 0
[ 1] .text PROGBITS 00000074 000074 003254 00 AX 0 0 4
[ 2] .rodata PROGBITS 000032c8 0032c8 0006a4 00 A 0 0 4
[ 3] .eh_frame PROGBITS 0000496c 00396c 000054 00 WA 0 0 4
[ 4] .init_array INIT_ARRAY 000049c0 0039c0 000008 04 WA 0 0 4
[ 5] .fini_array FINI_ARRAY 000049c8 0039c8 000004 04 WA 0 0 4
[ 6] .data PROGBITS 000049d0 0039d0 0004c8 00 WA 0 0 8
[ 7] .sdata PROGBITS 00004e98 003e98 00000c 00 WA 0 0 4
[ 8] .sbss NOBITS 00004ea4 003ea4 000008 00 WA 0 0 4
[ 9] .bss NOBITS 00004eac 003ea4 00201c 00 WA 0 0 4
[10] .comment PROGBITS 00000000 003ea4 000012 01 MS 0 0 1
[11] .riscv.attributes RISCV_ATTRIBUTE 00000000 003eb6 00002a 00 0 0 1
[12] .debug_aranges PROGBITS 00000000 003ee0 000078 00 0 0 1
[13] .debug_info PROGBITS 00000000 003f58 0017b0 00 0 0 1
[14] .debug_abbrev PROGBITS 00000000 005708 00059f 00 0 0 1
[15] .debug_line PROGBITS 00000000 005ca7 001792 00 0 0 1
[16] .debug_str PROGBITS 00000000 007439 0002ac 01 MS 0 0 1
[17] .debug_line_str PROGBITS 00000000 0076e5 0000aa 01 MS 0 0 1
[18] .debug_loclists PROGBITS 00000000 00778f 001aba 00 0 0 1
[19] .debug_rnglists PROGBITS 00000000 009249 0002c6 00 0 0 1
[20] .symtab SYMTAB 00000000 009510 000800 10 21 75 4
[21] .strtab STRTAB 00000000 009d10 000484 00 0 0 1
[22] .shstrtab STRTAB 00000000 00a194 0000ee 00 0 0 1
[ 1] .text PROGBITS 00000074 000074 001228 00 AX 0 0 4
[ 2] .rodata PROGBITS 0000129c 00129c 000100 00 A 0 0 4
[ 3] .eh_frame PROGBITS 0000239c 00139c 000004 00 WA 0 0 4
[ 4] .init_array INIT_ARRAY 000023a0 0013a0 000008 04 WA 0 0 4
[ 5] .fini_array FINI_ARRAY 000023a8 0013a8 000004 04 WA 0 0 4
[ 6] .data PROGBITS 000023b0 0013b0 000428 00 WA 0 0 8
[ 7] .sdata PROGBITS 000027d8 0017d8 00000c 00 WA 0 0 4
[ 8] .sbss NOBITS 000027e4 0017e4 000008 00 WA 0 0 4
[ 9] .bss NOBITS 000027ec 0017e4 00001c 00 WA 0 0 4
[10] .comment PROGBITS 00000000 0017e4 000012 01 MS 0 0 1
[11] .riscv.attributes RISCV_ATTRIBUTE 00000000 0017f6 000021 00 0 0 1
[12] .debug_aranges PROGBITS 00000000 001817 000040 00 0 0 1
[13] .debug_info PROGBITS 00000000 001857 000f77 00 0 0 1
[14] .debug_abbrev PROGBITS 00000000 0027ce 000389 00 0 0 1
[15] .debug_line PROGBITS 00000000 002b57 00102c 00 0 0 1
[16] .debug_str PROGBITS 00000000 003b83 0001ef 01 MS 0 0 1
[17] .debug_line_str PROGBITS 00000000 003d72 0000b0 01 MS 0 0 1
[18] .debug_loclists PROGBITS 00000000 003e22 001021 00 0 0 1
[19] .debug_rnglists PROGBITS 00000000 004e43 0001b5 00 0 0 1
[20] .symtab SYMTAB 00000000 004ff8 000540 10 21 65 4
[21] .strtab STRTAB 00000000 005538 0002b2 00 0 0 1
[22] .shstrtab STRTAB 00000000 0057ea 0000ee 00 0 0 1
Key to Flags:
W (write), A (alloc), X (execute), M (merge), S (strings), I (info),
L (link order), O (extra OS processing required), G (group), T (TLS),
......@@ -54,8 +54,8 @@ There are no section groups in this file.
Program Headers:
Type Offset VirtAddr PhysAddr FileSiz MemSiz Flg Align
LOAD 0x000000 0x00000000 0x00000000 0x0396c 0x0396c R E 0x1000
LOAD 0x00396c 0x0000496c 0x0000496c 0x00538 0x0255c RW 0x1000
LOAD 0x000000 0x00000000 0x00000000 0x0139c 0x0139c R E 0x1000
LOAD 0x00139c 0x0000239c 0x0000239c 0x00448 0x0046c RW 0x1000
Section to Segment mapping:
Segment Sections...
......@@ -68,18 +68,18 @@ There are no relocations in this file.
The decoding of unwind sections for machine type RISC-V is not currently supported.
Symbol table '.symtab' contains 128 entries:
Symbol table '.symtab' contains 84 entries:
Num: Value Size Type Bind Vis Ndx Name
0: 00000000 0 NOTYPE LOCAL DEFAULT UND
1: 00000074 0 SECTION LOCAL DEFAULT 1 .text
2: 000032c8 0 SECTION LOCAL DEFAULT 2 .rodata
3: 0000496c 0 SECTION LOCAL DEFAULT 3 .eh_frame
4: 000049c0 0 SECTION LOCAL DEFAULT 4 .init_array
5: 000049c8 0 SECTION LOCAL DEFAULT 5 .fini_array
6: 000049d0 0 SECTION LOCAL DEFAULT 6 .data
7: 00004e98 0 SECTION LOCAL DEFAULT 7 .sdata
8: 00004ea4 0 SECTION LOCAL DEFAULT 8 .sbss
9: 00004eac 0 SECTION LOCAL DEFAULT 9 .bss
2: 0000129c 0 SECTION LOCAL DEFAULT 2 .rodata
3: 0000239c 0 SECTION LOCAL DEFAULT 3 .eh_frame
4: 000023a0 0 SECTION LOCAL DEFAULT 4 .init_array
5: 000023a8 0 SECTION LOCAL DEFAULT 5 .fini_array
6: 000023b0 0 SECTION LOCAL DEFAULT 6 .data
7: 000027d8 0 SECTION LOCAL DEFAULT 7 .sdata
8: 000027e4 0 SECTION LOCAL DEFAULT 8 .sbss
9: 000027ec 0 SECTION LOCAL DEFAULT 9 .bss
10: 00000000 0 SECTION LOCAL DEFAULT 10 .comment
11: 00000000 0 SECTION LOCAL DEFAULT 11 .riscv.attributes
12: 00000000 0 SECTION LOCAL DEFAULT 12 .debug_aranges
......@@ -93,116 +93,70 @@ Symbol table '.symtab' contains 128 entries:
20: 00000000 0 FILE LOCAL DEFAULT ABS __call_atexit.c
21: 00000074 24 FUNC LOCAL DEFAULT 1 register_fini
22: 00000000 0 FILE LOCAL DEFAULT ABS crtstuff.c
23: 0000496c 0 OBJECT LOCAL DEFAULT 3 __EH_FRAME_BEGIN__
24: 000000dc 0 FUNC LOCAL DEFAULT 1 __do_global_dtors_aux
25: 00004eac 1 OBJECT LOCAL DEFAULT 9 completed.1
26: 000049c8 0 OBJECT LOCAL DEFAULT 5 __do_global_dtor[...]
27: 00000120 0 FUNC LOCAL DEFAULT 1 frame_dummy
28: 00004eb0 24 OBJECT LOCAL DEFAULT 9 object.0
29: 000049c4 0 OBJECT LOCAL DEFAULT 4 __frame_dummy_in[...]
23: 0000239c 0 OBJECT LOCAL DEFAULT 3
24: 0000008c 0 FUNC LOCAL DEFAULT 1 __do_global_dtors_aux
25: 000027ec 1 OBJECT LOCAL DEFAULT 9 completed.1
26: 000023a8 0 OBJECT LOCAL DEFAULT 5 __do_global_dtor[...]
27: 000000d0 0 FUNC LOCAL DEFAULT 1 frame_dummy
28: 000027f0 24 OBJECT LOCAL DEFAULT 9 object.0
29: 000023a4 0 OBJECT LOCAL DEFAULT 4 __frame_dummy_in[...]
30: 00000000 0 FILE LOCAL DEFAULT ABS console.c
31: 00004e9c 4 OBJECT LOCAL DEFAULT 7 _uartaddr
32: 00004ea4 4 OBJECT LOCAL DEFAULT 8 _uartstate
33: 00000144 64 FUNC LOCAL DEFAULT 1 _canputchar
34: 00000184 68 FUNC LOCAL DEFAULT 1 _haschar
35: 000001c8 96 FUNC LOCAL DEFAULT 1 _putchar
36: 00000228 84 FUNC LOCAL DEFAULT 1 _getchar
37: 0000027c 104 FUNC LOCAL DEFAULT 1 _puts
38: 000002e4 216 FUNC LOCAL DEFAULT 1 _gets
39: 000003bc 512 FUNC LOCAL DEFAULT 1 _d2s
40: 000005bc 424 FUNC LOCAL DEFAULT 1 _h2s
41: 00000764 252 FUNC LOCAL DEFAULT 1 _s2d
42: 00000860 312 FUNC LOCAL DEFAULT 1 _s2h
43: 00000998 140 FUNC LOCAL DEFAULT 1 _strcat
44: 00000a24 152 FUNC LOCAL DEFAULT 1 _strncmp
45: 00004ea8 4 OBJECT LOCAL DEFAULT 8 displayaddr
46: 00000abc 628 FUNC LOCAL DEFAULT 1 dispmem
47: 00000d30 372 FUNC LOCAL DEFAULT 1 liststatus
48: 00004ec8 4096 OBJECT LOCAL DEFAULT 9 coeff
49: 00005ec8 4096 OBJECT LOCAL DEFAULT 9 buf
50: 00000ea4 160 FUNC LOCAL DEFAULT 1 testmad
51: 00000f44 96 FUNC LOCAL DEFAULT 1 printhelp
52: 00000000 0 FILE LOCAL DEFAULT ABS libgcc2.c
53: 00000000 0 FILE LOCAL DEFAULT ABS libgcc2.c
54: 00000000 0 FILE LOCAL DEFAULT ABS libgcc2.c
55: 00000000 0 FILE LOCAL DEFAULT ABS exit.c
56: 00000000 0 FILE LOCAL DEFAULT ABS init.c
57: 00000000 0 FILE LOCAL DEFAULT ABS memcpy.c
58: 00000000 0 FILE LOCAL DEFAULT ABS fini.c
59: 00000000 0 FILE LOCAL DEFAULT ABS atexit.c
60: 00000000 0 FILE LOCAL DEFAULT ABS __atexit.c
61: 00000000 0 FILE LOCAL DEFAULT ABS sys_exit.c
62: 00000000 0 FILE LOCAL DEFAULT ABS errno.c
63: 00000000 0 FILE LOCAL DEFAULT ABS libgcc2.c
64: 00000000 0 FILE LOCAL DEFAULT ABS crtstuff.c
65: 000049bc 0 OBJECT LOCAL DEFAULT 3 __FRAME_END__
66: 00000000 0 FILE LOCAL DEFAULT ABS impure.c
67: 00004a70 1064 OBJECT LOCAL DEFAULT 6 impure_data
68: 00000000 0 FILE LOCAL DEFAULT ABS
69: 000049cc 0 NOTYPE LOCAL DEFAULT 5 __fini_array_end
70: 000049c8 0 NOTYPE LOCAL DEFAULT 5 __fini_array_start
71: 000049c8 0 NOTYPE LOCAL DEFAULT 4 __init_array_end
72: 000049c0 0 NOTYPE LOCAL DEFAULT 4 __preinit_array_end
73: 000049c0 0 NOTYPE LOCAL DEFAULT 4 __init_array_start
74: 000049c0 0 NOTYPE LOCAL DEFAULT 4 __preinit_array_start
75: 00001ff4 12 FUNC GLOBAL DEFAULT 1 cycle
76: 00002090 1144 FUNC GLOBAL HIDDEN 1 __divdi3
77: 00005698 0 NOTYPE GLOBAL DEFAULT ABS __global_pointer$
78: 000013a4 256 FUNC GLOBAL DEFAULT 1 testmod
79: 0000200c 12 FUNC GLOBAL DEFAULT 1 get_counter_addsub
80: 000032bc 12 FUNC GLOBAL DEFAULT 1 __errno
81: 000017a4 256 FUNC GLOBAL DEFAULT 1 testdivu
82: 00004e98 0 NOTYPE GLOBAL DEFAULT 7 __SDATA_BEGIN__
83: 00002e58 296 FUNC GLOBAL DEFAULT 1 memcpy
84: 000016a4 256 FUNC GLOBAL DEFAULT 1 testmulu
85: 000010a4 256 FUNC GLOBAL DEFAULT 1 testsub
86: 00002060 12 FUNC GLOBAL DEFAULT 1 get_counter_alui
87: 00002024 12 FUNC GLOBAL DEFAULT 1 get_counter_div
88: 00004e98 4 OBJECT GLOBAL DEFAULT 7 _global_impure_ptr
89: 00002dbc 156 FUNC GLOBAL DEFAULT 1 __libc_init_array
90: 00000fa4 256 FUNC GLOBAL DEFAULT 1 testadd
91: 00004a48 40 OBJECT GLOBAL DEFAULT 6 testname
92: 00002958 1072 FUNC GLOBAL HIDDEN 1 __udivdi3
93: 00003180 92 FUNC GLOBAL DEFAULT 1 __libc_fini_array
94: 000012a4 256 FUNC GLOBAL DEFAULT 1 testdiv
95: 0000203c 12 FUNC GLOBAL DEFAULT 1 get_counter_st
96: 00004a20 40 OBJECT GLOBAL DEFAULT 6 testf
97: 0000305c 292 FUNC GLOBAL DEFAULT 1 __call_exitprocs
98: 0000008c 80 FUNC GLOBAL DEFAULT 1 _start
99: 000031f0 156 FUNC GLOBAL DEFAULT 1 __register_exitproc
100: 000049f8 40 OBJECT GLOBAL DEFAULT 6 statusname
101: 000014a4 256 FUNC GLOBAL DEFAULT 1 testaddu
102: 00002048 12 FUNC GLOBAL DEFAULT 1 get_counter_jmp
103: 00002078 12 FUNC GLOBAL DEFAULT 1 clear_all_counter
104: 00006ec8 0 NOTYPE GLOBAL DEFAULT 9 __BSS_END__
105: 00004ea4 0 NOTYPE GLOBAL DEFAULT 8 __bss_start
106: 00002f80 220 FUNC GLOBAL DEFAULT 1 memset
107: 00001aa8 1356 FUNC GLOBAL DEFAULT 1 main
108: 000019a4 260 FUNC GLOBAL DEFAULT 1 testisa
109: 00002084 12 FUNC GLOBAL DEFAULT 1 stop_all_counter
110: 0000386c 256 OBJECT GLOBAL HIDDEN 2 __clz_tab
111: 000031dc 20 FUNC GLOBAL DEFAULT 1 atexit
112: 00002030 12 FUNC GLOBAL DEFAULT 1 get_counter_ld
113: 00004ea0 4 OBJECT GLOBAL DEFAULT 7 _impure_ptr
114: 0000206c 12 FUNC GLOBAL DEFAULT 1 get_counter_alu
115: 000049d0 0 NOTYPE GLOBAL DEFAULT 6 __DATA_BEGIN__
116: 00004ea4 0 NOTYPE GLOBAL DEFAULT 7 _edata
117: 000018a4 256 FUNC GLOBAL DEFAULT 1 testmodu
118: 00006ec8 0 NOTYPE GLOBAL DEFAULT 9 _end
119: 000049d0 40 OBJECT GLOBAL DEFAULT 6 statusgetfuncs
120: 00002018 12 FUNC GLOBAL DEFAULT 1 get_counter_mul
121: 00002d88 52 FUNC GLOBAL DEFAULT 1 exit
122: 00002054 12 FUNC GLOBAL DEFAULT 1 get_counter_j
123: 00002508 1104 FUNC GLOBAL HIDDEN 1 __moddi3
124: 0000328c 48 FUNC GLOBAL DEFAULT 1 _exit
125: 000011a4 256 FUNC GLOBAL DEFAULT 1 testmul
126: 00002000 12 FUNC GLOBAL DEFAULT 1 instrcount
127: 000015a4 256 FUNC GLOBAL DEFAULT 1 testsubu
31: 000027dc 4 OBJECT LOCAL DEFAULT 7 _uartaddr
32: 000027e4 4 OBJECT LOCAL DEFAULT 8 _uartstate
33: 000000f0 60 FUNC LOCAL DEFAULT 1 _canputchar
34: 0000012c 64 FUNC LOCAL DEFAULT 1 _haschar
35: 0000016c 88 FUNC LOCAL DEFAULT 1 _putchar
36: 000001c4 76 FUNC LOCAL DEFAULT 1 _getchar
37: 00000210 104 FUNC LOCAL DEFAULT 1 _puts
38: 00000278 216 FUNC LOCAL DEFAULT 1 _gets
39: 00000350 388 FUNC LOCAL DEFAULT 1 _i2s
40: 000004d4 424 FUNC LOCAL DEFAULT 1 _h2s
41: 0000067c 252 FUNC LOCAL DEFAULT 1 _s2d
42: 00000778 312 FUNC LOCAL DEFAULT 1 _s2h
43: 000027e8 4 OBJECT LOCAL DEFAULT 8 displayaddr
44: 000008b0 560 FUNC LOCAL DEFAULT 1 dispmem
45: 00000ae0 96 FUNC LOCAL DEFAULT 1 printhelp
46: 00000000 0 FILE LOCAL DEFAULT ABS exit.c
47: 00000000 0 FILE LOCAL DEFAULT ABS fini.c
48: 00000000 0 FILE LOCAL DEFAULT ABS atexit.c
49: 00000000 0 FILE LOCAL DEFAULT ABS __atexit.c
50: 00000000 0 FILE LOCAL DEFAULT ABS sys_exit.c
51: 00000000 0 FILE LOCAL DEFAULT ABS errno.c
52: 00000000 0 FILE LOCAL DEFAULT ABS crtstuff.c
53: 0000239c 0 OBJECT LOCAL DEFAULT 3 __FRAME_END__
54: 00000000 0 FILE LOCAL DEFAULT ABS impure.c
55: 000023b0 1064 OBJECT LOCAL DEFAULT 6 impure_data
56: 00000000 0 FILE LOCAL DEFAULT ABS libgcc2.c
57: 00000000 0 FILE LOCAL DEFAULT ABS libgcc2.c
58: 00000000 0 FILE LOCAL DEFAULT ABS
59: 000023ac 0 NOTYPE LOCAL DEFAULT 5 __fini_array_end
60: 000023a8 0 NOTYPE LOCAL DEFAULT 5 __fini_array_start
61: 000023a8 0 NOTYPE LOCAL DEFAULT 4 __init_array_end
62: 000023a0 0 NOTYPE LOCAL DEFAULT 4 __preinit_array_end
63: 000023a0 0 NOTYPE LOCAL DEFAULT 4 __init_array_start
64: 000023a0 0 NOTYPE LOCAL DEFAULT 4 __preinit_array_start
65: 00002bb0 0 NOTYPE GLOBAL DEFAULT ABS __global_pointer$
66: 00001294 8 FUNC GLOBAL DEFAULT 1 __errno
67: 000027d8 0 NOTYPE GLOBAL DEFAULT 7 __SDATA_BEGIN__
68: 000027d8 4 OBJECT GLOBAL DEFAULT 7 _global_impure_ptr
69: 0000115c 92 FUNC GLOBAL DEFAULT 1 __libc_fini_array
70: 00000f00 48 FUNC GLOBAL DEFAULT 1 __start
71: 0000103c 288 FUNC GLOBAL DEFAULT 1 __call_exitprocs
72: 000011cc 152 FUNC GLOBAL DEFAULT 1 __register_exitproc
73: 00002808 0 NOTYPE GLOBAL DEFAULT 9 __BSS_END__
74: 000027e4 0 NOTYPE GLOBAL DEFAULT 8 __bss_start
75: 00000f60 220 FUNC GLOBAL DEFAULT 1 memset
76: 00000b40 960 FUNC GLOBAL DEFAULT 1 main
77: 000011b8 20 FUNC GLOBAL DEFAULT 1 atexit
78: 000027e0 4 OBJECT GLOBAL DEFAULT 7 _impure_ptr
79: 000023b0 0 NOTYPE GLOBAL DEFAULT 6 __DATA_BEGIN__
80: 000027e4 0 NOTYPE GLOBAL DEFAULT 7 _edata
81: 00002808 0 NOTYPE GLOBAL DEFAULT 9 _end
82: 00000f30 48 FUNC GLOBAL DEFAULT 1 exit
83: 00001264 48 FUNC GLOBAL DEFAULT 1 _exit
No version information found in this file.
Attribute Section: riscv
File Attributes
Tag_RISCV_stack_align: 16-bytes
Tag_RISCV_arch: "rv32i2p0_m2p0_a2p0"
Tag_RISCV_priv_spec: 1
Tag_RISCV_priv_spec_minor: 11
Tag_RISCV_arch: "rv32i2p0_m2p0"
......@@ -6,7 +6,7 @@
OUTPUT_FORMAT("elf32-littleriscv", "elf32-littleriscv",
"elf32-littleriscv")
OUTPUT_ARCH(riscv)
ENTRY(_start)
ENTRY(__start)
SEARCH_DIR("/home/raoxianhong/work/riscv/riscv-elf/riscv32-unknown-elf/lib");
SECTIONS
{
......
int testadd()
{
int i;
int a[16] = {1545266173, 961151873, 1200110661, -97422775, -1533490803, 2068620817, 983215061, 374587097, -691010787, 1194515617, 1492053861, -1601560727, 262246573, 271427377, 1694893813, 1940231161, };
int b[16] = {-1135025456, 129406020, 240908792, -1966774292, 76116512, -594744172, 1769401160, 946127420, -975305360, 1124632804, 991715480, 756539532, 1840487616, -443127500, 2143902184, 1550566108, };
int c[16] = {410240717, 1090557893, 1441019453, -2064197067, -1457374291, 1473876645, -1542351075, 1320714517, -1666316147, -1975818875, -1811197955, -845021195, 2102734189, -171700123, -456171299, -804170027, };
int a[16] = {224865564, -1037576624, -1765171260, 997891448, -1055972500, -2131376736, -1049929708, -370217272, 1542839740, 1138735344, -164998044, -1394228200, -1184343028, 2118299712, -982281036, 1188830568, };
int b[16] = {-952286349, -779544617, -1451062405, -1209048481, 748855427, 379619815, 1199743627, -2045006225, -732188269, -864817161, 1497034139, 1305505407, -1602128221, 1290553863, 560229547, -74014065, };
int c[16] = {-727420785, -1817121241, 1078733631, -211157033, -307117073, -1751756921, 149813919, 1879743799, 810651471, 273918183, 1332036095, -88722793, 1508496047, -886113721, -422051489, 1114816503, };
for (i = 0; i < 16; i++) {
if (a[i] + b[i] != c[i])
return i;
......@@ -13,9 +13,9 @@ int testadd()
int testsub()
{
int i;
int a[16] = {1545266173, 961151873, 1200110661, -97422775, -1533490803, 2068620817, 983215061, 374587097, -691010787, 1194515617, 1492053861, -1601560727, 262246573, 271427377, 1694893813, 1940231161, };
int b[16] = {-1135025456, 129406020, 240908792, -1966774292, 76116512, -594744172, 1769401160, 946127420, -975305360, 1124632804, 991715480, 756539532, 1840487616, -443127500, 2143902184, 1550566108, };
int c[16] = {-1614675667, 831745853, 959201869, 1869351517, -1609607315, -1631602307, -786186099, -571540323, 284294573, 69882813, 500338381, 1936867037, -1578241043, 714554877, -449008371, 389665053, };
int a[16] = {224865564, -1037576624, -1765171260, 997891448, -1055972500, -2131376736, -1049929708, -370217272, 1542839740, 1138735344, -164998044, -1394228200, -1184343028, 2118299712, -982281036, 1188830568, };
int b[16] = {-952286349, -779544617, -1451062405, -1209048481, 748855427, 379619815, 1199743627, -2045006225, -732188269, -864817161, 1497034139, 1305505407, -1602128221, 1290553863, 560229547, -74014065, };
int c[16] = {1177151913, -258032007, -314108855, -2088027367, -1804827927, 1783970745, 2045293961, 1674788953, -2019939287, 2003552505, -1662032183, 1595233689, 417785193, 827745849, -1542510583, 1262844633, };
for (i = 0; i < 16; i++) {
if (a[i] - b[i] != c[i])
return i;
......@@ -25,9 +25,9 @@ int testsub()
int testmul()
{
int i;
int a[16] = {1545266173, 961151873, 1200110661, -97422775, -1533490803, 2068620817, 983215061, 374587097, -691010787, 1194515617, 1492053861, -1601560727, 262246573, 271427377, 1694893813, 1940231161, };
int b[16] = {-1135025456, 129406020, 240908792, -1966774292, 76116512, -594744172, 1769401160, 946127420, -975305360, 1124632804, 991715480, 756539532, 1840487616, -443127500, 2143902184, 1550566108, };
int c[16] = {-1105815664, 107315780, 18907096, -692209076, -1387332704, 1588833748, 141220584, -1224397604, 255258032, 1988757348, -575667208, -294384276, -11735616, -829485324, -1489077496, 830528508, };
int a[16] = {224865564, -1037576624, -1765171260, 997891448, -1055972500, -2131376736, -1049929708, -370217272, 1542839740, 1138735344, -164998044, -1394228200, -1184343028, 2118299712, -982281036, 1188830568, };
int b[16] = {-952286349, -779544617, -1451062405, -1209048481, 748855427, 379619815, 1199743627, -2045006225, -732188269, -864817161, 1497034139, 1305505407, -1602128221, 1290553863, 560229547, -74014065, };
int c[16] = {-1982621804, -1534710480, 1915170604, -841982072, 993697860, 679998304, 959281884, -1275234120, 1313951476, -1370259568, 510241932, 197040104, 166470564, 902123968, -247446468, 310394136, };
for (i = 0; i < 16; i++) {
if (a[i] * b[i] != c[i])
return i;
......@@ -37,9 +37,9 @@ int testmul()
int testdiv()
{
int i;
int a[16] = {1545266173, 961151873, 1200110661, -97422775, -1533490803, 2068620817, 983215061, 374587097, -691010787, 1194515617, 1492053861, -1601560727, 262246573, 271427377, 1694893813, 1940231161, };
int b[16] = {-1135025456, 129406020, 240908792, -1966774292, 76116512, -594744172, 1769401160, 946127420, -975305360, 1124632804, 991715480, 756539532, 1840487616, -443127500, 2143902184, 1550566108, };
int c[16] = {-1, 7, 4, 0, -20, -3, 0, 0, 0, 1, 1, -2, 0, 0, 0, 1, };
int a[16] = {224865564, -1037576624, -1765171260, 997891448, -1055972500, -2131376736, -1049929708, -370217272, 1542839740, 1138735344, -164998044, -1394228200, -1184343028, 2118299712, -982281036, 1188830568, };
int b[16] = {-952286349, -779544617, -1451062405, -1209048481, 748855427, 379619815, 1199743627, -2045006225, -732188269, -864817161, 1497034139, 1305505407, -1602128221, 1290553863, 560229547, -74014065, };
int c[16] = {0, 1, 1, 0, -1, -5, 0, 0, -2, -1, 0, -1, 0, 1, -1, -16, };
for (i = 0; i < 16; i++) {
if (a[i] / b[i] != c[i])
return i;
......@@ -49,9 +49,9 @@ int testdiv()
int testmod()
{
int i;
int a[16] = {1545266173, 961151873, 1200110661, -97422775, -1533490803, 2068620817, 983215061, 374587097, -691010787, 1194515617, 1492053861, -1601560727, 262246573, 271427377, 1694893813, 1940231161, };
int b[16] = {-1135025456, 129406020, 240908792, -1966774292, 76116512, -594744172, 1769401160, 946127420, -975305360, 1124632804, 991715480, 756539532, 1840487616, -443127500, 2143902184, 1550566108, };
int c[16] = {410240717, 55309733, 236475493, -97422775, -11160563, 284388301, 983215061, 374587097, -691010787, 69882813, 500338381, -88481663, 262246573, 271427377, 1694893813, 389665053, };
int a[16] = {224865564, -1037576624, -1765171260, 997891448, -1055972500, -2131376736, -1049929708, -370217272, 1542839740, 1138735344, -164998044, -1394228200, -1184343028, 2118299712, -982281036, 1188830568, };
int b[16] = {-952286349, -779544617, -1451062405, -1209048481, 748855427, 379619815, 1199743627, -2045006225, -732188269, -864817161, 1497034139, 1305505407, -1602128221, 1290553863, 560229547, -74014065, };
int c[16] = {224865564, -258032007, -314108855, 997891448, -307117073, -233277661, -1049929708, -370217272, 78463202, 273918183, -164998044, -88722793, -1184343028, 827745849, -422051489, 4605528, };
for (i = 0; i < 16; i++) {
if (a[i] % b[i] != c[i])
return i;
......@@ -61,9 +61,9 @@ int testmod()
int testaddu()
{
int i;
unsigned int a[16] = {0x8fc7f256, 0xa52dadfa, 0xb15d4cde, 0x8731d302, 0x4b378466, 0x1f0fe50a, 0x9c15b8ee, 0xe1410412, 0x384b0a76, 0x9612501a, 0x7a3e98fe, 0xf224e922, 0xc2eb8486, 0xfeedef2a, 0x8a60ed0e, 0x53368232, };
unsigned int b[16] = {0x442f9fc1, 0x3cc1fcd5, 0x9b13b029, 0x1fa3adbd, 0x6add2991, 0x8aeb97a5, 0x1bceabf9, 0xadae5a8d, 0x656ed761, 0x0b849675, 0xfd084bc9, 0xb30aeb5d, 0xd429a931, 0x0461f945, 0xe7258f99, 0x07ae602d, };
unsigned int c[16] = {0xd3f79217, 0xe1efaacf, 0x4c70fd07, 0xa6d580bf, 0xb614adf7, 0xa9fb7caf, 0xb7e464e7, 0x8eef5e9f, 0x9db9e1d7, 0xa196e68f, 0x7746e4c7, 0xa52fd47f, 0x97152db7, 0x034fe86f, 0x71867ca7, 0x5ae4e25f, };
unsigned int a[16] = {0x3aaf1c6d, 0xbd622f41, 0xd3196455, 0x15936fa9, 0x0e67453d, 0x7e981911, 0x44695f25, 0x5372cb79, 0x72f4520d, 0xb66a26e1, 0xe460bdf5, 0x3f88cb49, 0x660b42dd, 0x3b1d58b1, 0x0ed480c5, 0x783a6f19, };
unsigned int b[16] = {0x28ed3d7c, 0x6a505500, 0x728005c4, 0x381033c8, 0x130c030c, 0x3639d790, 0x4d9f5554, 0xe6456058, 0x833c1c9c, 0x83deee20, 0x3f5878e4, 0xf966a0e8, 0x945e8a2c, 0x247098b0, 0xc82c7074, 0x6a44f578, };
unsigned int c[16] = {0x639c59e9, 0x27b28441, 0x45996a19, 0x4da3a371, 0x21734849, 0xb4d1f0a1, 0x9208b479, 0x39b82bd1, 0xf6306ea9, 0x3a491501, 0x23b936d9, 0x38ef6c31, 0xfa69cd09, 0x5f8df161, 0xd700f139, 0xe27f6491, };
for (i = 0; i < 16; i++) {
if (a[i] + b[i] != c[i])
return i;
......@@ -73,9 +73,9 @@ int testaddu()
int testsubu()
{
int i;
unsigned int a[16] = {0x8fc7f256, 0xa52dadfa, 0xb15d4cde, 0x8731d302, 0x4b378466, 0x1f0fe50a, 0x9c15b8ee, 0xe1410412, 0x384b0a76, 0x9612501a, 0x7a3e98fe, 0xf224e922, 0xc2eb8486, 0xfeedef2a, 0x8a60ed0e, 0x53368232, };
unsigned int b[16] = {0x442f9fc1, 0x3cc1fcd5, 0x9b13b029, 0x1fa3adbd, 0x6add2991, 0x8aeb97a5, 0x1bceabf9, 0xadae5a8d, 0x656ed761, 0x0b849675, 0xfd084bc9, 0xb30aeb5d, 0xd429a931, 0x0461f945, 0xe7258f99, 0x07ae602d, };
unsigned int c[16] = {0x4b985295, 0x686bb125, 0x16499cb5, 0x678e2545, 0xe05a5ad5, 0x94244d65, 0x80470cf5, 0x3392a985, 0xd2dc3315, 0x8a8db9a5, 0x7d364d35, 0x3f19fdc5, 0xeec1db55, 0xfa8bf5e5, 0xa33b5d75, 0x4b882205, };
unsigned int a[16] = {0x3aaf1c6d, 0xbd622f41, 0xd3196455, 0x15936fa9, 0x0e67453d, 0x7e981911, 0x44695f25, 0x5372cb79, 0x72f4520d, 0xb66a26e1, 0xe460bdf5, 0x3f88cb49, 0x660b42dd, 0x3b1d58b1, 0x0ed480c5, 0x783a6f19, };
unsigned int b[16] = {0x28ed3d7c, 0x6a505500, 0x728005c4, 0x381033c8, 0x130c030c, 0x3639d790, 0x4d9f5554, 0xe6456058, 0x833c1c9c, 0x83deee20, 0x3f5878e4, 0xf966a0e8, 0x945e8a2c, 0x247098b0, 0xc82c7074, 0x6a44f578, };
unsigned int c[16] = {0x11c1def1, 0x5311da41, 0x60995e91, 0xdd833be1, 0xfb5b4231, 0x485e4181, 0xf6ca09d1, 0x6d2d6b21, 0xefb83571, 0x328b38c1, 0xa5084511, 0x46222a61, 0xd1acb8b1, 0x16acc001, 0x46a81051, 0x0df579a1, };
for (i = 0; i < 16; i++) {
if (a[i] - b[i] != c[i])
return i;
......@@ -85,9 +85,9 @@ int testsubu()
int testmulu()
{
int i;
unsigned int a[16] = {0x8fc7f256, 0xa52dadfa, 0xb15d4cde, 0x8731d302, 0x4b378466, 0x1f0fe50a, 0x9c15b8ee, 0xe1410412, 0x384b0a76, 0x9612501a, 0x7a3e98fe, 0xf224e922, 0xc2eb8486, 0xfeedef2a, 0x8a60ed0e, 0x53368232, };
unsigned int b[16] = {0x442f9fc1, 0x3cc1fcd5, 0x9b13b029, 0x1fa3adbd, 0x6add2991, 0x8aeb97a5, 0x1bceabf9, 0xadae5a8d, 0x656ed761, 0x0b849675, 0xfd084bc9, 0xb30aeb5d, 0xd429a931, 0x0461f945, 0xe7258f99, 0x07ae602d, };
unsigned int c[16] = {0xeb0b1cd6, 0x27bdd902, 0xab43ef8e, 0x13a7227a, 0x06b453c6, 0x09858572, 0x3d2bd97e, 0xda7991ea, 0x66ec10b6, 0xbcb5d7e2, 0x1fe8896e, 0xbabee75a, 0xfb06d3a6, 0x6aab5052, 0xbd5e7f5e, 0xed63a2ca, };
unsigned int a[16] = {0x3aaf1c6d, 0xbd622f41, 0xd3196455, 0x15936fa9, 0x0e67453d, 0x7e981911, 0x44695f25, 0x5372cb79, 0x72f4520d, 0xb66a26e1, 0xe460bdf5, 0x3f88cb49, 0x660b42dd, 0x3b1d58b1, 0x0ed480c5, 0x783a6f19, };
unsigned int b[16] = {0x28ed3d7c, 0x6a505500, 0x728005c4, 0x381033c8, 0x130c030c, 0x3639d790, 0x4d9f5554, 0xe6456058, 0x833c1c9c, 0x83deee20, 0x3f5878e4, 0xf966a0e8, 0x945e8a2c, 0x247098b0, 0xc82c7074, 0x6a44f578, };
unsigned int c[16] = {0x7f80bdcc, 0x48009500, 0x22e67a14, 0x2cfde708, 0xa882f5dc, 0x1d646090, 0xa8258124, 0x49605198, 0xa7e76bec, 0x57880a20, 0x566c0634, 0x131bda28, 0xed209ffc, 0xc24611b0, 0xba7c8944, 0x245b00b8, };
for (i = 0; i < 16; i++) {
if (a[i] * b[i] != c[i])
return i;
......@@ -97,9 +97,9 @@ int testmulu()
int testdivu()
{
int i;
unsigned int a[16] = {0x8fc7f256, 0xa52dadfa, 0xb15d4cde, 0x8731d302, 0x4b378466, 0x1f0fe50a, 0x9c15b8ee, 0xe1410412, 0x384b0a76, 0x9612501a, 0x7a3e98fe, 0xf224e922, 0xc2eb8486, 0xfeedef2a, 0x8a60ed0e, 0x53368232, };
unsigned int b[16] = {0x442f9fc1, 0x3cc1fcd5, 0x9b13b029, 0x1fa3adbd, 0x6add2991, 0x8aeb97a5, 0x1bceabf9, 0xadae5a8d, 0x656ed761, 0x0b849675, 0xfd084bc9, 0xb30aeb5d, 0xd429a931, 0x0461f945, 0xe7258f99, 0x07ae602d, };
unsigned int c[16] = {0x00000002, 0x00000002, 0x00000001, 0x00000004, 0x00000000, 0x00000000, 0x00000005, 0x00000001, 0x00000000, 0x0000000d, 0x00000000, 0x00000001, 0x00000000, 0x0000003a, 0x00000000, 0x0000000a, };
unsigned int a[16] = {0x3aaf1c6d, 0xbd622f41, 0xd3196455, 0x15936fa9, 0x0e67453d, 0x7e981911, 0x44695f25, 0x5372cb79, 0x72f4520d, 0xb66a26e1, 0xe460bdf5, 0x3f88cb49, 0x660b42dd, 0x3b1d58b1, 0x0ed480c5, 0x783a6f19, };
unsigned int b[16] = {0x28ed3d7c, 0x6a505500, 0x728005c4, 0x381033c8, 0x130c030c, 0x3639d790, 0x4d9f5554, 0xe6456058, 0x833c1c9c, 0x83deee20, 0x3f5878e4, 0xf966a0e8, 0x945e8a2c, 0x247098b0, 0xc82c7074, 0x6a44f578, };
unsigned int c[16] = {0x00000001, 0x00000001, 0x00000001, 0x00000000, 0x00000000, 0x00000002, 0x00000000, 0x00000000, 0x00000000, 0x00000001, 0x00000003, 0x00000000, 0x00000000, 0x00000001, 0x00000000, 0x00000001, };
for (i = 0; i < 16; i++) {
if (a[i] / b[i] != c[i])
return i;
......@@ -109,9 +109,9 @@ int testdivu()
int testmodu()
{
int i;
unsigned int a[16] = {0x8fc7f256, 0xa52dadfa, 0xb15d4cde, 0x8731d302, 0x4b378466, 0x1f0fe50a, 0x9c15b8ee, 0xe1410412, 0x384b0a76, 0x9612501a, 0x7a3e98fe, 0xf224e922, 0xc2eb8486, 0xfeedef2a, 0x8a60ed0e, 0x53368232, };
unsigned int b[16] = {0x442f9fc1, 0x3cc1fcd5, 0x9b13b029, 0x1fa3adbd, 0x6add2991, 0x8aeb97a5, 0x1bceabf9, 0xadae5a8d, 0x656ed761, 0x0b849675, 0xfd084bc9, 0xb30aeb5d, 0xd429a931, 0x0461f945, 0xe7258f99, 0x07ae602d, };
unsigned int c[16] = {0x0768b2d4, 0x2ba9b450, 0x16499cb5, 0x08a31c0e, 0x4b378466, 0x1f0fe50a, 0x110c5d11, 0x3392a985, 0x384b0a76, 0x0056ac29, 0x7a3e98fe, 0x3f19fdc5, 0xc2eb8486, 0x00bb7588, 0x8a60ed0e, 0x0666c070, };
unsigned int a[16] = {0x3aaf1c6d, 0xbd622f41, 0xd3196455, 0x15936fa9, 0x0e67453d, 0x7e981911, 0x44695f25, 0x5372cb79, 0x72f4520d, 0xb66a26e1, 0xe460bdf5, 0x3f88cb49, 0x660b42dd, 0x3b1d58b1, 0x0ed480c5, 0x783a6f19, };
unsigned int b[16] = {0x28ed3d7c, 0x6a505500, 0x728005c4, 0x381033c8, 0x130c030c, 0x3639d790, 0x4d9f5554, 0xe6456058, 0x833c1c9c, 0x83deee20, 0x3f5878e4, 0xf966a0e8, 0x945e8a2c, 0x247098b0, 0xc82c7074, 0x6a44f578, };
unsigned int c[16] = {0x11c1def1, 0x5311da41, 0x60995e91, 0x15936fa9, 0x0e67453d, 0x122469f1, 0x44695f25, 0x5372cb79, 0x72f4520d, 0x328b38c1, 0x26575349, 0x3f88cb49, 0x660b42dd, 0x16acc001, 0x0ed480c5, 0x0df579a1, };
for (i = 0; i < 16; i++) {
if (a[i] % b[i] != c[i])
return i;
......
......@@ -45,7 +45,12 @@
`define RAMSIZE 32768
`define CSROPCOUNTER
`define CSROPCOUNTER_
`define CSRBASECOUNTER_
`define USE3MUL_
`define USEMUL32
`define USE1DIV
`define USEDIV32
(*
HDL4SE="LCOM",
......@@ -91,11 +96,13 @@ module riscv_core(
/* CSR register */
reg [31:0] misa; /*0301*/
`ifdef CSRBASECOUNTER
reg [63:0] ucycle64; /*0c00/0c80*/
reg [63:0] utime64; /*0c01/0c81*/
reg [63:0] uinstret64; /*0c02/0c82*/
reg [63:0] mcycle64; /*0b00/0b80*/
reg [63:0] minstret64; /*0b02/0b82*/
`endif
`ifdef CSROPCOUNTER
reg [63:0] opcounter_addsub64; /*0c20/0ca0*/
reg [63:0] opcounter_mul64; /*0c21/0ca0*/
......@@ -113,6 +120,7 @@ module riscv_core(
if (state == `RISCVSTATE_READ_REGS)
case (bReadData[31:20])
12'h301: csr_r <= misa;
`ifdef CSRBASECOUNTER
12'hc00: csr_r <= ucycle64[31:0];
12'hc80: csr_r <= ucycle64[63:32];
12'hc01: csr_r <= utime64[31:0];
......@@ -123,6 +131,7 @@ module riscv_core(
12'hb80: csr_r <= mcycle64[63:32];
12'hb02: csr_r <= minstret64[31:0];
12'hb82: csr_r <= minstret64[63:32];
`endif
`ifdef CSROPCOUNTER
12'hc20: csr_r <= opcounter_addsub64[31:0];
12'hca0: csr_r <= opcounter_addsub64[63:32];
......@@ -168,7 +177,6 @@ module riscv_core(
wire [31:0] div_result_r, mod_result_r, divs_result_r, mods_result_r;
wire [31:0] div_result, mod_result, divs_result, mods_result;
`define USE3MUL_
`ifdef USE3MUL
mult mul(wClk, rs1, rs2, mul_result);
......@@ -178,7 +186,6 @@ module riscv_core(
wire signed [63:0] mul_result_sign = mul_result;
reg [31:0] mul_rs1, mul_rs2;
`define USEMUL32
`ifdef USEMUL32
wire muldone;
mul32 mul(wClk, (state == `RISCVSTATE_EXEC_INST)?1:0, mul_rs1, mul_rs2, mul_result, muldone);
......@@ -246,8 +253,6 @@ module riscv_core(
Embedded Multiplier 9-bit elements 0 / 532 ( 0 % )
*/
`define USE1DIV
`define USEDIV32
`ifdef USE1DIV
wire div_unsign_op = func3[0];
reg div_unsign;
......@@ -578,11 +583,13 @@ module riscv_core(
always @(posedge wClk)
if (nwReset == 0) begin
misa <= 32'b0100_0000_0001_0000_0001_0001_0000_0000;// RV32IM
`ifdef CSRBASECOUNTER
ucycle64 <= 0;
mcycle64 <= 0;
utime64 <= 0;
uinstret64 <= 0;
minstret64 <= 0;
`endif
`ifdef CSROPCOUNTER
opcounter_doit <= 1;
opcounter_addsub64 <= 0;
......@@ -600,15 +607,19 @@ module riscv_core(
`ifdef CSROPCOUNTER
if (opcounter_doit)
`endif
`ifdef CSRBASECOUNTER
ucycle64 <= ucycle64 + 1;
utime64 <= utime64 + 1;
mcycle64 <= mcycle64 + 1;
`endif
if (state == `RISCVSTATE_EXEC_INST) begin
`ifdef CSROPCOUNTER
if (opcounter_doit)
`endif
`ifdef CSRBASECOUNTER
uinstret64 <= uinstret64 + 1;
minstret64 <= minstret64 + 1;
`endif
`ifdef CSROPCOUNTER
if (opcounter_doit)
case (opcode)
......@@ -637,6 +648,7 @@ module riscv_core(
if (csr_op) begin
case (instr[31:20])
12'h301: misa <= csr_v;
`ifdef CSRBASECOUNTER
12'hc00: ucycle64[31:0] <= csr_v;
12'hc80: ucycle64[63:32] <= csr_v;
12'hc01: utime64[31:0] <= csr_v;
......@@ -647,6 +659,7 @@ module riscv_core(
12'hb80: mcycle64[63:32] <= csr_v;
12'hb02: minstret64[31:0] <= csr_v;
12'hb82: minstret64[63:32] <= csr_v;
`endif
`ifdef CSROPCOUNTER
12'hc20: opcounter_addsub64[31:0] <= csr_v;
12'hca0: opcounter_addsub64[63:32] <= csr_v;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册