Rework Makefile

Instead of building each file one by one (and having to track all
the dependencies manually), use the ghdl -c command that does
analysis and elaboration in one go.

Signed-off-by: Anton Blanchard <anton@linux.ibm.com>
jtag-port
Anton Blanchard 5 years ago committed by Anton Blanchard
parent b82d07c8d5
commit 224e7734a8

@ -1,134 +1,62 @@
GHDL=ghdl GHDL=ghdl
GHDLFLAGS=--std=08 -Psim-unisim GHDLFLAGS=--std=08 --work=unisim
CFLAGS=-O2 -Wall CFLAGS=-O2 -Wall


# We need a version of GHDL built with either the LLVM or gcc backend. # We need a version of GHDL built with either the LLVM or gcc backend.
# Fedora provides this, but other distros may not. Another option, although # Fedora provides this, but other distros may not. Another option is to use
# rather slow, is to use the Docker image. # the Docker image.
# #
# Uncomment one of these to build with Docker or podman # Uncomment one of these to build with Docker or podman
#DOCKER=docker #DOCKER=docker
#DOCKER=podman DOCKER=podman
# #
# Uncomment these lines to build with Docker/podman # Uncomment these lines to build with Docker/podman
#PWD = $(shell pwd) PWD = $(shell pwd)
#DOCKERARGS = run --rm -v $(PWD):/src:z -w /src DOCKERARGS = run --rm -v $(PWD):/src:z -w /src
#GHDL = $(DOCKER) $(DOCKERARGS) ghdl/ghdl:buster-llvm-7 ghdl GHDL = $(DOCKER) $(DOCKERARGS) ghdl/ghdl:buster-llvm-7 ghdl
#CC = $(DOCKER) $(DOCKERARGS) ghdl/ghdl:buster-llvm-7 gcc CC = $(DOCKER) $(DOCKERARGS) ghdl/ghdl:buster-llvm-7 gcc


all = core_tb soc_reset_tb icache_tb dcache_tb multiply_tb dmi_dtm_tb divider_tb \ all = core_tb icache_tb dcache_tb multiply_tb dmi_dtm_tb divider_tb \
rotator_tb countzero_tb wishbone_bram_tb rotator_tb countzero_tb wishbone_bram_tb soc_reset_tb

# XXX
# loadstore_tb fetch_tb


all: $(all) all: $(all)


%.o : %.vhdl CORE_FILES=decode_types.vhdl common.vhdl wishbone_types.vhdl fetch1.vhdl
$(GHDL) -a $(GHDLFLAGS) --workdir=$(shell dirname $@) $< CORE_FILES+=fetch2.vhdl utils.vhdl plru.vhdl cache_ram.vhdl icache.vhdl

CORE_FILES+=decode1.vhdl helpers.vhdl insn_helpers.vhdl gpr_hazard.vhdl
common.o: decode_types.o CORE_FILES+=cr_hazard.vhdl control.vhdl decode2.vhdl register_file.vhdl
control.o: gpr_hazard.o cr_hazard.o common.o CORE_FILES+=cr_file.vhdl crhelpers.vhdl ppc_fx_insns.vhdl rotator.vhdl
sim_jtag.o: sim_jtag_socket.o CORE_FILES+=logical.vhdl countzero.vhdl multiply.vhdl divider.vhdl
core_tb.o: common.o wishbone_types.o core.o soc.o sim_jtag.o CORE_FILES+=execute1.vhdl loadstore1.vhdl mmu.vhdl dcache.vhdl
core.o: common.o wishbone_types.o fetch1.o fetch2.o icache.o decode1.o decode2.o register_file.o cr_file.o execute1.o loadstore1.o mmu.o dcache.o writeback.o core_debug.o CORE_FILES+=writeback.vhdl core_debug.vhdl core.vhdl
core_debug.o: common.o
countzero.o: SOC_FILES=wishbone_arbiter.vhdl wishbone_bram_wrapper.vhdl
countzero_tb.o: common.o glibc_random.o countzero.o SOC_FILES+=wishbone_debug_master.vhdl xics.vhdl syscon.vhdl soc.vhdl
cr_file.o: common.o
crhelpers.o: common.o SOC_SIM_FILES=sim_console.vhdl sim_uart.vhdl sim_bram_helpers.vhdl
decode1.o: common.o decode_types.o SOC_SIM_FILES+=sim_bram.vhdl sim_jtag_socket.vhdl sim_jtag.vhdl
decode2.o: decode_types.o common.o helpers.o insn_helpers.o control.o SOC_SIM_FILES+=sim-unisim/BUFG.vhdl sim-unisim/unisim_vcomponents.vhdl
decode_types.o: SOC_SIM_FILES+=dmi_dtm_xilinx.vhdl
execute1.o: decode_types.o common.o helpers.o crhelpers.o insn_helpers.o ppc_fx_insns.o rotator.o logical.o countzero.o multiply.o divider.o
fetch1.o: common.o SOC_SIM_C_FILES=sim_vhpi_c.o sim_bram_helpers_c.o sim_console_c.o
fetch2.o: common.o wishbone_types.o SOC_SIM_C_FILES+=sim_jtag_socket_c.o
glibc_random_helpers.o: SOC_SIM_OBJ_FILES=$(SOC_SIM_C_FILES:.c=.o)
glibc_random.o: glibc_random_helpers.o comma := ,
helpers.o: SOC_SIM_LINK=$(patsubst %,-Wl$(comma)%,$(SOC_SIM_OBJ_FILES))
cache_ram.o:
plru.o: CORE_TBS=multiply_tb divider_tb rotator_tb countzero_tb
plru_tb.o: plru.o SOC_TBS=core_tb icache_tb dcache_tb dmi_dtm_tb wishbone_bram_tb
utils.o:
sim_bram.o: sim_bram_helpers.o utils.o $(processes): %_processes: tests/%.o main.c
wishbone_bram_wrapper.o: wishbone_types.o sim_bram.o utils.o
wishbone_bram_tb.o: wishbone_bram_wrapper.o $(SOC_TBS): %: $(CORE_FILES) $(SOC_FILES) $(SOC_SIM_FILES) $(SOC_SIM_OBJ_FILES) %.vhdl
icache.o: utils.o common.o wishbone_types.o plru.o cache_ram.o utils.o $(GHDL) -c $(GHDLFLAGS) $(SOC_SIM_LINK) $(CORE_FILES) $(SOC_FILES) $(SOC_SIM_FILES) $@.vhdl -e $@
icache_tb.o: common.o wishbone_types.o icache.o wishbone_bram_wrapper.o
dcache.o: utils.o common.o wishbone_types.o plru.o cache_ram.o utils.o $(CORE_TBS): %: $(CORE_FILES) glibc_random.vhdl glibc_random_helpers.vhdl %.vhdl
dcache_tb.o: common.o wishbone_types.o dcache.o wishbone_bram_wrapper.o $(GHDL) -c $(GHDLFLAGS) $(CORE_FILES) glibc_random.vhdl glibc_random_helpers.vhdl $@.vhdl -e $@
insn_helpers.o:
loadstore1.o: common.o decode_types.o soc_reset_tb: fpga/soc_reset_tb.vhdl fpga/soc_reset.vhdl
logical.o: decode_types.o $(GHDL) -c $(GHDLFLAGS) fpga/soc_reset_tb.vhdl fpga/soc_reset.vhdl -e $@
multiply_tb.o: decode_types.o common.o glibc_random.o ppc_fx_insns.o multiply.o
multiply.o: common.o decode_types.o
mmu.o: common.o
divider_tb.o: decode_types.o common.o glibc_random.o ppc_fx_insns.o divider.o
divider.o: common.o decode_types.o
ppc_fx_insns.o: helpers.o
register_file.o: common.o
rotator.o: common.o
rotator_tb.o: common.o glibc_random.o ppc_fx_insns.o insn_helpers.o rotator.o
sim_console.o:
sim_uart.o: wishbone_types.o sim_console.o
xics.o: wishbone_types.o common.o
soc.o: common.o wishbone_types.o core.o wishbone_arbiter.o sim_uart.o wishbone_bram_wrapper.o dmi_dtm_xilinx.o wishbone_debug_master.o xics.o syscon.o
syscon.o: wishbone_types.o
wishbone_arbiter.o: wishbone_types.o
wishbone_types.o:
writeback.o: common.o crhelpers.o
dmi_dtm_tb.o: dmi_dtm_xilinx.o wishbone_debug_master.o
dmi_dtm_xilinx.o: wishbone_types.o sim-unisim/unisim_vcomponents.o
wishbone_debug_master.o: wishbone_types.o

UNISIM_BITS = sim-unisim/unisim_vcomponents.vhdl sim-unisim/BSCANE2.vhdl sim-unisim/BUFG.vhdl
sim-unisim/unisim_vcomponents.o: $(UNISIM_BITS)
$(GHDL) -a $(GHDLFLAGS) --work=unisim --workdir=sim-unisim $^


fpga/soc_reset_tb.o: fpga/soc_reset.o

soc_reset_tb: fpga/soc_reset_tb.o fpga/soc_reset.o
$(GHDL) -e $(GHDLFLAGS) --workdir=fpga soc_reset_tb

core_tb: core_tb.o sim_vhpi_c.o sim_bram_helpers_c.o sim_console_c.o sim_jtag_socket_c.o
$(GHDL) -e $(GHDLFLAGS) -Wl,sim_vhpi_c.o -Wl,sim_bram_helpers_c.o -Wl,sim_console_c.o -Wl,sim_jtag_socket_c.o $@

fetch_tb: fetch_tb.o
$(GHDL) -e $(GHDLFLAGS) $@

icache_tb: icache_tb.o sim_vhpi_c.o sim_bram_helpers_c.o
$(GHDL) -e $(GHDLFLAGS) -Wl,sim_vhpi_c.o -Wl,sim_bram_helpers_c.o $@

dcache_tb: dcache_tb.o sim_vhpi_c.o sim_bram_helpers_c.o
$(GHDL) -e $(GHDLFLAGS) -Wl,sim_vhpi_c.o -Wl,sim_bram_helpers_c.o $@

plru_tb: plru_tb.o
$(GHDL) -e $(GHDLFLAGS) $@

loadstore_tb: loadstore_tb.o
$(GHDL) -e $(GHDLFLAGS) $@

multiply_tb: multiply_tb.o
$(GHDL) -e $(GHDLFLAGS) $@

divider_tb: divider_tb.o
$(GHDL) -e $(GHDLFLAGS) $@

rotator_tb: rotator_tb.o
$(GHDL) -e $(GHDLFLAGS) $@

countzero_tb: countzero_tb.o
$(GHDL) -e $(GHDLFLAGS) $@

simple_ram_tb: simple_ram_tb.o
$(GHDL) -e $(GHDLFLAGS) $@

wishbone_bram_tb: sim_vhpi_c.o sim_bram_helpers_c.o wishbone_bram_tb.o
$(GHDL) -e $(GHDLFLAGS) -Wl,sim_vhpi_c.o -Wl,sim_bram_helpers_c.o $@

dmi_dtm_tb: dmi_dtm_tb.o sim_vhpi_c.o sim_bram_helpers_c.o
$(GHDL) -e $(GHDLFLAGS) -Wl,sim_vhpi_c.o -Wl,sim_bram_helpers_c.o $@


tests = $(sort $(patsubst tests/%.out,%,$(wildcard tests/*.out))) tests = $(sort $(patsubst tests/%.out,%,$(wildcard tests/*.out)))
tests_console = $(sort $(patsubst tests/%.console_out,%,$(wildcard tests/*.console_out))) tests_console = $(sort $(patsubst tests/%.console_out,%,$(wildcard tests/*.console_out)))

Loading…
Cancel
Save