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

#include <HDLGenerator.hh>

Inheritance diagram for HDLGenerator::IntegerConstant:
Inheritance graph
Collaboration diagram for HDLGenerator::IntegerConstant:
Collaboration graph

Public Member Functions

 IntegerConstant (std::string name, int value)
 
int value () const noexcept
 
Width width () final
 
void declare (std::ostream &stream, Language lang, int level)
 
- 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 WireType wireType () const
 
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

int value_
 

Detailed Description

Integer constant.

Definition at line 287 of file HDLGenerator.hh.

Constructor & Destructor Documentation

◆ IntegerConstant()

HDLGenerator::IntegerConstant::IntegerConstant ( std::string  name,
int  value 
)
inline

Definition at line 289 of file HDLGenerator.hh.

290  : Generatable(name), value_(value) {}

Member Function Documentation

◆ declare()

void HDLGenerator::IntegerConstant::declare ( std::ostream &  stream,
Language  lang,
int  level 
)
inline

Definition at line 296 of file HDLGenerator.hh.

296  {
297  if (lang == Language::VHDL) {
298  stream << StringTools::indent(level) << "constant " << name()
299  << " : integer := " << value() << ";\n";
300  } else if (lang == Language::Verilog) {
301  stream << StringTools::indent(level) << "localparam integer "
302  << name() << " = " << value() << ";\n";
303  } else {
304  throw std::runtime_error(__PRETTY_FUNCTION__);
305  }
306  }

References StringTools::indent(), HDLGenerator::Generatable::name(), value(), HDLGenerator::Verilog, and HDLGenerator::VHDL.

Here is the call graph for this function:

◆ value()

int HDLGenerator::IntegerConstant::value ( ) const
inlinenoexcept

Definition at line 292 of file HDLGenerator.hh.

292 { return value_; }

References value_.

Referenced by declare().

◆ width()

Width HDLGenerator::IntegerConstant::width ( )
inlinefinalvirtual

Reimplemented from HDLGenerator::Generatable.

Definition at line 294 of file HDLGenerator.hh.

294 { return {name(), value_}; }

References HDLGenerator::Generatable::name(), and value_.

Here is the call graph for this function:

Member Data Documentation

◆ value_

int HDLGenerator::IntegerConstant::value_
private

Definition at line 309 of file HDLGenerator.hh.

Referenced by value(), and width().


The documentation for this class was generated from the following file:
HDLGenerator::IntegerConstant::value_
int value_
Definition: HDLGenerator.hh:309
StringTools::indent
static std::string indent(int level)
Definition: StringTools.cc:319
HDLGenerator::Generatable::Generatable
Generatable(std::string name)
Definition: Generatable.hh:53
HDLGenerator::IntegerConstant::value
int value() const noexcept
Definition: HDLGenerator.hh:292
HDLGenerator::Language::Verilog
@ Verilog
HDLGenerator::Generatable::name
const std::string & name() const noexcept
Definition: Generatable.hh:239
HDLGenerator::Language::VHDL
@ VHDL