From 3ec90b184375de4a7c5182e2f343cdf5166beb09 Mon Sep 17 00:00:00 2001 From: "(Tim) Efthimis Kritikos" Date: Wed, 1 Nov 2023 06:03:53 +0000 Subject: [PATCH] Added version stamp and last commit to json log --- common.mk | 14 ++++++++------ system/system.v | 6 ++++-- 2 files changed, 12 insertions(+), 8 deletions(-) diff --git a/common.mk b/common.mk index 9f00b39..6d8e069 100644 --- a/common.mk +++ b/common.mk @@ -10,6 +10,8 @@ SIM=VERILATOR NUMACTL=#numactl -m 0 -C 0,1 -- +VERSION="v0.2.0-dev" +COMMIT=$(shell git log --pretty=format:'%H' -1 |cat) ifeq "${QUIET}" "1" QUIET_AS = @echo ' AS '$@; @@ -49,29 +51,29 @@ endif ifeq "${SIM}" "ICARUS" %.fst %.memdump: %.txt ${SYSTEM_VVP} ${MICROCODE} ${QUIET_VVP} - ${Q}vvp "${SYSTEM_VVP}" -fst +BOOT_CODE="$<" +WAVEFORM="$(subst .txt,.fst,$<)" +MEMDUMP="$(subst .txt,.memdumptxt,$<)" +MICROCODE="${MICROCODE}" + ${Q}vvp "${SYSTEM_VVP}" -fst +VERSION=${VERSION} +COMMIT=${COMMIT} +BOOT_CODE="$<" +WAVEFORM="$(subst .txt,.fst,$<)" +MEMDUMP="$(subst .txt,.memdumptxt,$<)" +MICROCODE="${MICROCODE}" ${Q}grep -v '^//' "$(subst .txt,.memdumptxt,$<)" | xxd -ps -c 2 -r > "$(subst .txt,.memdump,$<)" ${Q}rm "$(subst .txt,.memdumptxt,$<)" %.run: %.txt ${SYSTEM_VVP} ${MICROCODE} ${QUIET_VVP} - ${Q}vvp -i "${SYSTEM_VVP}" +BOOT_CODE="$<" +MICROCODE="${MICROCODE}" + ${Q}vvp -i "${SYSTEM_VVP}" +VERSION=${VERSION} +COMMIT=${COMMIT} +BOOT_CODE="$<" +MICROCODE="${MICROCODE}" %.json: %.txt ${SYSTEM_VVP} ${MICROCODE} ${QUIET_VVP} - ${Q}vvp -i "${SYSTEM_VVP}" +STATS="$@" +BOOT_CODE="$<" +MICROCODE="${MICROCODE}" + ${Q}vvp -i "${SYSTEM_VVP}" +VERSION=${VERSION} +COMMIT=${COMMIT} +STATS="$@" +BOOT_CODE="$<" +MICROCODE="${MICROCODE}" else ifeq "${SIM}" "VERILATOR" %.fst %.memdump: %.txt ${VERILATOR_BIN} ${MICROCODE} $(call QUIET_VERILATOR_RUN,$(word 2,$^),$<) - ${Q}"${VERILATOR_BIN}" +BOOT_CODE="$<" +WAVEFORM="$(subst .txt,.fst,$<)" +MEMDUMP="$(subst .txt,.memdumptxt,$<)" +MICROCODE="${MICROCODE}" + ${Q}"${VERILATOR_BIN}" +VERSION=${VERSION} +COMMIT=${COMMIT} +BOOT_CODE="$<" +WAVEFORM="$(subst .txt,.fst,$<)" +MEMDUMP="$(subst .txt,.memdumptxt,$<)" +MICROCODE="${MICROCODE}" ${Q}grep -v '^//' "$(subst .txt,.memdumptxt,$<)" | xxd -ps -c 2 -r > "$(subst .txt,.memdump,$<)" ${Q}rm "$(subst .txt,.memdumptxt,$<)" %.json: %.txt ${VERILATOR_BIN} ${MICROCODE} $(call QUIET_VERILATOR_RUN,$(word 2,$^),$<) - ${Q} ${NUMACTL} "${VERILATOR_BIN}" +STATS=$@ +BOOT_CODE="$<" +MICROCODE="${MICROCODE}" + ${Q} ${NUMACTL} "${VERILATOR_BIN}" +VERSION=${VERSION} +COMMIT=${COMMIT} +STATS=$@ +BOOT_CODE="$<" +MICROCODE="${MICROCODE}" %.run: %.txt ${VERILATOR_BIN} ${MICROCODE} $(call QUIET_VERILATOR_RUN,$(word 2,$^),$<) - ${Q} ${NUMACTL} "${VERILATOR_BIN}" +BOOT_CODE="$<" +MICROCODE="${MICROCODE}" + ${Q} ${NUMACTL} "${VERILATOR_BIN}" +VERSION=${VERSION} +COMMIT=${COMMIT} +BOOT_CODE="$<" +MICROCODE="${MICROCODE}" endif %.disas: %.bin diff --git a/system/system.v b/system/system.v index 94f04d7..b132e19 100644 --- a/system/system.v +++ b/system/system.v @@ -47,7 +47,7 @@ processor p( doublemem sysmem(address_bus,data_bus,rd,wr,BHE,IOMEM); `ifdef OTUPUT_JSON_STATISTICS -string stats_name; +string stats_name,version,commit; integer json_file_descriptor; `endif string waveform_name; @@ -57,9 +57,11 @@ initial begin $dumpvars(0,p,cycles); end `ifdef OTUPUT_JSON_STATISTICS + if(!$value$plusargs("VERSION=%s",version)) version="unkown"; + if(!$value$plusargs("COMMIT=%s",commit)) commit="unkown"; if($value$plusargs("STATS=%s",stats_name))begin json_file_descriptor=$fopen(stats_name,"w"); - $fdisplay(json_file_descriptor,"{\n\"L1_size\":%0d,\n\"Cycles\":[",$rtoi($pow(2,`L1_CACHE_SIZE))); + $fdisplay(json_file_descriptor,"{\n\"L1_size\":%0d,\n\"9086 verison\":\"%s\",\n\"latest commit\":\"%s\",\n\"Cycles\":[",$rtoi($pow(2,`L1_CACHE_SIZE)),version,commit); first_json_cycle = 1; end else json_file_descriptor=0;