Added: gitignore

This commit is contained in:
201220107-贺柄毓 2022-01-20 12:26:32 +08:00
parent a6919de716
commit c163b67dbb
15 changed files with 227 additions and 119 deletions

41
.gitignore vendored
View File

@ -1,32 +1,9 @@
# Prerequisites
*.d
# Compiled Object files
*.slo
*.lo
*.o
*.obj
# Precompiled Headers
*.gch
*.pch
# Compiled Dynamic libraries
*.so
*.dylib
*.dll
# Fortran module files
*.mod
*.smod
# Compiled Static libraries
*.lai
*.la
*.a
*.lib
# Executables
*.exe
*.out
*.app
*.*
*
!*/
!.gitignore
!Makefile
!makefile
!LICENSE
!README.md
!README.en.md

View File

@ -2,84 +2,61 @@ ifndef TOPNAME
$(error TOPNAME should be given)
endif
# generated executable file
DST_DIR = build
DST_BIN = $(DST_DIR)/emu_board
# files of nboard
NBD_SRC = src
NBD_SRCS := $(shell find $(NBD_SRC) -name "*.cpp")
NBD_LIB = include
NBD_LIBS := $(shell find $(NBD_LIB) -name "*.h")
# update.cpp should be implemented by users.
NBD_OBJS := $(addprefix $(DST_DIR)/, $(addsuffix .o, $(basename $(notdir $(NBD_SRCS))))) \
$(DST_DIR)/update.o
# include path
INC_PATH ?=
# files of emu
EMU_DIR = emu
EMU_ARCH := $(shell find $(EMU_DIR) -name "*.a")
DIR ?= $(NBOARD_HOME)/test
OBJ_DIR = $(DIR)/obj_dir
VARCHIVE := $(OBJ_DIR)/V$(TOPNAME)__ALL.a
INC_PATH += $(OBJ_DIR)
### Constants...
# Perl executable (from $PERL)
PERL = perl
# Path to Verilator kit (from $VERILATOR_ROOT)
VERILATOR_ROOT = /usr/share/verilator
# SystemC include directory with systemc.h (from $SYSTEMC_INCLUDE)
SYSTEMC_INCLUDE ?=
# SystemC library directory with libsystemc.a (from $SYSTEMC_LIBDIR)
SYSTEMC_LIBDIR ?=
# generated executable file
DST_BIN = $(OBJ_DIR)/NVBOARD_$(TOPNAME)
### Switches...
# SystemC output mode? 0/1 (from --sc)
VM_SC = 0
# Legacy or SystemC output mode? 0/1 (from --sc)
VM_SP_OR_SC = $(VM_SC)
# Deprecated
VM_PCLI = 1
# Deprecated: SystemC architecture to find link library path (from $SYSTEMC_ARCH)
VM_SC_TARGET_ARCH = linux
# SRC of the project
VSRC_DIR ?= $(DIR)/vsrc
VSRCS ?= $(shell find $(VSRC_DIR) -name "*.v")
### Vars...
# Design prefix (from --prefix)
VM_PREFIX = V$(TOPNAME)
# Module prefix (from --prefix)
VM_MODPREFIX = V$(TOPNAME)
# User CFLAGS (from -CFLAGS on Verilator command line)
VM_USER_CFLAGS = -I $(NBD_LIB) -I $(EMU_DIR)
# User LDLIBS (from -LDFLAGS on Verilator command line)
VM_USER_LDLIBS = -lSDL2 -lSDL2_image
# User .cpp files (from .cpp's on Verilator command line)
VM_USER_CLASSES =
# User .cpp directories (from .cpp's on Verilator command line)
VM_USER_DIR = ./src
CSRC_DIR ?= $(DIR)/csrc
CSRCS ?= $(shell find $(CSRC_DIR) -name "*.c" -or -name "*.cc" -or -name "*.cpp")
COBJS = $(CSRCS:%.cpp=$(OBJ_DIR)/%.o)
### Default rules...
# Include list of all generated classes
include $(EMU_DIR)/V$(TOPNAME)_classes.mk
# Include global rules
include $(NBOARD_HOME)/scripts/vtrace.mk
include $(VERILATOR_ROOT)/include/verilated.mk
$(DST_BIN): $(NBD_OBJS) $(VK_GLOBAL_OBJS) $(EMU_DIR)/V$(TOPNAME)__ALL.a
@$(LINK) $(LD_FLAGS) $^ $(LOADLIBES) $(LDLIBS) $(LIBS) $(SC_LIBS) -o $@ $(SDL_FLAGS)
# Build rules of nboard
include $(NBOARD_HOME)/scripts/nboard.mk
$(DST_DIR)/%.o: $(NBD_SRC)/%.cpp $(NBD_LIBS)
-include V$(TOPNAME)_all.d
-include V$(TOPNAME)_ver.d
$(VARCHIVE): $(VSRCS)
@echo + VERILATOR "->" $^
@$(VERILATOR) $(VFLAGS) -top $(TOPNAME) -cc $(VSRCS)
$(OBJ_DIR)/%.o: %.cpp $(VARCHIVE)
@echo + CXX "->" $<
@mkdir -p $(dir $@)
@$(OBJCACHE) $(CXX) $(CXXFLAGS) $(CPPFLAGS) $(OPT_FAST) \
-I $(NBD_LIB) -I $(EMU_DIR) -c -o $@ $<
-DTOP_NAME="V$(TOPNAME)" -c -o $@ $<
$(DST_BIN): $(VK_GLOBAL_OBJS) $(COBJS) $(NBD_ARCHIVE) $(VARCHIVE)
@echo + LD "->" $@
@mkdir -p $(dir $@)
@$(LINK) $(LD_FLAGS) $^ $(LOADLIBES) $(LDLIBS) $(LIBS) $(SC_LIBS) -o $@ $(SDL_FLAGS)
src/update.cpp: emu/update.cpp
@ln -sf $(realpath ./$(EMU_DIR)/update.cpp) $(NBD_SRC)/update.cpp
run: $(DST_BIN)
@$(DST_BIN)
clean:
@rm -rf $(DST_DIR)
@rm -f *.o
@rm -f *.d
rm -rf $(OBJ_DIR)
rm -f verilated.d
rm -f verilated.o
.PHONY: clean run

1
emu/.gitignore vendored Normal file
View File

@ -0,0 +1 @@
!*

View File

@ -1,18 +1,23 @@
#include <nboard.h>
#include <map>
#include <string>
#include <topname.h>
TOP_NAME dut;
extern std::map<std::string, bool> input_map, output_map;
void update_input(TOP_NAME *dut_ptr) {
dut_ptr->clk = input_map["btnc"];
dut_ptr->reset = input_map["rst"];
void dut_eval() {
dut.eval();
}
void update_output(TOP_NAME *dut_ptr) {
output_map["ld0"] = (dut_ptr->out >> 0) & 1;
output_map["ld1"] = (dut_ptr->out >> 1) & 1;
output_map["ld2"] = (dut_ptr->out >> 2) & 1;
output_map["ld3"] = (dut_ptr->out >> 3) & 1;
void update_input() {
dut.clk = input_map["btnc"];
dut.reset = input_map["rst"];
}
void update_output() {
output_map["ld0"] = (dut.out >> 0) & 1;
output_map["ld1"] = (dut.out >> 1) & 1;
output_map["ld2"] = (dut.out >> 2) & 1;
output_map["ld3"] = (dut.out >> 3) & 1;
}

2
include/.gitignore vendored Normal file
View File

@ -0,0 +1,2 @@
!*.h
!*.hpp

View File

@ -1,12 +1,8 @@
#include <SDL2/SDL.h>
#include <topname.h>
#ifndef _VFPGA_CONSTRS_H
#define _VFPGA_CONSTRS_H
void update_input(TOP_NAME *dut_ptr);
void update_output(TOP_NAME *dut_ptr);
void init_input();
void init_output();

3
include/interface.h Normal file
View File

@ -0,0 +1,3 @@
void update_input();
void update_output();
void dut_eval();

4
pic/.gitignore vendored Normal file
View File

@ -0,0 +1,4 @@
!*.png
!*.jpg
!*.jpeg
!*.gif

1
scripts/.gitignore vendored Normal file
View File

@ -0,0 +1 @@
!*.mk

31
scripts/nboard.mk Normal file
View File

@ -0,0 +1,31 @@
# files of nboard
NBD_SRC = $(NBOARD_HOME)/src
NBD_SRCS := $(shell find $(NBD_SRC) -name "*.cpp")
NBD_LIB = $(NBOARD_HOME)/include
INC_PATH += $(NBD_LIB)
NBD_DST_DIR = $(NBOARD_HOME)/build
NBD_OBJS := $(addprefix $(NBD_DST_DIR)/, $(addsuffix .o, $(basename $(notdir $(NBD_SRCS)))))
# The archive of nvboard
NBD_ARCHIVE = $(NBD_DST_DIR)/NVBOARD.a
$(NBD_DST_DIR)/%.o: $(NBD_SRC)/%.cpp
@echo + CXX "->" NBOARD_HOME/$(shell realpath $< --relative-to $(NBOARD_HOME))
@mkdir -p $(dir $@)
@$(OBJCACHE) $(CXX) $(CXXFLAGS) $(CPPFLAGS) $(OPT_FAST) -I$(NBD_LIB) -c -o $@ $<
# Build the archive of nvboar
$(NBD_ARCHIVE): $(NBD_OBJS)
@echo + AR "->" $(shell realpath $@ --relative-to $(NBOARD_HOME))
@ar rcs $(NBD_ARCHIVE) $(NBD_OBJS)
# Rule (`#include` dependencies): paste in `.d` files generated by gcc on `-MMD`
-include $(NBD_OBJS:.o=.d)
.PHONY: archive nbd-clean
archive: $(NBD_ARCHIVE)
nbd-clean:
rm -rf $(NBD_DST_DIR)

91
scripts/vtrace.mk Normal file
View File

@ -0,0 +1,91 @@
### Constants...
# Perl executable (from $PERL)
PERL = perl
# Path to Verilator kit (from $VERILATOR_ROOT)
VERILATOR_ROOT = /usr/local/share/verilator
VERILATOR = verilator
VFLAGS = -Wall -build
# SystemC include directory with systemc.h (from $SYSTEMC_INCLUDE)
SYSTEMC_INCLUDE ?=
# SystemC library directory with libsystemc.a (from $SYSTEMC_LIBDIR)
SYSTEMC_LIBDIR ?=
### Switches...
# SystemC output mode? 0/1 (from --sc)
VM_SC = 0
# Legacy or SystemC output mode? 0/1 (from --sc)
VM_SP_OR_SC = $(VM_SC)
# Deprecated
VM_PCLI = 1
# Deprecated: SystemC architecture to find link library path (from $SYSTEMC_ARCH)
VM_SC_TARGET_ARCH = linux
### Vars...
# Design prefix (from --prefix)
VM_PREFIX = V$(TOPNAME)
# Module prefix (from --prefix)
VM_MODPREFIX = V$(TOPNAME)
# User CFLAGS (from -CFLAGS on Verilator command line)
INCFLAGS += $(addprefix -I, $(INC_PATH))
VM_USER_CFLAGS += $(INCFLAGS)
# User LDLIBS (from -LDFLAGS on Verilator command line)
VM_USER_LDLIBS = -lSDL2 -lSDL2_image
# User .cpp files (from .cpp's on Verilator command line)
VM_USER_CLASSES =
# Verilated -*- Makefile -*-
# DESCRIPTION: Verilator output: Make include file with class lists
#
# This file lists generated Verilated files, for including in higher level makefiles.
# See Vmod1.mk for the caller.
### Switches...
# C11 constructs required? 0/1 (always on now)
VM_C11 = 1
# Coverage output mode? 0/1 (from --coverage)
VM_COVERAGE = 0
# Parallel builds? 0/1 (from --output-split)
VM_PARALLEL_BUILDS = 0
# Threaded output mode? 0/1/N threads (from --threads)
VM_THREADS = 0
# Tracing output mode? 0/1 (from --trace/--trace-fst)
VM_TRACE = 0
# Tracing output mode in FST format? 0/1 (from --trace-fst)
VM_TRACE_FST = 0
# Tracing threaded output mode? 0/1/N threads (from --trace-thread)
VM_TRACE_THREADS = 0
# Separate FST writer thread? 0/1 (from --trace-fst with --trace-thread > 0)
VM_TRACE_FST_WRITER_THREAD = 0
# Copied from the classed file
### Object file lists...
# Generated module classes, fast-path, compile with highest optimization
VM_CLASSES_FAST += \
V$(TOPNAME) \
# Generated module classes, non-fast-path, compile with low/medium optimization
VM_CLASSES_SLOW += \
V$(TOPNAME)__Slow \
# Generated support classes, fast-path, compile with highest optimization
VM_SUPPORT_FAST += \
# Generated support classes, non-fast-path, compile with low/medium optimization
VM_SUPPORT_SLOW += \
V$(TOPNAME)__Syms \
# Global classes, need linked once per executable, fast-path, compile with highest optimization
VM_GLOBAL_FAST += \
verilated \
# Global classes, need linked once per executable, non-fast-path, compile with low/medium optimization
VM_GLOBAL_SLOW += \
# Verilated -*- Makefile -*-

3
src/.gitignore vendored Normal file
View File

@ -0,0 +1,3 @@
!*.c
!*.cc
!*.cpp

View File

@ -184,6 +184,11 @@ int read_event() {
case SDL_KEYDOWN:
return keydown_handler(ev);
break;
case SDL_WINDOWEVENT:
if(ev.window.event == SDL_WINDOWEVENT_CLOSE){
return -1;
}
break;
case SDL_KEYUP:
return keyup_handler(ev);
break;

View File

@ -5,24 +5,33 @@
#include <verilated.h>
#include <nboard.h>
#include <topname.h>
TOP_NAME *dut_ptr;
#include <stdlib.h>
#include <interface.h>
std::string nboard_home;
int main() {
printf("nboard v0.1\n");
// init verilog module
dut_ptr = new TOP_NAME;
// init SDL and SDL_image
SDL_Init(SDL_INIT_TIMER | SDL_INIT_VIDEO | SDL_INIT_EVENTS);
IMG_Init(IMG_INIT_PNG);
SDL_Window *vga_window = nullptr;
SDL_Renderer *vga_render = nullptr;
vga_window = SDL_CreateWindow("nboard-vga", SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, WINDOW_WIDTH, WINDOW_HEIGHT, SDL_WINDOW_SHOWN);
vga_render = SDL_CreateRenderer(vga_window, -1, SDL_RENDERER_ACCELERATED | SDL_RENDERER_PRESENTVSYNC);
SDL_Window *window = nullptr;
SDL_Renderer *render = nullptr;
window = SDL_CreateWindow("nboard", SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, WINDOW_WIDTH, WINDOW_HEIGHT, SDL_WINDOW_SHOWN);
window = SDL_CreateWindow("nboard", SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, WINDOW_WIDTH, WINDOW_HEIGHT, SDL_WINDOW_SHOWN);
render = SDL_CreateRenderer(window, -1, SDL_RENDERER_ACCELERATED | SDL_RENDERER_PRESENTVSYNC);
usleep(300000);
nboard_home = getenv("NBOARD_HOME");
load_background(render);
load_texture(render);
@ -30,8 +39,10 @@ int main() {
init_input();
init_output();
//dbg_wait_esc();
update_input(dut_ptr);
dut_ptr->eval();
update_input();
dut_eval();
update_output();
update_gui_output(render);
//dbg_wait_esc();
init_gui(render);
@ -41,25 +52,27 @@ int main() {
if (ev == -1) {
break;
} else if (ev) {
update_input(dut_ptr);
update_input();
update_gui_input(render);
dut_ptr->eval();
update_output(dut_ptr);
dut_eval();
update_output();
update_gui_output(render);
}
if (read_clock()) {
update_input(dut_ptr);
dut_ptr->eval();
update_output(dut_ptr);
update_input();
dut_eval();
update_output();
update_gui_output(render);
}
}
SDL_DestroyWindow(vga_window);
SDL_DestroyRenderer(vga_render);
SDL_DestroyWindow(window);
SDL_DestroyRenderer(render);
IMG_Quit();
SDL_Quit();
delete dut_ptr;
return 0;
}

View File

@ -1 +0,0 @@
/home/yuyake/virtual-fpga/emu/update.cpp