reload.fs 1.1 KB

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