# Each directory under ports/ is used as a port name. Each port is tested.
# Each port must have a spec.mk which describes how to build the object
# files and how to run the emulator.
-ALL_PORTS = $(filter-out .svn xa51 z80 gbz80 pic16,$(notdir $(wildcard $(PORTS_DIR)/*)))
+ALL_PORTS = $(filter-out .svn xa51 z80 gbz80 pic16 pic14,$(notdir $(wildcard $(PORTS_DIR)/*)))
# These ports will be cleaned with 'make clean'
CLEAN_PORTS = $(filter-out .svn,$(notdir $(wildcard $(PORTS_DIR)/*)))
test-pic16:
$(MAKE) test-port PORT=pic16
+# Helper rule for testing the pic14 port only(use gpsim simulator)
+test-pic14:
+ $(MAKE) test-port PORT=pic14
+
### Helper rule for testing the host cc only
test-host:
$(MAKE) test-port PORT=host
--- /dev/null
+# Port specification for the pic14 port running with gpsim
+
+# path to gpsim
+ifdef GPSIM_PATH
+ GPSIM := $(GPSIM_PATH)/gpsim
+else
+ GPSIM := gpsim
+endif
+
+SDCCFLAGS += -mpic14 -pp16f877 -I$(top_srcdir)/device/include/pic --nostdinc --less-pedantic -Wl,-q -DREENTRANT=reentrant -I$(top_srcdir)
+LINKFLAGS = --nostdlib
+LINKFLAGS += libsdcc.lib libm.lib
+LIBDIR = $(top_builddir)device/lib/build/pic
+
+OBJEXT = .o
+EXEEXT = .cod
+
+EXTRAS = $(PORT_CASES_DIR)/testfwk$(OBJEXT) $(PORT_CASES_DIR)/support$(OBJEXT)
+
+# Rule to link into .ihx
+%$(EXEEXT): %$(OBJEXT) $(EXTRAS)
+ -$(SDCC) $(SDCCFLAGS) $(LINKFLAGS) -L $(LIBDIR) $(EXTRAS) $< -o $@
+
+%$(OBJEXT): %.c
+ -$(SDCC) $(SDCCFLAGS) -c $< -o $@
+
+$(PORT_CASES_DIR)/%$(OBJEXT): $(PORTS_DIR)/$(PORT)/%.c
+ -$(SDCC) $(SDCCFLAGS) -c $< -o $@
+
+.PRECIOUS: gen/pic14/testfwk.o gen/pic14/support.o
+
+$(PORT_CASES_DIR)/%$(OBJEXT): fwk/lib/%.c
+ $(SDCC) $(SDCCFLAGS) -c $< -o $@
+
+# run simulator with 25 seconds timeout
+%.out: %$(EXEEXT) $(CASES_DIR)/timeout
+ mkdir -p $(dir $@)
+ -$(CASES_DIR)/timeout 25 "$(GPSIM)" -i -s $< -c $(PORTS_DIR)/pic14/gpsim.cmd > $@ || \
+ echo -e --- FAIL: \"timeout, simulation killed\" in $(<:$(EXEEXT)=.c)"\n"--- Summary: 1/1/1: timeout >> $@
+ python $(srcdir)/get_ticks.py < $@ >> $@
+ -grep -n FAIL $@ /dev/null || true
+
+$(CASES_DIR)/timeout: fwk/lib/timeout.c
+ $(CC) $< -o $@
+
+_clean:
--- /dev/null
+/*-------------------------------------------------------------------------
+ support.c - startup for PIC14 regression tests with gpsim
+
+ Copyright (c) 2006 Borut Razem
+
+ This program is free software; you can redistribute it and/or modify it
+ under the terms of the GNU General Public License as published by the
+ Free Software Foundation; either version 2, or (at your option) any
+ later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+
+ In other words, you are welcome to use, share and improve this program.
+ You are forbidden to forbid anyone else to use, share and improve
+ what you give them. Help stamp out software-hoarding!
+-------------------------------------------------------------------------*/
+
+#pragma preproc_asm -
+
+#include <pic16f877.h>
+
+
+void
+_putchar(char c)
+{
+ while (!TXIF)
+ ;
+ TXREG = c;
+}
+
+
+void
+_initEmu(void)
+{
+ /* load and configure the libgpsim_modules module */
+ _asm
+ ;; Set frequency to 20MHz
+ .direct "e", ".frequency=20e6"
+
+ ;; Load the USART library and module
+ .direct "e", "module library libgpsim_modules"
+ .direct "e", "module load usart U1"
+
+ ;; Define a node
+ .direct "e", "node PIC_tx"
+
+ ;; Tie the USART module to the PIC
+ .direct "e", "attach PIC_tx portc6 U1.RXPIN"
+
+ ;; Set the USART module's Baud Rate
+ .direct "e", "U1.rxbaud = 9600"
+
+ ;; Display the received character on terminal
+ .direct "e", "U1.console = true"
+ _endasm;
+
+ /* USART initialization */
+ PORTC |= 0x40; // Set TX pin to 1
+ TRISC &= ~0x40; // TX pin is output
+
+ //1. Initialize the SPBRG register for the appropriate
+ // baud rate. If a high speed baud rate is desired,
+ // set bit BRGH (Section 16.1).
+ BRGH = 1;
+ SPBRG = 129;
+
+ //2. Enable the asynchronous serial port by clearing
+ // bit SYNC and setting bit SPEN.
+ SPEN = 1;
+
+ //3. If interrupts are desired, set enable bit TXIE.
+ //4. If 9-bit transmission is desired, set transmit bit
+ // TX9. Can be used as address/data bit.
+ //5. Enable the transmission by setting bit TXEN,
+ // which will also set bit TXIF.
+ TXEN = 1;
+
+ //6. If 9-bit transmission is selected, the ninth bit
+ // should be loaded in bit TX9D.
+ //7. Load data to the TXREG register (starts
+ // transmission).
+}
+
+
+void
+_exitEmu(void)
+{
+ /* wait until the transmit buffer is empty */
+ while (!TRMT)
+ ;
+
+ /* set the breakpoint */
+ _asm
+ .direct "a", "\"\""
+ _endasm;
+}