Skip to content

Commit

Permalink
ZBasic, updated for the GPIO toggle test
Browse files Browse the repository at this point in the history
  • Loading branch information
ZipCPU committed Feb 9, 2019
1 parent 5a6563c commit e7b39a5
Show file tree
Hide file tree
Showing 113 changed files with 3,300 additions and 1,392 deletions.
3 changes: 2 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -117,14 +117,15 @@ archive:
#
.PHONY: autodata
autodata: check-autofpga
$(MAKE) --no-print-directory --directory=auto-data
$(SUBMAKE) auto-data
$(call copyif-changed,auto-data/toplevel.v,rtl/toplevel.v)
$(call copyif-changed,auto-data/main.v,rtl/main.v)
$(call copyif-changed,auto-data/iscachable.v,rtl/cpu/iscachable.cpp)
$(call copyif-changed,auto-data/regdefs.h,sw/host/regdefs.h)
$(call copyif-changed,auto-data/regdefs.cpp,sw/host/regdefs.cpp)
$(call copyif-changed,auto-data/board.h,sw/zlib/board.h)
$(call copyif-changed,auto-data/board.ld,sw/board/board.ld)
$(call copyif-changed,auto-data/bkram.ld,sw/board/bkram.ld)
$(call copyif-changed,auto-data/rtl.make.inc,rtl/make.inc)
$(call copyif-changed,auto-data/testb.h,sim/verilated/testb.h)
$(call copyif-changed,auto-data/main_tb.cpp,sim/verilated/main_tb.cpp)
Expand Down
2 changes: 2 additions & 0 deletions auto-data/.gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
board.h
board.ld
bkram.ld
build.xdc
main.v
regdefs.h
Expand All @@ -9,3 +10,4 @@ testb.h
toplevel.v
main_tb.cpp
iscachable.v
autofpga.dbg
23 changes: 14 additions & 9 deletions auto-data/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -47,11 +47,20 @@ all: data
# of parts and pieces of our project that autofpga will copy/paste into our
# main project files.
#
DATA := global.txt bkram.txt buserr.txt clock.txt \
dlyarbiter.txt nflash.txt rtclight.txt rtcdate.txt \
pic.txt pwrcount.txt \
version.txt busconsole.txt zipmaster.txt sdspi.txt
# hdmi.txt profile.txt
BASE := global.txt dlyarbiter.txt
AUX := version.txt buserr.txt pic.txt pwrcount.txt
IO := gpio.txt # spio.txt
RTC := rtclight.txt rtcdate.txt
DBGBUS := busconsole.txt
MEMORY := bkram.txt flash.txt # nflash.txt
CPU := zipmaster.txt
NETWORK := # mdio.txt enet.txt
SDCARD := sdspi.txt
SCOPES := # flashscope.txt cpuscope.txt
LDSCRIPT:= mem_flash_bkram.txt mem_bkram_only.txt
DATA := clock.txt $(BASE) $(AUX) $(IO) $(RTC) \
$(DBGBUS) $(MEMORY) $(CPU) $(NETWORK) $(SDCARD) \
$(SCOPES) $(LDSCRIPT)

AUTOFPGA := autofpga
$(AUTOFPGA):
Expand All @@ -60,10 +69,6 @@ $(AUTOFPGA):
data: $(AUTOFPGA) $(DATA)
$(AUTOFPGA) -o . $(DATA)

define notify-on-change
@bash -c 'cmp $(1) $(2)/$(1); if [[ $$? != 0 ]]; then echo "Files $(1) and $(2)/$(1) differ"; fi'
endef

clean:
rm -f toplevel.v main.v regdefs.h regdefs.cpp board.h board.ld
rm -f rtl.make.inc main_tb.cpp
Expand Down
3 changes: 2 additions & 1 deletion auto-data/buserr.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
##
################################################################################
##
## Copyright (C) 2017, Gisselquist Technology, LLC
## Copyright (C) 2017-2018, Gisselquist Technology, LLC
##
## 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
Expand Down Expand Up @@ -41,6 +41,7 @@
@SLAVE.TYPE=SINGLE
@SLAVE.BUS=wb
@SINGLE.INPUT= r_bus_err
@CLOCK.NAME=clk
@MAIN.DEFNS=
reg [@$(SLAVE.BUS.AWID)-1:0] r_@$(PREFIX)_addr;
@MAIN.INSERT=
Expand Down
12 changes: 6 additions & 6 deletions auto-data/clock.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
##
################################################################################
##
## Copyright (C) 2017, Gisselquist Technology, LLC
## Copyright (C) 2017-2019, Gisselquist Technology, LLC
##
## 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
Expand All @@ -35,16 +35,16 @@
################################################################################
##
##
@$CLKFREQHZ=100000000
@CLOCK.NAME=clk
@$CLOCK.FREQUENCY= @$(CLKFREQHZ)
@PREFIX=clk
@CLOCK.NAME=clk
@$CLOCK.FREQUENCY=100000000
@CLOCK.WIRE=i_clk
@TOP.DEFNS=
wire s_clk, s_reset;
@TOP.INSERT=
assign s_clk = i_clk;
assign s_reset = 1'b0; // This design requires local, not global resets
@REGDEFS.H.DEFNS=
#define CLKFREQHZ @$CLKFREQHZ
#define CLKFREQHZ @$(CLOCK.FREQUENCY)
@BDEF.DEFN=
#define CLKFREQHZ @$CLKFREQHZ
#define CLKFREQHZ @$(CLOCK.FREQUENCY)
9 changes: 3 additions & 6 deletions auto-data/dlyarbiter.txt
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,6 @@
@MASTER.TYPE=ARBITER
@MASTER.BUS=wb
@BUS.NAME=wb
@MASTER.TYPE=ARBITER
@MASTER.BUS=wb
@BUS.NAME=wb
@BUS.WIDTH=32
@BUS.TYPE=wb
@BUS.CLOCK=clk
Expand All @@ -77,13 +74,13 @@
// And an arbiter to decide who gets access to the bus
//
//
// Clock speed = @$(CLOCK.FREQUENCY)
// Clock speed = @$(CLOCK.FREQUENCY) Hz
wbpriarbiter #(32,@$(AWID)) bus_arbiter(i_clk,
// The Zip CPU bus master --- gets the priority slot
zip_cyc, (zip_stb)&&(zip_dwb_sel), zip_we, zip_addr, zip_data, zip_sel,
zip_dwb_ack, zip_dwb_stall, zip_dwb_err,
// The UART interface master
(@$(SLAVE.BUS.NAME)_cyc)&&(@$(PREFIX)_sel),
(@$(SLAVE.BUS.NAME)_cyc),
(@$(SLAVE.BUS.NAME)_stb)&&(@$(PREFIX)_sel),
@$(SLAVE.BUS.NAME)_we,
@$(SLAVE.BUS.NAME)_addr[(@$(AWID)-1):0],
Expand Down Expand Up @@ -141,5 +138,5 @@
assign zip_dwb_data = @$(PREFIX)i_idata;
`endif
@RTL.MAKE.GROUP= BUSDLY
@RTL.MAKE.FILES= busdelay.v
@RTL.MAKE.FILES= busdelay.v wbpriarbiter.v
@RTL.MAKE.SUBD=cpu
31 changes: 16 additions & 15 deletions auto-data/flash.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
##
################################################################################
##
## Copyright (C) 2017-2018, Gisselquist Technology, LLC
## Copyright (C) 2017-2019, Gisselquist Technology, LLC
##
## 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
Expand Down Expand Up @@ -178,29 +178,30 @@
#define ISPIF_EN @$ISPIF_EN
#define ISPIF_DIS @$ISPIF_DIS
#define ISPIF_CLR @$ISPIF_CLR
@SIM.INCLUDE+=
#include "qspiflashsim.h"
@SIM.DEFNS+=
##
@SIM.INCLUDE=
#include "flashsim.h"
@SIM.DEFNS=
#ifdef @$(ACCESS)
QSPIFLASHSIM *m_@$(MEM.NAME);
FLASHSIM *m_@$(MEM.NAME);
#endif // @$(ACCESS)
@SIM.INIT+=
@SIM.INIT=
#ifdef @$(ACCESS)
m_@$(MEM.NAME) = new QSPIFLASHSIM(FLASHLGLEN);
m_@$(MEM.NAME) = new FLASHSIM(FLASHLGLEN);
#endif // @$(ACCESS)
@SIM.TICK +=
@SIM.TICK =
#ifdef @$(ACCESS)
m_core->i_qspi_dat = (*m_@$(MEM.NAME))(m_core->o_qspi_cs_n,
m_core->o_qspi_sck, m_core->o_qspi_dat);
#endif // @$(ACCESS)
@SIM.LOAD +=
@SIM.LOAD =
m_@$(MEM.NAME)->load(start, &buf[offset], wlen);
#
#
#
#
#
# Now, the control interface
##
##
##
##
##
## Now, the control interface
@PREFIX= flctl
@NADDR= 4
@ACCESS= FLASH_ACCESS
Expand Down
4 changes: 2 additions & 2 deletions auto-data/global.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
##
################################################################################
##
## Copyright (C) 2015-2018, Gisselquist Technology, LLC
## Copyright (C) 2015-2019, Gisselquist Technology, LLC
##
## 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
Expand All @@ -35,7 +35,7 @@
################################################################################
##
##
@LEGAL=../auto-data/legalgen.txt
@LEGAL=legalgen.txt
@PROJECT=ZBasic, a generic toplevel implementation using the full ZipCPU
# @XDC.FILE=nexysv.xdc
# @XDC.FILE=arty.xdc
Expand Down
100 changes: 100 additions & 0 deletions auto-data/gpio.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
################################################################################
##
## Filename: gpio.txt
##
## Project: AutoFPGA, a utility for composing FPGA designs from peripherals
##
## Purpose:
##
## Creator: Dan Gisselquist, Ph.D.
## Gisselquist Technology, LLC
##
################################################################################
##
## Copyright (C) 2017-2019, Gisselquist Technology, LLC
##
## 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
## by the Free Software Foundation, either version 3 of the License, 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 MERCHANTIBILITY 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. (It's in the $(ROOT)/doc directory. Run make with no
## target there if the PDF file isn't present.) If not, see
## <http://www.gnu.org/licenses/> for a copy.
##
## License: GPL, v3, as defined and found on www.gnu.org,
## http://www.gnu.org/licenses/gpl.html
##
##
################################################################################
##
##
@PREFIX=gpio
@DEVID=GPIO
@NADDR=1
@ACCESS=@$(DEVID)_ACCESS
@SLAVE.TYPE=SINGLE
@SLAVE.BUS=wb
@NUMOUTPUT=11
@NUMINPUT=11
@INT.GPIO.WIRE=gpio_int
@INT.GPIO.PIC=buspic
@TOP.PORTLIST=
// GPIO ports
i_@$(PREFIX), o_@$(PREFIX)
@TOP.IODECL=
// GPIO wires
localparam NGPI = @$(NUMINPUT), NGPO=@$(NUMOUTPUT);
// GPIO ports
input wire [(@$(NUMINPUT)-1):0] i_@$(PREFIX);
output wire [(@$(NUMOUTPUT)-1):0] o_@$(PREFIX);
@TOP.MAIN=
// GPIO wires
i_@$(PREFIX), o_@$(PREFIX)
@MAIN.PORTLIST=
// GPIO ports
i_@$(PREFIX), o_@$(PREFIX)
@MAIN.IODECL=
localparam NGPI = @$(NUMINPUT), NGPO=@$(NUMOUTPUT);
// @$(DEVID) ports
input [(NGPI-1):0] i_@$(PREFIX);
output wire [(NGPO-1):0] o_@$(PREFIX);
@MAIN.INSERT=
//
// @$(DEVID)
//
// This interface should allow us to control up to 16 @$(DEVID) inputs, and
// another 16 @$(DEVID) outputs. The interrupt trips when any of the inputs
// changes. (Sorry, which input isn't (yet) selectable.)
//
localparam INITIAL_@$(DEVID) = @$(NUMOUTPUT)'h0;
wbgpio #(NGPI, NGPO, INITIAL_@$(DEVID))
@$(PREFIX)i(i_clk, 1'b1, (wb_stb)&&(@$(PREFIX)_sel), wb_we,
wb_data, @$(PREFIX)_data, i_@$(PREFIX), o_@$(PREFIX),
@$(PREFIX)_int);
@REGS.N=1
@REGS.0= 0 R_@$(DEVID) @$(DEVID) GPI GPO
@BDEF.DEFN=
//
// @$(DEVID) input wires
//
#define @$(DEVID)_IN(WIRE) (((WIRE)>>16)&1)
//
// @$(DEVID) output wires
//
#define @$(DEVID)_SET(WIRE) (((WIRE)<<16)|(WIRE))
#define @$(DEVID)_CLR(WIRE) ((WIRE)<<16)
//
//
@BDEF.IONAME= i_@$(PREFIX)
@BDEF.IOTYPE= unsigned
@BDEF.OSDEF= _BOARD_HAS_@$(DEVID)
@BDEF.OSVAL= static volatile @$.BDEF.IOTYPE *const _@$(PREFIX) = ((@$.BDEF.IOTYPE *)@$REGBASE);
@RTL.MAKE.FILES=wbgpio.v
@RTL.MAKE.GROUP=@$(DEVID)
2 changes: 1 addition & 1 deletion auto-data/legalgen.txt
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
//
////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2017-2018, Gisselquist Technology, LLC
// Copyright (C) 2017-2019, Gisselquist Technology, LLC
//
// 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
Expand Down
Loading

0 comments on commit e7b39a5

Please sign in to comment.