From 0fa7144084b792e64eb10abfed2b2d83d3dcbe7c Mon Sep 17 00:00:00 2001 From: Zihao Yu Date: Mon, 21 Feb 2022 12:22:27 +0800 Subject: [PATCH] first commit --- .gitignore | 12 ++++++++ Makefile | 19 ++++++++++++ README.md | 9 ++++++ init.sh | 77 ++++++++++++++++++++++++++++++++++++++++++++++ npc/.gitignore | 11 +++++++ npc/Makefile | 8 +++++ npc/csrc/main.cpp | 6 ++++ npc/vsrc/example.v | 2 ++ 8 files changed, 144 insertions(+) create mode 100644 .gitignore create mode 100644 Makefile create mode 100644 README.md create mode 100644 init.sh create mode 100644 npc/.gitignore create mode 100644 npc/Makefile create mode 100644 npc/csrc/main.cpp create mode 100644 npc/vsrc/example.v diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..c5a9b75 --- /dev/null +++ b/.gitignore @@ -0,0 +1,12 @@ +*.* +* +!*/ +!/nemu/* +!/nexus-am/* +!/nanos-lite/* +!/navy-apps/* +!/npc/* +!Makefile +!README.md +!.gitignore +!init.sh diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..e4cbbd8 --- /dev/null +++ b/Makefile @@ -0,0 +1,19 @@ +STUID = ysyx_22040000 +STUNAME = 张三 + +# DO NOT modify the following code!!! + +GITFLAGS = -q --author='tracer-ysyx2204 ' --no-verify --allow-empty + +# prototype: git_commit(msg) +define git_commit + -@git add .. -A --ignore-errors + -@while (test -e .git/index.lock); do sleep 0.1; done + -@(echo "> $(1)" && echo $(STUID) $(STUNAME) && uname -a && uptime) | git commit -F - $(GITFLAGS) + -@sync +endef + +_default: + @echo "Please run 'make' under subprojects." + +.PHONY: _default diff --git a/README.md b/README.md new file mode 100644 index 0000000..cb21758 --- /dev/null +++ b/README.md @@ -0,0 +1,9 @@ +# "一生一芯"工程项目 + +这是"一生一芯"的工程项目. 通过运行 +```bash +bash init.sh subproject-name +``` +进行初始化, 具体请参考[实验讲义][lecture note]. + +[lecture note]: https://docs.ysyx.org/schedule.html diff --git a/init.sh b/init.sh new file mode 100644 index 0000000..5a7a3ff --- /dev/null +++ b/init.sh @@ -0,0 +1,77 @@ +#!/bin/bash + +# usage: init repo branch directory trace [env] +# trace = true|false +function init() { + if [ -d $3 ]; then + echo "$3 is already initialized, skipping..." + return + fi + + while [ ! -d $3 ]; do + git clone -b $2 git@github.com:$1.git $3 + done + log="$1 `cd $3 && git log --oneline --no-abbrev-commit -n1`"$'\n' + + if [ $4 == "true" ] ; then + rm -rf $3/.git + git add -A $3 + git commit -am "$1 $2 initialized"$'\n\n'"$log" + else + sed -i -e "/^\/$3/d" .gitignore + echo "/$3" >> .gitignore + git add -A .gitignore + git commit --no-verify --allow-empty -am "$1 $2 initialized without tracing"$'\n\n'"$log" + fi + + if [ $5 ] ; then + sed -i -e "/^export $5=.*/d" ~/.bashrc + echo "export $5=`readlink -e $3`" >> ~/.bashrc + + echo "By default this script will add environment variables into ~/.bashrc." + echo "After that, please run 'source ~/.bashrc' to let these variables take effect." + echo "If you use shell other than bash, please add these environment variables manually." + fi +} + +case $1 in + nemu) + init NJU-ProjectN/nemu ysyx2204 nemu true NEMU_HOME + ;; + abstract-machine) + init NJU-ProjectN/abstract-machine ysyx2204 abstract-machine true AM_HOME + init NJU-ProjectN/fceux-am ics2021 fceux-am false + ;; + am-kernels) + init NJU-ProjectN/am-kernels ics2021 am-kernels false + ;; + nanos-lite) + init NJU-ProjectN/nanos-lite ics2021 nanos-lite true + ;; + navy-apps) + init NJU-ProjectN/navy-apps ics2021 navy-apps true NAVY_HOME + ;; + nvboard) + init NJU-ProjectN/nvboard master nvboard false NVBOARD_HOME + ;; + npc-chisel) + if [ -d npc/playground ]; then + echo "chisel repo is already initialized, skipping..." + else + rm -rf npc + init OpenXiangShan/chisel-playground ysyx2204 npc true NPC_HOME + fi + ;; + npc) + sed -i -e "/^export NPC_HOME=.*/d" ~/.bashrc + echo "export NPC_HOME=`readlink -e npc`" >> ~/.bashrc + + echo "By default this script will add environment variables into ~/.bashrc." + echo "After that, please run 'source ~/.bashrc' to let these variables take effect." + echo "If you use shell other than bash, please add these environment variables manually." + ;; + *) + echo "Invalid input..." + exit + ;; +esac diff --git a/npc/.gitignore b/npc/.gitignore new file mode 100644 index 0000000..adf9b7d --- /dev/null +++ b/npc/.gitignore @@ -0,0 +1,11 @@ +*.* +* +!*/ +!Makefile +!*.mk +!*.[cSh] +!*.v +!*.cc +!*.cpp +!.gitignore +!README.md diff --git a/npc/Makefile b/npc/Makefile new file mode 100644 index 0000000..46469fa --- /dev/null +++ b/npc/Makefile @@ -0,0 +1,8 @@ +all: + @echo "Write this Makefile by your self." + +sim: + $(call git_commit, "sim RTL") # DO NOT REMOVE THIS LINE!!! + @echo "Write this Makefile by your self." + +include ../Makefile diff --git a/npc/csrc/main.cpp b/npc/csrc/main.cpp new file mode 100644 index 0000000..5e95ddc --- /dev/null +++ b/npc/csrc/main.cpp @@ -0,0 +1,6 @@ +#include + +int main() { + printf("Hello, ysyx!\n"); + return 0; +} diff --git a/npc/vsrc/example.v b/npc/vsrc/example.v new file mode 100644 index 0000000..536579a --- /dev/null +++ b/npc/vsrc/example.v @@ -0,0 +1,2 @@ +module example(); +endmodule