Skip to content

Commit

Permalink
ADD: golden reference trace for debugging
Browse files Browse the repository at this point in the history
  • Loading branch information
iansseijelly committed Oct 2, 2024
1 parent 200dee9 commit 369dd65
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
5 changes: 4 additions & 1 deletion riscv/trace_encoder_n.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

trace_encoder_n::trace_encoder_n() {
this->trace_sink= fopen("trace_n.bin", "wb");
this->debug_reference = fopen("trace_n_ref_debug.log", "wb");
this->active = true;
this->enabled = false;
this->src = 0;
Expand All @@ -28,6 +29,7 @@ void trace_encoder_n::trace_encoder_push_commit(hart_to_encoder_ingress_t* packe
this->packet_0 = packet;
printf("[trace_encoder_n] new packet tcode: %lx\n", this->packet_0->i_type);
if (this->enabled) {
fprintf(this->debug_reference, "%lx\n", packet->i_addr);
if (this->state == TRACE_ENCODER_N_IDLE) {
trace_encoder_generate_packet(TCODE_PROG_TRACE_SYNC);
this->state = TRACE_ENCODER_N_DATA;
Expand Down Expand Up @@ -116,7 +118,8 @@ void trace_encoder_n::_set_indirect_branch_packet(trace_encoder_n_packet_t* pack
packet->tcode = TCODE_IBR;
packet->src = this->src;
packet->b_type = B_INDIRECT;
packet->icnt = this->icnt - this->packet_0->ilastsize; //
printf("[trace_encoder_n] _set_indirect_branch_packet: this->icnt: %lx, this->packet_0->ilastsize: %lx\n", this->icnt, this->packet_0->ilastsize);
packet->icnt = this->icnt - this->packet_0->ilastsize;
uint64_t e_addr = this->packet_0->i_addr >> 1;
packet->u_addr = e_addr ^ this->prev_addr;
this->prev_addr = e_addr;
Expand Down
1 change: 1 addition & 0 deletions riscv/trace_encoder_n.h
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ class trace_encoder_n {
void set_enable(bool enabled);
private:
FILE* trace_sink;
FILE* debug_reference;

bool updesc;

Expand Down

0 comments on commit 369dd65

Please sign in to comment.