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 xdma demo #1

Open
wants to merge 32 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 17 commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
184d1e8
temporarily change the url of libsystemctlm-soc
ruiqurm Oct 16, 2023
e26e3d0
provide a docker file to build container.
ruiqurm Oct 16, 2023
facb894
a simple xdma-demo that connect XDMA with qemu
ruiqurm Oct 16, 2023
89e501c
add a descriptor bypass and TLM bridge.
ruiqurm Oct 17, 2023
673139c
connect user logic and XDMA
ruiqurm Oct 30, 2023
0e66b8c
update libsystemctlm-soc submodule
ruiqurm Nov 2, 2023
3897225
add user logic example
ruiqurm Nov 19, 2023
7e57849
Configurations for formating
ruiqurm Nov 19, 2023
4b6f851
update Makefile
ruiqurm Nov 19, 2023
b969979
connect to userlogic and formating
ruiqurm Nov 19, 2023
d47209f
script to generate multiple channels
ruiqurm Nov 19, 2023
7ebb5c5
update Makefile
ruiqurm Nov 19, 2023
8f9bc7d
update module
ruiqurm Nov 19, 2023
0b5fb04
replace constant value and update script
ruiqurm Nov 21, 2023
1e94b13
fix some linter warnings
ruiqurm Nov 21, 2023
0ee53ac
remove redundant comments according to review
ruiqurm Nov 27, 2023
e50fc47
remove comments and convert Chinese comment
ruiqurm Nov 27, 2023
b2634f6
Fix makefile bug that can not run on parallel.
ruiqurm Dec 2, 2023
6ccf4db
Fix makefile bug that can not run on parallel.
ruiqurm Dec 2, 2023
38582b9
format xdma-demo.cc
ruiqurm Dec 2, 2023
e50bea1
add new user logic
ruiqurm Dec 20, 2023
ccab0e2
add a slow clock/reset according to new user logic
ruiqurm Dec 20, 2023
54fa335
use dynamic linking
ruiqurm Dec 20, 2023
488797d
Merge remote-tracking branch 'origin'
ruiqurm Dec 26, 2023
d0e323a
add python wrapper
ruiqurm Dec 26, 2023
130f4cd
update README.md
ruiqurm Dec 26, 2023
9a33861
python binding demo
ruiqurm Jan 3, 2024
1ac0aa7
move `xdma_cosim.cc` to new path
ruiqurm Jan 7, 2024
43d8b35
separate `distrosim` from previous `xdma` module
ruiqurm Jan 7, 2024
39f3986
New abstract for generic_initiator and generic_target. There's also a…
ruiqurm Jan 15, 2024
555565b
add comments
ruiqurm Jan 15, 2024
69c2e53
add comments
ruiqurm Jan 15, 2024
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
80 changes: 80 additions & 0 deletions .clang-format
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
# Google C/C++ Code Style settings
Language: Cpp
BasedOnStyle: Google
AccessModifierOffset: -1
AlignAfterOpenBracket: Align
AlignConsecutiveAssignments: None
AlignOperands: Align
AllowAllArgumentsOnNextLine: true
AllowAllConstructorInitializersOnNextLine: true
AllowAllParametersOfDeclarationOnNextLine: false
AllowShortBlocksOnASingleLine: Empty
AllowShortCaseLabelsOnASingleLine: false
AllowShortFunctionsOnASingleLine: Inline
AllowShortIfStatementsOnASingleLine: Never # To avoid conflict, set this "Never" and each "if statement" should include brace when coding
AllowShortLambdasOnASingleLine: Inline
AllowShortLoopsOnASingleLine: false
AlwaysBreakAfterReturnType: None
AlwaysBreakTemplateDeclarations: Yes
BinPackArguments: true
BreakBeforeBraces: Custom
BraceWrapping:
AfterCaseLabel: false
AfterClass: false
AfterStruct: false
AfterControlStatement: Never
AfterEnum: false
AfterFunction: false
AfterNamespace: false
AfterUnion: false
AfterExternBlock: false
BeforeCatch: false
BeforeElse: false
BeforeLambdaBody: false
IndentBraces: false
SplitEmptyFunction: false
SplitEmptyRecord: false
SplitEmptyNamespace: false
BreakBeforeBinaryOperators: None
BreakBeforeTernaryOperators: true
BreakConstructorInitializers: BeforeColon
BreakInheritanceList: BeforeColon
ColumnLimit: 80
CompactNamespaces: false
ContinuationIndentWidth: 4
Cpp11BracedListStyle: true
DerivePointerAlignment: false # Make sure the * or & align on the left
EmptyLineBeforeAccessModifier: LogicalBlock
FixNamespaceComments: true
IncludeBlocks: Preserve
IndentCaseLabels: true
IndentPPDirectives: None
IndentWidth: 2
KeepEmptyLinesAtTheStartOfBlocks: true
MaxEmptyLinesToKeep: 1
NamespaceIndentation: None
ObjCSpaceAfterProperty: false
ObjCSpaceBeforeProtocolList: true
PointerAlignment: Left
ReflowComments: false
# SeparateDefinitionBlocks: Always # Only support since clang-format 14
SpaceAfterCStyleCast: false
SpaceAfterLogicalNot: false
SpaceAfterTemplateKeyword: true
SpaceBeforeAssignmentOperators: true
SpaceBeforeCpp11BracedList: false
SpaceBeforeCtorInitializerColon: true
SpaceBeforeInheritanceColon: true
SpaceBeforeParens: ControlStatements
SpaceBeforeRangeBasedForLoopColon: true
SpaceBeforeSquareBrackets: false
SpaceInEmptyParentheses: false
SpacesBeforeTrailingComments: 2
SpacesInAngles: false
SpacesInCStyleCastParentheses: false
SpacesInContainerLiterals: false
SpacesInParentheses: false
SpacesInSquareBrackets: false
Standard: c++11
TabWidth: 4
UseTab: Never
126 changes: 126 additions & 0 deletions .clang-tidy
Original file line number Diff line number Diff line change
@@ -0,0 +1,126 @@
---
# Configure clang-tidy for this project.

# Here is an explanation for why some of the checks are disabled:
#
# -google-readability-namespace-comments: the *_CLIENT_NS is a macro, and
# clang-tidy fails to match it against the initial value.
#
# -modernize-use-trailing-return-type: clang-tidy recommends using
# `auto Foo() -> std::string { return ...; }`, we think the code is less
# readable in this form.
#
# --modernize-concat-nested-namespaces: clang-tidy recommends
# `namespace google::cloud {}` over `namespace google { namespace cloud { } }`
# We need to support C++14, which does not supported nested namespaces.
#
# --modernize-use-nodiscard: clang-tidy recommends adding a nodiscard annotation
# to functions where the return value should not be ignored.
# We need to support C++14, which does not supported the annotation.
#
# -modernize-return-braced-init-list: We think removing typenames and using
# only braced-init can hurt readability.
#
# -modernize-avoid-c-arrays: We only use C arrays when they seem to be the
# right tool for the job, such as `char foo[] = "hello"`. In these cases,
# avoiding C arrays often makes the code less readable, and std::array is
# not a drop-in replacement because it doesn't deduce the size.
#
# -performance-move-const-arg: This warning requires the developer to
# know/care more about the implementation details of types/functions than
# should be necessary. For example, `A a; F(std::move(a));` will trigger a
# warning IFF `A` is a trivial type (and therefore the move is
# meaningless). It would also warn if `F` accepts by `const&`, which is
# another detail that the caller need not care about.
#
# -performance-avoid-endl: we would like to turn this on, but there are too
# many legitimate uses in our samples.
#
# -readability-redundant-declaration: A friend declaration inside a class
# counts as a declaration, so if we also declare that friend outside the
# class in order to document it as part of the public API, that will
# trigger a redundant declaration warning from this check.
#
# -readability-function-cognitive-complexity: too many false positives with
# clang-tidy-12. We need to disable this check in macros, and that setting
# only appears in clang-tidy-13.
#
# -bugprone-narrowing-conversions: too many false positives around
# `std::size_t` vs. `*::difference_type`.
#
# -bugprone-easily-swappable-parameters: too many false positives.
#
# -bugprone-implicit-widening-of-multiplication-result: too many false positives.
# Almost any expression of the form `2 * variable` or `long x = a_int * b_int;`
# generates an error.
#
# -bugprone-unchecked-optional-access: too many false positives in tests.
# Despite what the documentation says, this warning appears after
# `ASSERT_TRUE(variable)` or `ASSERT_TRUE(variable.has_value())`.
#
# -misc-include-cleaner: too many *true* positives. We need to clean up the
# code, but we should do that over time, maybe per-directory, instead of
# blocking the adoption of Clang 17 until it is all fixed.
#
Checks: >
-*,
abseil-*,
bugprone-*,
google-*,
misc-*,
modernize-*,
performance-*,
portability-*,
readability-*,
-google-readability-braces-around-statements,
-google-readability-namespace-comments,
-google-runtime-references,
-misc-non-private-member-variables-in-classes,
-misc-const-correctness,
-misc-include-cleaner,
-modernize-return-braced-init-list,
-modernize-use-trailing-return-type,
-modernize-concat-nested-namespaces,
-modernize-use-nodiscard,
-modernize-avoid-c-arrays,
-performance-move-const-arg,
-performance-avoid-endl,
-readability-braces-around-statements,
-readability-identifier-length,
-readability-magic-numbers,
-readability-named-parameter,
-readability-redundant-declaration,
-readability-function-cognitive-complexity,
-bugprone-narrowing-conversions,
-bugprone-easily-swappable-parameters,
-bugprone-implicit-widening-of-multiplication-result,
-bugprone-unchecked-optional-access

# Turn all the warnings from the checks above into errors.
# WarningsAsErrors: "*"

HeaderFilterRegex: "libsystemctlm-soc/soc/pci/xilinx/xdma.h|libsystemctlm-soc/soc/pci/xilinx/xdma_signal.h"

CheckOptions:
- { key: readability-identifier-naming.NamespaceCase, value: lower_case }
- { key: readability-identifier-naming.ClassCase, value: lower_case }
- { key: readability-identifier-naming.StructCase, value: lower_case }
- { key: readability-identifier-naming.TemplateParameterCase, value: UPPER_CASE }
- { key: readability-identifier-naming.FunctionCase, value: aNy_CasE }
- { key: readability-identifier-naming.VariableCase, value: lower_case }
- { key: readability-identifier-naming.ClassMemberCase, value: lower_case }
- { key: readability-identifier-naming.ClassMemberSuffix, value: _ }
- { key: readability-identifier-naming.PrivateMemberSuffix, value: _ }
- { key: readability-identifier-naming.ProtectedMemberSuffix, value: _ }
- { key: readability-identifier-naming.EnumConstantCase, value: UPPER_CASE }
- { key: readability-identifier-naming.ConstexprVariableCase, value: UPPER_CASE }
- { key: readability-identifier-naming.ConstexprVariablePrefix, value: k }
- { key: readability-identifier-naming.GlobalConstantCase, value: UPPER_CASE }
- { key: readability-identifier-naming.GlobalConstantPrefix, value: k }
- { key: readability-identifier-naming.MemberConstantCase, value: CamelCase }
- { key: readability-identifier-naming.MemberConstantPrefix, value: k }
- { key: readability-identifier-naming.StaticConstantCase, value: CamelCase }
- { key: readability-identifier-naming.StaticConstantPrefix, value: k }
- { key: readability-implicit-bool-conversion.AllowIntegerConditions, value: 1 }
- { key: readability-implicit-bool-conversion.AllowPointerConditions, value: 1 }
- { key: readability-function-cognitive-complexity.IgnoreMacros, value: 1 }
14 changes: 14 additions & 0 deletions .devcontainer/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
FROM ubuntu:22.04
RUN apt-get update && apt-get install -y wget git cloud-image-utils libfdt1 unzip g++ make
ARG DEMO_PATH="/workspaces/cosim_demo"
ARG SYSTEMC_VERSION=systemc-2.3.3
ARG SYSTEMC_PATH="${DEMO_PATH}/${SYSTEMC_VERSION}"
# get clanged lsp
RUN wget https://github.com/clangd/clangd/releases/download/16.0.2/clangd-linux-16.0.2.zip && \
unzip clangd-linux-16.0.2.zip && \
mv clangd_16.0.2/bin/* /bin/ && \
mv clangd_16.0.2/lib/* /lib/ && \
rm -r clangd_16.0.2 && rm clangd-linux-16.0.2.zip
RUN mkdir -p $DEMO_PATH && cd $DEMO_PATH && wget -q https://www.accellera.org/images/downloads/standards/systemc/systemc-2.3.3.tar.gz && \
tar xzf systemc-2.3.3.tar.gz && cd $SYSTEMC_PATH && ./configure --prefix=$SYSTEMC_PATH && \
make -j && make install
14 changes: 14 additions & 0 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"name": "XDMA SystemC development environment",
"dockerFile": "Dockerfile",

"customizations": {
"vscode": {
"extensions": [
"llvm-vs-code-extensions.vscode-clangd"
]
}
},
"runArgs": ["--privileged"]
}

2 changes: 1 addition & 1 deletion .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@
url = https://github.com/Xilinx/pcie-model.git
[submodule "libsystemctlm-soc"]
path = libsystemctlm-soc
url = https://github.com/Xilinx/libsystemctlm-soc.git
url = https://github.com/ruiqurm/libsystemctlm-soc.git
97 changes: 33 additions & 64 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,10 @@ VERSAL_CPM_QDMA_DEMO_C = pcie/versal/cpm-qdma-demo.cc
VERSAL_CPM4_QDMA_DEMO_O = pcie/versal/cpm4-qdma-demo.o
VERSAL_CPM5_QDMA_DEMO_O = pcie/versal/cpm5-qdma-demo.o

PCIE_XDMA_DEMO_C = pcie/versal/xdma-demo.cc
PCIE_XDMA_DEMO_O = $(PCIE_XDMA_DEMO_C:.cc=.o)
PCIE_XDMA_DEMO_OBJS += $(PCIE_XDMA_DEMO_O) $(PCIE_MODEL_O)

VERSAL_CPM4_QDMA_DEMO_OBJS += $(VERSAL_CPM4_QDMA_DEMO_O) $(PCIE_MODEL_O)
VERSAL_CPM5_QDMA_DEMO_OBJS += $(VERSAL_CPM5_QDMA_DEMO_O) $(PCIE_MODEL_O)

Expand Down Expand Up @@ -117,105 +121,68 @@ CPPFLAGS += -I $(LIBRP_PATH)

VENV=SYSTEMC_INCLUDE=$(SYSTEMC_INCLUDE) SYSTEMC_LIBDIR=$(SYSTEMC_LIBDIR)
VOBJ_DIR=obj_dir
VFILES=apb_timer.v
VFILES_DIR=bsv
VFILES=mkBsvTop.v

ifeq "$(HAVE_VERILOG_VERILATOR)" "y"
# ifeq "$(HAVE_VERILOG_VERILATOR)" "y"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not needed comment ?

VERILATOR_ROOT?=/usr/share/verilator
VERILATOR=verilator

VM_SC?=1
VM_TRACE?=0
VM_COVERAGE?=0
V_LDLIBS += $(VOBJ_DIR)/Vapb_timer__ALL.a
V_LDLIBS += $(VOBJ_DIR)/Vaxilite_dev__ALL.a
V_LDLIBS += $(VOBJ_DIR)/Vaxifull_dev__ALL.a
V_LDLIBS += $(VOBJ_DIR)/VmkBsvTop__ALL.a
LDLIBS += $(V_LDLIBS)
VERILATED_O=$(VOBJ_DIR)/verilated.o

# Gives some compatibility with vcs
VFLAGS += --pins-bv 2 -Wno-fatal
VFLAGS += --output-split-cfuncs 500
VERILATED_O=verilated.o

VFLAGS+=--sc --Mdir $(VOBJ_DIR)
VFLAGS += -Wno-fatal
VFLAGS += --sc --Mdir $(VOBJ_DIR)
VFLAGS += -CFLAGS "-DHAVE_VERILOG" -CFLAGS "-DHAVE_VERILOG_VERILATOR"
VFLAGS += -y $(VFILES_DIR)
VFLAGS += --pins-bv 31
VFLAGS += --top-module mkBsvTop

CPPFLAGS += -DHAVE_VERILOG
CPPFLAGS += -DHAVE_VERILOG_VERILATOR
CPPFLAGS += -I $(VOBJ_DIR)
CPPFLAGS += -I $(VERILATOR_ROOT)/include

ifeq "$(VM_TRACE)" "1"
VFLAGS += --trace
SC_OBJS += verilated_vcd_c.o
SC_OBJS += verilated_vcd_sc.o
CPPFLAGS += -DVM_TRACE=1
endif
endif

ifeq "$(HAVE_VERILOG_VCS)" "y"
VCS=vcs
SYSCAN=syscan
VLOGAN=vlogan
VHDLAN=vhdlan

CSRC_DIR = csrc

VLOGAN_FLAGS += -sysc
VLOGAN_FLAGS += +v2k -sc_model apb_slave_timer

VHDLAN_FLAGS += -sysc
VHDLAN_FLAGS += -sc_model apb_slave_dummy

SYSCAN_ZYNQ_DEMO = zynq_demo.cc
SYSCAN_ZYNQMP_DEMO = zynqmp_demo.cc
SYSCAN_ZYNQMP_LMAC2_DEMO = zynqmp_lmac2_demo.cc
SYSCAN_SCFILES += demo-dma.cc debugdev.cc remote-port-tlm.cc
VCS_CFILES += remote-port-proto.c remote-port-sk.c safeio.c

SYSCAN_FLAGS += -tlm2 -sysc=opt_if
SYSCAN_FLAGS += -cflags -DHAVE_VERILOG -cflags -DHAVE_VERILOG_VCS
VCS_FLAGS += -sysc sc_main -sysc=adjust_timeres
VFLAGS += -CFLAGS "-DHAVE_VERILOG" -CFLAGS "-DHAVE_VERILOG_VERILATOR"
endif

OBJS = $(C_OBJS) $(SC_OBJS)

VERSAL_CPM4_QDMA_DEMO_OBJS += $(OBJS)
VERSAL_CPM5_QDMA_DEMO_OBJS += $(OBJS)
PCIE_XDMA_DEMO_OBJS += $(OBJS)

TARGET_VERSAL_CPM4_QDMA_DEMO = pcie/versal/cpm4-qdma-demo
TARGET_VERSAL_CPM5_QDMA_DEMO = pcie/versal/cpm5-qdma-demo
TARGET_PCIE_XDMA_DEMO = pcie/versal/xdma-demo

PCIE_MODEL_DIR=pcie-model/tlm-modules
ifneq ($(wildcard $(PCIE_MODEL_DIR)/.),)
TARGETS += $(TARGET_VERSAL_CPM4_QDMA_DEMO)
TARGETS += $(TARGET_VERSAL_CPM5_QDMA_DEMO)
endif

TARGETS += $(TARGET_PCIE_XDMA_DEMO)

all: $(TARGETS)

-include $(VERSAL_CPM4_QDMA_DEMO_OBJS:.o=.d)
-include $(VERSAL_CPM5_QDMA_DEMO_OBJS:.o=.d)
-include $(PCIE_XDMA_DEMO_OBJS:.o=.d)
CFLAGS += -MMD
CXXFLAGS += -MMD

## libpcie ##
-include pcie-model/libpcie/libpcie.mk

$(VERSAL_CPM5_QDMA_DEMO_O): $(VERSAL_CPM_QDMA_DEMO_C)
$(CXX) $(CXXFLAGS) $(CPPFLAGS) -c -o $@ $<

$(TARGET_VERSAL_CPM5_QDMA_DEMO): CPPFLAGS += $(PCIE_MODEL_CPPFLAGS)
$(TARGET_VERSAL_CPM5_QDMA_DEMO): LDLIBS += libpcie.a
$(TARGET_VERSAL_CPM5_QDMA_DEMO): $(VERSAL_CPM5_QDMA_DEMO_OBJS) libpcie.a
$(CXX) $(LDFLAGS) -o $@ $(VERSAL_CPM5_QDMA_DEMO_OBJS) $(LDLIBS)

$(VERSAL_CPM4_QDMA_DEMO_O): $(VERSAL_CPM_QDMA_DEMO_C)
$(CXX) $(CXXFLAGS) $(CPPFLAGS) -DQDMA_CPM4_VERSION -c -o $@ $<

$(TARGET_VERSAL_CPM4_QDMA_DEMO): CPPFLAGS += $(PCIE_MODEL_CPPFLAGS)
$(TARGET_VERSAL_CPM4_QDMA_DEMO): LDLIBS += libpcie.a
$(TARGET_VERSAL_CPM4_QDMA_DEMO): $(VERSAL_CPM4_QDMA_DEMO_OBJS) libpcie.a
$(CXX) $(LDFLAGS) -o $@ $(VERSAL_CPM4_QDMA_DEMO_OBJS) $(LDLIBS)

$(VERILATED_O) : $(VFILES_DIR)
$(VENV) $(VERILATOR) $(VFLAGS) $(VFILES)
$(MAKE) -C $(VOBJ_DIR) -f VmkBsvTop.mk
$(MAKE) -C $(VOBJ_DIR) -f VmkBsvTop.mk $(VERILATED_O)

$(TARGET_PCIE_XDMA_DEMO): CPPFLAGS += $(PCIE_MODEL_CPPFLAGS)
$(TARGET_PCIE_XDMA_DEMO): LDLIBS += libpcie.a
$(TARGET_PCIE_XDMA_DEMO): $(VERILATED_O) $(PCIE_XDMA_DEMO_OBJS) libpcie.a
$(CXX) $(LDFLAGS) -o $@ $(PCIE_XDMA_DEMO_OBJS) $(LDLIBS) $(VOBJ_DIR)/$(VERILATED_O)

verilated_%.o: $(VERILATOR_ROOT)/include/verilated_%.cpp

clean:
Expand All @@ -225,3 +192,5 @@ clean:
$(RM) $(TARGET_VERSAL_CPM4_QDMA_DEMO) $(VERSAL_CPM4_QDMA_DEMO_OBJS)
$(RM) $(VERSAL_CPM4_QDMA_DEMO_OBJS:.o=.d)
$(RM) -r libpcie libpcie.a
$(RM) $(TARGET_PCIE_XDMA_DEMO) $(PCIE_XDMA_DEMO_OBJS)
$(RM) -r $(VOBJ_DIR)
Loading