parent
9943d02600
commit
e3667e0ddd
|
@ -89,7 +89,7 @@ module idu_exu(
|
||||||
gen_en_dff #(32) inst_ff(clk, rst_n, en, i_inst, inst);
|
gen_en_dff #(32) inst_ff(clk, rst_n, en, i_inst, inst);
|
||||||
assign inst_o = inst;
|
assign inst_o = inst;
|
||||||
|
|
||||||
wire i_inst_valid = flush_i? 1'b0: inst_valid_i;
|
wire i_inst_valid = flush_i? 1'b0: stall_i[`STALL_EX]? 1'b1: inst_valid_i;
|
||||||
wire inst_valid;
|
wire inst_valid;
|
||||||
gen_en_dff #(1) inst_valid_ff(clk, rst_n, 1'b1, i_inst_valid, inst_valid);
|
gen_en_dff #(1) inst_valid_ff(clk, rst_n, 1'b1, i_inst_valid, inst_valid);
|
||||||
assign inst_valid_o = inst_valid;
|
assign inst_valid_o = inst_valid;
|
||||||
|
|
|
@ -46,7 +46,7 @@ module ifu_idu(
|
||||||
gen_en_dff #(32) inst_addr_ff(clk, rst_n, en, i_inst_addr, inst_addr);
|
gen_en_dff #(32) inst_addr_ff(clk, rst_n, en, i_inst_addr, inst_addr);
|
||||||
assign inst_addr_o = inst_addr;
|
assign inst_addr_o = inst_addr;
|
||||||
|
|
||||||
wire i_inst_valid = flush_i? 1'b0: inst_valid_i;
|
wire i_inst_valid = flush_i? 1'b0: stall_i[`STALL_ID]? 1'b1: inst_valid_i;
|
||||||
wire inst_valid;
|
wire inst_valid;
|
||||||
gen_en_dff #(1) inst_valid_ff(clk, rst_n, 1'b1, i_inst_valid, inst_valid);
|
gen_en_dff #(1) inst_valid_ff(clk, rst_n, 1'b1, i_inst_valid, inst_valid);
|
||||||
assign inst_valid_o = inst_valid;
|
assign inst_valid_o = inst_valid;
|
||||||
|
|
|
@ -365,16 +365,16 @@ module tracer(
|
||||||
|
|
||||||
|
|
||||||
function automatic void decode_u_insn(input string mnemonic);
|
function automatic void decode_u_insn(input string mnemonic);
|
||||||
decoded_str = $sformatf("%s\tx%0d,0x%0x", mnemonic, rd_addr, {inst_i[31:12]});
|
decoded_str = $sformatf("%s x%0d,0x%0x", mnemonic, rd_addr, {inst_i[31:12]});
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
function automatic void decode_j_insn(input string mnemonic);
|
function automatic void decode_j_insn(input string mnemonic);
|
||||||
decoded_str = $sformatf("%s\tx%0d,%0x", mnemonic, rd_addr,
|
decoded_str = $sformatf("%s x%0d,%0x", mnemonic, rd_addr,
|
||||||
{{12{inst_i[31]}}, inst_i[19:12], inst_i[20], inst_i[30:21], 1'b0});
|
{{12{inst_i[31]}}, inst_i[19:12], inst_i[20], inst_i[30:21], 1'b0});
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
function automatic void decode_i_jalr_insn(input string mnemonic);
|
function automatic void decode_i_jalr_insn(input string mnemonic);
|
||||||
decoded_str = $sformatf("%s\tx%0d,%0d(x%0d)", mnemonic, rd_addr,
|
decoded_str = $sformatf("%s x%0d,%0d(x%0d)", mnemonic, rd_addr,
|
||||||
$signed({{20 {inst_i[31]}}, inst_i[31:20]}), rs1_addr);
|
$signed({{20 {inst_i[31]}}, inst_i[31:20]}), rs1_addr);
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
|
@ -387,11 +387,11 @@ module tracer(
|
||||||
inst_i[30:25], inst_i[11:8], 1'b0 });
|
inst_i[30:25], inst_i[11:8], 1'b0 });
|
||||||
branch_target = pc_i + imm;
|
branch_target = pc_i + imm;
|
||||||
|
|
||||||
decoded_str = $sformatf("%s\tx%0d,x%0d,%0x", mnemonic, rs1_addr, rs2_addr, branch_target);
|
decoded_str = $sformatf("%s x%0d,x%0d,%0x", mnemonic, rs1_addr, rs2_addr, branch_target);
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
function automatic void decode_i_insn(input string mnemonic);
|
function automatic void decode_i_insn(input string mnemonic);
|
||||||
decoded_str = $sformatf("%s\tx%0d,x%0d,%0d", mnemonic, rd_addr, rs1_addr,
|
decoded_str = $sformatf("%s x%0d,x%0d,%0d", mnemonic, rd_addr, rs1_addr,
|
||||||
$signed({{20 {inst_i[31]}}, inst_i[31:20]}));
|
$signed({{20 {inst_i[31]}}, inst_i[31:20]}));
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
|
@ -399,11 +399,11 @@ module tracer(
|
||||||
logic [4:0] shamt;
|
logic [4:0] shamt;
|
||||||
|
|
||||||
shamt = {inst_i[24:20]};
|
shamt = {inst_i[24:20]};
|
||||||
decoded_str = $sformatf("%s\tx%0d,x%0d,0x%0x", mnemonic, rd_addr, rs1_addr, shamt);
|
decoded_str = $sformatf("%s x%0d,x%0d,0x%0x", mnemonic, rd_addr, rs1_addr, shamt);
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
function automatic void decode_r_insn(input string mnemonic);
|
function automatic void decode_r_insn(input string mnemonic);
|
||||||
decoded_str = $sformatf("%s\tx%0d,x%0d,x%0d", mnemonic, rd_addr, rs1_addr, rs2_addr);
|
decoded_str = $sformatf("%s x%0d,x%0d,x%0d", mnemonic, rd_addr, rs1_addr, rs2_addr);
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
function automatic void decode_csr_insn(input string mnemonic);
|
function automatic void decode_csr_insn(input string mnemonic);
|
||||||
|
@ -414,9 +414,9 @@ module tracer(
|
||||||
csr_name = get_csr_name(csr);
|
csr_name = get_csr_name(csr);
|
||||||
|
|
||||||
if (!inst_i[14]) begin
|
if (!inst_i[14]) begin
|
||||||
decoded_str = $sformatf("%s\tx%0d,%s,x%0d", mnemonic, rd_addr, csr_name, rs1_addr);
|
decoded_str = $sformatf("%s x%0d,%s,x%0d", mnemonic, rd_addr, csr_name, rs1_addr);
|
||||||
end else begin
|
end else begin
|
||||||
decoded_str = $sformatf("%s\tx%0d,%s,%0d", mnemonic, rd_addr, csr_name, { 27'b0, inst_i[19:15]});
|
decoded_str = $sformatf("%s x%0d,%s,%0d", mnemonic, rd_addr, csr_name, { 27'b0, inst_i[19:15]});
|
||||||
end
|
end
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
|
@ -444,7 +444,7 @@ module tracer(
|
||||||
return;
|
return;
|
||||||
end
|
end
|
||||||
|
|
||||||
decoded_str = $sformatf("%s\tx%0d,%0d(x%0d)", mnemonic, rd_addr,
|
decoded_str = $sformatf("%s x%0d,%0d(x%0d)", mnemonic, rd_addr,
|
||||||
$signed({{20 {inst_i[31]}}, inst_i[31:20]}), rs1_addr);
|
$signed({{20 {inst_i[31]}}, inst_i[31:20]}), rs1_addr);
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
|
@ -463,7 +463,7 @@ module tracer(
|
||||||
end
|
end
|
||||||
|
|
||||||
if (!inst_i[14]) begin
|
if (!inst_i[14]) begin
|
||||||
decoded_str = $sformatf("%s\tx%0d,%0d(x%0d)", mnemonic, rs2_addr,
|
decoded_str = $sformatf("%s x%0d,%0d(x%0d)", mnemonic, rs2_addr,
|
||||||
$signed({ {20 {inst_i[31]}}, inst_i[31:25], inst_i[11:7] }), rs1_addr);
|
$signed({ {20 {inst_i[31]}}, inst_i[31:25], inst_i[11:7] }), rs1_addr);
|
||||||
end else begin
|
end else begin
|
||||||
decode_mnemonic("INVALID");
|
decode_mnemonic("INVALID");
|
||||||
|
@ -494,7 +494,7 @@ module tracer(
|
||||||
|
|
||||||
predecessor = get_fence_description(inst_i[27:24]);
|
predecessor = get_fence_description(inst_i[27:24]);
|
||||||
successor = get_fence_description(inst_i[23:20]);
|
successor = get_fence_description(inst_i[23:20]);
|
||||||
decoded_str = $sformatf("fence\t%s,%s", predecessor, successor);
|
decoded_str = $sformatf("fence %s,%s", predecessor, successor);
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
|
|
||||||
|
@ -516,11 +516,7 @@ module tracer(
|
||||||
// OPIMM
|
// OPIMM
|
||||||
INSN_ADDI: begin
|
INSN_ADDI: begin
|
||||||
if (inst_i == 32'h00_00_00_13) begin
|
if (inst_i == 32'h00_00_00_13) begin
|
||||||
// TODO: objdump doesn't decode this as nop currently, even though it would be helpful
|
decode_mnemonic("nop");
|
||||||
// Decide what to do here: diverge from objdump, or make the trace less readable to
|
|
||||||
// users.
|
|
||||||
//decode_mnemonic("nop");
|
|
||||||
decode_i_insn("addi");
|
|
||||||
end else begin
|
end else begin
|
||||||
decode_i_insn("addi");
|
decode_i_insn("addi");
|
||||||
end
|
end
|
||||||
|
@ -584,14 +580,14 @@ module tracer(
|
||||||
|
|
||||||
$display("Writing execution trace to %s", file_name);
|
$display("Writing execution trace to %s", file_name);
|
||||||
file_handle = $fopen(file_name, "w");
|
file_handle = $fopen(file_name, "w");
|
||||||
$fwrite(file_handle, "\t\t\tTime\tCycle\tPC\tInsn\tDecoded instruction\n");
|
$fwrite(file_handle, "\t\t\tTime\t\tCycle\tPC\t\t\tInsn\t\tDecoded instruction\n");
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
function automatic void printbuffer_dumpline();
|
function automatic void printbuffer_dumpline();
|
||||||
string insn_str = $sformatf("%h", inst_i);
|
string insn_str = $sformatf("%h", inst_i);
|
||||||
|
|
||||||
$fwrite(file_handle, "%15t\t%d\t%h\t%s\t%s", $time, cycle, pc_i, insn_str, decoded_str);
|
$fwrite(file_handle, "%15t\t%d\t\t%h\t%s\t%s", $time, cycle, pc_i, insn_str, decoded_str);
|
||||||
$fwrite(file_handle, "\n");
|
$fwrite(file_handle, "\n");
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue