Date: | Thu, 4 Feb 2010 10:45:18 -0600 |
---|---|
From: | sparsh mittal ISU <sparsh@xxxxxxxxxxx> |
Subject: | Re: [Gems-users] Writing new get function for opal, to put value in variable |
Hello All, Thanks Dan for the reply. Yes, once I write the command for opal0.instructions, I can assign the value: simics> @U = conf.opal0.instructions however, the value to be returned by opal0.instructions is an integer, and the its scope is in a separate C file (hfa.C in opal), not in the python file (commands.py). For such functions, GEMS code uses SIM_get_attribute to separately define the function in the C file (hfa.C). So, for this case, the code would be In commands.py================= def opal_sim_instructions(obj): SIM_get_attribute( obj, "instructions" ) new_command("instructions", opal_sim_instructions, [], alias = "", type = "hfa commands", short = "returns the current instructions", namespace = "opal", doc = """ Returns the current instructions of the simulator.<br/> """) and in hfa.C======================= attr_value_t hfa_dispatch_get( void *id, conf_object_t *obj, attr_value_t *idx ) { attr_value_t ret; ret.kind = Sim_Val_Integer; ret.u.integer = 0; const char *attr_fn = (const char *) id; // obj is the hfa0 object if (!strcmp(attr_fn, "sim-flag")) { ret.kind = Sim_Val_Integer; ret.u.integer = system_t::inst->isSimulating(); } ...... else if (!strcmp(attr_fn, "instructions")) { printf(" %lld\n",system_t::inst->m_seq[0]->m_stat_committed[0]); ret.u.integer = system_t::inst->m_seq[0]->m_stat_committed[0]; } else { ERROR_OUT( "error: hfa: hfa_dispatch_get: unknown command: %s\n", attr_fn ); } return ret; } Now my question is that the function in the hfa.C returns a attr_value_t variable. Whether it can be used in the commands.py file or can the scope of (system_t::inst->m_seq[0]->m_stat_committed[0]) be accessed in the commands.py file? I would be thankful for the reply. Sparsh On Thu, Feb 4, 2010 at 10:41 AM, Dan Gibson <degibson@xxxxxxxx> wrote: The Simics CLI is a fully-functional python interpreter. Therefore, you can write whatever you like in Python. -- Thanks and Regards Sparsh Mittal Graduate Student Electrical and Computer Engineering Iowa State University, Iowa, USA |
[← Prev in Thread] | Current Thread | [Next in Thread→] |
---|---|---|
|
Previous by Date: | Re: [Gems-users] Writing new get function for opal, to put value in variable, Dan Gibson |
---|---|
Next by Date: | Re: [Gems-users] Writing new get function for opal, to put value in variable, Dan Gibson |
Previous by Thread: | Re: [Gems-users] Writing new get function for opal, to put value in variable, Dan Gibson |
Next by Thread: | Re: [Gems-users] Writing new get function for opal, to put value in variable, Dan Gibson |
Indexes: | [Date] [Thread] |