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

#include <HDLPort.hh>

Inheritance diagram for HDLGenerator::Port:
Inheritance graph
Collaboration diagram for HDLGenerator::Port:
Collaboration graph

Public Member Functions

 Port (std::string name, Direction dir, int width=1, WireType wireType=WireType::Auto)
 
 Port (std::string name, Direction dir, std::string parametricWidth, WireType wireType=WireType::Auto)
 
virtual ~Port ()=default
 
void declare (std::ostream &stream, Language lang, int level=0)
 
std::string name ()
 
Width width ()
 
WireType wireType () const
 

Protected Attributes

std::string name_
 
Direction dir_
 
std::string parametricWidth_
 
int width_
 
WireType wireType_
 

Detailed Description

Entity/module port base class.

Definition at line 38 of file HWGen/HDLPort.hh.

Constructor & Destructor Documentation

◆ Port() [1/2]

HDLGenerator::Port::Port ( std::string  name,
Direction  dir,
int  width = 1,
WireType  wireType = WireType::Auto 
)
inline

Definition at line 40 of file HWGen/HDLPort.hh.

◆ Port() [2/2]

HDLGenerator::Port::Port ( std::string  name,
Direction  dir,
std::string  parametricWidth,
WireType  wireType = WireType::Auto 
)
inline

Definition at line 43 of file HWGen/HDLPort.hh.

45 : name_(name), dir_(dir), parametricWidth_(parametricWidth),
std::string parametricWidth_

◆ ~Port()

virtual HDLGenerator::Port::~Port ( )
virtualdefault

Member Function Documentation

◆ declare()

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

Definition at line 50 of file HWGen/HDLPort.hh.

50 {
51 stream << StringTools::indent(level);
52 if (lang == Language::VHDL) {
53 stream << name_;
54 if (dir_ == Direction::In) {
55 stream << " : in ";
56 } else {
57 stream << " : out ";
58 }
59 if (!parametricWidth_.empty()) {
60 stream << "std_logic_vector(" << parametricWidth_
61 << "-1 downto 0)";
62 } else if (wireType_ == WireType::Vector || width_ > 1) {
63 stream << "std_logic_vector("
64 << std::to_string(width_) << "-1 downto 0)";
65 } else {
66 stream << "std_logic";
67 }
68 } else if (lang == Language::Verilog) {
69 if (dir_ == Direction::In) {
70 stream << "input ";
71 } else {
72 stream << "output reg ";
73 }
74 if (!parametricWidth_.empty()) {
75 stream << "[" << parametricWidth_ << "-1:0] ";
76 } else if (wireType_ == WireType::Vector || width_ > 1) {
77 stream << "[" << std::to_string(width_ - 1) << ":0] ";
78 }
79 stream << name_;
80 } else {
81 throw std::runtime_error(__PRETTY_FUNCTION__);
82 }
83 };
static std::string indent(int level)

References dir_, HDLGenerator::In, StringTools::indent(), name_, parametricWidth_, HDLGenerator::Vector, HDLGenerator::Verilog, HDLGenerator::VHDL, width_, and wireType_.

Here is the call graph for this function:

◆ name()

std::string HDLGenerator::Port::name ( )
inline

Definition at line 85 of file HWGen/HDLPort.hh.

85{ return name_; }

References name_.

◆ width()

Width HDLGenerator::Port::width ( )
inline

Definition at line 87 of file HWGen/HDLPort.hh.

87{ return {parametricWidth_, width_}; }

References parametricWidth_, and width_.

◆ wireType()

WireType HDLGenerator::Port::wireType ( ) const
inline

Definition at line 89 of file HWGen/HDLPort.hh.

89{ return wireType_; }

References wireType_.

Member Data Documentation

◆ dir_

Direction HDLGenerator::Port::dir_
protected

Definition at line 93 of file HWGen/HDLPort.hh.

Referenced by declare().

◆ name_

std::string HDLGenerator::Port::name_
protected

Definition at line 92 of file HWGen/HDLPort.hh.

Referenced by declare(), and name().

◆ parametricWidth_

std::string HDLGenerator::Port::parametricWidth_
protected

Definition at line 94 of file HWGen/HDLPort.hh.

Referenced by declare(), and width().

◆ width_

int HDLGenerator::Port::width_
protected

Definition at line 95 of file HWGen/HDLPort.hh.

Referenced by declare(), and width().

◆ wireType_

WireType HDLGenerator::Port::wireType_
protected

Definition at line 96 of file HWGen/HDLPort.hh.

Referenced by declare(), and wireType().


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