OpenASIP 2.2
Loading...
Searching...
No Matches
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 316 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 318 of file HDLGenerator.hh.

319 : Generatable(name), width_(width), wt_(wt) {}
const std::string & name() const noexcept
Generatable(std::string name)
Width width() final

◆ Wire() [2/2]

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

Definition at line 320 of file HDLGenerator.hh.

std::string strWidth_

Member Function Documentation

◆ declare()

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

Definition at line 325 of file HDLGenerator.hh.

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

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 323 of file HDLGenerator.hh.

323{ return {strWidth_, width_}; }

References strWidth_, and width_.

◆ wireType()

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

Reimplemented from HDLGenerator::Generatable.

Definition at line 356 of file HDLGenerator.hh.

356{ return wt_; }

References wt_.

Member Data Documentation

◆ strWidth_

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

Definition at line 359 of file HDLGenerator.hh.

Referenced by declare(), and width().

◆ width_

int HDLGenerator::Wire::width_
private

Definition at line 360 of file HDLGenerator.hh.

Referenced by declare(), and width().

◆ wt_

WireType HDLGenerator::Wire::wt_
private

Definition at line 361 of file HDLGenerator.hh.

Referenced by declare(), and wireType().


The documentation for this class was generated from the following file: