OpenASIP  2.0
Public Member Functions | Static Public Member Functions | Private Types | Private Member Functions | Private Attributes | Static Private Attributes | List of all members
ProGe::PortFactory Class Reference

#include <NetlistFactories.hh>

Collaboration diagram for ProGe::PortFactory:
Collaboration graph

Public Member Functions

 PortFactory (const TTAMachine::Machine &machine, const IDF::MachineImplementation &impl)
 
virtual ~PortFactory ()
 
NetlistPortcreatePort (SignalType type, Direction direction=IN) const
 
NetlistPortGroupcreatePortGroup (SignalGroupType type) const
 

Static Public Member Functions

static NetlistPortcreate (SignalType type, Direction direction=IN)
 
static NetlistPortGroupcreate (SignalGroupType type)
 
static void initializeContext (const TTAMachine::Machine &machine, const IDF::MachineImplementation &impl)
 
static PortFactoryinstance ()
 
static NetlistPortclockPort (Direction direction=IN)
 
static NetlistPortresetPort (Direction direction=IN)
 

Private Types

typedef std::map< SignalType, const NetlistPort * > PortPrototypeContainer
 
typedef std::map< SignalGroupType, const NetlistPortGroup * > PortGroupPrototypeContainer
 

Private Member Functions

 PortFactory ()
 
void registerPort (SignalType, const NetlistPort *port)
 
void registerPort (const NetlistPort *port)
 
void registerPorts ()
 
void registerPortGroup (SignalGroupType type, const NetlistPortGroup *portGroup)
 
void registerPortGroup (const NetlistPortGroup *portGroup)
 
void registerPortGroups ()
 

Private Attributes

PortPrototypeContainer portPrototypes_
 The creation context. More...
 
PortGroupPrototypeContainer portGroupPrototypes_
 Registered NetlistPortGroup prototypes. More...
 

Static Private Attributes

static PortFactoryinstance_ = NULL
 Singleton instance of the factory. More...
 
static const TTAMachine::MachinestaticMachine_ = NULL
 The creation context for singleton instance. More...
 
static const IDF::MachineImplementationstaticImplementation_ = NULL
 The creation context for singleton instance. More...
 

Detailed Description

Definition at line 55 of file NetlistFactories.hh.

Member Typedef Documentation

◆ PortGroupPrototypeContainer

Definition at line 90 of file NetlistFactories.hh.

◆ PortPrototypeContainer

Definition at line 88 of file NetlistFactories.hh.

Constructor & Destructor Documentation

◆ PortFactory() [1/2]

ProGe::PortFactory::PortFactory ( const TTAMachine::Machine machine,
const IDF::MachineImplementation impl 
)

Definition at line 53 of file NetlistFactories.cc.

58 {}

◆ ~PortFactory()

ProGe::PortFactory::~PortFactory ( )
virtual

Definition at line 60 of file NetlistFactories.cc.

60  {
61  PortPrototypeContainer::iterator port_it = portPrototypes_.begin();
62  while (port_it != portPrototypes_.end()) {
63  delete port_it->second;
64  port_it->second = NULL;
65  port_it++;
66  }
67  PortGroupPrototypeContainer::iterator portGroup_it =
68  portGroupPrototypes_.begin();
69  while (portGroup_it != portGroupPrototypes_.end()) {
70  delete portGroup_it->second;
71  portGroup_it->second = NULL;
72  portGroup_it++;
73  }
74 }

References portGroupPrototypes_, and portPrototypes_.

◆ PortFactory() [2/2]

ProGe::PortFactory::PortFactory ( )
private

Definition at line 48 of file NetlistFactories.cc.

51 {}

Referenced by instance().

Member Function Documentation

◆ clockPort()

NetlistPort * ProGe::PortFactory::clockPort ( Direction  direction = IN)
static

Creates default clock port.

Definition at line 200 of file NetlistFactories.cc.

200  {
201  static const InBitPort clkPortPrototype("clk", Signal(SignalType::CLOCK));
202  return clkPortPrototype.clone(direction != IN);
203 }

References ProGe::CLOCK, ProGe::NetlistPort::clone(), and ProGe::IN.

Referenced by ProGe::LoopBufferBlock::LoopBufferBlock(), ProGe::ProcessorWrapperBlock::ProcessorWrapperBlock(), ProGe::SinglePortByteMaskSSRAMBlock::SinglePortByteMaskSSRAMBlock(), and ProGe::SinglePortSSRAMBlock::SinglePortSSRAMBlock().

Here is the call graph for this function:

◆ create() [1/2]

NetlistPortGroup * ProGe::PortFactory::create ( SignalGroupType  type)
static

Definition at line 160 of file NetlistFactories.cc.

160  {
161  return instance()->createPortGroup(type);
162 }

References createPortGroup(), and instance().

Here is the call graph for this function:

◆ create() [2/2]

NetlistPort * ProGe::PortFactory::create ( SignalType  type,
Direction  direction = IN 
)
static

Definition at line 147 of file NetlistFactories.cc.

147  {
148  return instance()->createPort(type, direction);
149 }

References createPort(), and instance().

Here is the call graph for this function:

◆ createPort()

NetlistPort * ProGe::PortFactory::createPort ( SignalType  type,
Direction  direction = IN 
) const

Creates new NetlistPort for the given signal type.

Parameters
typeThe signal type.
Returns
Pointer to newly created NetlistPort. Returns nullptr if there is no prototype for the given signal type.

Definition at line 134 of file NetlistFactories.cc.

134  {
135  if (portPrototypes_.count(type)) {
136  NetlistPort* found = portPrototypes_.find(type)->second->clone();
137  if (found->direction() != direction) {
138  return NetlistTools::mirror(found);
139  } else {
140  return found;
141  }
142  }
143  return NULL;
144 }

References ProGe::NetlistPort::direction(), ProGe::NetlistTools::mirror(), and portPrototypes_.

Referenced by create().

Here is the call graph for this function:

◆ createPortGroup()

NetlistPortGroup * ProGe::PortFactory::createPortGroup ( SignalGroupType  type) const

Definition at line 152 of file NetlistFactories.cc.

152  {
153  if (portGroupPrototypes_.count(type)) {
154  return portGroupPrototypes_.find(type)->second->clone();
155  }
156  return NULL;
157 }

References portGroupPrototypes_.

Referenced by create().

◆ initializeContext()

void ProGe::PortFactory::initializeContext ( const TTAMachine::Machine machine,
const IDF::MachineImplementation impl 
)
static

Initializes factory context for the singleton factory. This function may be called only once.

Definition at line 169 of file NetlistFactories.cc.

171  {
172  assert(
173  staticMachine_ == NULL && staticImplementation_ == NULL &&
174  "Attempted to initialize twice.");
176  staticImplementation_ = &impl;
177 }

References assert, machine, staticImplementation_, and staticMachine_.

◆ instance()

PortFactory * ProGe::PortFactory::instance ( )
static

Global access to the factory as singleton. initializeContext() must be called once before this.

Definition at line 184 of file NetlistFactories.cc.

184  {
185  if (instance_) {
186  return instance_;
187  } else {
188  assert(staticMachine_ != NULL && staticImplementation_ != NULL);
189  return (
190  instance_ =
192  }
193 }

References assert, instance_, PortFactory(), staticImplementation_, and staticMachine_.

Referenced by create().

Here is the call graph for this function:

◆ registerPort() [1/2]

void ProGe::PortFactory::registerPort ( const NetlistPort port)
private

Definition at line 83 of file NetlistFactories.cc.

83  {
84  assert(port->assignedSignal().type() != SignalType::UNDEFINED);
85  registerPort(port->assignedSignal().type(), port);
86 }

References assert, ProGe::NetlistPort::assignedSignal(), registerPort(), ProGe::Signal::type(), and ProGe::UNDEFINED.

Here is the call graph for this function:

◆ registerPort() [2/2]

void ProGe::PortFactory::registerPort ( SignalType  type,
const NetlistPort port 
)
private

Definition at line 77 of file NetlistFactories.cc.

77  {
79  portPrototypes_.insert(std::make_pair(type, port));
80 }

References assert, AssocTools::containsKey(), and portPrototypes_.

Referenced by registerPort(), and registerPorts().

Here is the call graph for this function:

◆ registerPortGroup() [1/2]

void ProGe::PortFactory::registerPortGroup ( const NetlistPortGroup portGroup)
private

Definition at line 103 of file NetlistFactories.cc.

103  {
104  assert(
105  portGroup->assignedSignalGroup().type() !=
107 
108  registerPortGroup(portGroup->assignedSignalGroup().type(), portGroup);
109 }

References assert, ProGe::NetlistPortGroup::assignedSignalGroup(), registerPortGroup(), ProGe::SignalGroup::type(), and ProGe::UNDEFINED.

Here is the call graph for this function:

◆ registerPortGroup() [2/2]

void ProGe::PortFactory::registerPortGroup ( SignalGroupType  type,
const NetlistPortGroup portGroup 
)
private

Definition at line 96 of file NetlistFactories.cc.

97  {
99  portGroupPrototypes_.insert(std::make_pair(type, portGroup));
100 }

References assert, AssocTools::containsKey(), and portGroupPrototypes_.

Referenced by registerPortGroup(), and registerPortGroups().

Here is the call graph for this function:

◆ registerPortGroups()

void ProGe::PortFactory::registerPortGroups ( )
private

Definition at line 112 of file NetlistFactories.cc.

112  {
113  registerPortGroup(new NetlistPortGroup(
115  new OutBitPort(
116  "imem_en_x", Signal(SignalType::READ_REQUEST, ActiveState::LOW)),
117  new OutPort(
118  "imem_addr", "IMEMADDRWIDTH", BIT_VECTOR,
119  Signal(SignalType::ADDRESS)),
120  new InPort(
121  "imem_data", "IMEMWIDTHINMAUS*IMEMMAUWIDTH", BIT_VECTOR,
122  Signal(SignalType::FETCHBLOCK)),
123  new InBitPort("busy", Signal(SignalType::STALL))));
124 }

References ProGe::ADDRESS, ProGe::BIT_VECTOR, ProGe::FETCHBLOCK, ProGe::INSTRUCTION_LINE, ProGe::LOW, ProGe::READ_REQUEST, registerPortGroup(), and ProGe::STALL.

Here is the call graph for this function:

◆ registerPorts()

void ProGe::PortFactory::registerPorts ( )
private

Definition at line 89 of file NetlistFactories.cc.

89  {
90  registerPort(new InBitPort("clk", Signal(SignalType::CLOCK)));
92  new InBitPort("rstx", Signal(SignalType::RESET, ActiveState::LOW)));
93 }

References ProGe::CLOCK, ProGe::LOW, registerPort(), and ProGe::RESET.

Here is the call graph for this function:

◆ resetPort()

NetlistPort * ProGe::PortFactory::resetPort ( Direction  direction = IN)
static

Creates default active-low reset port.

Definition at line 209 of file NetlistFactories.cc.

209  {
210  static const InBitPort rstxPortPrototype(
211  "rstx", Signal(SignalType::RESET, ActiveState::LOW));
212  return rstxPortPrototype.clone(direction != IN);
213 }

References ProGe::NetlistPort::clone(), ProGe::IN, ProGe::LOW, and ProGe::RESET.

Referenced by ProGe::LoopBufferBlock::LoopBufferBlock(), and ProGe::ProcessorWrapperBlock::ProcessorWrapperBlock().

Here is the call graph for this function:

Member Data Documentation

◆ instance_

PortFactory * ProGe::PortFactory::instance_ = NULL
staticprivate

Singleton instance of the factory.

Definition at line 102 of file NetlistFactories.hh.

Referenced by instance().

◆ portGroupPrototypes_

PortGroupPrototypeContainer ProGe::PortFactory::portGroupPrototypes_
private

Registered NetlistPortGroup prototypes.

Definition at line 99 of file NetlistFactories.hh.

Referenced by createPortGroup(), registerPortGroup(), and ~PortFactory().

◆ portPrototypes_

PortPrototypeContainer ProGe::PortFactory::portPrototypes_
private

The creation context.

The creation context. Registered NetlistPort prototypes.

Definition at line 97 of file NetlistFactories.hh.

Referenced by createPort(), registerPort(), and ~PortFactory().

◆ staticImplementation_

const IDF::MachineImplementation * ProGe::PortFactory::staticImplementation_ = NULL
staticprivate

The creation context for singleton instance.

Definition at line 106 of file NetlistFactories.hh.

Referenced by initializeContext(), and instance().

◆ staticMachine_

const TTAMachine::Machine * ProGe::PortFactory::staticMachine_ = NULL
staticprivate

The creation context for singleton instance.

Definition at line 104 of file NetlistFactories.hh.

Referenced by initializeContext(), and instance().


The documentation for this class was generated from the following files:
ProGe::SignalType::FETCHBLOCK
@ FETCHBLOCK
Signal is TTA instruction block block containing (compressed) instruction.
machine
TTAMachine::Machine * machine
the architecture definition of the estimated processor
Definition: EstimatorCmdLineUI.cc:59
ProGe::BIT_VECTOR
@ BIT_VECTOR
Several bits.
Definition: ProGeTypes.hh:48
ProGe::PortFactory::createPort
NetlistPort * createPort(SignalType type, Direction direction=IN) const
Definition: NetlistFactories.cc:134
AssocTools::containsKey
static bool containsKey(const ContainerType &aContainer, const KeyType &aKey)
ProGe::SignalType::RESET
@ RESET
Reset signal.
ProGe::SignalType::UNDEFINED
@ UNDEFINED
Signal does not have specified usage.
ProGe::SignalGroupType::INSTRUCTION_LINE
@ INSTRUCTION_LINE
Signal group type for serial TTA instruction bus.
assert
#define assert(condition)
Definition: Application.hh:86
ProGe::ActiveState::LOW
@ LOW
ProGe::PortFactory::staticMachine_
static const TTAMachine::Machine * staticMachine_
The creation context for singleton instance.
Definition: NetlistFactories.hh:104
ProGe::SignalType::STALL
@ STALL
Signal to stopping destination device.
ProGe::PortFactory::portPrototypes_
PortPrototypeContainer portPrototypes_
The creation context.
Definition: NetlistFactories.hh:97
ProGe::PortFactory::instance
static PortFactory * instance()
Definition: NetlistFactories.cc:184
ProGe::PortFactory::PortFactory
PortFactory()
Definition: NetlistFactories.cc:48
ProGe::PortFactory::staticImplementation_
static const IDF::MachineImplementation * staticImplementation_
The creation context for singleton instance.
Definition: NetlistFactories.hh:106
ProGe::PortFactory::registerPortGroup
void registerPortGroup(SignalGroupType type, const NetlistPortGroup *portGroup)
Definition: NetlistFactories.cc:96
ProGe::SignalType::ADDRESS
@ ADDRESS
Signal holds address.
ProGe::SignalType::CLOCK
@ CLOCK
Clock signal.
ProGe::SignalGroupType::UNDEFINED
@ UNDEFINED
ProGe::SignalType::READ_REQUEST
@ READ_REQUEST
Signal to make read request.
ProGe::PortFactory::instance_
static PortFactory * instance_
Singleton instance of the factory.
Definition: NetlistFactories.hh:102
ProGe::PortFactory::createPortGroup
NetlistPortGroup * createPortGroup(SignalGroupType type) const
Definition: NetlistFactories.cc:152
ProGe::NetlistTools::mirror
static Direction mirror(Direction direction)
Definition: NetlistTools.cc:202
ProGe::PortFactory::portGroupPrototypes_
PortGroupPrototypeContainer portGroupPrototypes_
Registered NetlistPortGroup prototypes.
Definition: NetlistFactories.hh:99
ProGe::IN
@ IN
Input port.
Definition: ProGeTypes.hh:53
ProGe::PortFactory::registerPort
void registerPort(SignalType, const NetlistPort *port)
Definition: NetlistFactories.cc:77