Make it so that alpha_console can read the frequency from the correct
authorRon Dreslinski <rdreslin@umich.edu>
Fri, 19 Mar 2004 19:51:02 +0000 (14:51 -0500)
committerRon Dreslinski <rdreslin@umich.edu>
Fri, 19 Mar 2004 19:51:02 +0000 (14:51 -0500)
sim object(depends on which platform tsunami/tlaser is being used)

dev/alpha_console.cc:
    Use dynamice casting once during build to get at the proper device to calculate the frequency.
    It is either a tsunami_IO or a tlaser_clock depending on platform (tsunami/tlaser).
    If the simobject is not of either of those types then panic
dev/alpha_console.hh:
    Pass in a SimObject * that is to either a tlaser_clock or a tsunami_IO
sim/sim_object.cc:
    Make it so that you can have a SimObjectParam of type SimObject:

    example:
    SimObjectParam<SimObject *> so;

--HG--
extra : convert_revision : 08239ef23762b8ea11311630b73fe885d939402e

dev/alpha_console.cc
dev/alpha_console.hh
sim/sim_object.cc

index 2e9e09e935b76bcd7c8266a8f2aab5793de89899..111b23c816dcae23f8396e724a6c05677c885b54 100644 (file)
 #include "sim/builder.hh"
 #include "sim/system.hh"
 #include "dev/tsunami_io.hh"
+#include "sim/sim_object.hh"
 
 using namespace std;
 
 AlphaConsole::AlphaConsole(const string &name, SimConsole *cons, SimpleDisk *d,
-                           System *system, BaseCPU *cpu, TsunamiIO *clock,
+                           System *system, BaseCPU *cpu, SimObject *clock,
                            int num_cpus, MemoryController *mmu, Addr a,
                            HierParams *hier, Bus *bus)
     : PioDevice(name), disk(d), console(cons), addr(a)
@@ -79,8 +80,14 @@ AlphaConsole::AlphaConsole(const string &name, SimConsole *cons, SimpleDisk *d,
     alphaAccess->numCPUs = num_cpus;
     alphaAccess->mem_size = system->physmem->size();
     alphaAccess->cpuClock = cpu->getFreq() / 1000000;
-    alphaAccess->intrClockFrequency = clock->frequency();
-
+    TsunamiIO *clock_linux = dynamic_cast<TsunamiIO *>(clock);
+    TlaserClock *clock_tru64 = dynamic_cast<TlaserClock *>(clock);
+    if (clock_linux)
+        alphaAccess->intrClockFrequency = clock_linux->frequency();
+    else if (clock_tru64)
+        alphaAccess->intrClockFrequency = clock_tru64->frequency();
+    else
+        panic("clock must be of type TlaserClock or TsunamiIO\n");
     alphaAccess->diskUnit = 1;
 }
 
@@ -267,7 +274,7 @@ BEGIN_DECLARE_SIM_OBJECT_PARAMS(AlphaConsole)
     Param<Addr> addr;
     SimObjectParam<System *> system;
     SimObjectParam<BaseCPU *> cpu;
-    SimObjectParam<TsunamiIO *> clock;
+    SimObjectParam<SimObject *> clock;
     SimObjectParam<Bus*> io_bus;
     SimObjectParam<HierParams *> hier;
 
@@ -282,7 +289,7 @@ BEGIN_INIT_SIM_OBJECT_PARAMS(AlphaConsole)
     INIT_PARAM(addr, "Device Address"),
     INIT_PARAM(system, "system object"),
     INIT_PARAM(cpu, "Processor"),
-    INIT_PARAM(clock, "Turbolaser Clock"),
+    INIT_PARAM(clock, "Clock"),
     INIT_PARAM_DFLT(io_bus, "The IO Bus to attach to", NULL),
     INIT_PARAM_DFLT(hier, "Hierarchy global variables", &defaultHierParams)
 
index be8538e5052e694845339951b6e8b15429ea033c..4986d0e5f0702bf039f461903180b0b2b6793e84 100644 (file)
@@ -38,6 +38,7 @@
 #include "dev/io_device.hh"
 #include "sim/host.hh"
 #include "dev/tsunami_io.hh"
+#include "sim/sim_object.hh"
 
 class BaseCPU;
 class SimConsole;
@@ -90,7 +91,7 @@ class AlphaConsole : public PioDevice
   public:
     /** Standard Constructor */
     AlphaConsole(const std::string &name, SimConsole *cons, SimpleDisk *d,
-                 System *system, BaseCPU *cpu, TsunamiIO *clock,
+                 System *system, BaseCPU *cpu, SimObject *clock,
                  int num_cpus, MemoryController *mmu, Addr addr,
                  HierParams *hier, Bus *bus);
 
index c55021e41ab04dde132521c97f0f85b724ad44cb..2ec588afacefe1f55c431a3a3ac614ec29e0879f 100644 (file)
@@ -36,6 +36,7 @@
 #include "sim/host.hh"
 #include "sim/sim_object.hh"
 #include "sim/sim_stats.hh"
+#include "sim/param.hh"
 
 using namespace std;
 
@@ -191,3 +192,5 @@ SimObject::serializeAll(ostream &os)
         obj->serialize(os);
    }
 }
+
+DEFINE_SIM_OBJECT_CLASS_NAME("SimObject", SimObject)