OSDN Git Service

Index: component/ChangeLog
[pf3gnuchains/pf3gnuchains3x.git] / sid / component / testsuite / sidcomp.cache / lru.exp
1 # lru.exp -*- Tcl -*-
2 # Basic testing for the LRU replacement policy.
3 #
4 # Copyright (C) 2001 Red Hat, Inc.
5
6 source $srcdir/$subdir/utils.exp
7
8 set test "sid startup"
9 sid_config_component_test_with_tracing "cache.conf" \
10         "load [sid_find_file libcache.la] cache_component_library" \
11         "hw-cache-4way/16kb/32/lru"
12 if {[sid_start "cache.conf"]} { pass $test } else { fail $test; return }
13
14 set test "acquire upstream bus handle"
15 set cache_bus [sid_cmd "sid::component::find_bus $victim upstream"]
16 if {$cache_bus != ""} { pass $test } else { fail $test }
17
18 set test "generate test bus for downstream"
19 set mem_bus [sid_cmd "sid::bus::new"]
20 if {$mem_bus == ""} { fail $test } else { pass $test }
21
22 set test "connect test bus to cache"
23 set result [sid_cmd "sid::component::connect_accessor $victim downstream $mem_bus"]
24 if {$result == "ok"} { pass $test } else { fail $test }
25
26 instrument_bus $mem_bus
27
28 foreach addr {0x100 0x4100 0x8100 0xc100} {
29     set test "read byte from $addr"
30     clear_miss_flag
31     set result [sid_cmd "sid::bus::read_h4_l1 $cache_bus $addr"]
32     assert_miss
33 }
34
35 # These should still hit, since there are four lines per set.
36 foreach addr {0x100 0x4100 0x8100 0xc100} {
37     set test "read byte again from $addr"
38     clear_miss_flag
39     set result [sid_cmd "sid::bus::read_h4_l1 $cache_bus $addr"]
40     assert_hit
41 }
42
43 # Out of lines in the set!
44 set test "read byte from 0x10100"
45 clear_miss_flag
46 set result [sid_cmd "sid::bus::read_h4_l1 $cache_bus 0x10100"]
47 assert_miss
48
49 # This line should still be present, since it was used recently.
50 set test "read byte from 0x8100"
51 clear_miss_flag
52 set result [sid_cmd "sid::bus::read_h4_l1 $cache_bus 0x8100"]
53 assert_hit