Line 1... |
Line 1... |
################################################################################
|
################################################################################
|
#
|
##
|
# Filename: Makefile
|
## Filename: Makefile
|
#
|
##
|
# Project: Zip CPU -- a small, lightweight, RISC CPU soft core
|
## Project: Zip CPU -- a small, lightweight, RISC CPU soft core
|
#
|
##
|
# Purpose: To direct and simplify the build of a variety of simple assembly
|
## Purpose: To direct and simplify the build of a variety of simple assembly
|
# language test programs which will use one (or both) of the
|
## language test programs which will use one (or both) of the
|
# ZipCPU simulators.
|
## ZipCPU simulators.
|
#
|
##
|
# Targets include:
|
## Targets include:
|
#
|
##
|
# hellosim
|
## hellosim
|
# Using the SIM instruction, prints Hello World to the screen.
|
## Using the SIM instruction, prints Hello World to the screen.
|
#
|
##
|
# simuart
|
## simuart
|
# Same as hellosim, but without using the SIM instruction. This
|
## Same as hellosim, but without using the SIM instruction. This
|
# *should* be able to run successfully on a verilated or
|
## *should* be able to run successfully on a verilated or
|
# synthesized hardware, although I hvae yet to test it there.
|
## synthesized hardware, although I hvae yet to test it there.
|
#
|
##
|
# simtest
|
## simtest
|
# A set of simple tests designed to demonstrate if the simulator
|
## A set of simple tests designed to demonstrate if the simulator
|
# works or not.
|
## works or not.
|
#
|
##
|
# clean
|
## clean
|
# Removes the object file directory and any executables that have
|
## Removes the object file directory and any executables that have
|
# been created.
|
## been created.
|
#
|
##
|
# None of the files/targets below have any dependencies, or if they did,
|
## None of the files/targets below have any dependencies, or if they did,
|
# GCC can't determine them, so thus there is no make depends step.
|
## GCC can't determine them, so thus there is no make depends step.
|
#
|
##
|
# To actually run one of these programs, list the program on the command
|
## To actually run one of these programs, list the program on the command
|
# line with the ZipCPU simulator, zsim.
|
## line with the ZipCPU simulator, zsim.
|
#
|
##
|
#
|
##
|
#
|
##
|
# Creator: Dan Gisselquist, Ph.D.
|
## Creator: Dan Gisselquist, Ph.D.
|
# Gisselquist Technology, LLC
|
## Gisselquist Technology, LLC
|
#
|
##
|
################################################################################
|
################################################################################
|
#
|
##
|
# Copyright (C) 2017, Gisselquist Technology, LLC
|
## Copyright (C) 2017, Gisselquist Technology, LLC
|
#
|
##
|
# This program is free software (firmware): you can redistribute it and/or
|
## This program is free software (firmware): you can redistribute it and/or
|
# modify it under the terms of the GNU General Public License as published
|
## modify it under the terms of the GNU General Public License as published
|
# by the Free Software Foundation, either version 3 of the License, or (at
|
## by the Free Software Foundation, either version 3 of the License, or (at
|
# your option) any later version.
|
## your option) any later version.
|
#
|
##
|
# This program is distributed in the hope that it will be useful, but WITHOUT
|
## This program is distributed in the hope that it will be useful, but WITHOUT
|
# ANY WARRANTY; without even the implied warranty of MERCHANTIBILITY or
|
## ANY WARRANTY; without even the implied warranty of MERCHANTIBILITY or
|
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
## FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
# for more details.
|
## for more details.
|
#
|
##
|
# You should have received a copy of the GNU General Public License along
|
## You should have received a copy of the GNU General Public License along
|
# with this program. (It's in the $(ROOT)/doc directory. Run make with no
|
## with this program. (It's in the $(ROOT)/doc directory. Run make with no
|
# target there if the PDF file isn't present.) If not, see
|
## target there if the PDF file isn't present.) If not, see
|
# for a copy.
|
## for a copy.
|
#
|
##
|
# License: GPL, v3, as defined and found on www.gnu.org,
|
## License: GPL, v3, as defined and found on www.gnu.org,
|
# http://www.gnu.org/licenses/gpl.html
|
## http://www.gnu.org/licenses/gpl.html
|
#
|
##
|
#
|
##
|
################################################################################
|
################################################################################
|
#
|
##
|
|
##
|
.PHONY: all
|
.PHONY: all
|
all: $(OBJDIR)/ hellosim simtest simuart cmptest
|
all:
|
|
PROGRAMS := hellosim simuart simtest cmptest
|
|
all: $(PROGRAMS)
|
|
|
CC := zip-gcc
|
CC := zip-gcc
|
CPP := zip-cpp
|
CPP := zip-cpp
|
AS := zip-as
|
AS := zip-as
|
LD := zip-ld
|
LD := zip-ld
|
OBJDUMP := zip-objdump
|
OBJDUMP := zip-objdump
|
OBJDIR := obj-zip
|
OBJDIR := obj-zip
|
CFLAGS := -O3
|
CFLAGS := -O3
|
LIBD := ../../sw/install/cross-tools/zip/lib
|
LIBD := ../../sw/install/cross-tools/zip/lib
|
LIBS := -L$(LIBD) -lzipbasic
|
LIBS := -L$(LIBD) -lzipbasic
|
LDSCRIPT:= ../zipsim.ld
|
LDSCRIPT:= ./simscript.ld
|
|
|
$(OBJDIR)/%.o: %.c $(OBJDIR)/
|
$(OBJDIR)/%.o: %.c
|
|
$(mk-objdir)
|
$(CC) $(CFLAGS) -c $< -o $@
|
$(CC) $(CFLAGS) -c $< -o $@
|
|
|
$(OBJDIR)/%.o: %.s $(OBJDIR)/
|
$(OBJDIR)/%.o: %.s
|
|
$(mk-objdir)
|
$(AS) $< -o $@
|
$(AS) $< -o $@
|
|
|
%.txt: %
|
%.txt: %
|
$(OBJDUMP) -dr $< > $@
|
$(OBJDUMP) -dr $< > $@
|
|
|
Line 111... |
Line 116... |
# used to determine whether the simulator has a basic amount of functionality.
|
# used to determine whether the simulator has a basic amount of functionality.
|
# Because the test includes #define, #ifdef, and #endif statements, though, it
|
# Because the test includes #define, #ifdef, and #endif statements, though, it
|
# needs to be run through the C pre-processor before it can go through the
|
# needs to be run through the C pre-processor before it can go through the
|
# assembler. Hence the build is a tocuh trickier, but still simple enough.
|
# assembler. Hence the build is a tocuh trickier, but still simple enough.
|
#
|
#
|
$(OBJDIR)/simtest.o: simtest.s $(OBJDIR)/
|
$(OBJDIR)/simtest.o: simtest.s
|
|
$(mk-objdir)
|
$(CPP) $< > $(OBJDIR)/simtest.s
|
$(CPP) $< > $(OBJDIR)/simtest.s
|
$(AS) $(OBJDIR)/simtest.s -o $@
|
$(AS) $(OBJDIR)/simtest.s -o $@
|
|
|
simtest: $(OBJDIR)/simtest.o
|
simtest: $(OBJDIR)/simtest.o
|
$(LD) -T $(LDSCRIPT) $< -o $@
|
$(LD) -T $(LDSCRIPT) $< -o $@
|
|
|
cmptest: $(OBJDIR)/cmptest.o
|
cmptest: $(OBJDIR)/cmptest.o
|
$(LD) -T $(LDSCRIPT) -Map=map.txt $< -o $@
|
$(LD) -T $(LDSCRIPT) -Map=map.txt $< -o $@
|
|
|
|
|
$(OBJDIR)/:
|
define mk-objdir
|
@bash -c "if [[ ! -e $(OBJDIR) ]]; then mkdir -p $(OBJDIR)/; fi"
|
@bash -c "if [[ ! -e $(OBJDIR) ]]; then mkdir -p $(OBJDIR)/; fi"
|
|
endef
|
|
|
|
tags: $(wildcard *.c) $(wildcard *.h) $(wildcard *.cpp)
|
|
@echo "Generating tags"
|
|
@ctags $(wildcard *.c) $(wildcard *.h)
|
|
|
.PHONY: clean
|
.PHONY: clean
|
clean:
|
clean:
|
rm -rf $(OBJDIR)/
|
rm -rf $(OBJDIR)/
|
rm -rf hellosim simuart simtest
|
rm -rf $(PROGRAMS)
|
rm -rf $(PROGRAMS)
|
rm -rf $(PROGRAMS)
|