mirror of
https://github.com/openhwgroup/cvw.git
synced 2025-04-23 13:27:16 -04:00
Minor tweak of output of fpcalc - can be reversed with commented out code
This commit is contained in:
parent
f14acac1bf
commit
eba4eda245
3 changed files with 50 additions and 6 deletions
23
examples/fp/fpcalc/Makefile
Normal file
23
examples/fp/fpcalc/Makefile
Normal file
|
@ -0,0 +1,23 @@
|
|||
# Makefile
|
||||
|
||||
CC = gcc
|
||||
CFLAGS = -O3
|
||||
LIBS = -lm
|
||||
LFLAGS = -L.
|
||||
# Link against the riscv-isa-sim version of SoftFloat rather than
|
||||
# the regular version to get RISC-V NaN behavior
|
||||
IFLAGS = -I$(RISCV)/riscv-isa-sim/softfloat
|
||||
LIBS = $(RISCV)/riscv-isa-sim/build/libsoftfloat.a
|
||||
#IFLAGS = -I../../../addins/SoftFloat-3e/source/include/
|
||||
#LIBS = ../../../addins/SoftFloat-3e/build/Linux-x86_64-GCC/softfloat.a
|
||||
SRCS = $(wildcard *.c)
|
||||
|
||||
PROGS = $(patsubst %.c,%,$(SRCS))
|
||||
|
||||
all: $(PROGS)
|
||||
|
||||
%: %.c
|
||||
$(CC) $(CFLAGS) $(IFLAGS) $(LFLAGS) -o $@ $< $(LIBS)
|
||||
|
||||
clean:
|
||||
rm -f $(PROGS)
|
|
@ -93,8 +93,13 @@ void printF32(char *msg, float32_t f) {
|
|||
else sprintf(sci, "%c1.%s x 2^%d", sign, fractstr, exp-127);
|
||||
|
||||
//printf ("%s: 0x%08x = %g\n", msg, conv.v, conv.f);
|
||||
printf ("%s: 0x%08x = %g = %s: Biased Exp %d Fract 0x%lx\n",
|
||||
msg, conv.v, conv.f, sci, exp, fract);
|
||||
printf("%s: ", msg);
|
||||
printf("0x%04x", (conv.v >> 16));
|
||||
printf("_");
|
||||
printf("%04x", (conv.v & 0xFF));
|
||||
printf(" = %g = %s: Biased Exp %d Fract 0x%lx\n", conv.f, sci, exp, fract);
|
||||
//printf ("%s: 0x%08x = %g = %s: Biased Exp %d Fract 0x%lx\n",
|
||||
// msg, conv.v, conv.f, sci, exp, fract);
|
||||
}
|
||||
|
||||
void printF64(char *msg, float64_t f) {
|
||||
|
@ -118,8 +123,17 @@ void printF64(char *msg, float64_t f) {
|
|||
else sprintf(sci, "%c1.%s x 2^%d", sign, fractstr, exp-1023);
|
||||
|
||||
//printf ("%s: 0x%016lx = %lg\n", msg, conv.v, conv.d);
|
||||
printf ("%s: 0x%016lx = %lg = %s: Biased Exp %d Fract 0x%lx\n",
|
||||
msg, conv.v, conv.d, sci, exp, fract);
|
||||
printf("%s: ", msg);
|
||||
printf("0x%04x", (conv.v >> 48));
|
||||
printf("_");
|
||||
printf("%04x", (conv.v >> 32) & 0xFFFF);
|
||||
printf("_");
|
||||
printf("%04x", (conv.v >> 16));
|
||||
printf("_");
|
||||
printf("%04x", (conv.v & 0xFFFF));
|
||||
printf(" = %lg = %s: Biased Exp %d Fract 0x%lx\n", conv.d, sci, exp, fract);
|
||||
//printf ("%s: 0x%016lx = %lg = %s: Biased Exp %d Fract 0x%lx\n",
|
||||
// msg, conv.v, conv.d, sci, exp, fract);
|
||||
}
|
||||
|
||||
void printFlags(void) {
|
||||
|
|
|
@ -12,10 +12,17 @@ typedef union sp {
|
|||
float f;
|
||||
} sp;
|
||||
|
||||
void printF32(char *msg, float32_t f) {
|
||||
void printF32 (char *msg, float32_t f) {
|
||||
sp conv;
|
||||
int i, j;
|
||||
conv.v = f.v; // use union to convert between hexadecimal and floating-point views
|
||||
printf ("%s: 0x%08x = %g\n", msg, conv.v, conv.f);
|
||||
// Print out nicely
|
||||
printf("%s: ", msg);
|
||||
printf("0x%04x", (conv.v >> 16));
|
||||
printf("_");
|
||||
printf("%04x", (conv.v & 0xFFFF));
|
||||
printf(" = %g\n", conv.f);
|
||||
//printf ("%s: 0x%08x = %g\n", msg, conv.v, conv.f);
|
||||
}
|
||||
|
||||
void printFlags(void) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue