Skip to content

Commit

Permalink
vcs: warmup is implemented using the return value of simv_nstp
Browse files Browse the repository at this point in the history
  • Loading branch information
xiaokamikami committed Feb 24, 2025
1 parent e710bf0 commit f9ac7b6
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 35 deletions.
19 changes: 2 additions & 17 deletions src/test/csrc/vcs/vcs_main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@ static uint64_t max_instrs = 0;
static char *workload_list = NULL;
static uint32_t overwrite_nbytes = 0xe00;
static uint64_t warmup_instr = 0;
static svScope difftest_endpoint_scope;
struct core_end_info_t {
bool core_trap[NUM_CORES];
double core_cpi[NUM_CORES];
Expand All @@ -55,6 +54,7 @@ enum {
SIMV_RUN,
SIMV_DONE,
SIMV_FAIL,
SIMV_WARMUP,
} simv_state;

extern "C" void set_bin_file(char *s) {
Expand Down Expand Up @@ -100,10 +100,6 @@ extern "C" void set_max_instrs(uint64_t mc) {
max_instrs = mc;
}

extern "C" void set_difftest_endpoint_scope() {
difftest_endpoint_scope = svGetScope();
}

extern "C" uint64_t get_stuck_limit() {
#ifdef CONFIG_NO_DIFFTEST
return 0;
Expand Down Expand Up @@ -171,17 +167,6 @@ extern "C" void set_simjtag() {
enable_simjtag = true;
}

extern "C" void set_perfCtrl_clean();

void difftest_perfCtrl_clean() {
if (difftest_endpoint_scope == NULL) {
printf("Error: Could not retrieve DifftestEndpoint scope, set first\n");
assert(difftest_endpoint_scope);
}
svSetScope(difftest_endpoint_scope);
set_perfCtrl_clean();
}

extern "C" uint8_t simv_init() {
if (workload_list != NULL) {
if (switch_workload())
Expand Down Expand Up @@ -263,9 +248,9 @@ extern "C" uint8_t simv_step() {
for (int i = 0; i < NUM_CORES; i++) {
auto trap = difftest[i]->get_trap_event();
if (warmup_instr != 0 && trap->instrCnt > warmup_instr) {
difftest_perfCtrl_clean();
warmup_instr = 0;
Info("Warmup finished. The performance counters will be reset.\n");
return SIMV_WARMUP;
}

if (max_instrs != 0) { // 0 for no limit
Expand Down
21 changes: 3 additions & 18 deletions src/test/vsrc/vcs/DifftestEndpoint.sv
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@ 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" function void set_warmup_instr(longint instrs);
import "DPI-C" context function void set_difftest_endpoint_scope();
`ifdef WITH_DRAMSIM3
import "DPI-C" function void simv_tick();
`endif // WITH_DRAMSIM3
Expand All @@ -69,9 +68,11 @@ import "DPI-C" function void set_iotrace_name(string name);

`define SIMV_DONE 8'h1
`define SIMV_FAIL 8'h2
`define SIMV_WARMUP 8'h3

reg [63:0] difftest_logCtrl_begin_r;
reg [63:0] difftest_logCtrl_end_r;
reg difftest_perfCtrl_clean_r;

string bin_file;
string flash_bin_file;
Expand Down Expand Up @@ -103,7 +104,6 @@ initial begin
end
stuck_limit = 0;
`ifndef TB_NO_DPIC
set_difftest_endpoint_scope();
stuck_limit = get_stuck_limit();
// workload: bin file
if ($test$plusargs("workload")) begin
Expand Down Expand Up @@ -362,25 +362,10 @@ end
/*
* perf/log ctrl
*/
reg difftest_perfCtrl_clean_r;
assign difftest_logCtrl_begin = difftest_logCtrl_begin_r;
assign difftest_logCtrl_end = difftest_logCtrl_end_r;
assign difftest_logCtrl_level = 0;
assign difftest_perfCtrl_clean = difftest_perfCtrl_clean_r;

export "DPI-C" task set_perfCtrl_clean;
task set_perfCtrl_clean();
difftest_perfCtrl_clean_r <= 1'b1;
endtask

always @(posedge clock) begin
if (reset) begin
difftest_perfCtrl_clean_r <= 1'b0;
end
else if (difftest_perfCtrl_clean_r) begin
difftest_perfCtrl_clean_r <= 1'b0;
end
end
assign difftest_perfCtrl_clean = (simv_result == `SIMV_WARMUP);

`ifndef TB_NO_DPIC
assign difftest_perfCtrl_dump = simv_result != 0;
Expand Down

0 comments on commit f9ac7b6

Please sign in to comment.