Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Makefile.sv to directly simulate SV files using tools like VCS #38

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 43 additions & 0 deletions Makefile.sv
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
TOPLEVEL_LANG = verilog

SIM ?= questa
WAVES ?= 0

COCOTB_HDL_TIMEUNIT = 1ns
COCOTB_HDL_TIMEPRECISION = 1ns

DUT = gpu
TOPLEVEL = $(DUT)
MODULE = test.test_matadd

RTL_DIR = ./src

# VERILOG_SOURCES += $(RTL_DIR)/alu.sv
# VERILOG_SOURCES += $(RTL_DIR)/controller.sv
# VERILOG_SOURCES += $(RTL_DIR)/dcr.sv
# VERILOG_SOURCES += $(RTL_DIR)/decoder.sv
# VERILOG_SOURCES += $(RTL_DIR)/dispatch.sv
# VERILOG_SOURCES += $(RTL_DIR)/fetcher.sv
# VERILOG_SOURCES += $(RTL_DIR)/lsu.sv
# VERILOG_SOURCES += $(RTL_DIR)/pc.sv
# VERILOG_SOURCES += $(RTL_DIR)/registers.sv
# VERILOG_SOURCES += $(RTL_DIR)/scheduler.sv
# VERILOG_SOURCES += $(RTL_DIR)/core.sv
# VERILOG_SOURCES += $(RTL_DIR)/gpu.sv

VERILOG_SOURCES += build/gpu.v
COMPILE_ARGS += +define+SIM

ifeq ($(SIM), questa)
COMPILE_ARGS += -sv
endif

ifeq ($(SIM), vcs)
SIM_BUILD ?= .
COMPILE_ARGS += -V -debug_access+r+w+nomemcbk -debug_region+cell +define+VCS
endif

include $(shell cocotb-config --makefiles)/Makefile.sim

clean::
@rm -rf dump.fst $(TOPLEVEL).fst sim_build/runsim.do
3 changes: 2 additions & 1 deletion test/helpers/format.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ def format_register(register: int) -> str:
return f"%blockDim"
if register == 15:
return f"%threadIdx"

def format_instruction(instruction: str) -> str:
opcode = instruction[0:4]
rd = format_register(int(instruction[4:8], 2))
Expand Down Expand Up @@ -104,6 +104,7 @@ def format_cycle(dut, cycle_id: int, thread_id: Optional[int] = None):

logger.debug(f"\n+--------------------- Core {core.i.value} ---------------------+")

dir(core.core_instance)
instruction = str(core.core_instance.instruction.value)
for thread in core.core_instance.threads:
if int(thread.i.value) < int(str(core.core_instance.thread_count.value), 2): # if enabled
Expand Down