Skip to content
Snippets Groups Projects
Commit 040f4916 authored by Daniel van der Schuur's avatar Daniel van der Schuur
Browse files

-Removed example designs and components.

parent 63d448b7
No related branches found
No related tags found
No related merge requests found
...@@ -237,224 +237,3 @@ class Component(mp.Process): ...@@ -237,224 +237,3 @@ class Component(mp.Process):
return result return result
###############################################################################
# Component subclasses
###############################################################################
class SingleCounter(Component):
def __init__(self, data_width=32, inst_nr=None):
Component.__init__(self, inst_nr=inst_nr, name='SingleCounter')
self.vhdl_instance = 'A string that contains the SingleCounter VHDL instance\n'
self.set_output('src_out', data_width)
def run(self):
for value in xrange(10):
if self.inst_nr==None:
cnt_offset=0
else:
cnt_offset = self.inst_nr * 100
item = value + cnt_offset
print '[Counter] src', self.inst_nr, ': sending', item
# Offset sent value by 100 for each instance number increment
self.ports['src_out'].send(item)
class SinglePrinter(Component):
def __init__(self, data_width=32, inst_nr=None):
Component.__init__(self, inst_nr=inst_nr, name='SinglePrinter')
self.vhdl_instance = 'A string that contains the SinglePrinter VHDL instance\n'
self.set_input('snk_in', data_width)
def run(self):
for item in self.ports['snk_in'].recv():
print '[Printer] snk', self.inst_nr, ': receiving', item
class Counter(Component):
def __init__(self, nof_streams, data_width=32, inst_nr=None):
Component.__init__(self, inst_nr=inst_nr, name='Counter')
self.vhdl_instance = 'A string that contains the Counter VHDL instance\n'
self.set_output('src_out_arr', (nof_streams, data_width))
def run(self):
for value in xrange(10):
for src in self.ports['src_out_arr']:
item = value + src.stream_index*100
print '[Counter] src', src.stream_index, ': sending', item
# Offset sent value by 100 for each incremental stream
src.send(item)
class Through(Component):
def __init__(self, nof_streams, data_width=32, inst_nr=None):
Component.__init__(self, inst_nr=inst_nr, name='Through')
self.vhdl_instance = 'A string that contains the Through VHDL instance\n'
self.set_input('snk_in_arr', (nof_streams, data_width))
self.set_output('src_out_arr', (nof_streams, data_width))
def run(self):
for items in self.ports['snk_in_arr'].recv():
for item,src in zip(items, self.ports['src_out_arr']):
print '[Through] snk', src.stream_index, ': forwarding', item, 'to src', src.stream_index
src.send(item)
class Printer(Component):
def __init__(self, nof_streams, data_width=32, inst_nr=None):
Component.__init__(self, inst_nr=inst_nr, name='Printer')
self.vhdl_instance = 'A string that contains the Printer VHDL instance\n'
self.set_input('snk_in_arr', (nof_streams, data_width))
def run(self):
for items in self.ports['snk_in_arr'].recv():
for item_index, item in enumerate(items):
print '[Printer] snk', item_index, ': receiving', item
###############################################################################
# Help function for keypress
###############################################################################
def press_enter():
try:
input("Press enter to continue")
except SyntaxError:
pass
###############################################################################
# Main
###############################################################################
print
print '###############################################################################'
print '# Example 1: connect ports component-wise'
print '###############################################################################'
print
nof_streams = 3
a = Counter(nof_streams)
b = Through(nof_streams)
c = Printer(nof_streams)
connections = [ a>b>c ]
d = Component('my_component_1', [a,b,c], connections)
d.run_time(1)
d.generate()
press_enter()
print
print '###############################################################################'
print '# Example 2: connect ports array-wise'
print '###############################################################################'
print
nof_streams = 3
a = Counter(nof_streams)
b = Through(nof_streams)
c = Printer(nof_streams)
connections = []
connections.append( a.ports['src_out_arr'] > b.ports['snk_in_arr' ] )
connections.append( b.ports['src_out_arr'] > c.ports['snk_in_arr'] )
d = Component('my_component_2', [a,b,c], connections)
d.run_time(1)
d.generate()
press_enter()
print
print '###############################################################################'
print '# Example 3: connect ports stream-wise (with stream 0 / stream 1 swap)'
print '###############################################################################'
print
nof_streams = 3
a = Counter(nof_streams)
b = Through(nof_streams)
c = Printer(nof_streams)
connections = []
connections.append( a.ports['src_out_arr'][0] > b.ports['snk_in_arr' ][0] )
connections.append( a.ports['src_out_arr'][1] > b.ports['snk_in_arr' ][1] )
connections.append( a.ports['src_out_arr'][2] > b.ports['snk_in_arr' ][2] )
connections.append( b.ports['src_out_arr'][1] > c.ports['snk_in_arr'][0] ) # We're swapping streams 0 and 1 here
connections.append( b.ports['src_out_arr'][0] > c.ports['snk_in_arr'][1] ) # We're swapping streams 0 and 1 here
connections.append( b.ports['src_out_arr'][2] > c.ports['snk_in_arr'][2] )
d = Component('my_component_3', [a,b,c], connections)
d.run_time(1)
d.generate()
press_enter()
print
print '###############################################################################'
print '# Example 4: Mix single and multi stream components'
print '###############################################################################'
print
nof_streams = 1
a = SingleCounter()
b = Through(nof_streams)
c = Printer(nof_streams)
connections = []
connections.append( a.ports['src_out'] > b.ports['snk_in_arr' ][0] )
connections.append( b.ports['src_out_arr'] > c.ports['snk_in_arr'] )
d = Component('my_component_4', [a,b,c], connections)
d.run_time(1)
d.generate()
press_enter()
print
print '###############################################################################'
print '# Example 5: Creating multi-instance composites from single stream components'
print '# . We replace the Counter with a new component that instantiates 3 SingeCounters'
print '# . We replace the Printer with a new component that instantiates 3 SingePrinters'
print '###############################################################################'
print
nof_streams = 3
data_width = 32
# Create [nof_streams] SingleCounter instances
a_list = []
for i in range(nof_streams):
a_list.append(SingleCounter(inst_nr=i))
# Create a new components wrapping these SingleCounter instances
a_multi = Component('a_multi', a_list)
# Declare the output of this new component
a_multi.set_output('src_out_arr', (nof_streams, data_width))
# Forward the SingleCounter outputs to the new component's output
for i in range(nof_streams):
a_multi.components[i].ports['src_out'] > a_multi.ports['src_out_arr'][i]
# Unchanged: the Through component
b = Through(nof_streams)
# Create [nof_streams] SinglePrinter instances
c_list = []
for i in range(nof_streams):
c_list.append(SinglePrinter(inst_nr=i))
# Create a new components wrapping these SinglePrinter instances
c_multi = Component('c_multi', c_list)
# Declare the input of this new component
c_multi.set_input('snk_in_arr', (nof_streams, data_width))
# Forward the new component's input to the SinglePrinter inputs
for i in range(nof_streams):
c_multi.ports['snk_in_arr'][i] > c_multi.components[i].ports['snk_in']
# Continue as before (in the other examples)
connections = [ a_multi>b>c_multi ]
d = Component('my_component_5', [a_multi,b,c_multi], connections)
d.run_time(1)
d.generate()
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment