forked from jamesbowman/gd1-sdk
-
Notifications
You must be signed in to change notification settings - Fork 0
/
reload.fs
50 lines (37 loc) · 1.12 KB
/
reload.fs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
start-microcode reload
\ This short microprogram forces a full chip reset, just like a power-cycle
\ it talks to the Spartan 3A's ICAP interface to cause a full FPGA reload,
\ as described in
\ http://www.xilinx.com/support/documentation/user_guides/ug332.pdf page 278
\ ICAP data bus is bit-reversed!
: rev1 ( a b -- a' b' ) d# 2 * over d# 1 and + swap d# 1 rshift swap ;
: rev8 d# 0 rev1 rev1 rev1 rev1 rev1 rev1 rev1 rev1 nip ;
\ The ICAP_PORT low 8 bits are the reversed ICAP_I byte.
\ Bits 8,9,10 are:
h# 100 constant ICAP-CLK \ 1,0 is a pulse
h# 200 constant ICAP-CE \ 0 means select
h# 400 constant ICAP-WRITE \ 0 means write
: ICAP!
ICAP_PORT c! ;
: >cicap ( v -- ) \ clock byte v into ICAP
rev8 dup ICAP! ICAP-CLK or ICAP! ;
: >icap ( v -- ) \ 16-bit ICAP write
dup swab >cicap >cicap ;
: icap_reload
h# ffff >icap
h# aa99 >icap
h# 3261 >icap
h# 0000 >icap
h# 3281 >icap
h# 0000 >icap
h# 30a1 >icap
h# 000e >icap
h# 2000 >icap
h# 2000 >icap \ needs extra NOOP to complete reboot
;
: main
h# 0 ICAP!
icap_reload
begin again
;
end-microcode