@@ -379,24 +379,40 @@ def read_npy_data(self):
379379 if dtype == DataType ["BIPOLAR" ]:
380380 # use binary for bipolar storage
381381 dtype = DataType ["BINARY" ]
382- elem_bits = dtype .bitwidth ()
383- packed_bits = self .get_instream_width ()
384- packed_hls_type = "ap_uint<%d>" % packed_bits
385382 elem_hls_type = dtype .get_hls_datatype_str ()
386383 npy_type = "float"
387384 npy_in = "%s/input_0.npy" % code_gen_dir
388385 self .code_gen_dict ["$READNPYDATA$" ] = []
389- self .code_gen_dict ["$READNPYDATA$" ].append (
390- 'npy2apintstream<%s, %s, %d, %s>("%s", in0_%s);'
391- % (
392- packed_hls_type ,
393- elem_hls_type ,
394- elem_bits ,
395- npy_type ,
396- npy_in ,
397- self .hls_sname (),
386+
387+ cpp_interface = self .get_nodeattr ("cpp_interface" )
388+
389+ if cpp_interface == "packed" :
390+ elem_bits = dtype .bitwidth ()
391+ packed_bits = self .get_instream_width ()
392+ packed_hls_type = "ap_uint<%d>" % packed_bits
393+ self .code_gen_dict ["$READNPYDATA$" ].append (
394+ 'npy2apintstream<%s, %s, %d, %s>("%s", in0_%s);'
395+ % (
396+ packed_hls_type ,
397+ elem_hls_type ,
398+ elem_bits ,
399+ npy_type ,
400+ npy_in ,
401+ self .hls_sname (),
402+ )
403+ )
404+ else :
405+ folded_shape = self .get_folded_input_shape ()
406+ self .code_gen_dict ["$READNPYDATA$" ].append (
407+ 'npy2vectorstream<%s, %s, %d>("%s", in0_%s, false);'
408+ % (
409+ elem_hls_type ,
410+ npy_type ,
411+ folded_shape [- 1 ],
412+ npy_in ,
413+ self .hls_sname (),
414+ )
398415 )
399- )
400416
401417 def strm_decl (self ):
402418 """Function to generate the commands for the stream declaration in c++,
@@ -456,12 +472,13 @@ def dataoutstrm(self):
456472 )
457473 ]
458474 else :
475+ folded_shape = self .get_folded_output_shape ()
459476 self .code_gen_dict ["$DATAOUTSTREAM$" ] = [
460- 'vectorstream2npy<%s, %s, SIMD>(debug_out_%s , %s, "%s");'
477+ 'vectorstream2npy<%s, %s, %d>(strm , %s, "%s");'
461478 % (
462479 elem_hls_type ,
463480 npy_type ,
464- self . hls_sname () ,
481+ folded_shape [ - 1 ] ,
465482 oshape_cpp_str ,
466483 npy_out ,
467484 )
@@ -509,5 +526,5 @@ def timeout_condition(self):
509526 def timeout_read_stream (self ):
510527 """Set reading output stream procedure for HLS functions defined for one clock cycle"""
511528 self .code_gen_dict ["$TIMEOUT_READ_STREAM$" ] = [
512- "debug_out_{} << out_{}.read();" .format (self . hls_sname (), self .hls_sname ())
529+ "strm << out_{}.read();" .format (self .hls_sname ())
513530 ]
0 commit comments