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