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

Constructor & Destructor Documentation

◆ IntegerConstant()

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

Definition at line 290 of file HDLGenerator.hh.

const std::string & name() const noexcept
Generatable(std::string name)
int value() const noexcept

Member Function Documentation

◆ declare()

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

Definition at line 297 of file HDLGenerator.hh.

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

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

293{ return value_; }

References value_.

Referenced by declare().

◆ width()

Width HDLGenerator::IntegerConstant::width ( )
inlinefinalvirtual

Reimplemented from HDLGenerator::Generatable.

Definition at line 295 of file HDLGenerator.hh.

295{ 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 310 of file HDLGenerator.hh.

Referenced by value(), and width().


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