text
stringlengths
0
234
else
exit Parse_Options;
end if;
exception
when others =>
Put_Line("error: invalid option value");
return;
Function Definition: procedure Finish_Run(mem : in out Super_Type) is
Function Body: context : constant Context_Pointer := mem.context;
cost : constant Cost_Type := Get_Cost(mem);
value : Value_Type := Get_Value(mem'Access);
sum : Long_Float;
count : Long_Float;
total : Long_Integer;
var : LF_Variance.Variance_Type;
result : Result_Type;
begin
-- Scale the result if necessary.
if mem.current_length > context.total_length then
context.total_length := mem.current_length;
end if;
if mem.current_length /= context.total_length then
Put_Line("Prune");
declare
mult : constant Long_Float := Long_Float(context.total_length) /
Long_Float(mem.current_length);
fval : constant Long_Float := Long_Float(value) * mult;
begin
if fval >= Long_Float(Value_Type'Last) then
value := Value_Type'Last;
else
value := Value_Type(fval);
end if;
Function Definition: procedure Destroy is new Ada.Unchecked_Deallocation(Distribution_Type,
Function Body: Distribution_Pointer);
procedure Destroy is new Ada.Unchecked_Deallocation(Context_Type,
Context_Pointer);
procedure Finalize(mem : in out Super_Type) is
begin
for i in mem.contexts.First_Index .. mem.contexts.Last_Index loop
declare
cp : Context_Pointer := mem.contexts.Element(i);
begin
Destroy(cp);
Function Definition: procedure Free is
Function Body: new Ada.Unchecked_Deallocation(Cache_Data, Cache_Data_Pointer);
function Create_Cache(mem : access Memory_Type'Class;
line_count : Positive := 1;
line_size : Positive := 8;
associativity : Positive := 1;
latency : Time_Type := 1;
policy : Policy_Type := LRU;
write_back : Boolean := True)
return Cache_Pointer is
result : constant Cache_Pointer := new Cache_Type;
begin
Set_Memory(result.all, mem);
result.line_size := line_size;
result.line_count := line_count;
result.associativity := associativity;
result.latency := latency;
result.policy := policy;
result.write_back := write_back;
result.data.Set_Length(Count_Type(result.line_count));
for i in 0 .. result.line_count - 1 loop
result.data.Replace_Element(i, new Cache_Data);
end loop;
return result;
end Create_Cache;
function Random_Policy is new Random_Enum(Policy_Type);
function Random_Boolean is new Random_Enum(Boolean);
-- Set the latency based on associativity.
procedure Update_Latency(mem : in out Cache_Type'Class) is
begin
if Get_Device = ASIC then
mem.latency := CACTI.Get_Time(mem);
else
case mem.policy is
when PLRU =>
mem.latency := 3 + Time_Type(mem.associativity) / 8;
when others =>
mem.latency := 3 + Time_Type(mem.associativity) / 4;
end case;
end if;
end Update_Latency;
function Random_Cache(next : access Memory_Type'Class;
generator : Distribution_Type;
max_cost : Cost_Type)
return Memory_Pointer is