mirror of
https://github.com/openhwgroup/cvw
synced 2025-02-11 06:05:49 +00:00
Minor tweak of output of fpcalc - can be reversed with commented out code
This commit is contained in:
parent
f54ed94dbc
commit
76a4b80528
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);
|
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\n", msg, conv.v, conv.f);
|
||||||
printf ("%s: 0x%08x = %g = %s: Biased Exp %d Fract 0x%lx\n",
|
printf("%s: ", msg);
|
||||||
msg, conv.v, conv.f, sci, exp, fract);
|
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) {
|
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);
|
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\n", msg, conv.v, conv.d);
|
||||||
printf ("%s: 0x%016lx = %lg = %s: Biased Exp %d Fract 0x%lx\n",
|
printf("%s: ", msg);
|
||||||
msg, conv.v, conv.d, sci, exp, fract);
|
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) {
|
void printFlags(void) {
|
||||||
|
@ -12,10 +12,17 @@ typedef union sp {
|
|||||||
float f;
|
float f;
|
||||||
} sp;
|
} sp;
|
||||||
|
|
||||||
void printF32(char *msg, float32_t f) {
|
void printF32 (char *msg, float32_t f) {
|
||||||
sp conv;
|
sp conv;
|
||||||
|
int i, j;
|
||||||
conv.v = f.v; // use union to convert between hexadecimal and floating-point views
|
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) {
|
void printFlags(void) {
|
||||||
|
Loading…
Reference in New Issue
Block a user