##master-page:NoteTemplate #format wiki #language ja = HW実験Tips = == バイナリ版read_int, read_float == 誰得だけど、入力がビッグエンディアンのときの、3班のread_intとread_floatの実装(バイナリ読み込み版)。 確か審判サーバを-bオプションをつけて実行するとビッグエンディアンになると思います。 {{{ ! 入力はビッグエンディアンとする ! 返り値は%g3 min_caml_read_int: ! 0で初期化 add %g3, %g0, %g0 ! 24bit目 ~ 31bit目 input %g4 add %g3, %g3, %g4 slli %g3, %g3, 8 ! 16bit目 ~ 23bit目 input %g4 add %g3, %g3, %g4 slli %g3, %g3, 8 ! 8bit目 ~ 15bit目 input %g4 add %g3, %g3, %g4 slli %g3, %g3, 8 ! 0bit目 ~ 7bit目 input %g4 add %g3, %g3, %g4 return ! 返り値は%f0 min_caml_read_float: ! %f0 = imovf(min_caml_read_int()) call min_caml_read_int sti %g3, %g1, 0 fldi %f0, %g1, 0 return }}} == 全部Makefileで済ませてみた == とりあえずMakefileを晒します。 {{{ LIBDIR = ../lib LIBMINCAML = ../compiler/FirstArch/libmincaml.s SIMDIR = ../simulator CMPDIR = ../compiler HWDDIR = ../hardware/debugger CMP = $(CMPDIR)/min-caml ASM = $(SIMDIR)/asm SIM = $(SIMDIR)/sim IMPACT = ${HOME}/Xilinx/ISE_DS/ISE/bin/lin64/impact -batch SLEEP = @sleep 1 .PHONY: all clean .PRECIOUS: %.bin %.s %.txt all: @echo "please specify the target." libs: $(MAKE) --directory $(LIBDIR) sim: $(MAKE) --directory $(SIMDIR) asm: $(MAKE) --directory $(SIMDIR) cmp: $(MAKE) --directory $(CMPDIR) loader: $(MAKE) --directory $(HWDDIR) %.s: %.ml cmp $(CMP) $* %.bin: %.s $(LIBMINCAML) libs asm $(ASM) $(LIBMINCAML) $(LIBDIR)/*.s $< -o $@ %.txt: %.bin sim $(SIM) $< $(SLEEP) %.hw: %.bin loader $(IMPACT) loader.impact.cmd > /dev/null 2>&1 $(SLEEP) $(HWDDIR)/loader -s 0 $< > /dev/null 2>&1 $(SLEEP) $(IMPACT) 1starch.impact.cmd > /dev/null 2>&1 $(HWDDIR)/receiver %: %.s %: %.txt # このTabは重要! clean: rm -f *~ *.s *.kn *.bin *.txt a.out }}} \tが半角スペースになってしまっているかもしれません。<
> また、このMakefileは高確率で稚拙です<
> <
> 使い方は、make (ファイル名から.mlを除いたもの) で、.mlのコンパイル、.sのアセンブル、バイナリの実行をやってくれます。必要ならば、コンパイラ・アセンブラ・シミュレータのコンパイルもしてくれるので、「なんかおかしいぞ、あっシミュレータ古かった」という事もなくなっています。<
> <
> また、impactで.bitを焼いて、命令列をローダで送って、、、というのも非常に煩わしかったので自動化しました。<
> impact -batch (コマンドファイル) でimpactをCUIで扱えるのがキモです。コマンドファイルは、いつもimpactを使っていると勝手に出来ている_impact.cmdを参考にします。また、GUIでの実行中にも、下のペインをConsoleにすれば、logと一緒に表示されています。(GUIの操作とコマンドを対応付けられます。)<
> 参考までに、loader.impact.cmdを晒します。 {{{ setMode -bs setCable -port auto Identify -inferir identifyMPM assignFile -p 2 -file ../hardware/1starch/top.bit Program -p 2 quit }}} ただし、このHW自動化は、ちょっと挙動が怪しいので、フィードバックを募集中です。 ---- [[Categoryノート]]