[閒聊] The J1 Forth CPU

看板CompilerDev作者 (影斯作業系統)時間5年前 (2020/06/08 10:54), 編輯推噓2(203)
留言5則, 2人參與, 5年前最新討論串1/1
J1 Forth CPU 是完整的 FORTH 系統。 相對簡單易學。 J1 is a small (200 lines of Verilog) stack-based CPU, intended for FPGAs. A complete J1 with 16Kbytes of RAM fits easily on a small Xilinx FPGA. Some highlights: Extremely high code density. A complete system including the TCP/IP stack fits in under 8K bytes. Single cycle call, zero cycle return Instruction set maps trivially to Forth Cross compiler runs on Windows, Mac and Unix Basic software includes a sizeable subset of ANS Forth and a portable TCP/IP networking stack. J1 was originally designed to run the six WGE100 Ethernet cameras in the Willow Garage PR2 robot. More recently it was shown at SVFIG Forth Day 2010 on an XESS FPGA board (see Loading the XESS XSA-3S1000 from Python) running a few demonstration programs, including space invaders, Forth source invaders.fs. https://www.excamera.com/files/j1.pdf https://www.excamera.com/sphinx/fpga-j1.html https://www.excamera.com/files/j1demo.tar.gz Assembler 核心是下列幾行程式碼 crossj1.fs : j1asm only metacompiler also j1assembler definitions also forth ; j1asm : hex-literal ( u -- c-addr u ) s>d <# bl hold #s [char] $ hold #> ; : imm h# 8000 or t, ; : T h# 0000 ; : N h# 0100 ; : T+N h# 0200 ; : T&N h# 0300 ; : T|N h# 0400 ; : T^N h# 0500 ; : ~T h# 0600 ; : N==T h# 0700 ; : N<T h# 0800 ; : N>>T h# 0900 ; : T-1 h# 0a00 ; : rT h# 0b00 ; : [T] h# 0c00 ; : N<<T h# 0d00 ; : dsp h# 0e00 ; : Nu<T h# 0f00 ; : T->N h# 0080 or ; : T->R h# 0040 or ; : N->[T] h# 0020 or ; : d-1 h# 0003 or ; : d+1 h# 0001 or ; : r-1 h# 000c or ; : r-2 h# 0008 or ; : r+1 h# 0004 or ; : alu h# 6000 or t, ; : return T h# 1000 or r-1 alu ; : ubranch 2/ h# 0000 or t, ; : 0branch 2/ h# 2000 or t, ; : scall 2/ h# 4000 or t, ; FORTH 前輩有仔細研究過: http://sparkforth.blogspot.com/search/label/forth J1 Forth CPU 研究之一:Camera Firmware 的程式結構 J1 Forth CPU 研究之二:如何以 Xilinx ISE 來 Synthesize J1 CPU J1 Forth CPU 研究之三:系統重設和 program counter J1 Forth CPU 研究之四:資料堆疊和返回堆疊 J1 Forth CPU 研究之五:算術邏輯單元(ALU) J1 Forth CPU 研究之一:Camera Firmware 的程式結構 首先,看看這個目錄裡最重要的幾個檔案: main.fs:這是主程式 crossj1.fs:這是 J1 的 Cross compiler basewords.fs:在這兒,以 j1 的 assembler 來定義了基本的 Forth 指令。 對許多初學 Forth 的人來說,Cross compiler 無疑是最神秘玄奇之物了。 因此讓我們先看看它。只有 512 行,真的很短,在裡面最重要的三個命令是: meta:執行 meta 後就可以開始定義 J1 的 Cross compiler (或稱為 metacompiler) 了。 target:執行 target 後,之後定義的指令或是資料結構最後都會被放到 target 裡,也就是 j1 16k 的 RAM 裡。 j1asm:執行 j1asm 後可以開始定義 j1 的 assembler。 -- ※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 114.43.77.156 (臺灣) ※ 文章網址: https://www.ptt.cc/bbs/CompilerDev/M.1591584854.A.D6E.html

06/08 16:01, 5年前 , 1F
推,J1滿好玩的。他們之前有做一個簡化版的j1a,可以放
06/08 16:01, 1F

06/08 16:01, 5年前 , 2F
到便宜的Lattice iCEStick上面
06/08 16:01, 2F

06/08 16:02, 5年前 , 3F
而且有E2E開源的Syn-APR-Bitgen flow可以玩
06/08 16:02, 3F

06/08 16:03, 5年前 , 4F

06/09 02:09, 5年前 , 5F
有趣 我昨天才在看用Forth做的OS 這語言真的神奇
06/09 02:09, 5F
文章代碼(AID): #1UtQXMrk (CompilerDev)