From 8d87eacbcb26e7abc429d7824e90c617f172045e Mon Sep 17 00:00:00 2001 From: Alex AUVOLAT Date: Thu, 9 Jan 2014 16:10:58 +0100 Subject: Make things great ! --- .gitignore | 1 + README | 36 ++++++++++++++++++++++++------------ asm/test.asm | 25 ------------------------- cpu/Makefile | 8 ++++++-- cpu/ROM_count_seconds.rom | 6 ++++++ cpu/os.asm | 25 +++++++++++++++++++++++++ cpu/prog_rom0.rom | 6 ------ cpu/prog_test1.rom | 43 ------------------------------------------- 8 files changed, 62 insertions(+), 88 deletions(-) delete mode 100644 asm/test.asm create mode 100644 cpu/ROM_count_seconds.rom create mode 100644 cpu/os.asm delete mode 100644 cpu/prog_rom0.rom delete mode 100644 cpu/prog_test1.rom diff --git a/.gitignore b/.gitignore index e0ae8b6..49eedec 100644 --- a/.gitignore +++ b/.gitignore @@ -6,6 +6,7 @@ csim/csim sched/sched monitor/mon asm/asm +cpu/os.rom *.o *.ps */*.net diff --git a/README b/README index 1d1be18..d3ab4c2 100644 --- a/README +++ b/README @@ -36,6 +36,12 @@ cpu/ The netlist for the CPU is generated by Caml code (and not MiniJazz code), therefore this directory also contains Caml files for generating netlists with Caml code (see `netlist_gen.mli` and `example_cpu.ml` for usage example). + +asm/ + An assembler used to compile assembly files for the CPU. Produces ROM files + readable by the simulator. + $ cd asm/ + $ make monitor/ A C program used to monitor the simulator. The monitor has many functionnalities : @@ -84,6 +90,10 @@ Compile the monitor : $ cd monitor/; make; cd .. +Compile the assembler : + + $ cd asm/; make; cd .. + Run the CPU with the monitor : $ cd cpu/; make @@ -244,22 +254,25 @@ default stdin, but can be redirected from a file using the -in option) and of writing the outputs at each step to a file (by default stdout, but can be redirected with -out). -The input format is extremely straightforward : at each step, read a line -containing for each input variable, *in the order given in the program file*, -either a binary value (represented by a series of bits given in the standard -order), either a decimal value prefixed with a slash (/), which is then -converted to binary according to the standard representation defined above. - -The output format contains at each step one line for each output variable, in -the format : -\t\t -The output contains an empty line at the end of every cycle. - When the simulator is launched, it sends an output describing the I/O mechanism of the simulated circuit : \n [for each input : \n] +The input format is extremely straightforward : at each step, read a line +begenning with the keyword FEED followed by, for each input variable, *in the +order given in the program file*, either a binary value (represented by a series +of bits given in the standard order), either a decimal value prefixed with a +slash (/), which is then converted to binary according to the standard +representation defined above. + +The output format contains at each step one line with the keyword FED, followed +by one line for each output variable, in the format : + + \t\t + +The output contains an empty line at the end of every cycle. + How ROMs are handled -------------------- @@ -301,7 +314,6 @@ NEXT STEPS ---------- - Finish ALU -- Code assembler - Code basic OS for the CPU diff --git a/asm/test.asm b/asm/test.asm deleted file mode 100644 index 5d58ff7..0000000 --- a/asm/test.asm +++ /dev/null @@ -1,25 +0,0 @@ -.text -init: - li B _clock - lw B 0(B) - jz B init - add D D B - push D - li A msgtick - jal ser_out_msg - pop D - j init - -ser_out_msg: - li C _output -ser_out_msg_loop: - lb B 0(A) - jz B ser_out_msg_ret - sb B 0(C) - incri A 1 - j ser_out_msg_loop -ser_out_msg_ret: - jr RA - -msgtick: - ascii "Tick!" diff --git a/cpu/Makefile b/cpu/Makefile index 5efa691..7e92314 100644 --- a/cpu/Makefile +++ b/cpu/Makefile @@ -6,9 +6,13 @@ AUXILLARY=alu.ml SCHED=../sched/sched SIM=../csim/csim MON=../monitor/mon +ASM=../asm/asm -all: _build/cpu_opt.dumb - $(MON) $(SIM) -rom ROM0 prog_test1.rom $< +all: _build/cpu_opt.dumb os.rom + $(MON) $(SIM) -rom ROM0 os.rom $< + +os.rom: os.asm + $(ASM) $< > $@ %.sim: _build/%.dumb $(SIM) -n 12 $< diff --git a/cpu/ROM_count_seconds.rom b/cpu/ROM_count_seconds.rom new file mode 100644 index 0000000..7330dac --- /dev/null +++ b/cpu/ROM_count_seconds.rom @@ -0,0 +1,6 @@ +10 8 +x40 01011011 # liuz B 0x40 -> B = 0x4000 (address of ticker) +00000010 11000001 # lw C 0(B) +00110001 00100000 # add D D C +/1 10001100 # incri A 1 +/-6 11100010 # j -6 (ie to lw instruction) diff --git a/cpu/os.asm b/cpu/os.asm new file mode 100644 index 0000000..5d58ff7 --- /dev/null +++ b/cpu/os.asm @@ -0,0 +1,25 @@ +.text +init: + li B _clock + lw B 0(B) + jz B init + add D D B + push D + li A msgtick + jal ser_out_msg + pop D + j init + +ser_out_msg: + li C _output +ser_out_msg_loop: + lb B 0(A) + jz B ser_out_msg_ret + sb B 0(C) + incri A 1 + j ser_out_msg_loop +ser_out_msg_ret: + jr RA + +msgtick: + ascii "Tick!" diff --git a/cpu/prog_rom0.rom b/cpu/prog_rom0.rom deleted file mode 100644 index 7330dac..0000000 --- a/cpu/prog_rom0.rom +++ /dev/null @@ -1,6 +0,0 @@ -10 8 -x40 01011011 # liuz B 0x40 -> B = 0x4000 (address of ticker) -00000010 11000001 # lw C 0(B) -00110001 00100000 # add D D C -/1 10001100 # incri A 1 -/-6 11100010 # j -6 (ie to lw instruction) diff --git a/cpu/prog_test1.rom b/cpu/prog_test1.rom deleted file mode 100644 index 8156628..0000000 --- a/cpu/prog_test1.rom +++ /dev/null @@ -1,43 +0,0 @@ -56 8 - # init: -00000000 01010011 # lilz B 0 -00000010 01001011 # liu B 64 -00000010 01000001 # lw B 0(B) -00000000 10110011 # lilz E init -00000000 10101011 # liu E init -01000010 10101010 # jer E B Z -00010001 00100000 # add D D B -01111111 11101100 # incri SP -2 -00000111 00110001 # sw D 0(SP) -01001100 10010011 # lilz A msgtick -00000000 10001011 # liu A msgtick -00010000 00010010 # jal ser_out_msg -00000111 00100001 # lw D 0(SP) -01000000 11101100 # incri SP 2 -00100111 11100010 # j init - # ser_out_msg: -01000000 11010011 # lilz C 2 -10000010 11001011 # liu C 65 - # ser_out_msg_loop: -00000100 01001001 # lb B 0(A) -00001100 10110011 # lilz E ser_out_msg_ret -00000000 10101011 # liu E ser_out_msg_ret -01000010 10101010 # jer E B Z -00000110 01011001 # sb B 0(C) -10000000 10001100 # incri A 1 -00101111 11100010 # j ser_out_msg_loop - # ser_out_msg_ret: -00000000 01101010 # jr RA - # msgtick: -00101010 - # msgtick: -10010110 - # msgtick: -11000110 - # msgtick: -11010110 - # msgtick: -10000100 - # msgtick: -00000000 - -- cgit v1.2.3