Further improved build system and changed brainfuck print message

This commit is contained in:
(Tim) Efthimis Kritikos 2023-02-16 23:26:32 +00:00
parent ded47555a5
commit ed3d7101d3
5 changed files with 30 additions and 20 deletions

View File

@ -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

View File

@ -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 '++++++.------------.>----------.--------.++++++++.--.<<.'

View File

@ -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}"

View File

@ -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

View File

@ -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";
end
$dumpfile(waveform_name); $dumpfile(waveform_name);
$dumpvars(0,p,u1); $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);
if($value$plusargs("MEMDUMP=%s",memdump_name))begin
$writememh(memdump_name, sysmem.memory); $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);
if($value$plusargs("MEMDUMP=%s",memdump_name))begin
$writememh(memdump_name, sysmem.memory); $writememh(memdump_name, sysmem.memory);
end
#(`CPU_SPEED) //Just for the waveform #(`CPU_SPEED) //Just for the waveform
$finish; $finish;
end end