Giter VIP home page Giter VIP logo

nvboard's People

Contributors

bryanheby avatar fanshupei avatar huiyeruzhou avatar jaypiper avatar kingfish404 avatar nekomona avatar retrhelo avatar sashimi-yzh avatar shudorcl avatar wele0612 avatar xinyangli avatar yu-yake2002 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

nvboard's Issues

探讨提升依赖nvboard的项目编译性能的可能

问题提出

以项目中的example为例,example 将nvboard.a 作为库被 verilator 识别并链接,以此提供 nvboard 的相关功能.但是这样引入了一个问题: nvboard.a只是被 verilator 认为是外部的库而不会加入依赖项中,也就是说仅仅是 nvboard.a 的改变不会引起 main.cpp 的重新编译.
example中似乎使用删除veriator生成的相关代码并重新编译来避免这个问题

# example/Makefile:34-39
$(BIN): $(VSRCS) $(CSRCS) $(NVBOARD_ARCHIVE)
+++	@rm -rf $(OBJ_DIR) <--- 这里删除了obj_dir
	$(VERILATOR) $(VERILATOR_CFLAGS) \
		--top-module $(TOPNAME) $^ \
		$(addprefix -CFLAGS , $(CXXFLAGS)) $(addprefix -LDFLAGS , $(LDFLAGS)) \
		--Mdir $(OBJ_DIR) --exe -o $(abspath $(BIN))

对于example这样较小的项目这样做是没有问题的,但是如果Verilog部分的代码比较庞大(如ysyxSoC),删除重新编译的方法的耗时是相当巨大的,此时必须依赖ccache来提升编译性能,同时意外发现,有时候ccahce并没有起到作用,导致编译非常的折磨人.

因此我希望在此探讨提升依赖nvboard项目编译性能可能的办法:

尝试的方案

diff --git a/.gitignore b/.gitignore
index 0c7970f..5511ce6 100644
--- a/.gitignore
+++ b/.gitignore
@@ -11,3 +11,4 @@
 !*.v
 !*.cpp
 build/
+/usr/
\ No newline at end of file
diff --git a/include/pins.h b/include/pins.h
index 6075a29..d48d045 100644
--- a/include/pins.h
+++ b/include/pins.h
@@ -1,7 +1,7 @@
 #ifndef __PINS_H__
 #define __PINS_H__
 
-#include <../usr/include/pins.h>
+#include <usr/pins.h>
 #include <stdint.h>
 #include <assert.h>
 
diff --git a/usr/include/nvboard.h b/include/usr/nvboard.h
similarity index 100%
rename from usr/include/nvboard.h
rename to include/usr/nvboard.h
diff --git a/usr/include/pins.h b/include/usr/pins.h
similarity index 100%
rename from usr/include/pins.h
rename to include/usr/pins.h
diff --git a/scripts/nvboard.mk b/scripts/nvboard.mk
index 5144118..7f75e51 100644
--- a/scripts/nvboard.mk
+++ b/scripts/nvboard.mk
@@ -21,6 +21,8 @@ $(NVBOARD_BUILD_DIR)/%.o: $(NVBOARD_SRC)/%.cpp
 $(NVBOARD_ARCHIVE): $(NVBOARD_OBJS)
 	@echo + AR "->" $(shell realpath $@ --relative-to $(NVBOARD_HOME))
 	@ar rcs $(NVBOARD_ARCHIVE) $(NVBOARD_OBJS)
+	@mkdir -p $(NVBOARD_USR_INC)
+	@cp --no-preserve=timestamps $(NVBOARD_INC)/usr/* $(NVBOARD_USR_INC)
 
 # Rule (`#include` dependencies): paste in `.d` files generated by gcc on `-MMD`
 -include $(NVBOARD_OBJS:.o=.d)

最开始的想法为在 $(NVBOARD_ARCHIVE) 的编译过程中添加 touch $(NVBOARD_USR_INC)/* , 通过 $(NVBOARD_USR_INC)/{nvboard,pins}.h 的改变来告知make需要重新编译那些引用了nvboard.a的文件.
但是我发现pins.h同时被外部的程序与nvboard自生引用.因此 touch 的方案会导致对nvboard的大量的不必要的编译.因此有了这样的修改.将NVBOARD_USR_INC 移动到 include/usr , nvboard自身使用include/usr 中的内容而nvboard对外则依然使用 NVBOARD_USR_INC , 同时使用 cp --no-preserve=timestamps 来保证 NVBOARD_USR_INC 内容的更新.

修改带来的问题

  • nvboard并不自带两个头文件,需要make一下才会出现.这就导致外部的程序在初次编写时会缺失这两个文件,对代码提示不友好.
  • 修改并没有经过完全的测试,我不确定是不是会带来新的奇怪问题(但是至少他目前在example中工作的还算不错)

性能对比

我的makefile, 无rm obj_dir

$(BIN):$(TOP_MK) $(CSRC) $(HSRC) $(NVBOARD_ARCHIVE)
	@echo + MAKE "->" npc[$(notdir $(BIN))]
	make -C $(OBJ_DIR) -f $<

$(TOP_MK):$(VSRCS)
	@$(VERILATOR) --top-module $(TOP) $(SRCS) $(NVBOARD_ARCHIVE) \
		--cc --exe\
		-CFLAGS -I$(abspath ./include)\
		$(addprefix -CFLAGS , $(CFLAGS))\
		$(addprefix -LDFLAGS , $(LDFLAGS)) \
		$(addprefix -I, $(VSRC_INCLUDE_PATH))\
		--no-timing --timescale "1ns/1ns" --clk clock\
		--threads 1 --threads-dpi pure\
		-j\
		--trace-fst\
		$(addprefix +define+,$(DEFINE))\
		--Mdir $(OBJ_DIR) -o $(BIN)

参照example中的方式进行编译的代码, 有rm obj_dir

 $(BIN):$(SRCS) $(NVBOARD_ARCHIVE)
	@rm -rf $(OBJ_DIR)
 	@$(VERILATOR) --top-module $(TOP) $(SRCS) $(NVBOARD_ARCHIVE) \
 		--cc --exe --build\
 		-CFLAGS -I$(abspath ./include)\
		$(addprefix -CFLAGS , $(CFLAGS))\
 		$(addprefix -LDFLAGS , $(LDFLAGS)) \
 		$(addprefix -I, $(VSRC_INCLUDE_PATH))\
 		--no-timing --timescale "1ns/1ns" --clk clock\
 		--threads 1 --threads-dpi pure\
 		-j\
 		--trace-fst\
 		$(addprefix +define+,$(DEFINE))\
 		--Mdir $(OBJ_DIR) -o $(BIN)

测试指令: time make -j OBJCACHE="" 我这里强行不使用ccache来展示性能差异
测试流程为: make clean -> time make -> touch nvboard/src -> time make

  • 我的makefile 无rm 依赖改变
Executed in usr time sys time
第一次 11.18 secs 26.10 secs 1.23 secs
第二次 1.18 secs 1.39 secs 0.23 secs
  • example中的make 有rm
Executed in usr time sys time
第一次 11.10 secs 25.63 secs 1.43 secs
第二次 12.43 secs 29.72 secs 1.76 secs

可见性能提升相当明显.同时我makefile的写法要求nvboard.a nvboard.h pins.h同时发生改变,因此我认为对nvboard的相关修改是有一定可行性的.

虚拟机下反应很慢

在虚拟机的Ubuntu20.04系统下运行nvboard,界面出来很卡,请问有没有解决办法???

添加开关、按键等事件的日志

在开发 NVDL 时,hwr 想到,如果链接了 nvboard 的二进制文件能够输出按键等信息到日志,那么可以自动生成简单的 testbench (延时问题可以另外写程序解决)。
hwr 提议

关于去除C99标准代码的建议

近日尝试在mac环境下编译该项目,出现这种问题:
image
经过ask the fxxking gpt 得知该代码归于C99标准,不被macos自带的cpp编译器接受。
简单尝试修改后,随正常编译,以下是修改的两处代码。

  1. nvboard/src/term.cpp:6:12
Term::Term(SDL_Renderer *r, int x, int y, int w, int h):
    renderer(r), cursor_x(0), cursor_y(0), screen_y(0) {
  // region = { .x = x, .y = y, .w = w, .h = h };
  region.x = x;
  region.y = y;
  region.w = w;
  region.h = h;
  1. nvboard/src/keyboard.cpp:114:13
static void init_key_texture(SDL_Renderer *renderer, uint8_t sdl_key,
    const char *desc1, const char *desc2, SDL_Surface *key_shape, int x, int y) {
  Key *e = &keys[sdl_key];
  e->t_up   = gen_key_texture(renderer, desc1, desc2, key_shape, false);
  e->t_down = gen_key_texture(renderer, desc1, desc2, key_shape, true);
  // e->rect = { .x = x, .y = y, .w = key_shape->w, .h = key_shape->h };
  e->rect.x = x;
  e->rect.y = y;
  e->rect.w = key_shape->w;
  e->rect.h = key_shape->h;
}

注:在ubuntu22.04系统下编译正常,无此问题。

How to use AN in board/N4 line 48 -55

I was compiling code using ANx ports, but I get errors for there no enum like AN0. After that, I try to use rg to find if there is any SC about these ports, but found nothing about the definition of ANx ports.

My question is are they useless or replaced by other ports?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.