Skip to content
Snippets Groups Projects
Commit d757fb53 authored by auphelia's avatar auphelia
Browse files

[Code generation] Added function to determine the number of FIFOs and...

[Code generation] Added function to determine the number of FIFOs and intergrated it into the generation of the stream declarations to help writing the parameters as variables into the commands
parent f9d8ad66
No related branches found
No related tags found
No related merge requests found
...@@ -25,17 +25,42 @@ def get_layer_attributes(node): ...@@ -25,17 +25,42 @@ def get_layer_attributes(node):
def strm_decl(model, code_gen_dict): def strm_decl(model, code_gen_dict):
num_FIFOs = get_num_of_FIFOs(model)
code_gen_dict["stream_declarations"] = [] code_gen_dict["stream_declarations"] = []
FIFO_ind = 1
for node in model.graph.node: for node in model.graph.node:
if node.op_type == "FIFO": if node.op_type == "FIFO":
name = node.name name = node.name
# last number in input shape determines the bits per cycle if FIFO_ind == 1:
bits_per_cycle = (model.get_tensor_shape(node.input[0]))[2] code_gen_dict["stream_declarations"].append(
code_gen_dict["stream_declarations"].append( 'hls::stream<ap_uint<L{}_SIMD>> {}("DoCompute.{}");'.format(
'hls::stream<ap_uint<{}>> {}("DoCompute.{}");'.format( FIFO_ind - 1, name, name
bits_per_cycle, name, name )
) )
) # TO DO: check if elif and else path can be summarized
elif FIFO_ind == num_FIFOs:
code_gen_dict["stream_declarations"].append(
'hls::stream<ap_uint<L{}_PE>> {}("DoCompute.{}");'.format(
FIFO_ind - 2, name, name
)
)
else:
code_gen_dict["stream_declarations"].append(
"hls::stream<ap_uint<L{}_PE * (L{}_AP + L{}_APF)>> "
'{}("DoCompute.{}");'.format(
FIFO_ind - 2, FIFO_ind - 2, FIFO_ind - 2, name, name
)
)
FIFO_ind += 1
def get_num_of_FIFOs(model):
i = 0
for node in model.graph.node:
if node.op_type == "FIFO":
i += 1
return i
def strm_prgm(model, code_gen_dict): def strm_prgm(model, code_gen_dict):
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment