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

#include <HDLGenerator.hh>

Inheritance diagram for HDLGenerator::Asynchronous:
Inheritance graph
Collaboration diagram for HDLGenerator::Asynchronous:
Collaboration graph

Public Member Functions

 Asynchronous (const std::string &name)
 
template<typename SS >
Asynchronousoperator<< (SS op)
 
template<typename Var >
void addVariable (Var op)
 
virtual void reads (const std::string &var) override
 
virtual void build () override
 
virtual void hdl (std::ostream &stream, Language lang, int level) override
 
- Public Member Functions inherited from HDLGenerator::Generatable
 Generatable (std::string name)
 
virtual ~Generatable ()=default
 
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

std::vector< std::shared_ptr< Variable > > variables_
 
std::unordered_set< std::string > readList_
 

Detailed Description

Async process/always.

Definition at line 900 of file HDLGenerator.hh.

Constructor & Destructor Documentation

◆ Asynchronous()

HDLGenerator::Asynchronous::Asynchronous ( const std::string &  name)
inline

Definition at line 903 of file HDLGenerator.hh.

903 : Generatable(name) {}

Member Function Documentation

◆ addVariable()

template<typename Var >
void HDLGenerator::Asynchronous::addVariable ( Var  op)
inline

Definition at line 913 of file HDLGenerator.hh.

913  {
914  std::shared_ptr<Variable> ptr = std::make_shared<Var>(op);
915  variables_.push_back(ptr);
916  }

References variables_.

Referenced by FUGen::buildOperations().

◆ build()

void HDLGenerator::Asynchronous::build ( )
overridevirtual

Reimplemented from HDLGenerator::Generatable.

Definition at line 47 of file HDLGenerator.cc.

47  {
49  for (auto&& v : variables_) {
50  parentType<Module>()->registerVariable(v);
51  }
52 }

References HDLGenerator::Generatable::build(), and variables_.

Here is the call graph for this function:

◆ hdl()

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

@lassetodo Sensitivity list implementation here for verilog if needed.

If sensitivity list is needed for verilog replace
@* with @(, uncomment following code, and add ) before
begin
std::string separator = "";
for (auto&& r : readList_) {
  stream << separator << r;
  separator = " or ";
}

Reimplemented from HDLGenerator::Generatable.

Definition at line 928 of file HDLGenerator.hh.

928  {
929  if (lang == Language::VHDL) {
930  stream << "\n";
931  stream << StringTools::indent(level) << name() << " : process(";
932  std::string separator = "";
933  for (auto&& r : readList_) {
934  if (!isConstant(r)) {
935  stream << separator << r;
936  separator = ", ";
937  }
938  }
939  stream << ")\n";
940  for (auto&& v : variables_) {
941  v->declare(stream, lang, level + 1);
942  }
943  stream << StringTools::indent(level) << "begin\n";
944  implementAll(stream, lang, level + 1);
945  stream << StringTools::indent(level) << "end process "
946  << name() << ";\n";
947  } else if (lang == Language::Verilog) {
948  stream << "\n";
949  stream << StringTools::indent(level) << "// " << name() << "\n";
950  stream << StringTools::indent(level) << "always @*";
951  /**
952  * @lassetodo Sensitivity list implementation here
953  * for verilog if needed.
954  * <pre>
955  * If sensitivity list is needed for verilog replace
956  * @* with @(, uncomment following code, and add ) before
957  * begin
958  *
959  * std::string separator = "";
960  * for (auto&& r : readList_) {
961  * stream << separator << r;
962  * separator = " or ";
963  * }
964  * </pre>
965  */
966  stream << " begin\n";
967  implementAll(stream, lang, level + 1);
968  stream << StringTools::indent(level) << "end\n";
969  } else {
970  throw std::runtime_error(__PRETTY_FUNCTION__);
971  }
972  }

References HDLGenerator::Generatable::implementAll(), StringTools::indent(), HDLGenerator::Generatable::isConstant(), HDLGenerator::Generatable::name(), readList_, variables_, HDLGenerator::Verilog, and HDLGenerator::VHDL.

Here is the call graph for this function:

◆ operator<<()

template<typename SS >
Asynchronous& HDLGenerator::Asynchronous::operator<< ( SS  op)
inline

Definition at line 906 of file HDLGenerator.hh.

906  {
907  std::shared_ptr<SequentialStatement> ptr = std::make_shared<SS>(op);
908  pushComponent(ptr);
909  return *this;
910  }

References HDLGenerator::Generatable::pushComponent().

Here is the call graph for this function:

◆ reads()

virtual void HDLGenerator::Asynchronous::reads ( const std::string &  var)
inlineoverridevirtual

Reimplemented from HDLGenerator::Generatable.

Definition at line 918 of file HDLGenerator.hh.

918  {
919  readList_.emplace(var);
920  if (parent() != nullptr) {
921  parent()->reads(var);
922  }
923  }

References HDLGenerator::Generatable::parent(), readList_, and HDLGenerator::Generatable::reads().

Referenced by FUGen::buildOperations().

Here is the call graph for this function:

Member Data Documentation

◆ readList_

std::unordered_set<std::string> HDLGenerator::Asynchronous::readList_
private

Definition at line 976 of file HDLGenerator.hh.

Referenced by hdl(), and reads().

◆ variables_

std::vector< std::shared_ptr<Variable> > HDLGenerator::Asynchronous::variables_
private

Definition at line 975 of file HDLGenerator.hh.

Referenced by addVariable(), build(), and hdl().


The documentation for this class was generated from the following files:
HDLGenerator::Generatable::pushComponent
void pushComponent(std::shared_ptr< Generatable > c)
Definition: Generatable.hh:230
StringTools::indent
static std::string indent(int level)
Definition: StringTools.cc:319
HDLGenerator::Asynchronous::variables_
std::vector< std::shared_ptr< Variable > > variables_
Definition: HDLGenerator.hh:975
HDLGenerator::Generatable::isConstant
virtual bool isConstant(const std::string &name)
Definition: Generatable.hh:125
HDLGenerator::Generatable::Generatable
Generatable(std::string name)
Definition: Generatable.hh:53
HDLGenerator::Generatable::parent
Generatable * parent() const noexcept
Definition: Generatable.hh:242
HDLGenerator::Language::Verilog
@ Verilog
HDLGenerator::Generatable::build
virtual void build()
Definition: Generatable.hh:56
HDLGenerator::Generatable::implementAll
virtual void implementAll(std::ostream &stream, Language lang)
Definition: Generatable.hh:183
HDLGenerator::Generatable::reads
virtual void reads(const std::string &var)
Definition: Generatable.hh:63
HDLGenerator::Generatable::name
const std::string & name() const noexcept
Definition: Generatable.hh:239
HDLGenerator::Asynchronous::readList_
std::unordered_set< std::string > readList_
Definition: HDLGenerator.hh:976
HDLGenerator::Language::VHDL
@ VHDL