-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbenchmarks.tcl
65 lines (52 loc) · 2.4 KB
/
benchmarks.tcl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
# This script runs all the benchmarks in the test-programs directory and checks that the outputs
# of the processor are the same as the expected outputs given for each benchmark.
# This scripts requires the diff program to be on the system path.
vlib work
# Compile components
vcom mips_instruction_set.vhd
vcom cache/cache_controller.vhd
vcom cache/cache_block.vhd
vcom cache/cache.vhd
vcom cache/memory.vhd
vcom cache/arbiter.vhd
vcom branch_prediction/bp_predict_not_taken.vhd
vcom branch_prediction/bp_predict_taken.vhd
vcom branch_prediction/bp_1bit_predictor.vhd
vcom branch_prediction/bp_2bit_predictor.vhd
vcom branch_prediction/bp_correlating_2_2.vhd
vcom branch_prediction/bp_tournament_2_2.vhd
vcom branch_prediction/branch_prediction.vhd
vcom registers.vhd
vcom alu/alu.vhd
vcom hazards/hazard_detector.vhd
vcom processor.vhd
vcom testbench.vhd
# Get the program names
set programs [dir /b /o:n /ad test-programs]
set programs [regexp -all -inline {\S+} $programs]
# Start simulation
vsim -t ps testbench
# Generate a clock with 1 ns period
force -deposit clock 0 0 ns, 1 0.5 ns -repeat 1 ns
# Print performance counter header
echo Program,Instruction Count,I\$ Stall Count,D\$ Stall Count,Data Hazard Stall Count,Branch Hazard Stall Count
foreach program $programs {
# Set up the results directory
file mkdir results/$program
# Restart the simulation
restart -f
# Load program into main memory
mem load -infile test-programs/$program/program.txt -format bin -filldata 0 /testbench/dut/mem/ram_block
# Run
run 20us
# Save the memory and register file to files
mem save -outfile results/$program/memory.txt -format bin -wordsperline 1 -noaddress /testbench/dut/mem/ram_block
mem save -outfile results/$program/register_file.txt -format bin -wordsperline 1 -noaddress /testbench/dut/register_file/registers
# Print performance counters
echo $program,[examine -radix dec /testbench/dut/instruction_count],[examine -radix dec /testbench/dut/i_memory_access_stall_count],[examine -radix dec /testbench/dut/d_memory_access_stall_count],[examine -radix dec /testbench/dut/data_hazard_stall_count],[examine -radix dec /testbench/dut/branch_hazard_stall_count]
}
# Compare results
foreach program $programs {
echo [diff -ws results/$program/memory.txt test-programs/$program/memory.txt]
echo [diff -ws results/$program/register_file.txt test-programs/$program/register_file.txt]
}