From 2107a328c4d1fe406791dc4c53ea49e246f0ef6c Mon Sep 17 00:00:00 2001 From: Clifford Wolf Date: Sat, 6 Jun 2015 21:27:07 +0200 Subject: Added insn timing hack to dryhstone testbench --- dhrystone/testbench.v | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) (limited to 'dhrystone') diff --git a/dhrystone/testbench.v b/dhrystone/testbench.v index 216cc87..c14779e 100644 --- a/dhrystone/testbench.v +++ b/dhrystone/testbench.v @@ -43,12 +43,14 @@ module testbench; assign mem_ready = 1; always @(posedge clk) begin - mem_rdata <= memory[mem_la_addr >> 2]; + mem_rdata <= mem_la_read ? memory[mem_la_addr >> 2] : 'bx; if (mem_valid) begin case (mem_addr) 32'h1000_0000: begin +`ifndef INSN_TIMING $write("%c", mem_wdata); $fflush(); +`endif end default: begin if (mem_wstrb[0]) memory[mem_addr >> 2][ 7: 0] <= mem_wdata[ 7: 0]; @@ -72,4 +74,16 @@ module testbench; $finish; end end + +`ifdef INSN_TIMING + initial begin + repeat (100000) @(posedge clk); + $finish; + end + always @(uut.count_instr[0]) begin + // iverilog -DINSN_TIMING testbench.v ../picorv32.v && ./a.out > x + // sed 's,.*## ,,' x | gawk 'x != "" {print x,$2-y;} {x=$1;y=$2;}' | sort | uniq -c | sort -k3 -n + $display("## %-s %d", uut.instruction, uut.count_cycle); + end +`endif endmodule -- cgit