Well i’m trying to make a program for newbie practice and, in the while
loop at the bottom, i am not allowed to put in any information when i
run it. Can anyone help me out? Thanks
[src]
#!/usr/bin/ruby
sim_outorder_path = “/home/software/simplescalar/bin/sim-outorder”
puts “Welcome to the sim-outorder configuration utility.”
Put output name into script_name and remove the ‘\n’
puts “Enter script output name.”
script_name = gets
script_name.chomp
simplesim holds the names of and default values of the parameters
default_options =
{
"fastfwd" => "300000",
"max:inst" => "2000000",
“config” => nil,
“dumpconfig” => nil,
“h” => “true”,
“v” => “false”,
“d” => “false”,
“i” => “false”,
“seed” => “1”,
“q” => “false”,
“chkpt” => nil,
"fetch:ifqsize" => "4",
"fetch:mplat" => "3",
"fetch:speed" => "1",
“bpred” => “bimod”,
“bpred:bimod” => “2048”,
“bpred:2lev” => “1 1024 8 0”,
“bpred:comb” => “1024”,
“bpred:ras” => “8”,
"bpred:btb" => "512 4",
“bpred:spec_update” => nil,
"lsq:size" => "8",
"cache:dl1" => "dl1:128:32:4:l",
"cache:dl1lat" => "1",
"cache:dl2" => "ul2:1024:64:4:l",
"cache:dl2lat" => "6",
"cache:il1" => "il1:512:32:1:l",
"cache:il1lat" => "1",
"cache:il2" => "dl2",
"cache:il2lat" => "6",
“cache:flush” => “false”,
“cache:icompress” => “false”,
"mem:lat" => "18 2",
"mem:width" => "8",
“tlb:itlb” => “itlb:16:4096:4:l”,
“tlb:dtlb” => “dtlb:32:4096:4:l”,
"tlb:lat" => "30",
"res:ialu" => "4",
"res:imult" => "1",
"res:memport" => "2",
"res:fpalu" => "4",
"res:fpmult" => "1"
}
Initialize user_options
user_options = “”
Print the defaults and ask for changes
default_options.each_key do |key|
Show the option_name and the default value
puts key.to_s + "\tDefault = " + default_options[key].to_s
puts “Type ‘d’ to use default value”
Get the option_value or d
Set to " " to allow while loop to work
option_value = " "
While user input is nothing
while option_value == “”
option_value = gets.chomp.to_s
end
if option_value.to_s == “d”
# Use default value
user_options += “-” + key.to_s + " " + default_options[key].to_s + "
"
else
# Use given value
# user_options += “-” + key.to_s + " " + option_value + " "
end
end
[/src]