Permalink
Browse files

Added support for Blackice II

  • Loading branch information...
lawrie committed Apr 23, 2018
1 parent b731cf6 commit 946feb7bb9a996b862f1ef31a7f1e0e0bb033be4
@@ -0,0 +1,106 @@
# User Constraint File for BlackIce Acorn Atom (Ice40Atom)

# Onboard 100MHz oscillator
set_io clk100 129

# ARM SPI Port
set_io arm_ss 71 # also LED1
set_io arm_miso 67 # also LED2
set_io arm_mosi 68 # also LED3
set_io arm_sclk 70 # also LED4

# Test
#set_io test0 106 # PMOD23 PMOD 5/6 pin 6
#set_io test1 110 # PMOD22 PMOD 5/6 pin 8
#set_io test2 113 # PMOD21 PMOD 5/6 pin 10
#set_io test3 144 # PMOD20 PMOD 5/6 pin 12

set_io n_reset 64 # sw4

# SRAM
set_io sramData[0] 136
set_io sramData[1] 135
set_io sramData[2] 134
set_io sramData[3] 130
set_io sramData[4] 125
set_io sramData[5] 124
set_io sramData[6] 122
set_io sramData[7] 121

set_io sramAddress[0] 137
set_io sramAddress[1] 138
set_io sramAddress[2] 139
set_io sramAddress[3] 141
set_io sramAddress[4] 142
set_io sramAddress[5] 42
set_io sramAddress[6] 43
set_io sramAddress[7] 44
set_io sramAddress[8] 73
set_io sramAddress[9] 74
set_io sramAddress[10] 75
set_io sramAddress[11] 76
set_io sramAddress[12] 115
set_io sramAddress[13] 116
set_io sramAddress[14] 117
set_io sramAddress[15] 118
set_io sramAddress[16] 119
set_io sramAddress[17] 78

set_io n_sRamWE 120
set_io n_sRamCS 23
set_io n_sRamOE 29
set_io n_sRamUB 28
set_io n_sRamLB 24

# USB UART / Pi Connector
#
# From the schematic it looks like:
#
# Pin 2 of the CH340G (TxD output) is connected to
# - Pin 8 of the Pi Header (TxD0 output)
# - STM32F103RET6 pin 43 (PA10)
# - net is called RX
# - and also via a resistor to PMOD P2, FPGA Pin 88
#
# Pin 3 of the CH340G (RxD input) is connected to
# - Pin 10 of the Pi Header (RxD0 input)
# - STM32F103RET6 pin 42 (PA9)
# - net is called TX
# - and also via a resistor to PMOD P3, FPGA Pin 85
#
# NOTE: It appears the conenections to the Pi Header are swapped (i.e. Pi output to USB UART output)

set_io rxd1 88
set_io txd1 85

# SD Card
set_io sdCS 38 # DIG18
set_io sdMOSI 41 # DIG16
set_io sdMISO 63 # B1
set_io sdSCLK 37 # DIG19

# Keyboard - Matches Digilent PmodPS/2 plugged into lower half of PMOD11/12
set_io ps2Clk 26 # PMOD46 = PMOD 11/12 pin 8
set_io ps2Data 32 # PMOD44 = PMOD 11/12 pin 12

# VGA Output - Matches Digilent PmodVGA plugged into PMOD7/8/9/10
set_io videoR1 15 # PMOD35 = PMOD 9/10 pin 5
set_io videoR0 16 # PMOD34 = PMOD 9/10 pin 7
#set_io red[1] 19 # PMOD33 = PMOD 9/10 pin 9
#set_io red[0] 20 # PMOD32 = PMOD 9/10 pin 11

set_io videoG1 1 # PMOD27 = PMOD 7/8 pin 5
set_io videoG0 2 # PMOD26 = PMOD 7/8 pin 7
#set_io green[1] 9 # PMOD25 = PMOD 7/8 pin 9
#set_io green[0] 10 # PMOD24 = PMOD 7/8 pin 11

set_io videoB1 11 # PMOD39 = PMOD 9/10 pin 6
set_io videoB0 12 # PMOD38 = PMOD 9/10 pin 8
#set_io blue[1] 17 # PMOD37 = PMOD 9/10 pin 10
#set_io blue[0] 18 # PMOD36 = PMOD 9/10 pin 12

set_io hSync 8 # PMOD28 = PMOD 7/8 pin 12
set_io vSync 7 # PMOD29 = PMOD 7/8 pin 10

set_io videoSync 21 # PMOD43 PMOD 11/12 pin 5
set_io video 22 # PMOD42 PMOD 11/12 pin 7
@@ -0,0 +1,14 @@
#!/bin/bash

TOP=Microcomputer
NAME=cpmz80
PACKAGE=tq144:4k
SRCS="../src/bootstrap.v ../src/Microcomputer/Microcomputer.v ../src/ROMS/ROM.v ../src/Components/SDCARD/sd_controller.v ../src/Components/UART/bufferedUART.v ../src/Components/Z80/tv80_core.v ../src/Components/Z80/tv80n.v ../src/Components/Z80/tv80_mcode.v ../src/Components/Z80/tv80_reg.v ../src/Components/Z80/tv80_alu.v ../src/Components/TERMINAL/DisplayRam.v ../src/Components/TERMINAL/SBCTextDisplayRGB.v "

./clean.sh

yosys -q -f "verilog -Dblackice2 -Duse_sb_io" -l ${NAME}.log -p "synth_ice40 -top ${TOP} -abc2 -blif ${NAME}.blif" ${SRCS}
arachne-pnr -d 8k -P ${PACKAGE} -p blackice.pcf ${NAME}.blif -o ${NAME}.txt
icepack ${NAME}.txt ${NAME}.bin
icetime -d hx8k -P ${PACKAGE} -t ${NAME}.txt
truncate -s 135104 ${NAME}.bin
@@ -0,0 +1,9 @@
#!/bin/bash

PROG=cpmz80

# Remove BlackIce files
rm -f $PROG.blif $PROG.txt $PROG.bin $PROG.log

# Remove Simulation files
#rm -f a.out dump.vcd
@@ -0,0 +1,81 @@
[*]
[*] GTKWave Analyzer v3.3.58 (w)1999-2014 BSI
[*] Sat Sep 16 14:38:30 2017
[*]
[dumpfile] "/home/dmb/atom/Ice40CPM/blackice/dump.vcd"
[dumpfile_mtime] "Sat Sep 16 14:38:30 2017"
[dumpfile_size] 53305344
[savefile] "/home/dmb/atom/Ice40CPM/blackice/signals.gtkw"
[timestart] 20449
[size] 1855 1176
[pos] -1 -1
*-7.000000 21026 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1
[treeopen] cpmz80_tb.
[treeopen] cpmz80_tb.DUT.
[treeopen] cpmz80_tb.DUT.cpu1.
[treeopen] cpmz80_tb.DUT.cpu1.i_tv80_core.
[sst_width] 223
[signals_width] 206
[sst_expanded] 1
[sst_vpaned_height] 354
@22
cpmz80_tb.DUT.basRomData[7:0]
@28
cpmz80_tb.DUT.clk
cpmz80_tb.DUT.clk100
@22
cpmz80_tb.DUT.cpuAddress[15:0]
cpmz80_tb.DUT.cpuClkCount[5:0]
@28
cpmz80_tb.DUT.cpuClock
@22
cpmz80_tb.DUT.cpuDataIn[7:0]
cpmz80_tb.DUT.cpuDataOut[7:0]
@28
cpmz80_tb.DUT.driveLED
@22
cpmz80_tb.DUT.interface1DataOut[7:0]
@28
cpmz80_tb.DUT.n_IORQ
cpmz80_tb.DUT.n_MREQ
cpmz80_tb.DUT.n_RD
cpmz80_tb.DUT.n_WR
cpmz80_tb.DUT.n_basRomCS
cpmz80_tb.DUT.n_externalRamCS
cpmz80_tb.DUT.n_int1
cpmz80_tb.DUT.n_interface1CS
cpmz80_tb.DUT.n_ioRD
cpmz80_tb.DUT.n_ioWR
cpmz80_tb.DUT.n_memRD
cpmz80_tb.DUT.n_memWR
cpmz80_tb.DUT.n_reset
cpmz80_tb.DUT.n_sRamCS
cpmz80_tb.DUT.n_sRamOE
cpmz80_tb.DUT.n_sRamWE
cpmz80_tb.DUT.n_sdCardCS
cpmz80_tb.DUT.rxd1
cpmz80_tb.DUT.sdCS
@22
cpmz80_tb.DUT.sdCardDataOut[7:0]
cpmz80_tb.DUT.sdClkCount[5:0]
@28
cpmz80_tb.DUT.sdClock
cpmz80_tb.DUT.sdMISO
cpmz80_tb.DUT.sdMOSI
cpmz80_tb.DUT.sdSCLK
@22
cpmz80_tb.DUT.serialClkCount[15:0]
@28
cpmz80_tb.DUT.serialClock
@22
cpmz80_tb.DUT.sramAddress[17:0]
cpmz80_tb.DUT.sramData[7:0]
@28
cpmz80_tb.DUT.txd1
cpmz80_tb.DUT.cpu1.m1_n
@22
cpmz80_tb.data_out[7:0]
cpmz80_tb.addr[17:0]
cpmz80_tb.data_in[7:0]
[pattern_trace] 1
[pattern_trace] 0
@@ -0,0 +1,72 @@
[*]
[*] GTKWave Analyzer v3.3.58 (w)1999-2014 BSI
[*] Mon Sep 18 11:46:35 2017
[*]
[dumpfile] "/home/dmb/atom/Ice40CPMZ80/blackice/dump.vcd"
[dumpfile_mtime] "Mon Sep 18 11:31:53 2017"
[dumpfile_size] 98800645
[savefile] "/home/dmb/atom/Ice40CPMZ80/blackice/signals_terminal.gtkw"
[timestart] 81395
[size] 1855 1176
[pos] -1 -1
*-10.000000 83230 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1
[treeopen] terminal_tb.
[treeopen] terminal_tb.DUT.
[treeopen] terminal_tb.DUT.genblk1.
[treeopen] terminal_tb.DUT.genblk3.
[treeopen] terminal_tb.DUT.genblk6.
[sst_width] 223
[signals_width] 174
[sst_expanded] 1
[sst_vpaned_height] 354
@28
terminal_tb.clk
@23
terminal_tb.dataIn[7:0]
@22
terminal_tb.dataOut[7:0]
@28
terminal_tb.hSync
@22
terminal_tb.i[31:0]
@28
terminal_tb.n_rd
terminal_tb.n_reset
terminal_tb.n_wr
terminal_tb.ps2Clk
terminal_tb.ps2Data
terminal_tb.regSel
terminal_tb.vSync
terminal_tb.videoR1
terminal_tb.videoR0
terminal_tb.videoG1
terminal_tb.videoG0
terminal_tb.videoB1
terminal_tb.videoB0
terminal_tb.DUT.dispByteSent
terminal_tb.DUT.dispByteWritten
terminal_tb.DUT.statusReg[7:0]
@22
terminal_tb.DUT.genblk6.dispAttRam.address_b[10:0]
terminal_tb.DUT.genblk6.dispAttRam.data_b[7:0]
@28
terminal_tb.DUT.genblk6.dispAttRam.wren_b
@22
terminal_tb.DUT.genblk3.dispCharRam.address_b[10:0]
terminal_tb.DUT.genblk3.dispCharRam.data_b[7:0]
@28
terminal_tb.DUT.genblk3.dispCharRam.wren_b
terminal_tb.DUT.escState[1:0]
@22
terminal_tb.DUT.dispAttWRData[7:0]
@28
terminal_tb.DUT.paramCount[2:0]
@22
terminal_tb.DUT.dispByteLatch[7:0]
terminal_tb.DUT.param1[6:0]
terminal_tb.DUT.param2[6:0]
@28
terminal_tb.DUT.attInverse
terminal_tb.DUT.attBold
[pattern_trace] 1
[pattern_trace] 0
@@ -0,0 +1,7 @@
#!/bin/bash

SRCS="../src/bootstrap.v ../src/Microcomputer/Microcomputer.v ../src/ROMS/ROM.v ../src/Components/SDCARD/sd_controller.v ../src/Components/UART/bufferedUART.v ../src/Components/Z80/tv80_core.v ../src/Components/Z80/tv80n.v ../src/Components/Z80/tv80_mcode.v ../src/Components/Z80/tv80_reg.v ../src/Components/Z80/tv80_alu.v ../src/Components/TERMINAL/DisplayRam.v ../src/Components/TERMINAL/SBCTextDisplayRGB.v "

iverilog ../src/Test/cpmz80_tb.v $SRCS
./a.out
gtkwave -g -a signals.gtkw dump.vcd
@@ -0,0 +1,7 @@
#!/bin/bash

SRCS="../src/ROMS/ROM.v ../src/Components/TERMINAL/DisplayRam.v ../src/Components/TERMINAL/SBCTextDisplayRGB.v "

iverilog ../src/Test/terminal_tb.v $SRCS
./a.out
gtkwave -g -a signals_terminal.gtkw dump.vcd
@@ -0,0 +1,39 @@
#!/bin/bash

mkdir -p releases

release=releases/ice40cpmz80_$(date +"%Y%m%d_%H%M").zip

echo building ${release}

rm -rf build
mkdir -p build

for board in blackice blackice2
do

echo building ${board}

pushd ${board}
./clean.sh
./build.sh
mv cpmz80.bin ../build/cpmz80_${board}.bin
popd

pushd target/blackice/iceboot
make clean
make raw
cp output/iceboot.raw icebootcpmz80_${board}.raw
truncate -s 126976 icebootcpmz80_${board}.raw
cat ../../../build/cpmz80_${board}.bin >> icebootcpmz80_${board}.raw
mv icebootcpmz80_${board}.raw ../../../build
popd

done

pushd build
zip -qr ../${release} .
popd

unzip -l ${release}

@@ -36,6 +36,10 @@ module Microcomputer
output n_sRamWE,
output n_sRamCS,
output n_sRamOE,
`ifdef blackice2
output n_sRamLB,
output n_sRamUB,
`endif
input rxd1,
output txd1,
`ifdef include_video
@@ -89,6 +93,11 @@ module Microcomputer
reg clk = 0;
wire driveLED;

`ifdef blackice2
assign n_sRamUB = 0;
assign n_sRamLB = 0;
`endif

// High during the initial ROM bootstrap phase
wire booting;

0 comments on commit 946feb7

Please sign in to comment.