This commit is contained in:
Kip Macsai-Goren 2022-02-28 19:14:18 +00:00
commit 0715c62de5
6 changed files with 166 additions and 27 deletions

2
.gitignore vendored
View File

@ -53,7 +53,7 @@ examples/asm/example/example
examples/C/sum/sum
examples/C/fir/fir
examples/fp/softfloat_demo/softfloat_demo
examples/fp/softfloat_calc/softfloat_calc
examples/fp/fpcalc/fpcalc
pipelined/src/fma/fma16_testgen
linux/devicetree/debug/*
!linux/devicetree/debug/dump-dts.sh

View File

@ -29,26 +29,97 @@ typedef union dp {
int opSize = 0;
void long2binstr(long val, char *str, int bits) {
int i;
long masked;
if (val == 0) { // just return zero
str[0] = '0';
str[1] = 0;
} else {
for (i=0; i<bits && val != 0; i++) {
masked = val & ~(1 << (bits-i-1)); // mask off the bit
if (masked != val) str[i] = '1';
else str[i] = '0';
//printf(" Considering %d masked %d str[%d] %c\n", val, masked, i, str[i]);
val = masked;
if (!val) str[i+1] = 0; // terminate when out of nonzero digits
}
}
}
void printF16(char *msg, float16_t f) {
hp convh;
sp convf;
long exp, fract;
char sign;
char sci[80], fractstr[80];
float32_t temp;
convh.v = f.v; // use union to convert between hexadecimal and floating-point views
temp = f16_to_f32(convh.h);
convf.ft = temp;
printf ("%s: 0x%04x = %g\n", msg, convh.v, convf.f); // no easy way to print half prec.
fract = f.v & ((1<<10) - 1); long2binstr(fract, fractstr, 10);
exp = (f.v >> 10) & ((1<<5) -1);
sign = f.v >> 15 ? '-' : '+';
//printf("%c %d %d ", sign, exp, fract);
if (exp == 0 && fract == 0) sprintf(sci, "%czero", sign);
else if (exp == 0 && fract != 0) sprintf(sci, "Denorm: %c0.%s x 2^-14", sign, fractstr);
else if (exp == 31 && fract == 0) sprintf(sci, "%cinf", sign);
else if (exp == 31 && fract != 0) sprintf(sci, "NaN Payload: %c%s", sign, fractstr);
else sprintf(sci, "%c1.%s x 2^%d", sign, fractstr, exp-15);
printf ("%s: 0x%04x = %g = %s: Biased Exp %d Fract 0x%lx\n",
msg, convh.v, convf.f, sci, exp, fract); // no easy way to print half prec.
}
void printF32(char *msg, float32_t f) {
sp conv;
long exp, fract;
char sign;
char sci[80], fractstr[80];
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);
fract = f.v & ((1<<23) - 1); long2binstr(fract, fractstr, 23);
exp = (f.v >> 23) & ((1<<8) -1);
sign = f.v >> 31 ? '-' : '+';
//printf("%c %d %d ", sign, exp, fract);
if (exp == 0 && fract == 0) sprintf(sci, "%czero", sign);
else if (exp == 0 && fract != 0) sprintf(sci, "Denorm: %c0.%s x 2^-126", sign, fractstr);
else if (exp == 255 && fract == 0) sprintf(sci, "%cinf", sign);
else if (exp == 255 && fract != 0) sprintf(sci, "NaN Payload: %c%s", sign, fractstr);
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);
}
void printF64(char *msg, float64_t f) {
dp conv;
long exp, fract;
long mask;
char sign;
char sci[80], fractstr[80];
conv.v = f.v; // use union to convert between hexadecimal and floating-point views
printf ("%s: 0x%016lx = %lg\n", msg, conv.v, conv.d);
mask = 1; mask = (mask << 52) - 1;
fract = f.v & mask; long2binstr(fract, fractstr, 52);
exp = (f.v >> 52) & ((1<<11) -1);
sign = f.v >> 63 ? '-' : '+';
//printf("%c %d %d ", sign, exp, fract);
if (exp == 0 && fract == 0) sprintf(sci, "%czero", sign);
else if (exp == 0 && fract != 0) sprintf(sci, "Denorm: %c0.%s x 2^-1022", sign, fractstr);
else if (exp == 2047 && fract == 0) sprintf(sci, "%cinf", sign);
else if (exp == 2047 && fract != 0) sprintf(sci, "NaN Payload: %c%s", sign, fractstr);
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);
}
void printFlags(void) {

View File

@ -37,6 +37,7 @@ module adrdecs (
input logic [1:0] Size,
output logic [8:0] SelRegions
);
logic [3:0] clintaccesssize;
// Determine which region of physical memory (if any) is being accessed
// *** eventually uncomment Access signals
@ -44,7 +45,8 @@ module adrdecs (
adrdec boottimdec(PhysicalAddress, `BOOTROM_BASE, `BOOTROM_RANGE, `BOOTROM_SUPPORTED, /*1'b1*/AccessRX, Size, 4'b1111, SelRegions[6]);
adrdec timdec(PhysicalAddress, `RAM_BASE, `RAM_RANGE, `RAM_SUPPORTED, /*1'b1*/AccessRWX, Size, 4'b1111, SelRegions[5]);
adrdec clintdec(PhysicalAddress, `CLINT_BASE, `CLINT_RANGE, `CLINT_SUPPORTED, AccessRW, Size, 4'b1111, SelRegions[4]);
assign clintaccesssize = (`XLEN==64) ? 4'b1000 : 4'b0100;
adrdec clintdec(PhysicalAddress, `CLINT_BASE, `CLINT_RANGE, `CLINT_SUPPORTED, AccessRW, Size, clintaccesssize, SelRegions[4]);
adrdec gpiodec(PhysicalAddress, `GPIO_BASE, `GPIO_RANGE, `GPIO_SUPPORTED, AccessRW, Size, 4'b0100, SelRegions[3]);
adrdec uartdec(PhysicalAddress, `UART_BASE, `UART_RANGE, `UART_SUPPORTED, AccessRW, Size, 4'b0001, SelRegions[2]);
adrdec plicdec(PhysicalAddress, `PLIC_BASE, `PLIC_RANGE, `PLIC_SUPPORTED, AccessRW, Size, 4'b0100, SelRegions[1]);

View File

@ -124,11 +124,11 @@ module hptw
assign {Dirty, Accessed} = PTE[7:6];
assign WriteAccess = (MemRWM[0] | |AtomicM);
assign SetDirty = ~Dirty & & DTLBWalk & WriteAccess;
assign WriteAccess = MemRWM[0] | (|AtomicM);
assign SetDirty = ~Dirty & DTLBWalk & WriteAccess;
assign ReadAccess = MemRWM[1];
assign EffectivePrivilegeMode = (DTLBWalk == 0) ? PrivilegeModeW : (STATUS_MPRV ? STATUS_MPP : PrivilegeModeW); // DTLB uses MPP mode when MPRV is 1
assign EffectivePrivilegeMode = DTLBWalk ? (STATUS_MPRV ? STATUS_MPP : PrivilegeModeW) : PrivilegeModeW; // DTLB uses MPP mode when MPRV is 1
assign ImproperPrivilege = ((EffectivePrivilegeMode == `U_MODE) & ~PTE_U) |
((EffectivePrivilegeMode == `S_MODE) & PTE_U & (~STATUS_SUM & DTLBWalk));

View File

@ -22,11 +22,10 @@ export OUTPUTDIR := runs/$(DESIGN)_$(CONFIG)_$(TECH)nm_$(FREQ)_MHz_$(time)_$(has
export SAIFPOWER ?= 0
CONFIGDIR ?= ~/riscv-wally/pipelined/config
#CONFIGS ?= $(shell find $(CONFIGDIR) -name "rv*")
CONFIGS ?= ("rv32e", "rv32ic")
CONFIGFILES ?= $(shell find $(CONFIGDIR) -name rv*_*)
CONFIGFILESTRIM = $(notdir $(CONFIGFILES))
print:
echo "files in $(CONFIGDIR) are $(CONFIGS)."
echo $(CONFIGFILESTRIM)
default:
@echo "Basic synthesis procedure for Wally:"
@ -38,22 +37,64 @@ test: rv%
rv%.log: rv%
echo $<
flavors:
rm -rf $(CONFIGDIR)/rv32em
cp -r $(CONFIGDIR)/rv32e $(CONFIGDIR)/rv32em
sed -i 's/h00000010/h00001010/' $(CONFIGDIR)/rv32em/wally-config.vh
# rv32e, 32ic, 32gc 64ic, 64gc
# 64gc - FPU
# PMP16
# PMP0
# No virtual memory
# Muldiv
allsynth:
make flavors
make synth DESIGN=wallypipelinedcore CONFIG=rv32e TECH=sky90 FREQ=500 MAXCORES=1
make synth DESIGN=wallypipelinedcore CONFIG=rv32em TECH=sky90 FREQ=500 MAXCORES=1
DIRS = rv32e rv32gc rv64ic rv64gc rv32ic
# DELDIRS = rv32e rv32gc rv64ic rv64gc rv32ic
# CONFIGSUBDIRS = _FPUoff _noMulDiv _noVirtMem _PMP0 _PMP16 _orig
del:
@$(foreach dir, $(DIRS), rm -rf $(CONFIGDIR)/$(dir)_orig;)
@$(foreach dir, $(DIRS), rm -rf $(CONFIGDIR)/$(dir)_FPUoff;)
@$(foreach dir, $(DIRS), rm -rf $(CONFIGDIR)/$(dir)_PMP16;)
@$(foreach dir, $(DIRS), rm -rf $(CONFIGDIR)/$(dir)_PMP0;)
@$(foreach dir, $(DIRS), rm -rf $(CONFIGDIR)/$(dir)_noVirtMem;)
@$(foreach dir, $(DIRS), rm -rf $(CONFIGDIR)/$(dir)_noMulDiv;)
configs: $(DIRS)
$(DIRS):
#turn off FPU
rm -rf $(CONFIGDIR)/$@_FPUoff
cp -r $(CONFIGDIR)/$@ $(CONFIGDIR)/$@_FPUoff
sed -i 's/1 *<< *3/0 << 3/' $(CONFIGDIR)/$@_FPUoff/wally-config.vh
sed -i 's/1 *<< *5/0 << 5/' $(CONFIGDIR)/$@_FPUoff/wally-config.vh
# PMP 16
rm -rf $(CONFIGDIR)/$@_PMP16
cp -r $(CONFIGDIR)/$@_FPUoff $(CONFIGDIR)/$@_PMP16
# sed -i 's/1 *<< *3/0 << 3/' $(CONFIGDIR)/$@_PMP16/wally-config.vh
# sed -i 's/1 *<< *5/0 << 5/' $(CONFIGDIR)/$@_PMP16/wally-config.vh
sed -i 's/PMP_ENTRIES \(64\|16\|0\)/PMP_ENTRIES 16/' $(CONFIGDIR)/$@_PMP16/wally-config.vh
# PMP 0
rm -rf $(CONFIGDIR)/$@_PMP0
cp -r $(CONFIGDIR)/$@_FPUoff $(CONFIGDIR)/$@_PMP0
# sed -i 's/1 *<< *3/0 << 3/' $(CONFIGDIR)/$@_PMP0/wally-config.vh
# sed -i 's/1 *<< *5/0 << 5/' $(CONFIGDIR)/$@_PMP0/wally-config.vh
sed -i 's/PMP_ENTRIES \(64\|16\|0\)/PMP_ENTRIES 0/' $(CONFIGDIR)/$@_PMP0/wally-config.vh
# No Virtual Memory
rm -rf $(CONFIGDIR)/$@_noVirtMem
# cp -r $(CONFIGDIR)/$@ $(CONFIGDIR)/$@_noVirtMem
# sed -i 's/1 *<< *3/0 <_PMP0< 3/' $(CONFIGDIR)/$@_noVirtMem/wally-config.vh
# sed -i 's/1 *<< *5/0 << 5/' $(CONFIGDIR)/$@_noVirtMem/wally-config.vh
# sed -i 's/PMP_ENTRIES \(64\|16\|0\)/PMP_ENTRIES 0/' $(CONFIGDIR)/$@_noVirtMem/wally-config.vh
sed -i 's/VIRTMEM_SUPPORTED 1/VIRTMEM_SUPPORTED 0/' $(CONFIGDIR)/$@_noVirtMem/wally-config.vh
#no muldiv
rm -rf $(CONFIGDIR)/$@_noMulDiv
cp -r $(CONFIGDIR)/$@_noVirtMem $(CONFIGDIR)/$@_noMulDiv
# sed -i 's/1 *<< *3/0 << 3/' $(CONFIGDIR)/$@_noMulDiv/wally-config.vh
# sed -i 's/1 *<< *5/0 << 5/' $(CONFIGDIR)/$@_noMulDiv/wally-config.vh
# sed -i 's/PMP_ENTRIES \(64\|16\|0\)/PMP_ENTRIES 0/' $(CONFIGDIR)/$@_noMulDiv/wally-config.vh
# sed -i 's/VIRTMEM_SUPPORTED 1/VIRTMEM_SUPPORTED 0/' $(CONFIGDIR)/$@_noMulDiv/wally-config.vh
sed -i 's/1 *<< *12/0 << 12/' $(CONFIGDIR)/$@_noMulDiv/wally-config.vh
allsynth: $(CONFIGFILESTRIM)
$(CONFIGFILESTRIM):
make synth DESIGN=wallypipelinedcore CONFIG=$@ TECH=sky90 FREQ=500 MAXCORES=1 --jobs
synth:
@echo "DC Synthesis"

25
synthDC/extractSummary.py Normal file
View File

@ -0,0 +1,25 @@
import glob
import re
import csv
field_names = [ 'Name', 'Critical Path Length', 'Cell Area']
data = []
for name in glob.glob("/home/ssanghai/riscv-wally/synthDC/runs/*/reports/wallypipelinedcore_qor.rep"):
f = open(name, 'r')
# trimName = re.search("runs\/(.*?)\/reports", name).group(1)
trimName = re.search("wallypipelinedcore_(.*?)_sky9",name).group(1)
for line in f:
if "Critical Path Length" in line:
pathLen = re.search("Length: *(.*?)\\n", line).group(1)
if "Cell Area" in line:
area = re.search("Area: *(.*?)\\n", line).group(1)
data += [{'Name' : trimName, 'Critical Path Length': pathLen, 'Cell Area' : area}]
with open('Summary.csv', 'w') as csvfile:
writer = csv.DictWriter(csvfile, fieldnames=field_names)
writer.writeheader()
writer.writerows(data)