diff --git a/examples/chstone_proj/src/hls/adpcm/Makefile b/examples/chstone_proj/src/hls/adpcm/Makefile new file mode 100644 index 0000000..bb9cb17 --- /dev/null +++ b/examples/chstone_proj/src/hls/adpcm/Makefile @@ -0,0 +1,25 @@ +VERBOSE= 1 +TARGET ?=adpcm + +FUNC=encode +LDFLAGS= +CFLAGS= + +ifeq ($(CUSTOM_INST), 1) + CFLAGS+=-DCUSTOM_INST +endif + +ifeq ($(CUSTOM_DRIVER), 1) + CFLAGS+=-DCUSTOM_DRIVER +endif + +ifeq ($(LLVM), 1) + ACCEL ?=0 + include ../../../../Makefile.llvm.in +else +ifeq ($(GCC), 1) + include ../../../../Makefile.gcc.in +else + include ../../../../Makefile.bm.in +endif +endif diff --git a/examples/chstone/adpcm/adpcm.c b/examples/chstone_proj/src/hls/adpcm/adpcm.c similarity index 100% rename from examples/chstone/adpcm/adpcm.c rename to examples/chstone_proj/src/hls/adpcm/adpcm.c diff --git a/examples/chstone_proj/src/hls/adpcm/adpcm_soc.json b/examples/chstone_proj/src/hls/adpcm/adpcm_soc.json new file mode 100644 index 0000000..0a33d69 --- /dev/null +++ b/examples/chstone_proj/src/hls/adpcm/adpcm_soc.json @@ -0,0 +1,11 @@ +{ + "RoCC": { + "custom0": { + "pgm": "adpcm", + "func": "encode", + "srcs": [ + "adpcm.c" + ] + } + } +} \ No newline at end of file diff --git a/examples/chstone_proj/src/hls/adpcm_tl/Makefile b/examples/chstone_proj/src/hls/adpcm_tl/Makefile new file mode 100644 index 0000000..b24cddb --- /dev/null +++ b/examples/chstone_proj/src/hls/adpcm_tl/Makefile @@ -0,0 +1,25 @@ +VERBOSE= 1 +TARGET ?=adpcm_tl + +FUNC=encode +LDFLAGS= +CFLAGS= + +ifeq ($(CUSTOM_INST), 1) + CFLAGS+=-DCUSTOM_INST +endif + +ifeq ($(CUSTOM_DRIVER), 1) + CFLAGS+=-DCUSTOM_DRIVER +endif + +ifeq ($(LLVM), 1) + ACCEL ?=0 + include ../../../../Makefile.llvm.in +else +ifeq ($(GCC), 1) + include ../../../../Makefile.gcc.in +else + include ../../../../Makefile.bm.in +endif +endif diff --git a/examples/chstone/adpcm_tl/adpcm_tl.c b/examples/chstone_proj/src/hls/adpcm_tl/adpcm_tl.c similarity index 100% rename from examples/chstone/adpcm_tl/adpcm_tl.c rename to examples/chstone_proj/src/hls/adpcm_tl/adpcm_tl.c diff --git a/examples/chstone_proj/src/hls/adpcm_tl/adpcm_tl_soc.json b/examples/chstone_proj/src/hls/adpcm_tl/adpcm_tl_soc.json new file mode 100644 index 0000000..985d85d --- /dev/null +++ b/examples/chstone_proj/src/hls/adpcm_tl/adpcm_tl_soc.json @@ -0,0 +1,12 @@ +{ + "TL": [ + { + "pgm": "adpcm_tl", + "func": "encode", + "addr": "0x30000", + "srcs": [ + "adpcm_tl.c" + ] + } + ] +} \ No newline at end of file diff --git a/examples/chstone_proj/src/hls/aes/Makefile b/examples/chstone_proj/src/hls/aes/Makefile new file mode 100644 index 0000000..1596901 --- /dev/null +++ b/examples/chstone_proj/src/hls/aes/Makefile @@ -0,0 +1,25 @@ +VERBOSE= 1 +TARGET ?=aes + +FUNC=encrypt +LDFLAGS= +CFLAGS= + +ifeq ($(CUSTOM_INST), 1) + CFLAGS+=-DCUSTOM_INST +endif + +ifeq ($(CUSTOM_DRIVER), 1) + CFLAGS+=-DCUSTOM_DRIVER +endif + +ifeq ($(LLVM), 1) + ACCEL ?=0 + include ../../../../Makefile.llvm.in +else +ifeq ($(GCC), 1) + include ../../../../Makefile.gcc.in +else + include ../../../../makefiles/Makefile.bm.in +endif +endif diff --git a/examples/chstone/aes/aes.c b/examples/chstone_proj/src/hls/aes/aes.c similarity index 100% rename from examples/chstone/aes/aes.c rename to examples/chstone_proj/src/hls/aes/aes.c diff --git a/examples/chstone/aes/aes.h b/examples/chstone_proj/src/hls/aes/aes.h similarity index 100% rename from examples/chstone/aes/aes.h rename to examples/chstone_proj/src/hls/aes/aes.h diff --git a/examples/chstone/aes/aes_dec.c b/examples/chstone_proj/src/hls/aes/aes_dec.c similarity index 100% rename from examples/chstone/aes/aes_dec.c rename to examples/chstone_proj/src/hls/aes/aes_dec.c diff --git a/examples/chstone/aes/aes_enc.c b/examples/chstone_proj/src/hls/aes/aes_enc.c similarity index 100% rename from examples/chstone/aes/aes_enc.c rename to examples/chstone_proj/src/hls/aes/aes_enc.c diff --git a/examples/chstone/aes/aes_func.c b/examples/chstone_proj/src/hls/aes/aes_func.c similarity index 100% rename from examples/chstone/aes/aes_func.c rename to examples/chstone_proj/src/hls/aes/aes_func.c diff --git a/examples/chstone/aes/aes_key.c b/examples/chstone_proj/src/hls/aes/aes_key.c similarity index 100% rename from examples/chstone/aes/aes_key.c rename to examples/chstone_proj/src/hls/aes/aes_key.c diff --git a/examples/chstone_proj/src/hls/aes/aes_soc.json b/examples/chstone_proj/src/hls/aes/aes_soc.json new file mode 100644 index 0000000..a1e7fc0 --- /dev/null +++ b/examples/chstone_proj/src/hls/aes/aes_soc.json @@ -0,0 +1,11 @@ +{ + "RoCC": { + "custom0": { + "pgm": "aes", + "func": "encrypt", + "srcs": [ + "aes.c" + ] + } + } +} \ No newline at end of file diff --git a/examples/chstone_proj/src/hls/aes_tl/Makefile b/examples/chstone_proj/src/hls/aes_tl/Makefile new file mode 100644 index 0000000..79a1e3f --- /dev/null +++ b/examples/chstone_proj/src/hls/aes_tl/Makefile @@ -0,0 +1,25 @@ +VERBOSE= 1 +TARGET ?=aes_tl + +FUNC=encrypt +LDFLAGS= +CFLAGS= + +ifeq ($(CUSTOM_INST), 1) + CFLAGS+=-DCUSTOM_INST +endif + +ifeq ($(CUSTOM_DRIVER), 1) + CFLAGS+=-DCUSTOM_DRIVER +endif + +ifeq ($(LLVM), 1) + ACCEL ?=0 + include ../../../../Makefile.llvm.in +else +ifeq ($(GCC), 1) + include ../../../../Makefile.gcc.in +else + include ../../../../Makefile.bm.in +endif +endif diff --git a/examples/chstone/aes_tl/aes.h b/examples/chstone_proj/src/hls/aes_tl/aes.h similarity index 100% rename from examples/chstone/aes_tl/aes.h rename to examples/chstone_proj/src/hls/aes_tl/aes.h diff --git a/examples/chstone/aes_tl/aes_dec.c b/examples/chstone_proj/src/hls/aes_tl/aes_dec.c similarity index 100% rename from examples/chstone/aes_tl/aes_dec.c rename to examples/chstone_proj/src/hls/aes_tl/aes_dec.c diff --git a/examples/chstone/aes_tl/aes_enc.c b/examples/chstone_proj/src/hls/aes_tl/aes_enc.c similarity index 100% rename from examples/chstone/aes_tl/aes_enc.c rename to examples/chstone_proj/src/hls/aes_tl/aes_enc.c diff --git a/examples/chstone/aes_tl/aes_func.c b/examples/chstone_proj/src/hls/aes_tl/aes_func.c similarity index 100% rename from examples/chstone/aes_tl/aes_func.c rename to examples/chstone_proj/src/hls/aes_tl/aes_func.c diff --git a/examples/chstone/aes_tl/aes_key.c b/examples/chstone_proj/src/hls/aes_tl/aes_key.c similarity index 100% rename from examples/chstone/aes_tl/aes_key.c rename to examples/chstone_proj/src/hls/aes_tl/aes_key.c diff --git a/examples/chstone/aes_tl/aes_tl.c b/examples/chstone_proj/src/hls/aes_tl/aes_tl.c similarity index 100% rename from examples/chstone/aes_tl/aes_tl.c rename to examples/chstone_proj/src/hls/aes_tl/aes_tl.c diff --git a/examples/chstone_proj/src/hls/aes_tl/aes_tl_soc.json b/examples/chstone_proj/src/hls/aes_tl/aes_tl_soc.json new file mode 100644 index 0000000..258217e --- /dev/null +++ b/examples/chstone_proj/src/hls/aes_tl/aes_tl_soc.json @@ -0,0 +1,12 @@ +{ + "TL": [ + { + "pgm": "aes_tl", + "func": "encrypt", + "addr": "0x30000", + "srcs": [ + "aes_tl.c" + ] + } + ] +} \ No newline at end of file diff --git a/examples/chstone_proj/src/hls/gsm/Makefile b/examples/chstone_proj/src/hls/gsm/Makefile new file mode 100644 index 0000000..5f631e1 --- /dev/null +++ b/examples/chstone_proj/src/hls/gsm/Makefile @@ -0,0 +1,25 @@ +VERBOSE= 1 +TARGET ?=gsm + +FUNC=lpc +LDFLAGS= +CFLAGS= + +ifeq ($(CUSTOM_INST), 1) + CFLAGS+=-DCUSTOM_INST +endif + +ifeq ($(CUSTOM_DRIVER), 1) + CFLAGS+=-DCUSTOM_DRIVER +endif + +ifeq ($(LLVM), 1) + ACCEL ?=0 + include ../../../../Makefile.llvm.in +else +ifeq ($(GCC), 1) + include ../../../../Makefile.gcc.in +else + include ../../../../Makefile.bm.in +endif +endif diff --git a/examples/chstone/gsm/add.c b/examples/chstone_proj/src/hls/gsm/add.c similarity index 100% rename from examples/chstone/gsm/add.c rename to examples/chstone_proj/src/hls/gsm/add.c diff --git a/examples/chstone/gsm/gsm.c b/examples/chstone_proj/src/hls/gsm/gsm.c similarity index 100% rename from examples/chstone/gsm/gsm.c rename to examples/chstone_proj/src/hls/gsm/gsm.c diff --git a/examples/chstone_proj/src/hls/gsm/gsm_soc.json b/examples/chstone_proj/src/hls/gsm/gsm_soc.json new file mode 100644 index 0000000..a1b3456 --- /dev/null +++ b/examples/chstone_proj/src/hls/gsm/gsm_soc.json @@ -0,0 +1,11 @@ +{ + "RoCC": { + "custom0": { + "pgm": "gsm", + "func": "lpc", + "srcs": [ + "gsm.c" + ] + } + } +} \ No newline at end of file diff --git a/examples/chstone/gsm/lpc.c b/examples/chstone_proj/src/hls/gsm/lpc.c similarity index 100% rename from examples/chstone/gsm/lpc.c rename to examples/chstone_proj/src/hls/gsm/lpc.c diff --git a/examples/chstone/gsm/private.h b/examples/chstone_proj/src/hls/gsm/private.h similarity index 100% rename from examples/chstone/gsm/private.h rename to examples/chstone_proj/src/hls/gsm/private.h diff --git a/examples/chstone_proj/src/hls/gsm_tl/Makefile b/examples/chstone_proj/src/hls/gsm_tl/Makefile new file mode 100644 index 0000000..7d98a79 --- /dev/null +++ b/examples/chstone_proj/src/hls/gsm_tl/Makefile @@ -0,0 +1,25 @@ +VERBOSE= 1 +TARGET ?=gsm_tl + +FUNC=lpc +LDFLAGS= +CFLAGS= + +ifeq ($(CUSTOM_INST), 1) + CFLAGS+=-DCUSTOM_INST +endif + +ifeq ($(CUSTOM_DRIVER), 1) + CFLAGS+=-DCUSTOM_DRIVER +endif + +ifeq ($(LLVM), 1) + ACCEL ?=0 + include ../../../../Makefile.llvm.in +else +ifeq ($(GCC), 1) + include ../../../../Makefile.gcc.in +else + include ../../../../Makefile.bm.in +endif +endif diff --git a/examples/chstone/gsm_tl/add.c b/examples/chstone_proj/src/hls/gsm_tl/add.c similarity index 100% rename from examples/chstone/gsm_tl/add.c rename to examples/chstone_proj/src/hls/gsm_tl/add.c diff --git a/examples/chstone/gsm_tl/gsm_tl.c b/examples/chstone_proj/src/hls/gsm_tl/gsm_tl.c similarity index 100% rename from examples/chstone/gsm_tl/gsm_tl.c rename to examples/chstone_proj/src/hls/gsm_tl/gsm_tl.c diff --git a/examples/chstone_proj/src/hls/gsm_tl/gsm_tl_soc.json b/examples/chstone_proj/src/hls/gsm_tl/gsm_tl_soc.json new file mode 100644 index 0000000..08ec212 --- /dev/null +++ b/examples/chstone_proj/src/hls/gsm_tl/gsm_tl_soc.json @@ -0,0 +1,12 @@ +{ + "TL": [ + { + "pgm": "gsm_tl", + "func": "lpc", + "addr": "0x30000", + "srcs": [ + "gsm_tl.c" + ] + } + ] +} \ No newline at end of file diff --git a/examples/chstone/gsm_tl/lpc.c b/examples/chstone_proj/src/hls/gsm_tl/lpc.c similarity index 100% rename from examples/chstone/gsm_tl/lpc.c rename to examples/chstone_proj/src/hls/gsm_tl/lpc.c diff --git a/examples/chstone/gsm_tl/private.h b/examples/chstone_proj/src/hls/gsm_tl/private.h similarity index 100% rename from examples/chstone/gsm_tl/private.h rename to examples/chstone_proj/src/hls/gsm_tl/private.h diff --git a/examples/chstone_proj/src/hls/sha/Makefile b/examples/chstone_proj/src/hls/sha/Makefile new file mode 100644 index 0000000..df74168 --- /dev/null +++ b/examples/chstone_proj/src/hls/sha/Makefile @@ -0,0 +1,26 @@ +VERBOSE= 1 +TARGET ?=sha + +FUNC=sha_update + +LDFLAGS= +CFLAGS= + +ifeq ($(CUSTOM_INST), 1) + CFLAGS+=-DCUSTOM_INST +endif + +ifeq ($(CUSTOM_DRIVER), 1) + CFLAGS+=-DCUSTOM_DRIVER +endif + +ifeq ($(LLVM), 1) + ACCEL ?=0 + include ../../../../Makefile.llvm.in +else +ifeq ($(GCC), 1) + include ../../../../Makefile.gcc.in +else + include ../../../../Makefile.bm.in +endif +endif diff --git a/examples/chstone/sha/sha.c b/examples/chstone_proj/src/hls/sha/sha.c similarity index 100% rename from examples/chstone/sha/sha.c rename to examples/chstone_proj/src/hls/sha/sha.c diff --git a/examples/chstone/sha/sha.h b/examples/chstone_proj/src/hls/sha/sha.h similarity index 100% rename from examples/chstone/sha/sha.h rename to examples/chstone_proj/src/hls/sha/sha.h diff --git a/examples/chstone/sha/sha_helper.c b/examples/chstone_proj/src/hls/sha/sha_helper.c similarity index 99% rename from examples/chstone/sha/sha_helper.c rename to examples/chstone_proj/src/hls/sha/sha_helper.c index 82c40f7..cf6d3ff 100755 --- a/examples/chstone/sha/sha_helper.c +++ b/examples/chstone_proj/src/hls/sha/sha_helper.c @@ -232,7 +232,7 @@ sha_stream () sha_info_data[16+5 +1] = 0; //sha_init (); - uint64_t begin, end, dur; + int begin, end, dur; for (j = 0; j < VSIZE; j++) { diff --git a/examples/chstone_proj/src/hls/sha/sha_soc.json b/examples/chstone_proj/src/hls/sha/sha_soc.json new file mode 100644 index 0000000..276ce2c --- /dev/null +++ b/examples/chstone_proj/src/hls/sha/sha_soc.json @@ -0,0 +1,11 @@ +{ + "RoCC": { + "custom0": { + "pgm": "sha", + "func": "sha_update", + "srcs": [ + "sha.c" + ] + } + } +} \ No newline at end of file diff --git a/examples/chstone_proj/src/hls/sha_tl/Makefile b/examples/chstone_proj/src/hls/sha_tl/Makefile new file mode 100644 index 0000000..38c66b0 --- /dev/null +++ b/examples/chstone_proj/src/hls/sha_tl/Makefile @@ -0,0 +1,26 @@ +VERBOSE= 1 +TARGET ?=sha_tl + +FUNC=sha_update + +LDFLAGS= +CFLAGS= + +ifeq ($(CUSTOM_INST), 1) + CFLAGS+=-DCUSTOM_INST +endif + +ifeq ($(CUSTOM_DRIVER), 1) + CFLAGS+=-DCUSTOM_DRIVER +endif + +ifeq ($(LLVM), 1) + ACCEL ?=0 + include ../../../../Makefile.llvm.in +else +ifeq ($(GCC), 1) + include ../../../../Makefile.gcc.in +else + include ../../../../Makefile.bm.in +endif +endif diff --git a/examples/chstone/sha_tl/sha.h b/examples/chstone_proj/src/hls/sha_tl/sha.h similarity index 100% rename from examples/chstone/sha_tl/sha.h rename to examples/chstone_proj/src/hls/sha_tl/sha.h diff --git a/examples/chstone/sha_tl/sha_helper.c b/examples/chstone_proj/src/hls/sha_tl/sha_helper.c similarity index 99% rename from examples/chstone/sha_tl/sha_helper.c rename to examples/chstone_proj/src/hls/sha_tl/sha_helper.c index 6d12b24..ab92434 100755 --- a/examples/chstone/sha_tl/sha_helper.c +++ b/examples/chstone_proj/src/hls/sha_tl/sha_helper.c @@ -228,6 +228,8 @@ sha_stream () //int sha_info_count_hi = 0L; int sha_info_count[2]={0L, 0L}; + uint64_t begin, end, dur; + sha_init (); begin = read_cycle(); for (j = 0; j < VSIZE; j++) @@ -235,8 +237,6 @@ sha_stream () i = in_i[j]; p = &indata[j][0]; -uint64_t begin, end, dur; - #ifdef CUSTOM_DRIVER sha_update_wrapper(p, i, sha_info_digest, sha_info_data, sha_info_count); #else diff --git a/examples/chstone/sha_tl/sha_tl.c b/examples/chstone_proj/src/hls/sha_tl/sha_tl.c similarity index 100% rename from examples/chstone/sha_tl/sha_tl.c rename to examples/chstone_proj/src/hls/sha_tl/sha_tl.c diff --git a/examples/chstone_proj/src/hls/sha_tl/sha_tl_soc.json b/examples/chstone_proj/src/hls/sha_tl/sha_tl_soc.json new file mode 100644 index 0000000..de2261e --- /dev/null +++ b/examples/chstone_proj/src/hls/sha_tl/sha_tl_soc.json @@ -0,0 +1,12 @@ +{ + "TL": [ + { + "pgm": "sha_tl", + "func": "sha_update", + "addr": "0x30000", + "srcs": [ + "sha_tl.c" + ] + } + ] +} \ No newline at end of file diff --git a/examples/generate_json.py b/examples/generate_json.py index 95da253..d09c491 100755 --- a/examples/generate_json.py +++ b/examples/generate_json.py @@ -14,15 +14,23 @@ with open(sys.argv[1] + "/Makefile") as f: for line in f: line = line.strip() if line.startswith("TARGET"): - pgm = line.split("=")[-1] + pgm = line.split("=")[-1].strip() elif line.startswith("FUNC"): - func = line.split("=")[-1] + func = line.split("=")[-1].strip() accel_dict = {"pgm": pgm, "func": func} if pgm.endswith("_tl"): accel_dict["addr"] = "0x30000" srcs = [filename for filename in os.listdir(sys.argv[1]) if filename.endswith(".c") or filename.endswith(".cpp") or filename.endswith(".h")] -accel_dict["srcs"] = srcs + +for src in srcs: + with open(sys.argv[1] + "/" + src) as f: + src_code = f.read() + # Reformatting src_code in case "int main" is formatted weirdly + src_code = " ".join(src_code.split()) + if "int main" in src_code: + accel_dict["srcs"] = [src] + break if pgm.endswith("_tl"): res = {"TL": [accel_dict]}