require "cfg.rb"
+RubySystem.reset
+
# default values
num_cores = 2
-L1_CACHE_SIZE_KB = 32
-L1_CACHE_ASSOC = 8
-L1_CACHE_LATENCY = 1
+l1_cache_size_kb = 32
+l1_cache_assoc = 8
+l1_cache_latency = 1
num_memories = 2
memory_size_mb = 1024
-NUM_DMA = 1
+num_dma = 1
protocol = "MI_example"
# check for overrides
require protocol+".rb"
num_cores.times { |n|
- cache = SetAssociativeCache.new("l1u_"+n.to_s, L1_CACHE_SIZE_KB, L1_CACHE_LATENCY, L1_CACHE_ASSOC, "PSEUDO_LRU")
+ cache = SetAssociativeCache.new("l1u_"+n.to_s, l1_cache_size_kb, l1_cache_latency, l1_cache_assoc, "PSEUDO_LRU")
sequencer = Sequencer.new("Sequencer_"+n.to_s, cache, cache)
iface_ports << sequencer
net_ports << MI_example_CacheController.new("L1CacheController_"+n.to_s,
"Directory",
directory, memory_control)
}
-NUM_DMA.times { |n|
+num_dma.times { |n|
dma_sequencer = DMASequencer.new("DMASequencer_"+n.to_s)
iface_ports << dma_sequencer
net_ports << MI_example_DMAController.new("DMAController_"+n.to_s, "DMA", dma_sequencer)
+require "util.rb"
+
class MI_example_CacheController < L1CacheController
attr :cache
def initialize(obj_name, mach_type, cache, sequencer)
def argv()
vec = super()
vec += " directory_latency "+directory_latency.to_s
+ vec += " dma_select_low_bit "+log_int(RubySystem.block_size_bytes).to_s
+ vec += " dma_select_num_bits "+log_int(NetPort.totalOfType("DMA")).to_s
end
end
require "cfg.rb"
-
-def log_int(n)
- assert(n.is_a?(Fixnum), "log_int takes a number for an argument")
- counter = 0
- while n >= 2 do
- counter += 1
- n = n >> 1
- end
- return counter
-end
+require "util.rb"
class MOESI_CMP_directory_L1CacheController < L1CacheController
require "cfg.rb"
+RubySystem.reset
+
# default values
num_cores = 2
-L1_ICACHE_SIZE_KB = 32
-L1_ICACHE_ASSOC = 8
-L1_ICACHE_LATENCY = 1
-L1_DCACHE_SIZE_KB = 32
-L1_DCACHE_ASSOC = 8
-L1_DCACHE_LATENCY = 1
-L2_CACHE_SIZE_KB = 2048 # total size (sum of all banks)
-L2_CACHE_ASSOC = 16
-L2_CACHE_LATENCY = 12
+l1_icache_size_kb = 32
+l1_icache_assoc = 8
+l1_icache_latency = 1
+l1_dcache_size_kb = 32
+l1_dcache_assoc = 8
+l1_dcache_latency = 1
+l2_cache_size_kb = 2048 # total size (sum of all banks)
+l2_cache_assoc = 16
+l2_cache_latency = 12
num_l2_banks = num_cores
num_memories = 1
memory_size_mb = 1024
-NUM_DMA = 1
+num_dma = 1
protocol = "MOESI_CMP_directory"
require protocol+".rb"
num_cores.times { |n|
- icache = SetAssociativeCache.new("l1i_"+n.to_s, L1_ICACHE_SIZE_KB, L1_ICACHE_LATENCY, L1_ICACHE_ASSOC, "PSEUDO_LRU")
- dcache = SetAssociativeCache.new("l1d_"+n.to_s, L1_DCACHE_SIZE_KB, L1_DCACHE_LATENCY, L1_DCACHE_ASSOC, "PSEUDO_LRU")
+ icache = SetAssociativeCache.new("l1i_"+n.to_s, l1_icache_size_kb, l1_icache_latency, l1_icache_assoc, "PSEUDO_LRU")
+ dcache = SetAssociativeCache.new("l1d_"+n.to_s, l1_dcache_size_kb, l1_dcache_latency, l1_dcache_assoc, "PSEUDO_LRU")
sequencer = Sequencer.new("Sequencer_"+n.to_s, icache, dcache)
iface_ports << sequencer
if protocol == "MOESI_CMP_directory"
end
}
num_l2_banks.times { |n|
- cache = SetAssociativeCache.new("l2u_"+n.to_s, L2_CACHE_SIZE_KB/num_l2_banks, L2_CACHE_LATENCY, L2_CACHE_ASSOC, "PSEUDO_LRU")
+ cache = SetAssociativeCache.new("l2u_"+n.to_s, l2_cache_size_kb/num_l2_banks, l2_cache_latency, l2_cache_assoc, "PSEUDO_LRU")
if protocol == "MOESI_CMP_directory"
net_ports << MOESI_CMP_directory_L2CacheController.new("L2CacheController_"+n.to_s,
"L2Cache",
memory_control)
end
}
-NUM_DMA.times { |n|
+num_dma.times { |n|
dma_sequencer = DMASequencer.new("DMASequencer_"+n.to_s)
iface_ports << dma_sequencer
if protocol == "MOESI_CMP_directory"
def cppClassName
"NetPort"
end
+ def self.totalOfType(mach_type)
+ return @@type_cnt[mach_type]
+ end
end
class MemoryVector < LibRubyObject
class RubySystem
@@params = Hash.new
+ @@defaults = Hash.new
@@network = nil
def self.init(iface_ports, network)
@@network = network
end
+ def self.reset()
+ @@iface_ports = nil
+ @@network = nil
+ @@params.each { |param_name, param|
+ param = @@defaults[param_name]
+ }
+ end
+
def self.default_param(param_name, type, default)
if default.is_a?(FalseClass) || default.is_a?(TrueClass)
assert type.is_a?(Boolean), "default value of param \"#{param_name}\" must be either true or false"
assert default.is_a?(type), "default value of param \"#{param_name}\" does not match type #{type}"
end
@@params[param_name] = default
+ @@defaults[param_name] = default
method_name = (param_name.to_s).to_sym
instance_eval <<-EOS
def #{method_name.to_s}
--- /dev/null
+
+def log_int(n)
+ assert(n.is_a?(Fixnum), "log_int takes a number for an argument")
+ counter = 0
+ while n >= 2 do
+ counter += 1
+ n = n >> 1
+ end
+ return counter
+end