ruby: added random seed option to config scripts
[gem5.git] / src / mem / ruby / config / MI_example-homogeneous.rb
1 #!/usr/bin/ruby
2 #
3 # Creates a homogeneous CMP system with a single unified cache per
4 # core and a crossbar network. Uses the default parameters listed
5 # below, which can be overridden if a wrapper script sets the hash
6 # libruby_args.
7 #
8
9 require "cfg.rb"
10
11 RubySystem.reset
12
13 # default values
14
15 num_cores = 2
16 l1_cache_size_kb = 32
17 l1_cache_assoc = 8
18 l1_cache_latency = 1
19 num_memories = 2
20 memory_size_mb = 1024
21 num_dma = 1
22 protocol = "MI_example"
23
24 # check for overrides
25
26
27 for i in 0..$*.size-1 do
28 if $*[i] == "-c"
29 protocol = $*[i+1]
30 i = i+1
31 elsif $*[i] == "-p"
32 num_cores = $*[i+1].to_i
33 i = i+1
34 elsif $*[i] == "-m"
35 num_memories = $*[i+1].to_i
36 i = i+1
37 elsif $*[i] == "-R"
38 if $*[i+1] == "rand"
39 RubySystem.random_seed = "rand"
40 else
41 RubySystem.random_seed = $*[i+1].to_i
42 end
43 i = i+ 1
44 elsif $*[i] == "-s"
45 memory_size_mb = $*[i+1].to_i
46 i = i + 1
47 end
48 end
49
50 net_ports = Array.new
51 iface_ports = Array.new
52
53 assert(protocol == "MI_example", __FILE__ + " cannot be used with protocol " + protocol)
54
55 require protocol+".rb"
56
57 num_cores.times { |n|
58 cache = SetAssociativeCache.new("l1u_"+n.to_s, l1_cache_size_kb, l1_cache_latency, l1_cache_assoc, "PSEUDO_LRU")
59 sequencer = Sequencer.new("Sequencer_"+n.to_s, cache, cache)
60 iface_ports << sequencer
61 net_ports << MI_example_CacheController.new("L1CacheController_"+n.to_s,
62 "L1Cache",
63 cache,
64 sequencer)
65 }
66 num_memories.times { |n|
67 directory = DirectoryMemory.new("DirectoryMemory_"+n.to_s, memory_size_mb/num_memories)
68 memory_control = MemoryControl.new("MemoryControl_"+n.to_s)
69 net_ports << MI_example_DirectoryController.new("DirectoryController_"+n.to_s,
70 "Directory",
71 directory, memory_control)
72 }
73 num_dma.times { |n|
74 dma_sequencer = DMASequencer.new("DMASequencer_"+n.to_s)
75 iface_ports << dma_sequencer
76 net_ports << MI_example_DMAController.new("DMAController_"+n.to_s, "DMA", dma_sequencer)
77 }
78
79 topology = CrossbarTopology.new("theTopology", net_ports)
80 on_chip_net = Network.new("theNetwork", topology)
81
82 RubySystem.init(iface_ports, on_chip_net)