OpenASIP 2.2
Loading...
Searching...
No Matches
Public Member Functions | Private Attributes | List of all members
HDLGenerator::Switch Class Reference

#include <HDLGenerator.hh>

Inheritance diagram for HDLGenerator::Switch:
Inheritance graph
Collaboration diagram for HDLGenerator::Switch:
Collaboration graph

Public Member Functions

 Switch (LHSValue control)
 
void addCase (Case rhs)
 
void addCase (DefaultCase rhs)
 
void build () override
 
void hdl (std::ostream &stream, Language lang, int level) override
 
- Public Member Functions inherited from HDLGenerator::SequentialStatement
 SequentialStatement (std::string name)
 
- Public Member Functions inherited from HDLGenerator::Generatable
 Generatable (std::string name)
 
virtual ~Generatable ()=default
 
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 Width width ()
 
virtual WireType wireType () const
 
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

LHSValue control_
 

Detailed Description

Switch-case switch.

Definition at line 744 of file HDLGenerator.hh.

Constructor & Destructor Documentation

◆ Switch()

HDLGenerator::Switch::Switch ( LHSValue  control)
inline

Definition at line 746 of file HDLGenerator.hh.

746 : SequentialStatement("switch"),
747 control_(control) {}

Member Function Documentation

◆ addCase() [1/2]

void HDLGenerator::Switch::addCase ( Case  rhs)
inline

Definition at line 749 of file HDLGenerator.hh.

749 {
750 addComponent(rhs);
751 }
void addComponent(Component c)

References HDLGenerator::Generatable::addComponent().

Referenced by FUGen::buildOperations().

Here is the call graph for this function:

◆ addCase() [2/2]

void HDLGenerator::Switch::addCase ( DefaultCase  rhs)
inline

Definition at line 753 of file HDLGenerator.hh.

753 {
754 addComponent(rhs);
755 }

References HDLGenerator::Generatable::addComponent().

Here is the call graph for this function:

◆ build()

void HDLGenerator::Switch::build ( )
inlineoverridevirtual

Reimplemented from HDLGenerator::Generatable.

Definition at line 757 of file HDLGenerator.hh.

757 {
760 }
virtual void reads(const std::string &var)

References HDLGenerator::Generatable::build(), control_, and HDLGenerator::Generatable::reads().

Here is the call graph for this function:

◆ hdl()

void HDLGenerator::Switch::hdl ( std::ostream &  stream,
Language  lang,
int  level 
)
inlineoverridevirtual

Reimplemented from HDLGenerator::SequentialStatement.

Definition at line 762 of file HDLGenerator.hh.

762 {
763 if (lang == Language::VHDL) {
764 stream << StringTools::indent(level) << "case ";
765 control_.hdl(stream, lang);
766 stream << " is\n";
767 implementAll(stream, lang, level + 1);
768 stream << StringTools::indent(level) << "end case;\n";
769 } else if (lang == Language::Verilog) {
770 stream << StringTools::indent(level) << "case (";
771 control_.hdl(stream, lang);
772 stream << ")\n";
773 implementAll(stream, lang, level + 1);
774 stream << StringTools::indent(level) << "endcase\n";
775 } else {
776 throw std::runtime_error(__PRETTY_FUNCTION__);
777 }
778 }
virtual void implementAll(std::ostream &stream, Language lang)
void hdl(std::ostream &stream, Language lang, int level)
Definition LHSValue.cc:37
static std::string indent(int level)

References control_, HDLGenerator::LHSValue::hdl(), HDLGenerator::Generatable::implementAll(), StringTools::indent(), HDLGenerator::Verilog, and HDLGenerator::VHDL.

Here is the call graph for this function:

Member Data Documentation

◆ control_

LHSValue HDLGenerator::Switch::control_
private

Definition at line 781 of file HDLGenerator.hh.

Referenced by build(), and hdl().


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