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

Constructor & Destructor Documentation

◆ Asynchronous()

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

Definition at line 904 of file HDLGenerator.hh.

904: Generatable(name) {}
const std::string & name() const noexcept
Generatable(std::string name)

Member Function Documentation

◆ addVariable()

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

Definition at line 914 of file HDLGenerator.hh.

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

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

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

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

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

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

919 {
920 readList_.emplace(var);
921 if (parent() != nullptr) {
922 parent()->reads(var);
923 }
924 }
virtual void reads(const std::string &var)
Generatable * parent() const noexcept

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

Referenced by hdl(), and reads().

◆ variables_

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

Definition at line 976 of file HDLGenerator.hh.

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


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