Я пытаюсь запустить SAM (инструмент моделирования архитектуры SPARC) и после компиляции, когда я использую скрипт run_sam.sh, он вызывает интерфейс python и дает ошибку:Не удалось импортировать модуль python (riesling)
starting py interface...
UI: start py thread, tid = 5
stop: Traceback (most recent call last):
File "lib/frontend/sam_n1.py", line 26, in ?
import riesling_n1
File "/scratch/sam-t1/lib/frontend/riesling_n1.py", line 4, in ?
import _riesling_n1
ImportError: dynamic module does not define init function (init_riesling_n1)
Прикрепление Makefile.swig:
# ========== Copyright Header Begin ==========================================
2 #
3 # OpenSPARC T1 Processor File: Makefile.swig
4 # Copyright (c) 2006 Sun Microsystems, Inc. All Rights Reserved.
5 # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES.
6 #
7 # The above named program is free software; you can redistribute it and/or
8 # modify it under the terms of the GNU General Public
9 # License version 2 as published by the Free Software Foundation.
10 #
11 # The above named program is distributed in the hope that it will be
12 # useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 # General Public License for more details.
15 #
16 # You should have received a copy of the GNU General Public
17 # License along with this work; if not, write to the Free Software
18 # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
19 #
20 # ========== Copyright Header End ============================================
21 RIESLING_ROOT = ../..
22
23 include $(RIESLING_ROOT)/src/Makefile.moddefs
24
25 MODULE = swig
26 DEPENDENT_MODULES = $(MODULE) fw mmu asi strand core cpu system trap blaze register
27
28 NAMESPACE = ""
29
30 CPPFLAGS += -I$(DEVTOOLS)/shade/inc -I$(PYTHONINC)
31
32 include Makefile.$(PRODUCT)
33 include $(RIESLING_ROOT)/src/Makefile.modrules
34
35 autoregs.i: AutoRegs.xml
36 PYTHONPATH=$(PYTHONPATH) $(PYTHON) genregs ../../src AutoRegs.xml autoregs.i
37
38 riesling_$(PRODUCT)_wrap.cc: riesling_$(PRODUCT).i autoregs.i strand.i system.i fw.i conv.i
39 $(SWIG) $(SWIG_FLAGS) -o [email protected] riesling_$(PRODUCT).i
40
41 riesling_$(PRODUCT)_blaze_wrap.cc: riesling_$(PRODUCT)_blaze.i riesling_$(PRODUCT).i autoregs.i strand.i system.i fw.i conv.i
42 $(SWIG) $(SWIG_FLAGS) -o [email protected] riesling_$(PRODUCT)_blaze.i
Я новичок в этом и заранее извиняюсь, если не в состоянии задать вопрос правильно. Пожалуйста помоги.
Я вижу следующие файлы: "riesling_n1.i", "riesling_n1_wrap.cc" и "riesling_n1.py". Я думаю, что последний из них - это файл python, созданный после запуска Makefile.swig.
апреля 10,2014:
Schollii, вот Makefile.n1:
1 # ========== Copyright Header Begin ==========================================
2 #
3 # OpenSPARC T1 Processor File: Makefile.n1
4 # Copyright (c) 2006 Sun Microsystems, Inc. All Rights Reserved.
5 # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES.
6 #
7 # The above named program is free software; you can redistribute it and/or
8 # modify it under the terms of the GNU General Public
9 # License version 2 as published by the Free Software Foundation.
10 #
11 # The above named program is distributed in the hope that it will be
12 # useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 # General Public License for more details.
15 #
16 # You should have received a copy of the GNU General Public
17 # License along with this work; if not, write to the Free Software
18 # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
19 #
20 # ========== Copyright Header End ============================================
21
22 REGISTERED_XML_FILES.n1 =
23
24 XML_FILES.n1 =
25
26 REGISTERED_CCFILES.n1 =
27
28 CCFILES.n1 =\
29 riesling_$(PRODUCT)_wrap.cc
30
~
Кроме того, riesling_n1.i код здесь:
/*
* ========== Copyright Header Begin ==========================================
*
* OpenSPARC T1 Processor File: riesling_n1.i
* Copyright (c) 2006 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES.
*
* The above named program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public
* License version 2 as published by the Free Software Foundation.
*
* The above named program is distributed in the hope that it will be
* useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public
* License along with this work; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
*
* ========== Copyright Header End ============================================
*/
%module riesling_n1
/*==========================================================================*\
* NOTE: Some method signatures use uint64_t even though the
* actual riesling method defines the type as uint32_t. The
* 8-byte type is used to keep python from sign extending unsigned
* 4-byte values when they are converted to a python long types.
*==========================================================================*/
%{
typedef uint64_t VaddrT;
typedef uint64_t PaddrT;
typedef uint16_t ContextT;
#include "Ni/Ni_System.h"
//#include "Ni/Ni_CBInterface.h"
#include "Ni/Ni_ArchStateConf.h"
#include "Ni/Ni_Tlb.h"
#include "Ni/Ni_Tte.h"
%}
%ignore operator=;
%ignore operator<<;
/* print is a Python keyword, so we rename it here */
%rename (rsPrint) print;
#define RIESLING_REGISTER_CONSTRUCTOR(class_name, ... ) class_name (__VA_ARGS__)
#define RIESLING_REGISTER_METHOD(handle, return_type, method_name, ... ) return_type method_name (__VA_ARGS__)
#define RIESLING_REGISTER_CHILD(handle, type, var_name)\ type var_name
#define RIESLING_REGISTER_CHILD_PTR(handle, type, var_name)\ type var_name
#define RIESLING_CACHE_RV(handle, cacheName, size)
%include "fw.i"
%include "strand.i"
%include "cpu.i"
%include "system.i"
#include "autoregs.i"
%include "std_string.i"
%include "conv.i"
%inline %{
// n1_system_base() is used when we already have created a N1_Cpu elsewhere
// and we have a long value representing its pointer. n1_system_base() casts
// it to a proper SWIG pointer
Riesling::Ni_SystemBase* n1_system_base(uint64_t p)
{
union { Riesling::Ni_SystemBase* sys; uint64_t ptr; } u;
u.ptr = p;
return u.sys;
}
%}
namespace Riesling {
/*--------------------------------------------------------------------------*/
/*-------------------------------------
class Ni_PerfCtlReg
{
public:
std::string toString();
uint64_t getNative();
void setNative(uint64_t);
};
-------------------------------------*/
/*-------------------------------------
class Ni_PicReg
{
public:
std::string toString();
uint64_t getNative();
void setNative(uint64_t);
};
-------------------------------------*/
/*-------------------------------------
class Ni_IsfsrReg
{
public:
std::string toString();
uint64_t getNative();
void setNative(uint64_t);
};
-------------------------------------*/
/*-------------------------------------
class Ni_DsfsrReg
{
public:
std::string toString();
uint64_t getNative();
void setNative(uint64_t);
};
-------------------------------------*/
/*-------------------------------------
class Ni_DsfarReg
{
public:
std::string toString();
uint64_t getNative();
void setNative(uint64_t);
};
-------------------------------------*/
/*--------------------------------------------------------------------------*/
class Ni_Tlb
{
public:
std::string toString();
Riesling::TtePos insert(const Riesling::Ni_Tte &tte);
Riesling::Ni_Tte* at(int);
uint32_t getNLines();
int next_valid_index(int i);
};
class Ni_Tte
{
public:
Ni_Tte();
std::string toString() const;
Riesling::Ni_TteDataSun4u& data4u();
void context(uint16_t c);
uint16_t context() const;
void pid(uint32_t p);
uint32_t pid() const;
uint64_t vaddr() const;
void vaddr(uint64_t vaddr);
uint32_t r() const;
void r(uint32_t _r);
uint64_t translate(VaddrT vaddr) const;
bool tagMatch ( uint64_t va, uint16_t context) const;
bool tagMatch ( uint64_t va, uint16_t context, uint32_t pid, uint32_t r) const;
};
class Ni_TteDataSun4u
{
public:
Ni_TteDataSun4u();
uint64_t getNative() const;
void setNative(uint64_t value);
uint64_t getV() const;
uint64_t getSZL() const;
uint64_t getNFO() const;
uint64_t getIE() const;
uint64_t getSZH() const;
uint64_t getDIAG7_3() const;
uint64_t getPA() const;
uint64_t getL() const;
uint64_t getCP() const;
uint64_t getCV() const;
uint64_t getE() const;
uint64_t getP() const;
uint64_t getW() const;
void setV(uint64_t value);
void setSZL(uint64_t value);
void setNFO(uint64_t value);
void setIE(uint64_t value);
void setSZH(uint64_t value);
void setDIAG7_3(uint64_t value);
void setPA(uint64_t value);
void setL(uint64_t value);
void setCP(uint64_t value);
void setCV(uint64_t value);
void setE(uint64_t value);
void setP(uint64_t value);
void setW(uint64_t value);
};
class Ni_IDPartitionIdReg
{
public:
std::string toString();
uint64_t getNative();
void setNative(uint64_t);
};
class Sf_ContextReg
{
public:
std::string toString();
uint64_t getNative();
void setNative(uint64_t);
};
/*-------------------------------------
class Ni_TlbDataIn
{
public:
std::string toString();
uint64_t getNative();
void setNative(uint64_t);
};
-------------------------------------*/
/*-------------------------------------
class Ni_TlbDataAccess
{
public:
std::string toString();
uint64_t getNative();
void setNative(uint64_t);
};
-------------------------------------*/
class Sf_TagTargetReg
{
public:
std::string toString();
uint64_t getNative();
void setNative(uint64_t);
};
class Sf_TagAccessReg
{
public:
std::string toString();
uint64_t getNative();
void setNative(uint64_t);
};
/*-------------------------------------
class Ni_TsbSearch
{
public:
std::string toString();
uint64_t getNative();
void setNative(uint64_t);
};
-------------------------------------*/
/*-------------------------------------
class Ni_RealRange
{
public:
std::string toString();
uint64_t getNative();
void setNative(uint64_t);
};
-------------------------------------*/
/*-------------------------------------
class Ni_PhysOffset
{
public:
std::string toString();
uint64_t getNative();
void setNative(uint64_t);
};
-------------------------------------*/
/*-------------------------------------
class Ni_TsbConfig
{
public:
std::string toString();
uint64_t getNative();
void setNative(uint64_t);
};
-------------------------------------*/
/*-------------------------------------
class Ni_TsbPointer
{
public:
std::string toString();
uint64_t getNative();
void setNative(uint64_t);
};
-------------------------------------*/
/*-------------------------------------
class Ni_TimedTlb
{
public:
std::string toString();
};
-------------------------------------*/
class Ni_Mmu
{
public:
std::string toString();
//int getContextSize();
//int getTsbConfigSize();
//Ni_IDPartitionIdReg* getPartitionIdPtr();
//Sf_ContextReg* getPrimaryContextPtr(int i);
//Sf_ContextReg* getSecondaryContextPtr(int i);
//Ni_TlbDataIn* getItlbDataInPtr();
//Ni_TlbDataAccess* getItlbDataAccessPtr();
//Sf_TagTargetReg* getItagTargetPtr();
//Sf_TagAccessReg* getItagAccessPtr();
//Ni_IsfsrReg* getIsfsrPtr();
//Ni_TlbDataIn* getDtlbDataInPtr();
//Ni_TlbDataAccess* getDtlbDataAccessPtr();
//Sf_TagTargetReg* getDtagTargetPtr();
//Sf_TagAccessReg* getDtagAccessPtr();
//Ni_DsfsrReg* getDsfsrPtr();
//Ni_DsfarReg* getDsfarPtr();
//Ni_TsbSearch* getTsbSearchPtr();
//Ni_RealRange* getRealRangePtr(int i);
//Ni_PhysOffset* getPhysOffsetPtr(int i);
//Ni_TsbConfig* getZeroContextTsbConfigPtr(int i);
//Ni_TsbConfig* getNonzeroContextTsbConfigPtr(int i);
//Ni_TsbPointer* getItsbPointerPtr(int i);
//Ni_TsbPointer* getDtsbPointerPtr(int i);
};
/*--------------------------------------------------------------------------*/
/*-------------------------------------
class CMP_CoreIdReg
{
public:
std::string toString();
uint64_t getNative();
void setNative(uint64_t);
};
-------------------------------------*/
/*-------------------------------------
class CMP_CoreInterruptIdReg
{
public:
std::string toString();
uint64_t getNative();
void setNative(uint64_t);
};
-------------------------------------*/
/*--------------------------------------------------------------------------*/
class Hv_InstructionWord
{
public:
std::string toString() const;
uint32_t getNative() const;
uint64_t getPc() const;
uint64_t getPpc() const;
};
class Ni_InstructionWord
{
public:
std::string toString() const;
uint32_t getNative() const;
uint64_t getPc() const;
uint64_t getPpc() const;
};
class Ni_TstateEntry
{
public:
Ni_TstateEntry();
std::string toString();
uint64_t getNative();
void setNative(uint64_t);
};
class Ni_Tstate
{
public:
std::string toString();
Ni_TstateEntry getTstateEntry(uint32_t);
void setTstateEntry(uint32_t, const Ni_TstateEntry&);
};
class Ni_PstateReg
{
public:
std::string toString();
uint64_t getNative();
void setNative(uint64_t);
};
class Hv_HtstateEntry
{
public:
Hv_HtstateEntry();
std::string toString();
uint64_t getNative();
void setNative(uint64_t);
};
class Hv_Htstate
{
public:
std::string toString();
Hv_HtstateEntry getHtstateEntry(uint32_t);
void setHtstateEntry(uint32_t, const Hv_HtstateEntry&);
int getMaxTl();
};
class Vis2_GsrReg
{
public:
std::string toString();
uint64_t getNative();
void setNative(uint64_t);
};
class Hv_HpstateReg
{
public:
std::string toString();
uint64_t getNative();
void setNative(uint64_t);
};
class Hv_HtbaReg
{
public:
std::string toString();
uint64_t getNative();
void setNative(uint64_t);
};
class Ni_HverReg
{
public:
std::string toString();
uint64_t getNative();
void setNative(uint64_t);
};
class Hv_HintpReg
{
public:
std::string toString();
uint64_t getNative();
void setNative(uint64_t);
};
class Hv_HstickCompareReg
{
public:
std::string toString();
uint64_t getNative();
void setNative(uint64_t);
};
class Hv_GlobalLevelReg
{
public:
std::string toString();
uint64_t getNative();
void setNative(uint64_t);
};
class Hv_ScratchPad
{
public:
std::string toString();
uint64_t getNative();
void setNative(uint64_t);
};
class Ni_ArchState
{
public:
std::string toString();
uint64_t getPc();
void setPc(uint64_t);
uint64_t getNpc();
void setNpc(uint64_t);
RegisterFile* getRegisterFilePtr();
FloatRegisterFile* getFloatRegisterFilePtr();
Ni_Tstate* getTstateRegPtr();
Ni_PstateReg* getPstateRegPtr();
Hv_Htstate* getHtstateRegPtr();
Vis2_GsrReg* getGsrRegPtr();
Hv_HpstateReg* getHpstateRegPtr();
Hv_HtbaReg* getHtbaRegPtr();
Ni_HverReg* getHverRegPtr();
//Ni_PerfCtlReg* getNiPcrRegPtr();
//Ni_PicReg* getNiPicRegPtr();
Hv_HintpReg* getHintpRegPtr();
Hv_HstickCompareReg* getHstickCompareRegPtr();
Hv_GlobalLevelReg* getGlobalLevelRegPtr();
Hv_ScratchPad* getScratchPadPtr(int);
V9_TickReg* getStickRegPtr();
Sf_SoftIntReg* getSoftIntRegPtr();
V9_TickCompareReg* getTickCmprRegPtr();
V9_TickCompareReg* getStickCmprRegPtr();
V9_CcrReg* getCcrRegPtr();
V9_YReg* getYRegPtr();
V9_FprsReg* getFprsRegPtr();
V9_FsrReg* getFsrRegPtr();
V9_TickReg* getTickRegPtr();
V9_TbaReg* getTbaRegPtr();
V9_PilReg* getPilRegPtr();
V9_AsiReg* getAsiRegPtr();
V9_Tpc* getTpcRegPtr();
V9_Tnpc* getTnpcRegPtr();
V9_WstateReg* getWstateRegPtr();
V9_TrapLevelReg* getTrapLevelRegPtr();
V9_VerReg* getVerRegPtr();
V9_TrapType* getTrapTypeRegPtr();
//CMP_CoreIdReg* getCmpCoreIdRegPtr();
//CMP_CoreInterruptIdReg* getCmpCoreIntrIdRegPtr();
};
/*-------------------------------------
class Ni_WatchPointReg
{
public:
std::string toString();
uint64_t getNative();
void setNative(uint64_t);
};
-------------------------------------*/
/*-------------------------------------
class Ni_LsuControlReg
{
public:
std::string toString();
uint64_t getNative();
void setNative(uint64_t);
};
-------------------------------------*/
class Ni_Strand
{
public:
%extend {
uint_t get_max_tl() { return Riesling::Ni_ArchStateConf::MAXTL; }
uint_t get_max_ptl() { return Riesling::Ni_ArchStateConf::MAXPTL; }
uint_t get_max_gl() { return Riesling::Ni_ArchStateConf::MAXGL; }
uint_t get_max_pgl() { return Riesling::Ni_ArchStateConf::MAXGL; } // used in done/retry instruction ...
}
int step();
Ni_ArchState* getArchStatePtr();
Ni_InstructionWord* getLastInstrPtr();
Ni_Mmu* getMmuPtr();
//Ni_WatchPointReg* getWatchpointPtr();
//Ni_LsuControlReg* getLsuControlPtr();
uint32_t lastInstr();
std::string lastInstrToString();
/* when a (uint32_t)iw has bit31=1, the python->C++ conversion complains,
so have to use uint64_t here to fool it, what a pain */
Ni_InstructionWord* RS_getInstrPtr(uint64_t);
uint64_t RS_translate(int, uint64_t);
uint64_t RS_access(uint64_t, uint64_t, int, int);
uint64_t RS_asiRead (int asi, uint64_t va, bool nse);
void RS_asiWrite(int asi, uint64_t va, uint64_t value, bool nse);
std::string RS_dumpTlb(int itlb, int valid);
};
/*--------------------------------------------------------------------------*/
class Ni_Core
{
public:
std::string toString();
uint_t getNStrands() const;
Ni_Strand* getStrandPtr(uint_t);
Ni_Tlb* getdTlbPtr();
Ni_Tlb* getiTlbPtr();
};
/*--------------------------------------------------------------------------*/
class Ni_Cpu
{
public:
std::string toString();
uint_t getNCores() const;
Ni_Core* getCorePtr(uint_t);
//CMP_CpuLevelCmpRegs* getCpuLevelCmpRegsPtr();
};
/*--------------------------------------------------------------------------*/
class Ni_System
{
public:
Ni_System();
std::string toString();
uint_t getNCpus() const;
Ni_Cpu* getCpuPtr(uint_t);
void loadMemdatImage(const std::string&);
SparseMemory* getRam();
uint64_t getThisPtr();
BreakpointTable* getBreakpointTablePtr();
};
/*--------------------------------------------------------------------------*/
class Ni_SystemBase
{
public:
Ni_SystemBase();
uint_t getNCpus() const;
Ni_Cpu* getCpuPtr(uint_t);
BreakpointTable* getBreakpointTablePtr();
};
/*-------------------------------------
class Ni_CBInterface
{
public:
static void suspendCB();
static void resumeCB();
};
-------------------------------------*/
}; /* namespace Riesling */
Я понял, в Makefile , существуют следующие строки кода вместе с другими:
И, _riesling_n1.so становится поврежденным, как только я скомпилирую swig и, таким образом, получаю исходную ошибку. Когда я заменил _riesling_n1.so оригинальным (тот, который поставляется вместе с пакетом), SAM работает. Это означает, что во время компиляции это как-то испортило файлы библиотеки Shared Object.
Просьба сообщить (если возможно), чтобы выяснить, что вызывает это.
Можете ли вы разместить сообщение 'riesling_n1.i'? и является SWIG_FLAGS, определенным в среде оболочки, на что он установлен? Возможно, это одно из трех включений (Makefile.n1 и два других). Наконец, вы можете указать версию SWIG? – Schollii