OpenCores
URL https://opencores.org/ocsvn/forth-cpu/forth-cpu/trunk

Subversion Repositories forth-cpu

[/] [forth-cpu/] [trunk/] [makefile] - Diff between revs 3 and 5

Show entire file | Details | Blame | View Log

Rev 3 Rev 5
Line 1... Line 1...
#
#
# Makefile to simulate and synthesize VHDL designs
# Makefile to simulate and synthesize VHDL designs
#
#
# @Author      Marc Eberhard/Richard Howe
# @Author      Marc Eberhard/Richard Howe
# @Copyright   Copyright 2013 Marc Eberhard, 2016 Richard Howe
# @Copyright   Copyright 2013 Marc Eberhard, 2016,2020 Richard Howe
# @License     LGPL
# @License     LGPL
#
#
# This makefile can build the toolchain, simulators, and the bit
# This makefile can build the toolchain, simulators, and the bit
# file for the FPGA. Type "make help" at the command line for a
# file for the FPGA. Type "make help" at the command line for a
# list of options
# list of options
#
#
 
 
NETLIST=top
NETLIST=top
#TIME=time -p
CFLAGS=-Wall -Wextra -O2 -g -pedantic
 
CC=gcc
TIME=
TIME=
 
#TIME=time -p
 
 
OS_FLAGS =
OS_FLAGS =
# From: https://stackoverflow.com/questions/714100/os-detecting-makefile
# From: https://stackoverflow.com/questions/714100/os-detecting-makefile
ifeq ($(OS),Windows_NT)
ifeq ($(OS),Windows_NT)
GUI_LDFLAGS = -lfreeglut -lopengl32 -lm
GUI_LDFLAGS = -lfreeglut -lopengl32 -lm
Line 43... Line 45...
        uart.vhd \
        uart.vhd \
        kbd.vhd \
        kbd.vhd \
        vga.vhd \
        vga.vhd \
        h2.vhd \
        h2.vhd \
        ram.vhd \
        ram.vhd \
        core.vhd \
        core.vhd
        led.vhd
 
 
 
OBJECTS = ${SOURCES:.vhd=.o}
OBJECTS = ${SOURCES:.vhd=.o}
 
 
all:
all:
        @echo ""
        @echo ""
Line 58... Line 59...
        @echo "make viewer         - start waveform viewer for simulation results"
        @echo "make viewer         - start waveform viewer for simulation results"
        @echo "make documentation  - build the PDF and HTML documentation"
        @echo "make documentation  - build the PDF and HTML documentation"
        @echo "make h2${EXE}             - build C based CLI emulator for the VHDL SoC"
        @echo "make h2${EXE}             - build C based CLI emulator for the VHDL SoC"
        @echo "make gui${EXE}            - build C based GUI emulator for the Nexys3 board"
        @echo "make gui${EXE}            - build C based GUI emulator for the Nexys3 board"
        @echo "make run            - run the C CLI emulator on h2.fth"
        @echo "make run            - run the C CLI emulator on h2.fth"
        @echo "make gui-run        - run the GUI emulator on h2.hex"
        @echo "make gui-run        - run the GUI emulator on ${EFORTH}"
        @echo ""
        @echo ""
        @echo "Synthesis:"
        @echo "Synthesis:"
        @echo ""
        @echo ""
        @echo "make synthesis      - synthesize design"
        @echo "make synthesis      - synthesize design"
        @echo "make implementation - implement design"
        @echo "make implementation - implement design"
Line 85... Line 86...
        pandoc -V geometry:margin=0.5in --toc $< -o $@
        pandoc -V geometry:margin=0.5in --toc $< -o $@
 
 
%.htm: %.md
%.htm: %.md
        pandoc --toc --self-contained $^ -o $@
        pandoc --toc --self-contained $^ -o $@
 
 
## Assembler ===============================================================
## Assembler, Virtual Machine and UART communications ======================
 
 
%.hex: %.fth h2${EXE}
 
        ${DF}h2 -S h2.sym -a $< > $@
 
 
 
## Virtual Machine and UART communications =================================
EFORTH=h2.hex
 
 
CFLAGS=-Wall -Wextra -O2 -g
 
 
 
h2${EXE}: h2.c h2.h
h2${EXE}: h2.c h2.h
        ${CC} ${CFLAGS} -std=c99 $< -o $@
        ${CC} ${CFLAGS} -std=c99 $< -o $@
 
 
disassemble: h2${EXE} h2.fth
embed${EXE}: embed.c
        ${DF}h2 -S h2.sym -a h2.fth > h2.hex
        ${CC} ${CFLAGS} -std=c99 $< -o $@
        ${DF}h2 -L h2.sym h2.hex | awk '{printf "%04x %s\n", NR-1, $$0;}' | less -
 
 
${EFORTH}: embed${EXE} embed.blk embed.fth
 
        ${DF}embed${EXE} embed.blk $@ embed.fth
 
 
block${EXE}: block.c
block${EXE}: block.c
        ${CC} ${CFLAGS} -std=c99 $< -o $@
        ${CC} ${CFLAGS} -std=c99 $< -o $@
 
 
h2.sym: h2.hex
nvram.blk: nvram.txt block${EXE}
 
 
nvram.blk: nvram.txt h2.sym block${EXE}
 
        ${DF}block${EXE} < nvram.txt >  $@
        ${DF}block${EXE} < nvram.txt >  $@
        ${DF}block${EXE} < h2.sym    >> $@
 
 
 
# %.blk: %.txt block${EXE}
 
#       ${DF}block${EXE} < $< > $@
 
 
 
run: h2${EXE} h2.fth nvram.blk
run: h2${EXE} ${EFORTH} text.hex nvram.blk
        ${DF}h2 -H -R h2.fth
        ${DF}h2 -H -r ${EFORTH}
 
 
h2nomain.o: h2.c h2.h
h2nomain.o: h2.c h2.h
        ${CC} ${CFLAGS} -std=c99 -DNO_MAIN  $< -c -o $@
        ${CC} ${CFLAGS} -std=c99 -DNO_MAIN  $< -c -o $@
 
 
gui.o: gui.c h2.h
gui.o: gui.c h2.h
        ${CC} ${CFLAGS} -std=gnu99  $< -c -o $@
        ${CC} ${CFLAGS} -std=gnu99  $< -c -o $@
 
 
gui${EXE}: h2nomain.o gui.o
gui${EXE}: h2nomain.o gui.o
        ${CC} ${CFLAGS} $^ ${GUI_LDFLAGS} -o $@
        ${CC} ${CFLAGS} $^ ${GUI_LDFLAGS} -o $@
 
 
gui-run: gui${EXE} h2.hex nvram.blk text.hex
gui-run: gui${EXE} ${EFORTH} nvram.blk text.hex
        ${DF}$< h2.hex
        ${DF}$< ${EFORTH}
 
 
text${EXE}: text.c
text${EXE}: text.c
        ${CC} ${CFLAGS} -std=c99 $< -o $@
        ${CC} ${CFLAGS} -std=c99 $< -o $@
 
 
text.hex: text${EXE}
text.hex: text${EXE}
        ${DF}$< -g > $@
        ${DF}$< -g > $@
 
 
## Simulation ==============================================================
## Simulation ==============================================================
 
 
%.o: %.vhd
%.o: %.vhd
        ghdl -a $<
        ghdl -a -g $<
 
 
ram.o: util.o
ram.o: util.o
led.o: util.o led.vhd
 
kbd.o: util.o kbd.vhd
kbd.o: util.o kbd.vhd
vga.o: util.o vga.vhd text.hex font.bin
vga.o: util.o vga.vhd text.hex font.bin
core.o: util.o h2.o core.vhd h2.hex
core.o: util.o h2.o core.vhd ${EFORTH}
uart.o: util.o uart.vhd
uart.o: util.o uart.vhd
top.o: util.o timer.o core.o uart.o vga.o kbd.o led.o ram.o top.vhd
timer.o: util.o
 
top.o: util.o timer.o core.o uart.o vga.o kbd.o ram.o top.vhd
tb.o: top.o util.o tb.vhd
tb.o: top.o util.o tb.vhd
 
 
tb: ${OBJECTS} tb.o
tb: ${OBJECTS} tb.o
        ghdl -e tb
        ghdl -e tb
 
 
 
# max stack alloc needed for GHDL >0.35
 
# ghdl -r $< --wave=$<.ghw --max-stack-alloc=16384 --unbuffered --ieee-asserts=disable
%.ghw: % %.cfg
%.ghw: % %.cfg
        ghdl -r $< --wave=$<.ghw
        ghdl -r $< --wave=$<.ghw --max-stack-alloc=16384 --ieee-asserts=disable --unbuffered
 
 
simulation: tb.ghw h2${EXE}
simulation: tb.ghw h2${EXE}
 
 
## Simulation ==============================================================
## Simulation ==============================================================
 
 
 
 
# gtkwave -S signals -f tb.ghw &> /dev/null&
 
 
 
ifeq ($(OS),Windows_NT)
ifeq ($(OS),Windows_NT)
viewer: simulation
viewer: simulation signals.tcl
        gtkwave -S signals -f tb.ghw
        gtkwave -S signals.tcl -f tb.ghw
else
else
viewer: simulation
viewer: simulation signals.tcl
        gtkwave -S signals -f tb.ghw &> /dev/null&
        gtkwave -S signals.tcl -f tb.ghw &> /dev/null&
endif
endif
 
 
USB?=/dev/ttyUSB0
USB?=/dev/ttyUSB0
 
BAUD?=115200
 
#BAUD?=9600
 
 
talk:
talk:
        picocom --omap delbs -e b -b 115200 ${USB}
        picocom --omap delbs -e b -b ${BAUD} ${USB}
 
 
bitfile: design.bit
bitfile: design.bit
 
 
reports:
reports:
        @[ -d reports    ]    || mkdir reports
        @[ -d reports    ]    || mkdir reports
Line 209... Line 202...
            echo "-top top"; \
            echo "-top top"; \
            echo "-opt_mode speed"; \
            echo "-opt_mode speed"; \
            echo "-opt_level 2" \
            echo "-opt_level 2" \
        ) > tmp/top.xst
        ) > tmp/top.xst
 
 
synthesis: h2.hex text.hex reports tmp tmp/_xmsgs tmp/top.prj tmp/top.xst
synthesis: ${EFORTH} text.hex reports tmp tmp/_xmsgs tmp/top.prj tmp/top.xst
        @echo "Synthesis running..."
        @echo "Synthesis running..."
        @${TIME} xst -intstyle silent -ifn tmp/top.xst -ofn reports/xst.log
        @${TIME} xst -intstyle silent -ifn tmp/top.xst -ofn reports/xst.log
        @mv _xmsgs/* tmp/_xmsgs
        @mv _xmsgs/* tmp/_xmsgs
        @rmdir _xmsgs
        @rmdir _xmsgs
        @mv top_xst.xrpt tmp
        @mv top_xst.xrpt tmp
        @grep "ERROR\|WARNING" reports/xst.log | \
        @grep "ERROR\|WARNING" reports/xst.log | \
         grep -v "WARNING.*has a constant value.*This FF/Latch will be trimmed during the optimization process." | \
         grep -v "WARNING.*has a constant value.*This FF/Latch will be trimmed during the optimization process." | \
         cat
         cat
 
        @grep ns reports/xst.log | grep 'Clock period'
 
 
implementation: reports tmp
implementation: reports tmp
        @echo "Implementation running..."
        @echo "Implementation running..."
 
 
        @[ -d tmp/xlnx_auto_0_xdb ] || mkdir tmp/xlnx_auto_0_xdb
        @[ -d tmp/xlnx_auto_0_xdb ] || mkdir tmp/xlnx_auto_0_xdb
Line 280... Line 274...
postsyn:
postsyn:
        @netgen -w -ofmt vhdl -sim ${NETLIST}.ngc post_synthesis.vhd
        @netgen -w -ofmt vhdl -sim ${NETLIST}.ngc post_synthesis.vhd
        @netgen -w -ofmt vhdl -sim ${NETLIST}.ngd post_translate.vhd
        @netgen -w -ofmt vhdl -sim ${NETLIST}.ngd post_translate.vhd
        @netgen  -pcf ${NETLIST}.pcf -w -ofmt vhdl -sim ${NETLIST}.ncd post_map.vhd
        @netgen  -pcf ${NETLIST}.pcf -w -ofmt vhdl -sim ${NETLIST}.ncd post_map.vhd
 
 
 
 
clean:
clean:
        @echo "Deleting temporary files and cleaning up directory..."
        git clean -dffx
        @rm -vf *~ *.o trace.dat tb tb.ghw work-obj93.cf top.ngc top.ngd top_map.ngm \
 
              top.pcf top_map.ncd top.ncd top_xsim.vhd top_tsim.vhd top_tsim.sdf \
 
              top_tsim.nlf top_xst.xrpt top_ngdbuild.xrpt top_usage.xml top_summary.xml \
 
              top_map.map top_map.xrpt par_usage_statistics.html top.ptwx top.pad top_pad.csv \
 
              top.unroutes top.xpi top_par.xrpt top.twx top.nlf design.bit top_map.mrp
 
        @rm -vrf _xmsgs reports tmp xlnx_auto_0_xdb
 
        @rm -vrf _xmsgs reports tmp xlnx_auto_0_xdb
 
        @rm -vrf h2${EXE} gui${EXE} block${EXE} text${EXE}
 
        @rm -vrf text.bin h2.hex text.hex
 
        @rm -vrf *.pdf *.htm
 
        @rm -vrf *.blk *.sym
 
        @rm -vrf xst/
 
        @rm -vf usage_statistics_webtalk.html
 
        @rm -vf mem_h2.binary mem_h2.hexadecimal
 
 
 

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.