OpenASIP  2.0
Public Member Functions | Private Attributes | List of all members
HDLGenerator::Wire Class Reference

#include <HDLGenerator.hh>

Inheritance diagram for HDLGenerator::Wire:
Inheritance graph
Collaboration diagram for HDLGenerator::Wire:
Collaboration graph

Public Member Functions

 Wire (std::string name, int width=1, WireType wt=WireType::Auto)
 
 Wire (std::string name, std::string width)
 
Width width () final
 
void declare (std::ostream &stream, Language lang, int ident)
 
WireType wireType () const final
 
- Public Member Functions inherited from HDLGenerator::Generatable
 Generatable (std::string name)
 
virtual ~Generatable ()=default
 
virtual void build ()
 
virtual void reads (const std::string &var)
 
virtual void reads (const LHSValue &var)
 
virtual void writes (const std::string &var)
 
virtual RegistergetRegister (const std::string &var)
 
virtual bool hasOption (const std::string &var)
 
virtual bool isRegister (const std::string &name)
 
virtual bool isVariable (const std::string &name)
 
virtual bool isConstant (const std::string &name)
 
virtual Width width (const std::string &name)
 
int integerWidth (const std::string &name)
 
virtual WireType wireType (const std::string &name)
 
virtual void hdl (std::ostream &stream, Language lang, int indent)
 
virtual void hdl (std::ostream &stream, Language lang)
 
virtual void implementAll (std::ostream &stream, Language lang)
 
virtual void implementAll (std::ostream &stream, Language lang, int indent)
 
template<typename Func >
void forAll (Func func)
 
template<typename Type , typename Func >
void forAll (Func func)
 
template<class Type >
bool parentIs ()
 
template<class Type >
Type * parentType ()
 
void pushComponent (std::shared_ptr< Generatable > c)
 
template<class Component >
void addComponent (Component c)
 
const std::string & name () const noexcept
 
void setParent (Generatable *parent) noexcept
 
Generatableparent () const noexcept
 

Private Attributes

std::string strWidth_
 
int width_
 
WireType wt_
 

Detailed Description

Async signal/wire.

Definition at line 315 of file HDLGenerator.hh.

Constructor & Destructor Documentation

◆ Wire() [1/2]

HDLGenerator::Wire::Wire ( std::string  name,
int  width = 1,
WireType  wt = WireType::Auto 
)
inline

Definition at line 317 of file HDLGenerator.hh.

318  : Generatable(name), width_(width), wt_(wt) {}

◆ Wire() [2/2]

HDLGenerator::Wire::Wire ( std::string  name,
std::string  width 
)
inline

Definition at line 319 of file HDLGenerator.hh.

320  : Generatable(name), strWidth_(width), width_(-1) {}

Member Function Documentation

◆ declare()

void HDLGenerator::Wire::declare ( std::ostream &  stream,
Language  lang,
int  ident 
)
inline

Definition at line 324 of file HDLGenerator.hh.

324  {
325  if (lang == Language::VHDL) {
326  stream << StringTools::indent(ident) << "signal "
327  << name() << " : ";
328  if (width_ < 0 || width_ > 1 || wt_ == WireType::Vector) {
329  if (strWidth_.empty()) {
330  stream << "std_logic_vector("
331  << std::to_string(width_ - 1)
332  << " downto 0);\n";
333  } else {
334  stream << "std_logic_vector(" << strWidth_
335  << "-1 downto 0);\n";
336  }
337  } else {
338  stream << "std_logic;\n";
339  }
340  } else if (lang == Language::Verilog) {
341  stream << StringTools::indent(ident) << "reg ";
342  if (width_ < 0 || width_ > 1) {
343  if (strWidth_.empty()) {
344  stream << "[" << std::to_string(width_ - 1) << ":0] ";
345  } else {
346  stream << "[" << strWidth_ << "-1:0] ";
347  }
348  }
349  stream << name() << ";\n";
350  } else {
351  throw std::runtime_error(__PRETTY_FUNCTION__);
352  }
353  }

References StringTools::indent(), HDLGenerator::Generatable::name(), strWidth_, HDLGenerator::Vector, HDLGenerator::Verilog, HDLGenerator::VHDL, width_, and wt_.

Here is the call graph for this function:

◆ width()

Width HDLGenerator::Wire::width ( )
inlinefinalvirtual

Reimplemented from HDLGenerator::Generatable.

Definition at line 322 of file HDLGenerator.hh.

322 { return {strWidth_, width_}; }

References strWidth_, and width_.

◆ wireType()

WireType HDLGenerator::Wire::wireType ( ) const
inlinefinalvirtual

Reimplemented from HDLGenerator::Generatable.

Definition at line 355 of file HDLGenerator.hh.

355 { return wt_; }

References wt_.

Member Data Documentation

◆ strWidth_

std::string HDLGenerator::Wire::strWidth_
private

Definition at line 358 of file HDLGenerator.hh.

Referenced by declare(), and width().

◆ width_

int HDLGenerator::Wire::width_
private

Definition at line 359 of file HDLGenerator.hh.

Referenced by declare(), and width().

◆ wt_

WireType HDLGenerator::Wire::wt_
private

Definition at line 360 of file HDLGenerator.hh.

Referenced by declare(), and wireType().


The documentation for this class was generated from the following file:
StringTools::indent
static std::string indent(int level)
Definition: StringTools.cc:319
HDLGenerator::Wire::strWidth_
std::string strWidth_
Definition: HDLGenerator.hh:358
HDLGenerator::Generatable::Generatable
Generatable(std::string name)
Definition: Generatable.hh:53
HDLGenerator::Language::Verilog
@ Verilog
HDLGenerator::Wire::width
Width width() final
Definition: HDLGenerator.hh:322
HDLGenerator::Generatable::name
const std::string & name() const noexcept
Definition: Generatable.hh:239
HDLGenerator::WireType::Vector
@ Vector
HDLGenerator::Wire::wt_
WireType wt_
Definition: HDLGenerator.hh:360
HDLGenerator::Wire::width_
int width_
Definition: HDLGenerator.hh:359
HDLGenerator::Language::VHDL
@ VHDL