Merge master to hby

This commit is contained in:
BryanHeBY 2022-02-24 23:44:51 +08:00
commit 48c1fb7041
7 changed files with 19 additions and 14 deletions

View File

@ -54,7 +54,12 @@ NVBoard提供了以下几组API
- `void nvboard_init()`: 初始化NVBoard
- `void nvboard_quit()`: 退出NVBoard
- `void nvboard_bind_pin(pin, void *signal)`: 将HDL的信号signal连接到NVBoard里的引脚pin上
- `void nvboard_bind_pin(void *signal, bool is_rt, bool is_output, int len, ...)`: 将HDL的信号signal连接到NVBoard里的引脚上具体地
- `is_rt`为`true`时表示该信号为实时信号每个周期都要更新才能正确工作如键盘和VGA相关信号
`is_rt`为`false`时表示该信号为普通信号可以在NVBoard更新画面时才更新从而提升NVBoard的性能如拨码开关和LED灯等无需每个周期都更新
- `is_output`为`true`时,表示该信号方向为输出方向(从RTL代码到NVBoard);否则为输入方向(从NVBoard到RTL代码)
- `len`为信号的长度大于1时为向量信号
- 可变参数列表`...`为引脚编号列表编号为整数绑定向量信号时引脚编号列表从MSB到LSB排列
- `void nvboard_update()`: 更新NVBoard中各组件的状态每当电路状态发生改变时都需要调用该函数
### 引脚绑定

View File

@ -1,3 +1,11 @@
# 编译运行
# 示例工程
先设置环境变量`NVBOARD_HOME`, 然后执行`make run`.
该示例的演示效果如下:
1. 左边8个LED为流水灯效果
1. 拨动右边的8个拨码开关, 可控制对应LED的亮灭
1. 8个数码管流水显示数字1-8
1. 按钮暂无展示效果
1. 窗口右侧为VGA输出, 将会展示一张图片
1. 敲击键盘, 终端将会输出按键的扫描码

View File

@ -1,6 +1,5 @@
top=top
VGA_CLK VGA_CLK
VGA_VSYNC VGA_VSYNC
VGA_HSYNC VGA_HSYNC
VGA_BLANK_N VGA_BLANK_N

View File

@ -24,7 +24,6 @@ int main() {
while(1) {
nvboard_update();
dut.clk = !dut.clk;
dut.eval();
single_cycle();
}
}

View File

@ -10,7 +10,7 @@ module led(
if (rst) begin led <= 1; count <= 0; end
else begin
if (count == 0) led <= {led[6:0], led[7]};
count <= (count >= 50000 ? 32'b0 : count + 1);
count <= (count >= 5000000 ? 32'b0 : count + 1);
end
end

View File

@ -21,7 +21,7 @@ assign segs[5] = 8'b10111110;
assign segs[6] = 8'b11100000;
assign segs[7] = 8'b11111110;
parameter CLK_NUM = 500000;
parameter CLK_NUM = 5000000;
reg [31:0] count;
reg [2:0] offset;

View File

@ -34,7 +34,7 @@ VGA::~VGA() {
}
void VGA::update_gui() {
#ifdef SHOW_FRAME_UPDATE
#ifdef DEBUG
static int frames = 0;
frames ++;
printf("%d frames\n", frames);
@ -48,14 +48,9 @@ void VGA::update_gui() {
}
void VGA::update_state() {
int vga_clk = output_map[VGA_CLK];
int vga_vsync = output_map[VGA_VSYNC];
int vga_hsync = output_map[VGA_HSYNC];
int vga_blank_n = output_map[VGA_BLANK_N];
if(!VGA_NEG_EDGE(clk)){
vga_pre_clk = vga_clk;
return;
}
if(vga_blank_n) {
int vga_r = (output_map[VGA_R7] << 7) |
(output_map[VGA_R6] << 6) |
@ -91,5 +86,4 @@ void VGA::update_state() {
update_gui();
}
vga_pre_vsync = vga_vsync;
vga_pre_clk = vga_clk;
}