When running the following script
BEGIN: {
// import python file for access to riscvmodel lib
import(extern);
icnt=0;
lastclkcnt=0;
clkcnt=0;
printed=0;
ilen = 0;
// create some aliases for shorter signal names
alias(clk, tb.adapter.core.TGC_C.clk);
alias(reset, tb.adapter.core.TGC_C.reset);
alias(trap, tb.adapter.core.TGC_C.core_trace_exc_o);
alias(valid, tb.adapter.core.TGC_C.core_trace_valid_o);
alias(instr, tb.adapter.core.TGC_C.core_trace_instr_o);
alias(pc, tb.adapter.core.TGC_C.core_trace_pc_o);
alias(reg_addr, tb.adapter.core.TGC_C.core_trace_reg_addr_o);
alias(reg_val, tb.adapter.core.TGC_C.core_trace_reg_val_o);
alias(reg_wr, tb.adapter.core.TGC_C.core_trace_reg_wr_o);
}
clk, valid: {
if(printed==0) {
icnt=icnt+1;
delay=(clkcnt-lastclkcnt)/2;
lastclkcnt=clkcnt;
op = call(extern.decode, instr);
shifted = instr/128;
was_call = shifted[4:0]!=0 && (op == "jal" || op == "jalr");
ilen = 2;
if (instr[1:0]==3)
ilen = 4;
printf("0x%x, %d, %d, %d, 0x%x, %s\n", pc, delay, ilen, was_call, instr, op);
printed = 1;
} else
printed = 0;
}
clk, !reset: {
clkcnt=clkcnt+1;
}
END: {
printf("%f (%d/%d)\n", icnt/clkcnt, icnt, clkcnt);
}
on a vcd file I get in 2 consecutive runs
(.wal) eyck$:~/tmp/wal$ wawk cpi.wawk ../vtgc_tb_xlevel.vcd
0x20, 3, 4, 1, 0x297, auipc
0x24, 1, 4, 1, 0xc028293, addi
0x28, 1, 4, 0, 0x30529073, csrrw
0x2c, 1, 4, 1, 0x2a00093, addi
0x30, 1, 4, 1, 0x2a00113, addi
0x34, 1, 4, 1, 0x2a00193, addi
0x38, 1, 4, 1, 0x200513, addi
0x3a, 1, 4, 1, 0x300a13, addi
0x3e, 1, 4, 1, 0x700f93, addi
0x40, 1, 4, 0, 0x43507b, 4411515
0.000000 (10/28)
(.wal) eyck$:~/tmp/wal$ wawk cpi.wawk ../vtgc_tb_xlevel.vcd
0x20, 3, 4, 0, 0x297, auipc
0x24, 1, 4, 0, 0xc028293, addi
0x28, 1, 4, 0, 0x30529073, csrrw
0x2c, 1, 4, 0, 0x2a00093, addi
0x30, 1, 4, 0, 0x2a00113, addi
0x34, 1, 4, 0, 0x2a00193, addi
0x38, 1, 4, 0, 0x200513, addi
0x3a, 1, 4, 0, 0x300a13, addi
0x3e, 1, 4, 0, 0x700f93, addi
0x40, 1, 4, 0, 0x43507b, 4411515
0.000000 (10/28)
bug