diff --git a/src/finn/backend/fpgadataflow/utils.py b/src/finn/backend/fpgadataflow/utils.py
index b0268237739476e3a8fb99377fda9f76a6a8c5c2..0f3049ec70050657c4a648fe8b51a2d16691bed0 100644
--- a/src/finn/backend/fpgadataflow/utils.py
+++ b/src/finn/backend/fpgadataflow/utils.py
@@ -6,11 +6,15 @@ from finn.core.datatype import DataType
 from finn.core.utils import pack_innermost_dim_as_hex_string
 
 
-def numpy_to_hls_code(ndarray, dtype, hls_var_name, pack_innermost_dim=True):
+def numpy_to_hls_code(
+    ndarray, dtype, hls_var_name, pack_innermost_dim=True, no_decl=False
+):
     """Return C++ code representation of a numpy ndarray with FINN DataType
     dtype, using hls_var_name as the resulting C++ variable name. If
     pack_innermost_dim is specified, the innermost dimension of the ndarray
-    will be packed into a hex string using array2hexstring.
+    will be packed into a hex string using array2hexstring. If no_decl is
+    set to True, no variable name and type will be generated as part of the
+    emitted string.
     """
     hls_dtype = dtype.get_hls_datatype_str()
     if type(ndarray) != np.ndarray or ndarray.dtype != np.float32:
@@ -47,5 +51,8 @@ def numpy_to_hls_code(ndarray, dtype, hls_var_name, pack_innermost_dim=True):
     strarr = np.array2string(ndarray, separator=", ", formatter={"all": elem2str})
     np.set_printoptions(**orig_printops)
     strarr = strarr.replace("[", "{").replace("]", "}")
-    ret = ret + " = \n" + strarr + ";"
+    if no_decl:
+        ret = strarr + ";"
+    else:
+        ret = ret + " = \n" + strarr + ";"
     return ret
diff --git a/tests/test_npy2hls.py b/tests/test_npy2hls.py
index ea54d900a8e3a06b53cb4074072b15747c6c598c..34893251e3e39923c64c597caded39a886246f49 100644
--- a/tests/test_npy2hls.py
+++ b/tests/test_npy2hls.py
@@ -41,3 +41,7 @@ def test_numpy_to_hls_code():
     {{ap_uint<4>("f", 16), ap_uint<4>("f", 16)},
      {ap_uint<4>("7", 16), ap_uint<4>("d", 16)}};"""
     assert remove_all_whitespace(ret) == remove_all_whitespace(eB)
+    ret = numpy_to_hls_code(B, DataType.UINT2, "test", True, True)
+    eB = """{{ap_uint<4>("f", 16), ap_uint<4>("f", 16)},
+     {ap_uint<4>("7", 16), ap_uint<4>("d", 16)}};"""
+    assert remove_all_whitespace(ret) == remove_all_whitespace(eB)