Skip to content

Commit ea63c0c

Browse files
authored
Merge pull request #171 from JdeRobot/refactor-sim-code
Refactor sim code
2 parents 8d94f55 + dbf680e commit ea63c0c

File tree

112 files changed

+3210
-33
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

112 files changed

+3210
-33
lines changed

.gitignore

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,4 +13,7 @@
1313

1414
debug.log
1515

16-
.vscode
16+
.vscode
17+
obj_dir
18+
*.fst
19+
imgui.ini

.gitmodules

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
[submodule "utils/poc_verilator_simulation/sim/third_party/imgui"]
2-
path = sim_fpga/sim/third_party/imgui
2+
path = third_party/imgui
33
url = https://github.com/ocornut/imgui.git
Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
MKFILE_PATH := $(abspath $(lastword $(MAKEFILE_LIST)))
2+
SIM_DIR := $(realpath $(dir $(MKFILE_PATH))/../..)
3+
PROJECT_DIR := $(realpath $(SIM_DIR)/..)
4+
IMGUI_DIR = $(PROJECT_DIR)/third_party/imgui
5+
EXAMPLE_DIR = $(SIM_DIR)/examples/example1
6+
SIM_INC_DIR = $(SIM_DIR)/include
7+
RTL_DIR = $(EXAMPLE_DIR)/rtl
8+
INC_DIR = $(EXAMPLE_DIR)/include
9+
SRC_DIR = $(EXAMPLE_DIR)/src
10+
ASSETS_DIR := $(SRC_DIR)
11+
SOURCES = $(SRC_DIR)/input_driver.cpp $(SRC_DIR)/output_monitor.cpp $(SRC_DIR)/main.cpp
12+
SOURCES += $(SIM_DIR)/src/gl_texture_utils.cpp
13+
SOURCES += $(IMGUI_DIR)/imgui.cpp $(IMGUI_DIR)/imgui_demo.cpp $(IMGUI_DIR)/imgui_draw.cpp $(IMGUI_DIR)/imgui_tables.cpp $(IMGUI_DIR)/imgui_widgets.cpp
14+
SOURCES += $(IMGUI_DIR)/backends/imgui_impl_sdl.cpp $(IMGUI_DIR)/backends/imgui_impl_opengl3.cpp
15+
HEADERS = $(INC_DIR)/
16+
V_SOURCES = $(RTL_DIR)/design_top.v
17+
UNAME_S := $(shell uname -s)
18+
LINUX_GL_LIBS = -lGL
19+
20+
CXXFLAGS = -I$(INC_DIR) -I$(SIM_INC_DIR) -I$(IMGUI_DIR) -I$(IMGUI_DIR)/backends -DASSETS_DIR=\\\"$(ASSETS_DIR)\\\" -g
21+
LIBS =
22+
23+
##---------------------------------------------------------------------
24+
## BUILD FLAGS PER PLATFORM
25+
##---------------------------------------------------------------------
26+
27+
ifeq ($(UNAME_S), Linux) #LINUX
28+
ECHO_MESSAGE = "Linux"
29+
LIBS += $(LINUX_GL_LIBS) -ldl `sdl2-config --libs` `pkg-config --libs opencv4`
30+
31+
CXXFLAGS += `sdl2-config --cflags` `pkg-config --cflags opencv4`
32+
CFLAGS = $(CXXFLAGS)
33+
endif
34+
35+
ifeq ($(UNAME_S), Darwin) #APPLE
36+
ECHO_MESSAGE = "Mac OS X"
37+
LIBS += -framework OpenGL -framework Cocoa -framework IOKit -framework CoreVideo `sdl2-config --libs`
38+
LIBS += -L/usr/local/lib -L/opt/local/lib
39+
40+
CXXFLAGS += `sdl2-config --cflags`
41+
CXXFLAGS += -I/usr/local/include -I/opt/local/include
42+
CFLAGS = $(CXXFLAGS)
43+
endif
44+
45+
ifeq ($(OS), Windows_NT)
46+
ECHO_MESSAGE = "MinGW"
47+
LIBS += -lgdi32 -lopengl32 -limm32 `pkg-config --static --libs sdl2`
48+
49+
CXXFLAGS += `pkg-config --cflags sdl2`
50+
CFLAGS = $(CXXFLAGS)
51+
endif
52+
53+
##---------------------------------------------------------------------
54+
## BUILD RULES
55+
##---------------------------------------------------------------------
56+
57+
all: obj_dir/Vdesign_top
58+
@echo Build complete for $(ECHO_MESSAGE)
59+
60+
obj_dir/Vdesign_top.h: $(V_SOURCES)
61+
verilator --cc $(V_SOURCES) -x-assign unique --trace-fst -CFLAGS "$(CXXFLAGS)" --exe $(SOURCES) -I$(RTL_DIR)
62+
63+
obj_dir/Vdesign_top: obj_dir/Vdesign_top.h $(SOURCES)
64+
make -j 4 -C obj_dir/ -f Vdesign_top.mk Vdesign_top LIBS="$(LIBS)"
65+
66+
clean:
67+
rm -rf obj_dir
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

0 commit comments

Comments
 (0)