-
Notifications
You must be signed in to change notification settings - Fork 68
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
vcs, palldium: support warmup, set difftest_perfCtrl_clean by DPI-C #506
Conversation
d7fde62
to
738ad3a
Compare
wait until passing perfclean to helper. And we will add ci test for this feature |
290db17
to
5671a64
Compare
Previous we use tapAndRead to hidden IO ports for read-only probe like some Difftest Bundle. However, chisel does not support hierarchical wiring for writable probe, so we must addSource first, which requires us to createTopIO before generating DUT. By the way, addSink/addSource will also be deprecated later, and latest Also, chisel's probe seems can only accessed top-to-bottom. For example, we can use SimTop.xx.yy.zz in SimTop, but can not use SimTop.aa in Module SimTop.xx.yy. That means even we addSource first and use tapAndRead, explicit IO port will be generated to pass timer and so on. In next step, seems we should still try isVisible to reduce number of LogPerfHelper |
Seems we can use Builder.currentModule and tap to get LogPerfelper instantiate in same parent Module. I'm trying but some helper instantiated in |
5671a64
to
6d33ca9
Compare
src/test/csrc/vcs/vcs_main.cpp
Outdated
@@ -44,6 +42,8 @@ static bool enable_difftest = true; | |||
static uint64_t max_instrs = 0; | |||
static char *workload_list = NULL; | |||
static uint32_t overwrite_nbytes = 0xe00; | |||
static uint64_t warmup_instrs = 0; | |||
static svScope wamupScope; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
warmup
instead of wamup
src/test/csrc/vcs/vcs_main.cpp
Outdated
@@ -57,6 +57,8 @@ enum { | |||
SIMV_FAIL, | |||
} simv_state; | |||
|
|||
extern "C" void claer_perfcnt(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
clear
instead of claer
src/test/csrc/vcs/vcs_main.cpp
Outdated
@@ -84,6 +86,17 @@ extern "C" void set_overwrite_autoset() { | |||
fclose(fp); | |||
} | |||
|
|||
// The workload warms up and clears the instruction counter | |||
extern "C" void set_warmup_insts(uint64_t warmup_inst, uint64_t cmn_inst) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why cmn_inst here? We only need to pass warmup from vcs_top, and set difftest_clean/dump by dpic
src/test/vsrc/vcs/DifftestEndpoint.v
Outdated
assign difftest_uart_in_ch = 8'hff; | ||
|
||
export "DPI-C" task claer_perfcnt; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
MissSpelling here too.
src/test/vsrc/vcs/DifftestEndpoint.v
Outdated
dpi_perfCtrl_clean <= 1'b1; | ||
endtask | ||
|
||
reg clear_perf_cnt; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe we can simplify logic here. Use RegNext(just example) as mask to ensure clean
raise only 1 cycle.
6d33ca9
to
9af8f51
Compare
src/test/csrc/vcs/vcs_main.cpp
Outdated
// The workload warms up and clears the instruction counter | ||
extern "C" void set_warmup_insts(uint64_t warmup_inst, uint64_t cmn_inst) { | ||
warmup_instrs = warmup_inst + cmn_inst; | ||
wamupScope = svGetScope(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
warmup
here.
src/test/csrc/vcs/vcs_main.cpp
Outdated
printf("Error: Could not retrieve wamup scope, set first\n"); | ||
assert(wamupScope); | ||
} | ||
printf("set warmp insts %ld, cmn insts %ld\n", warmup_inst, cmn_inst); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
warmup
here.
src/test/csrc/vcs/vcs_main.cpp
Outdated
@@ -57,6 +57,8 @@ enum { | |||
SIMV_FAIL, | |||
} simv_state; | |||
|
|||
extern "C" void clear_perfcnt(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also use set_[signalName] for consistent API style.
src/test/csrc/vcs/vcs_main.cpp
Outdated
auto trap = difftest[i]->get_trap_event(); | ||
if (warmup_instrs != 0 && trap->instrCnt > warmup_instrs) { | ||
svSetScope(wamupScope); | ||
clear_perfcnt(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wrap setScope and setSignal to same function. Don't expose Scope to avoid abuse.
src/test/vsrc/vcs/DifftestEndpoint.v
Outdated
@@ -50,6 +50,7 @@ import "DPI-C" function void set_max_instrs(longint mc); | |||
import "DPI-C" function longint get_stuck_limit(); | |||
import "DPI-C" function void set_overwrite_nbytes(longint len); | |||
import "DPI-C" function void set_overwrite_autoset(); | |||
import "DPI-C" context function void set_warmup_insts(longint workload_inst, longint cmn_inst); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems no need to add context
?
src/test/vsrc/vcs/DifftestEndpoint.v
Outdated
if ($test$plusargs("warmup-inst")) begin | ||
$value$plusargs("warmup-inst=%d", warmup_instrs); | ||
end | ||
if ($test$plusargs("cmn-instrs")) begin |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it's no need to pass cmn-instrs here.
Difftest should only process basic workload, no need to care CMN. Total warmup-insts should be calculated before passing to Difftest
src/test/vsrc/vcs/DifftestEndpoint.v
Outdated
@@ -170,12 +185,29 @@ initial begin | |||
end | |||
end | |||
|
|||
reg dpi_perfCtrl_clean; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use simply difftest_perfCtrl_clean_r for same coding style.
src/test/vsrc/vcs/DifftestEndpoint.v
Outdated
end else begin | ||
if (dpi_perfCtrl_clean) begin | ||
dpi_perfCtrl_clean <= 1'b0; | ||
$display("claer perfCnt"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe no need to add display
. Code here is just to set a singal, the effect has already printed by Software
0d42b8c
to
73db456
Compare
src/test/csrc/vcs/vcs_main.cpp
Outdated
@@ -84,6 +86,17 @@ extern "C" void set_overwrite_autoset() { | |||
fclose(fp); | |||
} | |||
|
|||
// The workload warms up and clears the instruction counter | |||
extern "C" void set_warmup_insts(uint64_t warmup_inst, uint64_t cmn_inst) { | |||
warmup_instrs = warmup_inst + cmn_inst; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it necessary to add CMN here? Difftest is a common verification framework cross mutli-platform, no need to add specific param here if we can add in another way, such as platform-specific scripts.
dpic_perfCtrl_clean = 1'b1; | ||
endtask | ||
|
||
always @(posedge clock) begin |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use difftest_perfCtrl_clean_r for same nameing style.
3288ad0
to
741dca1
Compare
src/test/csrc/vcs/vcs_main.cpp
Outdated
// The workload warms up and clears the instruction counter | ||
extern "C" void set_warmup_insts(uint64_t warmup_inst) { | ||
warmup_instrs = warmup_inst; | ||
wamupScope = svGetScope(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
MissSpelling here. warmup
instead of wamup
src/test/csrc/vcs/vcs_main.cpp
Outdated
extern "C" void set_warmup_insts(uint64_t warmup_inst) { | ||
warmup_instrs = warmup_inst; | ||
wamupScope = svGetScope(); | ||
if (wamupScope == NULL) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No need to check here, but need to check svSetSope.
src/test/csrc/vcs/vcs_main.cpp
Outdated
for (int i = 0; i < NUM_CORES; i++) { | ||
auto trap = difftest[i]->get_trap_event(); | ||
if (warmup_instrs != 0 && trap->instrCnt > warmup_instrs) { | ||
svSetScope(wamupScope); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wrap setScope and setSignal to same function. Don't expose Scope to avoid abuse.
Modified as review before. Like below
extern "C" void set_squash_enable(int enable);
void difftest_squash_enable(int enable) {
if (squashScope == NULL) {
printf("Error: Could not retrieve squash scope, set first\n");
assert(squashScope);
}
svSetScope(squashScope);
set_squash_enable(enable);
}
src/test/csrc/vcs/vcs_main.cpp
Outdated
@@ -44,6 +42,8 @@ static bool enable_difftest = true; | |||
static uint64_t max_instrs = 0; | |||
static char *workload_list = NULL; | |||
static uint32_t overwrite_nbytes = 0xe00; | |||
static uint64_t warmup_instrs = 0; | |||
static svScope wamupScope; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe we should seperate scope to warmup. We can add a context function set_difftest_endpoint_scope and rm context
from passing warmup_instrs. Later we may also use the scope to change top ports of Difftest like dump
clean
and so on.
Previous commit is made by @xiaokamikami. Author is append because of rebasing. |
No description provided.