Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"Hacker" Tomu FPGA (Fomu) v0.0 support #34

Merged
merged 30 commits into from
Jul 6, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
5370afa
Tomu Fomu hacker board enumerates as a serial port!
osresearch Jan 13, 2019
55f0ab2
common/serial: Fix syntax error
smunaut Sep 2, 2018
05dc098
common: Make sure RAM inference works with yosys
smunaut Sep 2, 2018
36ff013
common: Make sure to always assign all 'reg's in processes to avoid l…
smunaut Sep 2, 2018
a9a78ea
silence warnings
osresearch Jan 13, 2019
5f69075
rename flash pins
osresearch Jan 14, 2019
248bd4f
nextpnr works with this seed
osresearch Jan 14, 2019
9385cb5
replace endpoint logic with a lookup table in BRAM
osresearch Jan 14, 2019
eb2f37e
force nextpnr
osresearch Jan 14, 2019
13d31d6
remove unused pll include
osresearch Jan 14, 2019
f0541d9
common: increase host presence timeout
osresearch Jan 14, 2019
d288b4a
common: remove initializers that were causing yosys warnings
osresearch Jan 14, 2019
e2257c8
JSON files for security registers 0 and 1
osresearch Jan 14, 2019
50edcb9
common: Make sure RAM inference works with yosys
smunaut Sep 2, 2018
1b6dfd8
common/serial: Fix syntax error
smunaut Sep 2, 2018
483cdf6
common: Make sure to always assign all 'reg's in processes to avoid l…
smunaut Sep 2, 2018
50f16d0
silence warnings
osresearch Jan 13, 2019
50144c0
TinyFPGA_BX: enable some IO pins
osresearch Jan 18, 2019
a0676aa
TinyFPGA_BX: use clock crossing strobe to bridge the 48 MHz USB clock
osresearch Jan 18, 2019
ea370fe
usb_fs_rx: Document clock domains
osresearch Jan 18, 2019
e44d6d2
Clock crossing success - endpoint runs at 12 Mhz
osresearch Jan 18, 2019
324eae5
Clock crossing: cleanup uart debugging code
osresearch Jan 18, 2019
8a6bc3a
Clock crossing: cleanup uart debugging code and helpers
osresearch Jan 18, 2019
28a72be
TinyFPGA_BX: enable all the pins, with -nowarn
osresearch Jan 18, 2019
84959e7
TinyFPGA_BX: use nextpnr-ice40
osresearch Jan 18, 2019
22f8d62
Merge branch 'clock-crossing' into tomu
osresearch Jan 18, 2019
cf20a92
Tomu: use 12 MHz clock for USB endpoint
osresearch Jan 18, 2019
0b706bb
Tomu: fixes for iverilog tests
osresearch Jan 19, 2019
e15f487
test: generate 24 Mhz clk for tinyfpga_bootloader endpoint
osresearch Jan 19, 2019
ee3043b
Merge branch 'master' into tomu to test split USB bootloader
osresearch May 26, 2019
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 12 additions & 2 deletions boards/TinyFPGA_BX/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,22 @@ PKG = cm81

all: $(PROJ).rpt fw.bin

%.json: %.v ../../common/*.v
yosys -q -p 'synth_ice40 -top $(PROJ) -json $@' $^
%.blif: %.v ../../common/*.v
yosys -p 'synth_ice40 -top $(PROJ) -blif $@' $^
yosys -q -p 'synth_ice40 -top $(PROJ) -blif $@' $^

%.asc: $(PIN_DEF) %.blif
NO-%.asc: $(PIN_DEF) %.blif
arachne-pnr -d 8k -P $(PKG) -o $@ -p $^

%.asc: $(PIN_DEF) %.json
nextpnr-ice40 \
--$(DEVICE) \
--package $(PKG) \
--asc $@ \
--pcf $(PIN_DEF) \
--json $(basename $@).json \

%.bin: %.asc
icepack $< $@

Expand Down
72 changes: 37 additions & 35 deletions boards/TinyFPGA_BX/bootloader.v
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ module bootloader (
////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
wire clk_48mhz;
wire lock;
wire reset = !lock;

SB_PLL40_CORE #(
.DIVR(4'b0000),
Expand All @@ -43,13 +45,18 @@ module bootloader (
.RESETB(1'b1),
.BYPASS(1'b0),
.LATCHINPUTVALUE(),
.LOCK(),
.LOCK(lock),
.SDI(),
.SDO(),
.SCLK()
);

reg clk_24mhz;
reg clk_12mhz;
always @(posedge clk_48mhz) clk_24mhz = !clk_24mhz;
always @(posedge clk_24mhz) clk_12mhz = !clk_12mhz;

wire clk = clk_12mhz; // quarter speed clock

////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
Expand All @@ -74,7 +81,6 @@ module bootloader (
////////
////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
wire reset;
wire usb_p_tx;
wire usb_n_tx;
wire usb_p_rx;
Expand All @@ -85,6 +91,7 @@ module bootloader (

tinyfpga_bootloader tinyfpga_bootloader_inst (
.clk_48mhz(clk_48mhz),
.clk(clk),
.reset(reset),
.usb_p_tx(usb_p_tx),
.usb_n_tx(usb_n_tx),
Expand All @@ -100,44 +107,39 @@ module bootloader (
);

assign pin_pu = 1'b1;

wire usb_p_rx_io;
wire usb_n_rx_io;
assign usb_p_rx = usb_tx_en ? 1'b1 : usb_p_rx_io;
assign usb_n_rx = usb_tx_en ? 1'b0 : usb_n_rx_io;

SB_IO #(
.PIN_TYPE(6'b101001),
.PULLUP(1'b0),
.NEG_TRIGGER(1'b0),
.IO_STANDARD("SB_LVCMOS")
) io_dp_I (
.PACKAGE_PIN(pin_usbp),
.LATCH_INPUT_VALUE(1'b0),
.CLOCK_ENABLE(1'b1),
.INPUT_CLK(1'b0),
.OUTPUT_CLK(1'b0),
.OUTPUT_ENABLE(usb_tx_en),
.D_OUT_0(usb_p_tx),
.D_OUT_1(1'b0),
.D_IN_0(usb_p_rx_io),
.D_IN_1()
tristate usbn_buffer(
.pin(pin_usbn),
.enable(usb_tx_en),
.data_in(usb_n_rx_io),
.data_out(usb_n_tx)
);

SB_IO #(
.PIN_TYPE(6'b101001),
.PULLUP(1'b0),
.NEG_TRIGGER(1'b0),
.IO_STANDARD("SB_LVCMOS")
) io_dn_I (
.PACKAGE_PIN(pin_usbn),
.LATCH_INPUT_VALUE(1'b0),
.CLOCK_ENABLE(1'b1),
.INPUT_CLK(1'b0),
.OUTPUT_CLK(1'b0),
.OUTPUT_ENABLE(usb_tx_en),
.D_OUT_0(usb_n_tx),
.D_OUT_1(1'b0),
.D_IN_0(usb_n_rx_io),
.D_IN_1()
tristate usbp_buffer(
.pin(pin_usbp),
.enable(usb_tx_en),
.data_in(usb_p_rx_io),
.data_out(usb_p_tx)
);
endmodule

assign reset = 1'b0;
module tristate(
inout pin,
input enable,
input data_out,
output data_in
);
SB_IO #(
.PIN_TYPE(6'b1010_01) // tristatable output
) buffer(
.PACKAGE_PIN(pin),
.OUTPUT_ENABLE(enable),
.D_IN_0(data_in),
.D_OUT_0(data_out)
);
endmodule
84 changes: 42 additions & 42 deletions boards/TinyFPGA_BX/pins.pcf
Original file line number Diff line number Diff line change
Expand Up @@ -3,46 +3,46 @@
# Package: CM81
###############################################################################

#set_io pin_1 A2
#set_io pin_2 A1
#set_io pin_3 B1
#set_io pin_4 C2
#set_io pin_5 C1
#set_io pin_6 D2
#set_io pin_7 D1
#set_io pin_8 E2
#set_io pin_9 E1
#set_io pin_10 G2
#set_io pin_11 H1
#set_io pin_12 J1
#set_io pin_13 H2
#set_io pin_14 H9
#set_io pin_15 D9
#set_io pin_16 D8
#set_io pin_17 C9
#set_io pin_18 A9
#set_io pin_19 B8
#set_io pin_20 A8
#set_io pin_21 B7
#set_io pin_22 A7
#set_io pin_23 B6
#set_io pin_24 A6
#set_io pin_25 G1
#set_io pin_26 J3
#set_io pin_27 J4
#set_io pin_28 H4
set_io pin_29_miso H7
set_io pin_30_cs F7
set_io pin_31_mosi G6
set_io pin_32_sck G7
#set_io pin_33 J8
#set_io pin_34 G9
#set_io pin_35 J9
#set_io pin_36 E8
#set_io pin_37 J2
set_io pin_led B3
set_io pin_usbp B4
set_io pin_usbn A4
set_io pin_pu A3
set_io pin_clk B2
set_io -nowarn pin_1 A2
set_io -nowarn pin_2 A1
set_io -nowarn pin_3 B1
set_io -nowarn pin_4 C2
set_io -nowarn pin_5 C1
set_io -nowarn pin_6 D2
set_io -nowarn pin_7 D1
set_io -nowarn pin_8 E2
set_io -nowarn pin_9 E1
set_io -nowarn pin_10 G2
set_io -nowarn pin_11 H1
set_io -nowarn pin_12 J1
set_io -nowarn pin_13 H2
set_io -nowarn pin_14 H9
set_io -nowarn pin_15 D9
set_io -nowarn pin_16 D8
set_io -nowarn pin_17 C9
set_io -nowarn pin_18 A9
set_io -nowarn pin_19 B8
set_io -nowarn pin_20 A8
set_io -nowarn pin_21 B7
set_io -nowarn pin_22 A7
set_io -nowarn pin_23 B6
set_io -nowarn pin_24 A6
set_io -nowarn pin_25 G1
set_io -nowarn pin_26 J3
set_io -nowarn pin_27 J4
set_io -nowarn pin_28 H4
set_io -nowarn pin_29_miso H7
set_io -nowarn pin_30_cs F7
set_io -nowarn pin_31_mosi G6
set_io -nowarn pin_32_sck G7
set_io -nowarn pin_33 J8
set_io -nowarn pin_34 G9
set_io -nowarn pin_35 J9
set_io -nowarn pin_36 E8
set_io -nowarn pin_37 J2
set_io -nowarn pin_led B3
set_io -nowarn pin_usbp B4
set_io -nowarn pin_usbn A4
set_io -nowarn pin_pu A3
set_io -nowarn pin_clk B2

69 changes: 69 additions & 0 deletions boards/Tomu_Fomu/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
# Makefile borrowed from https://github.com/cliffordwolf/icestorm/blob/master/examples/icestick/Makefile
#
# The following license is from the icestorm project and specifically applies to this file only:
#
# Permission to use, copy, modify, and/or distribute this software for any
# purpose with or without fee is hereby granted, provided that the above
# copyright notice and this permission notice appear in all copies.
#
# THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
# WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
# MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
# ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
# WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
# ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
# OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.

PROJ = bootloader

PIN_DEF = pins.pcf
DEVICE = up5k
PKG = uwg30
SEED ?= 12345678

#all: $(PROJ).rpt multiboot.bin
all: multiboot.bin

%.json: %.v ../../common/*.v
yosys -q -p 'synth_ice40 -top $(PROJ) -json $@' $^
%.blif: %.v ../../common/*.v
yosys -q -p 'synth_ice40 -top $(PROJ) -blif $@' $^

%.asc: $(PIN_DEF) %.json
nextpnr-ice40 \
--seed $(SEED) \
--up5k \
--package $(PKG) \
--json $(basename $@).json \
--pcf $(PIN_DEF) \
--asc $@ \

no-%.asc: $(PIN_DEF) %.blif
arachne-pnr -d 5k -P $(PKG) -o $@ -p $^

%.bin: %.asc
icepack $< $@

multiboot.bin: bootloader.bin
cp bootloader.bin bootloader_0.bin
cp bootloader.bin bootloader_1.bin
icemulti -v -o multiboot.bin -a16 -p0 bootloader_0.bin bootloader_1.bin

%.rpt: %.asc
icetime -d $(DEVICE) -mtr $@ $<

%_syn.v: %.blif
yosys -p 'read_blif -wideports $^; write_verilog $@'

prog: multiboot.bin
iceprog $<

sudo-prog: multiboot.bin
@echo 'Executing prog as root!!!'
sudo iceprog $<

clean:
rm -f $(PROJ).blif $(PROJ).asc $(PROJ).rpt $(PROJ).bin multiboot.bin

.SECONDARY:
.PHONY: all prog clean
6 changes: 6 additions & 0 deletions boards/Tomu_Fomu/boardmeta.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{"boardmeta":{
"name": "Tomu Fomu Hacker",
"fpga": "ice40up5k-uwg30",
"hver": "0.0",
"serial": 1234
}}
Loading