Further improved build system and changed brainfuck print message
This commit is contained in:
parent
ded47555a5
commit
ed3d7101d3
8
Makefile
8
Makefile
@ -24,12 +24,18 @@ GTKWSAVE=./gtkwave_savefile.gtkw
|
||||
include common.mk
|
||||
|
||||
|
||||
boot_code/%txt:
|
||||
.PHONY:${BOOT_CODE}
|
||||
${BOOT_CODE}:
|
||||
${Q}make ${MAKEOPTS} -C boot_code $(subst boot_code/,,$@)
|
||||
|
||||
boot_code/%.txt:
|
||||
${Q}make ${MAKEOPTS} -C boot_code $(subst boot_code/,,$@)
|
||||
|
||||
.PHONY:${SYSTEM_VVP}
|
||||
${SYSTEM_VVP}:
|
||||
${Q}make ${MAKEOPTS} -C system system.vvp
|
||||
|
||||
.PHONY: clean
|
||||
clean:
|
||||
${Q}make ${MAKEOPTS} -C system clean
|
||||
${Q}make ${MAKEOPTS} -C boot_code clean
|
||||
|
@ -117,5 +117,8 @@ hlt
|
||||
|
||||
bracket: .BLKB 280
|
||||
data: .BLKB 560
|
||||
;prog db '++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++.f'
|
||||
prog:.ASCII '++++++++[>++++[>++>+++>+++>+<<<<-]>+>+>->>+[<]<-]>>.>---.+++++++..+++.>>.<-.<.+++.------.--------.>>+.>++.'
|
||||
prog:
|
||||
.ASCII '++++++++++[>+>+++>+++++++>++++++++++<<<<-]>>>++.>+.+++++++..+++.<<++.>+++++++++++++++.>.+++.------.--------.<<.>>++.+++++'
|
||||
.ASCII '+++++++.---.--.<<.>---------------------.>+++++.-----------------.++++++++.+++++.--------.+++++++++++++++.---------------'
|
||||
.ASCII '---.++++++++.<<<.>>>------------------.++++++++++++++++++++++.++++++.---.+.<<.>>+.--.+++.---------.+++++++++++++.<<++++++'
|
||||
.ASCII '++++++.------------.>----------.--------.++++++++.--.<<.'
|
||||
|
15
common.mk
15
common.mk
@ -1,3 +1,4 @@
|
||||
.PRECIOUS:${BOOT_CODE}
|
||||
QUIET=1
|
||||
|
||||
ifeq "${QUIET}" "1"
|
||||
@ -12,15 +13,13 @@ else
|
||||
Q =
|
||||
endif
|
||||
|
||||
run: ${BOOT_CODE} ${SYSTEM_VVP}
|
||||
${QUIET_VVP}
|
||||
${Q}vvp "${SYSTEM_VVP}" -lxt2 +BOOT_CODE="$<" +WAVEFORM="$(subst .txt,.lx2,$<)" +MEMDUMP="$(subst .txt,.memdumptxt,$<)"
|
||||
${Q}grep -v '^//' "$(subst .txt,.memdumptxt,$<)" | xxd -ps -c 2 -r > "$(subst .txt,.memdump,$<)"
|
||||
${Q}rm "$(subst .txt,.memdumptxt,$<)"
|
||||
|
||||
.PHONY: run wave disas
|
||||
run: $(subst .txt,.run,${BOOT_CODE})
|
||||
wave: $(subst .txt,.wave,${BOOT_CODE})
|
||||
disas: $(subst .txt,.disas,${BOOT_CODE})
|
||||
|
||||
|
||||
# Assembling code
|
||||
%.txt:%.bin
|
||||
${Q}dd if=/dev/zero bs=1 count=16384 of="$(subst .bin,.stage,$<)" status=none
|
||||
@ -39,11 +38,13 @@ disas: $(subst .txt,.disas,${BOOT_CODE})
|
||||
${Q}grep -v '^//' "$(subst .txt,.memdumptxt,$<)" | xxd -ps -c 2 -r > "$(subst .txt,.memdump,$<)"
|
||||
${Q}rm "$(subst .txt,.memdumptxt,$<)"
|
||||
|
||||
.PHONY: disas
|
||||
%.run: %.txt ${SYSTEM_VVP}
|
||||
${QUIET_VVP}
|
||||
${Q}vvp "${SYSTEM_VVP}" +BOOT_CODE="$<"
|
||||
|
||||
%.disas: %.bin
|
||||
objdump -D -b binary -m i8086 $^ | less
|
||||
|
||||
# Tools
|
||||
.PHONY: %.wave
|
||||
%.wave : %.lx2
|
||||
gtkwave "$<" "${GTKWSAVE}"
|
||||
|
@ -26,7 +26,7 @@ include ../common.mk
|
||||
# COMPILING
|
||||
${SYSTEM_VVP} : ${SOURCES} ${INCLUDES}
|
||||
${QUIET_IVERILOG}
|
||||
${Q}iverilog -g2012 ${SOURCES} -o $@
|
||||
${Q}iverilog -g2012 -o "$@" ${SOURCES}
|
||||
|
||||
|
||||
.PHONY: clean
|
||||
|
@ -41,13 +41,9 @@ integer cycles=0;
|
||||
string memdump_name;
|
||||
initial begin
|
||||
string waveform_name;
|
||||
if(!$value$plusargs("WAVEFORM=%s",waveform_name))begin
|
||||
waveform_name="waveform.lx2";
|
||||
end
|
||||
if($value$plusargs("WAVEFORM=%s",waveform_name))begin
|
||||
$dumpfile(waveform_name);
|
||||
$dumpvars(0,p,u1);
|
||||
if(!$value$plusargs("MEMDUMP=%s",memdump_name))begin
|
||||
memdump_name="memdump.txt";
|
||||
end
|
||||
reset = 0;
|
||||
clk_enable <= 1;
|
||||
@ -59,7 +55,9 @@ end
|
||||
|
||||
always @(posedge HALT) begin
|
||||
$display("Processor halted.\nCycles run for: %d",cycles);
|
||||
if($value$plusargs("MEMDUMP=%s",memdump_name))begin
|
||||
$writememh(memdump_name, sysmem.memory);
|
||||
end
|
||||
#(`CPU_SPEED) //Just for the waveform
|
||||
$finish;
|
||||
end
|
||||
@ -67,7 +65,9 @@ end
|
||||
always @(posedge ERROR) begin
|
||||
clk_enable <= 0;
|
||||
$display("PROCESSOR RUN INTO AN ERROR.\nCycles run for: %d",cycles);
|
||||
if($value$plusargs("MEMDUMP=%s",memdump_name))begin
|
||||
$writememh(memdump_name, sysmem.memory);
|
||||
end
|
||||
#(`CPU_SPEED) //Just for the waveform
|
||||
$finish;
|
||||
end
|
||||
|
Loading…
Reference in New Issue
Block a user