OpenASIP 2.2
Loading...
Searching...
No Matches
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.
 
PortGroupPrototypeContainer portGroupPrototypes_
 Registered NetlistPortGroup prototypes.
 

Static Private Attributes

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

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 =
69 while (portGroup_it != portGroupPrototypes_.end()) {
70 delete portGroup_it->second;
71 portGroup_it->second = NULL;
72 portGroup_it++;
73 }
74}
PortPrototypeContainer portPrototypes_
The creation context.
PortGroupPrototypeContainer portGroupPrototypes_
Registered NetlistPortGroup prototypes.

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}
@ IN
Input port.
Definition ProGeTypes.hh:53
@ CLOCK
Clock signal.

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}
NetlistPortGroup * createPortGroup(SignalGroupType type) const
static PortFactory * instance()

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}
NetlistPort * createPort(SignalType type, Direction direction=IN) const

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}
static Direction mirror(Direction direction)

References ProGe::NetlistPort::clone(), 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 ProGe::NetlistPortGroup::clone(), and portGroupPrototypes_.

Referenced by create().

Here is the call graph for this function:

◆ 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}
#define assert(condition)
TTAMachine::Machine * machine
the architecture definition of the estimated processor
static const IDF::MachineImplementation * staticImplementation_
The creation context for singleton instance.
static const TTAMachine::Machine * staticMachine_
The creation context for singleton instance.

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}
static PortFactory * instance_
Singleton instance of the factory.

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

Referenced by create(), and 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}
void registerPort(SignalType, const NetlistPort *port)
@ UNDEFINED
Signal does not have specified usage.

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}
static bool containsKey(const ContainerType &aContainer, const KeyType &aKey)

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}
void registerPortGroup(SignalGroupType type, const NetlistPortGroup *portGroup)

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}
@ BIT_VECTOR
Several bits.
Definition ProGeTypes.hh:48
@ INSTRUCTION_LINE
Signal group type for serial TTA instruction bus.
@ READ_REQUEST
Signal to make read request.
@ ADDRESS
Signal holds address.
@ FETCHBLOCK
Signal is TTA instruction block block containing (compressed) instruction.
@ STALL
Signal to stopping destination device.

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}
@ RESET
Reset signal.

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: