⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 verilog.hh

📁 将Verilog代码转换成C++代码的软件
💻 HH
📖 第 1 页 / 共 3 页
字号:
	Port(const char* ref,Expression* con):	  ref_(ref),	  con_(con),	  net_(NULL)	{}	Port():	  con_(NULL),	  net_(NULL)	{}	virtual ~Port();	const string&     reference() const { return ref_; }	const Expression* connect() const { return con_; }	void toXML( std::ostream& ostr,int indent=0 ) const;	void toVerilog( std::ostream& ostr,int indent=0 ) const;	void link(const map<string,Net*>& net,Module* mod,Module* rmod,int idx);	const Net* net() const { return net_; }	Port* clone(const string& hname) const;	void ungroup(Module* mod,const string& cname,const string& sname);	void callback(Callback& cb) const;      };      string        type_;      vector<Port*> port_;      Module*       module_;    public:      Instance(const char* t):	type_(t),	module_(NULL)      {}      Instance():	module_(NULL)      {}      virtual ~Instance();      const string&        type() const { return type_; }      const vector<Port*>& port() const { return port_; }      const Module* module() const { return module_; }      void setType(const char* type){ type_ =type; }      void addPort(Port* p);      void toXML( std::ostream& ostr,const string& name,int indent=0 ) const;      void toVerilog( std::ostream& ostr,const string& name,int indent=0 ) const;      void link(Verilog* veri,const map<string,Net*>& net,Module* mod);      Instance* clone(const string& hname) const;      void ungroup(Module* mod,const string& cname,const string& sname);      void callback(Callback& cb) const;    };    ////////////////////////////////////////////////////////////////////////    class Module    {    private:      string                name_;      vector<string>        port_;      map<string,Net*>      net_;      map<string,Function*> function_;      map<string,Instance*> instance_;      vector<Process*>      process_;    public:      Module(){}      virtual ~Module();      const vector<string>&        port()     const { return port_; }      const map<string,Net*>&      net()      const { return net_; }      const map<string,Function*>& function() const { return function_; }      const map<string,Instance*>& instance() const { return instance_; }      const vector<Process*>&      process()  const { return process_; }      const string&                name()     const { return name_; }      map<string,Instance*>& instance() { return instance_; }      Instance* newInstance(const char* name);      Function* newFunction(const char* name);      Net*      newNet(const char* name,		       int type,		       Expression* msb=NULL,Expression* lsb=NULL,		       int inter=Net::PRIVATE,		       Expression* sa=NULL,Expression* ea=NULL,		       bool sign=false);      void addPort(const char* name);      void addNet(const char* name,Net* net);      void addAssign(Expression* l,Expression* r);      void addParameter(Expression* l,Expression* r);      void addProcess(Process* proc);      void addFunction(const char* name,Function* func);      void addInstance(const char* name,Instance* inst);      void toXML( std::ostream& ostr,const string& name,int indent=0 ) const;      void toVerilog( std::ostream& ostr,const string& name,int indent=0 ) const;      void link(Verilog* veri);      void ungroup(Module* mod,const string& hname);      void link();      void ungroup();      const Net* findNet(const char* name) const { map<string,Net*>::const_iterator i;i=net_.find(string(name));if( i!=net_.end() ) return i->second; else return NULL; }      //      const char* findName(const Net* net) const      {	map<string,Net*>::const_iterator i;	for( i=net_.begin();i!=net_.end();++i )	  if( i->second==net )	    return i->first.c_str();	return NULL;      }      //      void callback(Callback& cb) const;    };    ////////////////////////////////////////////////////////////////////////    map<string,Module*> module_;    bool                debug_;    //    map<string,Number*> constant_;        bool                dec_tpd_;  public:    Verilog(bool debug=false):      debug_(debug),      dec_tpd_(false)    {}    virtual ~Verilog();    bool decTPD() const { return dec_tpd_; }    void setDecTPD(bool flag) { dec_tpd_ =flag; }    bool debug() const { return debug_; }    int parse(const char* filename);    int parse(FILE* fp);    const map<string,Module*>& module() const { return module_; }    Module* addModule(const char* name);    void toXML(std::ostream& ostr,int indent=0) const;    virtual void toVerilog(std::ostream& ostr,int indent=0) const;    void link();    void ungroup(Module* top);    Module* findModule(const char* name){ map<string,Module*>::const_iterator i;i=module_.find(string(name));if( i!=module_.end() ) return i->second; else return NULL; }    //    const char* findName(const Module* mod) const    {      map<string,Module*>::const_iterator i;      for( i=module_.begin();i!=module_.end();++i )	if( i->second==mod )	  return i->first.c_str();      return NULL;    }    //    void callback(Callback& cb) const;    ////////////////////////////////////////////////////////////////////////    class Callback    {    public:      Callback(){}      virtual ~Callback(){}      virtual void trap(const Case::Item* self)      {	if( self==NULL )	  return;	vector<Expression*>::const_iterator i;	for( i=self->expression().begin();i!=self->expression().end();++i )	  (*i)->callback( *this );	self->statement()->callback( *this );      }      virtual void trap(const Instance::Port* self)      {	if( self==NULL )	  return;	self->callback( *this );      }      virtual void trap(const Assign* self)      {	if( self==NULL )	  return;	self->rightValue()->callback( *this );	self->leftValue()->callback( *this );      }      virtual void trap(const Binary* self)      {	if( self==NULL )	  return;	self->left()->callback( *this );	self->right()->callback( *this );      }      virtual void trap(const Block* self)      {	if( self==NULL )	  return;	vector<Statement*>::const_iterator i;	for( i=self->list().begin();i!=self->list().end();++i )	  (*i)->callback( *this );      }      virtual void trap(const CallFunction* self)      {	if( self==NULL )	  return;	vector<Expression*>::const_iterator i;	for( i=self->parameter().begin();i!=self->parameter().end();++i )	  (*i)->callback( *this );      }      virtual void trap(const Case* self)      {	if( self==NULL )	  return;	vector<Case::Item*>::const_iterator i;	for( i=self->items().begin();i!=self->items().end();++i )	  {	    if( !(*i)->expression().empty() )	      {		vector<Expression*>::const_iterator ii;		for( ii=(*i)->expression().begin();ii!=(*i)->expression().end();++ii )		  (*ii)->callback( *this );	      }	    (*i)->statement()->callback( *this );	  }      }      virtual void trap(const Concat* self)      {	if( self==NULL )	  return;	vector<Expression*>::const_reverse_iterator i;	for( i=self->list().rbegin();i!=self->list().rend();++i )	  (*i)->callback( *this );      }      virtual void trap(const Condition* self)      {	if( self==NULL )	  return;	self->expression()->callback( *this );	self->trueStatement()->callback( *this );	if( self->falseStatement()!=NULL )	  self->falseStatement()->callback( *this );      }      virtual void trap(const Event* self)      {	if( self==NULL )	  return;	self->expression()->callback( *this );      }      virtual void trap(const EventStatement* self)      {	if( self==NULL )	  return;	vector<Event*>::const_reverse_iterator i;	for( i=self->event().rbegin();i!=self->event().rend();++i )	  (*i)->callback( *this );	self->statement()->callback( *this );      }      virtual void trap(const For* self)      {	if( self==NULL )	  return;	//	self->iterat()->callback( *this );	//	self->begin()->callback( *this );	//	self->condition()->callback( *this );	//	self->reach()->callback( *this );	self->statement()->callback( *this );      }      virtual void trap(const Function* self)      {	if( self==NULL )	  return;	self->statement()->callback( *this );      }      virtual void trap(const Gate* self){}      virtual void trap(const Identifier* self)      {	if( self==NULL )	  return;	if( self->msb()!=NULL )	  self->msb()->callback( *this );	if( self->lsb()!=NULL )	  self->lsb()->callback( *this );	if( self->idx()!=NULL )	  self->idx()->callback( *this );	if( self->net()!=NULL )	  self->net()->callback( *this );      }      virtual void trap(const Instance* self)      {	if( self==NULL )	  return;	vector<Instance::Port*>::const_iterator i;	for( i=self->port().begin();i!=self->port().end();++i )	  (*i)->callback( *this );      }      virtual void trap(const Module* self)      {	if( self==NULL )	  return;	{	  map<string,Net*>::const_iterator i;	  for( i=self->net().begin();i!=self->net().end();++i )	    i->second->callback( *this );	}	{	  map<string,Function*>::const_iterator i;	  for( i=self->function().begin();i!=self->function().end();++i )	    i->second->callback( *this );	}	{	  map<string,Instance*>::const_iterator i;	  for( i=self->instance().begin();i!=self->instance().end();++i )	    i->second->callback( *this );	}	{	  vector<Process*>::const_iterator i;	  for( i=self->process().begin();i!=self->process().end();++i )	    (*i)->callback( *this );	}      }      virtual void trap(const Net* self)      {	if( self==NULL )	  return;		if( self->msb()!=NULL )	  self->msb()->callback( *this );	if( self->lsb()!=NULL )	  self->lsb()->callback( *this );	if( self->sa()!=NULL )	  self->sa()->callback( *this );	if( self->ea()!=NULL )	  self->ea()->callback( *this );      }      virtual void trap(const Number* self){}      virtual void trap(const Process* self)      {	if( self==NULL )	  return;	self->statement()->callback( *this );	{	  set<const Net*>::const_iterator i;	  for( i=self->eventChain().begin();i!=self->eventChain().end();++i )	    (*i)->callback( *this );	}	      }      virtual void trap(const Ternary* self)      {	if( self==NULL )	  return;	if( self->condition()!=NULL )	  self->condition()->callback( *this );	if( self->trueValue()!=NULL )	  self->trueValue()->callback( *this );	if( self->falseValue()!=NULL )	  self->falseValue()->callback( *this );      }      virtual void trap(const Unary* self)      {	if( self==NULL )	  return;	if( self->value()!=NULL )	  self->value()->callback( *this );      }      virtual void trap(const Verilog* self)      {	if( self==NULL )	  return;	map<string,Module*>::const_iterator i;	for( i=self->module().begin();i!=self->module().end();++i )	  i->second->callback( *this );	      }    };    ////////////////////////////////////////////////////////////////////////    class LeftNetChainCB : public Callback    {      set<const Net*>& chain_;    public:      LeftNetChainCB(set<const Net*>& chain):	chain_(chain)      {}      ~LeftNetChainCB(){}      void trap(const Case::Item* self);      void trap(const Assign* self);      void trap(const Block* self);      void trap(const Case* self);      void trap(const Concat* self);      void trap(const Condition* self);      void trap(const EventStatement* self);      void trap(const Identifier* self);      void trap(const Net* self);      void trap(const Process* self);    };    ////////////////////////////////////////////////////////////////////////    class RightNetChainCB : public Callback    {      set<const Net*>& chain_;      bool             left_;    public:      RightNetChainCB(set<const Net*>& chain):	chain_(chain),	left_(false)      {}      ~RightNetChainCB(){}      void trap(const Case::Item* self);      void trap(const Assign* self);      void trap(const Block* self);      void trap(const Case* self);      void trap(const Condition* self);      void trap(const EventStatement* self);      void trap(const Net* self);      void trap(const Process* self);      void trap(const Binary* self);      void trap(const CallFunction* self);      void trap(const Concat* self);      void trap(const Ternary* self);      void trap(const Unary* self);      void trap(const Identifier* self);          };    ////////////////////////////////////////////////////////////////////////    class EventNetChainCB : public Callback    {      set<const Net*>& chain_;    public:      EventNetChainCB(set<const Net*>& chain):	chain_(chain)      {}      ~EventNetChainCB(){}      void trap(const Process* self);      void trap(const EventStatement* self);      void trap(const Event* self);      void trap(const Identifier* self);      void trap(const Net* self);    };    ////////////////////////////////////////////////////////////////////////    class NetChainCB : public Callback    {      set<const Net*>& nbLeftChain_;      set<const Net*>& nbRightChain_;      set<const Net*>& bLeftChain_;      set<const Net*>& bRightChain_;      bool             left_;      bool             blocking_;    public:      NetChainCB(set<const Net*>& nbLeftChain,		 set<const Net*>& nbRightChain,		 set<const Net*>& bLeftChain,		 set<const Net*>& bRightChain):	nbLeftChain_(nbLeftChain),	nbRightChain_(nbRightChain),	bLeftChain_(bLeftChain),	bRightChain_(bRightChain),	left_(false),	blocking_(false)      {}      ~NetChainCB(){}      void trap(const Case::Item* self);      void trap(const Assign* self);      void trap(const Block* self);      void trap(const Case* self);      void trap(const Concat* self);      void trap(const Condition* self);      void trap(const EventStatement* self);      void trap(const Identifier* self);      void trap(const Net* self);      void trap(const Process* self);      // only right net       void trap(const Binary* self);      void trap(const CallFunction* self);      void trap(const Ternary* self);      void trap(const Unary* self);    };    ////////////////////////////////////////////////////////////////////////  };}#endif

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -