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

Gen C++ and Verilog macros by GatewayConfig #251

Merged
merged 1 commit into from
Jan 17, 2024

Conversation

klin02
Copy link
Member

@klin02 klin02 commented Jan 15, 2024

Currently all macros in Gateway can be decided by GatewayConfig, we move macros inside Config for better comprehension.

Difftest-related macros in Verilog can be configured in generated DifftestMacros.v, which should be included by all files use those macros.

Some redundant passing of config and return val of collect is removed. Some macros are renamed for similar format.

@klin02 klin02 force-pushed the verilog-macro-config branch from 6e96fa9 to a9eb938 Compare January 15, 2024 16:34
poemonsense
poemonsense previously approved these changes Jan 16, 2024
def generateVeriogHeader(): Unit = {
val difftestVeriog = ListBuffer.empty[String]
vMacros.foreach(m => difftestVeriog += s"`define $m")
val outputDir = sys.env("NOOP_HOME") + "/build/rtl"
Copy link
Member

Choose a reason for hiding this comment

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

Generate files must be put in generated-src only to avoid confusions. build/rtl is only for chisel design files.

Copy link
Member

Choose a reason for hiding this comment

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

Make the output directory a function shared by generateVeriogHeader and generateCppHeader

Copy link
Member

Choose a reason for hiding this comment

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

Sure.

@@ -32,16 +32,38 @@ case class GatewayConfig(
replaySize : Int = 256,
diffStateSelect: Boolean = false,
isBatch : Boolean = false,
batchSize : Int = 32
batchSize : Int = 32,
isNonBlock : Boolean = false
Copy link
Member

Choose a reason for hiding this comment

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

Always add a , after the arguments. Then adding arguments will not modify the previous line. isNonBlock: Boolean = false,

}
def vMacros: Seq[String] = {
val macros = ListBuffer.empty[String]
macros += s"TB_DIFF_STEP_WIDTH ${stepWidth}"
Copy link
Member

Choose a reason for hiding this comment

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

why not also use the CONFIG_DIFFTEST_* names?

One of the good naming practice is to avoid abbreviations if acceptable.

@klin02 klin02 force-pushed the verilog-macro-config branch 3 times, most recently from bee2c4e to ed8bcfe Compare January 16, 2024 07:00
@poemonsense
Copy link
Member

CI fails because NutShell changes the RTL path. I'll fix it later

Makefile Outdated
@@ -64,7 +64,8 @@ PLUGIN_CSRC_DIR = $(abspath ./src/test/csrc/plugin)
PLUGIN_INC_DIR = $(abspath $(PLUGIN_CSRC_DIR)/include)
SIM_CXXFLAGS += -I$(PLUGIN_INC_DIR)

VSRC_DIR = $(abspath ./src/test/vsrc/common)
GEN_VSRC_DIR = $(BUILD_DIR)/generated-src
VSRC_DIR = $(abspath ./src/test/vsrc/common) $(GEN_VSRC_DIR)
Copy link
Member

Choose a reason for hiding this comment

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

No need to add $(GEN_VSRC_DIR) to VSRC_DIR?

VCS and verilator will search for the missing modules in include paths

Copy link
Member Author

Choose a reason for hiding this comment

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

Sure, I will delete it. Now I have trouble using cross-directory include on Palladium,and I am asking Palladium engineer for help.

Copy link
Member

Choose a reason for hiding this comment

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

what about passing all verilog files, including the generated ones, to palladium?

poemonsense
poemonsense previously approved these changes Jan 16, 2024
@klin02 klin02 marked this pull request as draft January 16, 2024 09:43
@klin02 klin02 force-pushed the verilog-macro-config branch from ed8bcfe to 88ae92e Compare January 17, 2024 03:19
Currently all macros in Gateway can be decided by GatewayConfig,
we move macros inside Config for better comprehension.

Difftest-related macros in Verilog can be configured in generated
DifftestMacros.v, which should be included by all files use those macros.

Some redundant passing of config and return val of collect is removed.
Some macros are renamed for similar format.

Makefile and mk are changed to include generated/DifftestMacros.v
@klin02 klin02 marked this pull request as ready for review January 17, 2024 03:22
@klin02 klin02 requested a review from poemonsense January 17, 2024 03:23
@poemonsense poemonsense changed the title Gen Cpp and Verilog Macros by GatewayConfig Gen C++ and Verilog macros by GatewayConfig Jan 17, 2024
@klin02 klin02 merged commit afabff2 into OpenXiangShan:master Jan 17, 2024
3 checks passed
xiaokamikami pushed a commit to xiaokamikami/difftest that referenced this pull request Jan 17, 2024
Currently all macros in Gateway can be decided by GatewayConfig,
we move macros inside Config for better comprehension.

Difftest-related macros in Verilog can be configured in generated
DifftestMacros.v, which should be included by all files use those macros.

Some redundant passing of config and return val of collect is removed.
Some macros are renamed for similar format.

Makefile and mk are changed to include generated/DifftestMacros.v
pxk27 pushed a commit to pxk27/difftest that referenced this pull request Jan 30, 2024
Currently all macros in Gateway can be decided by GatewayConfig,
we move macros inside Config for better comprehension.

Difftest-related macros in Verilog can be configured in generated
DifftestMacros.v, which should be included by all files use those macros.

Some redundant passing of config and return val of collect is removed.
Some macros are renamed for similar format.

Makefile and mk are changed to include generated/DifftestMacros.v
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants