Hi Mohamed,

The gem5-users list is probably a better place to ask this question
(forwarding it there).

It's not totally clear from your email what "CLASSONE" is, though I
appreciate all of the detail :).

However, the error that you're seeing is because you didn't set the
variable named "system.cp_cntrl0.class_one" in the python config scripts
with a value.

Somewhere you should have the line
system.cp_cntrl0.class_one = <something>
OR
system.cp_cntrl0 = WHATEVERCLASS(class_one = <something>).

Basically, you need to initialize the class_one member of the instance
"system.cp_cntrl0".

Hope this helps,
Jason

On Mon, Jun 20, 2016 at 1:30 PM Mohamed Ibrahim <maibra...@email.wm.edu>
wrote:

> Hi,
>
> I want to add a new object in the SLICC code that has some getter functions
> to read some values from the command line and use it within the SLICC code,
> however, I got the following error:
> fatal: system.cp_cntrl0.class_one without default or user set value
>
> In order to add a new object, I have added a structure in
> gem5/src/mem/protocol/RubySlicc_Types.sm file with (external = "yes")
>
> structure (NEWCLASS, external = "yes") {
>   int getX1();
>   int getX2();
>   int getX3();
> }
>
> and added the equivalent py, cc, and hh files in the structure
> gem5/src/mem/ruby/structures following the instructions listed in the
> following link:
> http://www.lowepower.com/jason/learning_gem5/part2/simobject.html
>
> from m5.params import *
> from m5.proxy import *
> from m5.SimObject import SimObject
>
> class NEWCLASS(SimObject):
>     type = 'NEWCLASS'
>     cxx_class = 'NEWCLASS'
>     cxx_header = "mem/ruby/structures/NEWCLASS.hh"
>
>     X1 = Param.Int(0, "X1")
>     X2 = Param.Int(0, "X2")
>     X3 = Param.Int(0, "X3")
>
> -----------------------------
>
> #ifndef __MEM_RUBY_STRUCTURES_NEWCLASS_HH__
> #define __MEM_RUBY_STRUCTURES_NEWCLASS_HH__
>
> #include <iostream>
> #include <string>
>
> #include "params/NEWCLASS.hh"
> #include "sim/sim_object.hh"
>
> class NEWCLASS : public SimObject
> {
>   public:
>     typedef NEWCLASSParams Params;
>     NEWCLASS(const Params *p);
>     ~NEWCLASS();
>
>     int getX1();
>     int geX2();
>     int getX3();
>
>   private:
>     int m_X1;
>     int m_X2;
>     int m_X3;
> };
>
> #endif // __MEM_RUBY_STRUCTURES_NEWCLASS_HH__
>
> -----------------------------
>
> #include "mem/ruby/structures/NEWCLASS.hh"
>
> using namespace std;
>
> NEWCLASS::NEWCLASS(const Params *p)
>     : SimObject(p)
> {
>     m_X1 = p->X1;
>     m_X2 = p->X2;
>     m_X3 = p->X3;
> }
>
> NEWCLASS::~NEWCLASS()
> {
> }
>
> int
> NEWCLASS::getX1()
> {
>     return m_X1;
> }
>
> int
> NEWCLASS::getX2()
> {
>     return m_X2;
> }
>
> int
> NEWCLASS::getX3()
> {
>     return m_X3;
> }
>
> NEWCLASS*
> NEWCLASS::create()
> {
>     return new NEWCLASS(this);
> }
>
> Then, I have updated the required sm files by creating an object of the
> structure
>
> e.g.
> machine(MachineType:TCP, "GPU TCP (L1 Data Cache)")
>  : GPUCoalescer* coalescer;
>    Sequencer* sequencer;
>    bool use_seq_not_coal;
>    CacheMemory * L1cache;
>    int TCC_select_num_bits;
>    Cycles issue_latency := 40;  // time to send data down to TCC
>    Cycles l2_hit_latency := 18;
>    NEWCLASS* new_class;
>    ....
>
> and using the created object to call the getter functions
>
> xyz + new_class.getX1()
>
> As for the options, I have updated the gem5/configs/example/apu_se.py to
> add new options.
>
> # NEWCLASS options
> ...
> parser.add_option("--X1", type="int", default=0, help="")
> parser.add_option("--X2", type="int", default=0, help="")
> parser.add_option("--X3", type="int", default=0, help="")
> ....
>
> Additionally, I have updated the following files:
> -> gem5/src/mem/ruby/SConscript
> MakeInclude('structures/NEWCLASS.hh')
>
> -> gem5/src/mem/ruby/structures/SConscript
> SimObject('NEWCLASS.py')
> Source('NEWCLASS.cc')
>
> -> gem5/src/mem/slicc/symbols/StateMachine.py
> python_class_map = {
>                     "int": "Int",
>                     "NodeID": "Int",
>                     "uint32_t" : "UInt32",
>                     "std::string": "String",
>                     ...
>                     "NEWCLASS":"NEWCLASS",
>                    }
>
> Also, I have updated the corresponding py files in the gem5/configs/ruby to
> initialize the new object. I created another python class that initialize
> the object by the options from the command line.
>
> For example, in gem5/configs/ruby/GPU_RfO.py file, I added the following
> class
>
> class CLSONE(CLASSONE, CntrlBase):
>     def create(self, options, ruby_system, system):
>         self.X1 = options.X1
>         self.X2 = options.X2
>         self.X3 = options.X3
>
> and updated the TCPCntrl class with the following
>
> class TCPCntrl(TCP_Controller, CntrlBase):
>
>     def create(self, options, ruby_system, system):
>         self.version = self.versionCount()
>
>         ...
>         self.new_class = CLSONE()
>         self.new_class.create(options, ruby_system, system)
>         ...
>
> Finally, I build gem5 using the following:
> scons -j 17 build/HSAIL_X86/gem5.opt
>
> and when I tried to run the simulator, I got he following error:
> fatal: system.cp_cntrl0.class_one without default or user set value
>
> Can you point the cause? From what I understand, the created object needs
> to be initialized, however,  I don't know where I should initialize other
> than what I have already mentioned.
>
> Thanks.
>
> --
> Regard,
> Mohamed Ibrahim
> _______________________________________________
> gem5-dev mailing list
> gem5-...@gem5.org
> http://m5sim.org/mailman/listinfo/gem5-dev
>
-- 

Jason
_______________________________________________
gem5-users mailing list
gem5-users@gem5.org
http://m5sim.org/cgi-bin/mailman/listinfo/gem5-users

Reply via email to