1
0

further generalize fpga/vlsi builds

This commit is contained in:
Yunsup Lee 2014-09-08 00:21:57 -07:00
parent 3175a40509
commit ddfd3ce968
8 changed files with 45 additions and 48 deletions

View File

@ -1,5 +1,4 @@
MODEL := Top MODEL := Top
FPGAMODEL := FPGATop
CXX := g++ CXX := g++
CXXFLAGS := -O1 CXXFLAGS := -O1
@ -22,23 +21,14 @@ timeout_cycles = 100000000
# VLSI Backend # VLSI Backend
$(generated_dir)/$(MODEL).v: $(chisel_srcs) $(generated_dir)/$(MODEL).v: $(chisel_srcs)
cd $(base_dir) && mkdir -p $(generated_dir) && $(SBT) "project rocketchip" "elaborate $(MODEL) --backend rocketchip.RocketChipBackend --targetDir $(generated_dir) --noInlineMem --configInstance rocketchip.DefaultVLSIConfig" cd $(base_dir) && mkdir -p $(generated_dir) && $(SBT) "project rocketchip" "elaborate $(MODEL) --backend $(BACKEND) --targetDir $(generated_dir) --noInlineMem --configInstance rocketchip.$(CONFIG)"
cd $(generated_dir) && \ cd $(generated_dir) && \
if [ -a $(MODEL).conf ]; then \ if [ -a $(MODEL).conf ]; then \
sed -i 's*^*$(vlsi_mem_gen) *' $(MODEL).conf && \ $(mem_gen) $(generated_dir)/$(MODEL).conf >> $(generated_dir)/$(MODEL).v; \
sed -i 's*$$* >> $(MODEL).v*' $(MODEL).conf && \
sh $(MODEL).conf; \
fi fi
# FPGA Backend
$(generated_dir)/$(FPGAMODEL).v: $(chisel_srcs)
cd $(base_dir) && mkdir -p $(generated_dir) && $(SBT) "project rocketchip" "elaborate $(FPGAMODEL) --backend fpga --targetDir $(generated_dir) --configInstance rocketchip.DefaultFPGAConfig"
$(generated_dir)/$(FPGAMODEL)Mem.v: $(generated_dir)/$(FPGAMODEL).conf $(mem_gen)
$(mem_gen) $(generated_dir)/$(FPGAMODEL).conf > $(generated_dir)/$(FPGAMODEL)Mem.v
$(generated_dir)/memdessertMemDessert.v: $(base_dir)/$(src_path)/*.scala $(base_dir)/uncore/$(src_path)/*.scala $(generated_dir)/memdessertMemDessert.v: $(base_dir)/$(src_path)/*.scala $(base_dir)/uncore/$(src_path)/*.scala
cd $(base_dir) && mkdir -p $(generated_dir) && $(SBT) "project rocketchip" "elaborate MemDessert --backend v --targetDir $(generated_dir) --moduleNamePrefix memdessert --configInstance rocketchip.DefaultVLSIConfig" cd $(base_dir) && mkdir -p $(generated_dir) && $(SBT) "project rocketchip" "elaborate MemDessert --backend v --targetDir $(generated_dir) --moduleNamePrefix memdessert --configInstance rocketchip.$(CONFIG)"
#-------------------------------------------------------------------- #--------------------------------------------------------------------
# DRAMSim2 # DRAMSim2

View File

@ -15,6 +15,9 @@ mem_gen = $(base_dir)/fsim/fpga_mem_gen
sim_dir = . sim_dir = .
output_dir = $(sim_dir)/output output_dir = $(sim_dir)/output
BACKEND = fpga
CONFIG = DefaultFPGAConfig
include $(base_dir)/Makefrag include $(base_dir)/Makefrag
include $(sim_dir)/Makefrag include $(sim_dir)/Makefrag
include $(base_dir)/vsim/Makefrag-sim include $(base_dir)/vsim/Makefrag-sim

View File

@ -6,8 +6,7 @@
# Verilog sources # Verilog sources
sim_vsrcs = \ sim_vsrcs = \
$(generated_dir)/$(FPGAMODEL).v \ $(generated_dir)/$(MODEL).v \
$(generated_dir)/$(FPGAMODEL)Mem.v \
$(generated_dir)/memdessertMemDessert.v \ $(generated_dir)/memdessertMemDessert.v \
$(base_dir)/vsrc/const.vh \ $(base_dir)/vsrc/const.vh \
$(base_dir)/vsrc/rocketTestHarness.v \ $(base_dir)/vsrc/rocketTestHarness.v \
@ -45,7 +44,6 @@ VCS_OPTS = -notice -line +lint=all,noVCDE,noONGS,noUI -timescale=1ns/10ps -quiet
$(RISCV)/lib/libfesvr.so \ $(RISCV)/lib/libfesvr.so \
$(sim_dir)/libdramsim.a \ $(sim_dir)/libdramsim.a \
+define+FPGA \ +define+FPGA \
+define+TOP=$(FPGAMODEL) \
+define+CLOCK_PERIOD=0.5 $(sim_vsrcs) $(sim_csrcs) \ +define+CLOCK_PERIOD=0.5 $(sim_vsrcs) $(sim_csrcs) \
+define+PRINTF_COND=rocketTestHarness.verbose \ +define+PRINTF_COND=rocketTestHarness.verbose \
+libext+.v \ +libext+.v \

View File

@ -160,6 +160,7 @@ class FPGAConfig(default: ChiselConfig) extends ChiselConfig {
case NITLBEntries => 4 case NITLBEntries => 4
case NBTBEntries => 8 case NBTBEntries => 8
case NDTLBEntries => 4 case NDTLBEntries => 4
case UseBackupMemoryPort => false
case _ => default.topDefinitions(pname,site,here) case _ => default.topDefinitions(pname,site,here)
} }
} }

View File

@ -11,10 +11,13 @@ default: all
base_dir = $(abspath ..) base_dir = $(abspath ..)
generated_dir = $(abspath ./generated-src) generated_dir = $(abspath ./generated-src)
vlsi_mem_gen = $(base_dir)/vsim/vlsi_mem_gen mem_gen = $(base_dir)/vsim/vlsi_mem_gen
sim_dir = . sim_dir = .
output_dir = $(sim_dir)/output output_dir = $(sim_dir)/output
BACKEND = rocketchip.RocketChipBackend
CONFIG = DefaultVLSIConfig
include $(base_dir)/Makefrag include $(base_dir)/Makefrag
include $(sim_dir)/Makefrag include $(sim_dir)/Makefrag
include $(base_dir)/vsim/Makefrag-sim include $(base_dir)/vsim/Makefrag-sim

View File

@ -43,7 +43,6 @@ VCS_OPTS = -notice -line +lint=all,noVCDE,noONGS,noUI -timescale=1ns/10ps -quiet
-e vcs_main \ -e vcs_main \
$(RISCV)/lib/libfesvr.so \ $(RISCV)/lib/libfesvr.so \
$(sim_dir)/libdramsim.a \ $(sim_dir)/libdramsim.a \
+define+TOP=$(MODEL) \
+define+CLOCK_PERIOD=0.5 $(sim_vsrcs) $(sim_csrcs) \ +define+CLOCK_PERIOD=0.5 $(sim_vsrcs) $(sim_csrcs) \
+define+PRINTF_COND=rocketTestHarness.verbose \ +define+PRINTF_COND=rocketTestHarness.verbose \
+libext+.v \ +libext+.v \

View File

@ -4,6 +4,31 @@ import math
use_latches = 0 use_latches = 0
def parse_line(line):
name = ''
width = 0
depth = 0
ports = ''
mask_gran = 1
tokens = line.split()
i = 0
for i in xrange(0,len(tokens),2):
s = tokens[i]
if s == 'name':
name = tokens[i+1]
elif s == 'width':
width = int(tokens[i+1])
elif s == 'depth':
depth = int(tokens[i+1])
elif s == 'ports':
ports = tokens[i+1].split(',')
elif s == 'mask_gran':
# currently used only for fpga, but here for .conf format compatability
mask_gran = int(tokens[i+1])
else:
sys.exit('%s: unknown argument %s' % (sys.argv[0], a))
return (name, width, depth, ports)
def gen_mem(name, width, depth, ports): def gen_mem(name, width, depth, ports):
addr_width = max(math.ceil(math.log(depth)/math.log(2)),1) addr_width = max(math.ceil(math.log(depth)/math.log(2)),1)
port_spec = ['input CLK', 'input RST', 'input init'] port_spec = ['input CLK', 'input RST', 'input init']
@ -112,33 +137,11 @@ def gen_mem(name, width, depth, ports):
endmodule\n" % (name, ',\n '.join(port_spec), body) endmodule\n" % (name, ',\n '.join(port_spec), body)
return s return s
name = '' def main():
width = 0 if len(sys.argv) < 2:
depth = 0 sys.exit('Please give a .conf file as input')
ports = '' for line in open(sys.argv[1]):
print gen_mem(*parse_line(line))
tokens = sys.argv[1:len(sys.argv)] if __name__ == '__main__':
i = 0 main()
while i < len(tokens):
a = tokens[i]
if a == 'name':
name = tokens[i+1]
i += 1
elif a == 'width':
width = int(tokens[i+1])
i += 1
elif a == 'depth':
depth = int(tokens[i+1])
i += 1
elif a == 'ports':
ports = tokens[i+1].split(',')
i += 1
elif a == 'mask_gran':
# currently used only for fpga, but here for .conf format compatability
mask_gran = int(tokens[i+1])
i += 1
else:
sys.exit('%s: unknown argument %s' % (sys.argv[0], a))
i += 1
print gen_mem(name, width, depth, ports)

View File

@ -112,7 +112,7 @@ module rocketTestHarness;
wire #0.1 mem_bk_in_valid_delay = mem_bk_in_valid; wire #0.1 mem_bk_in_valid_delay = mem_bk_in_valid;
wire mem_bk_out_valid_delay; assign #0.1 mem_bk_out_valid = mem_bk_out_valid_delay; wire mem_bk_out_valid_delay; assign #0.1 mem_bk_out_valid = mem_bk_out_valid_delay;
`TOP dut Top dut
( (
.clk(clk), .clk(clk),
.reset(reset), .reset(reset),