docstr: Write a weights array to C++ header files.
  
  Args:
      var (WeightVariable): Weight to write
      layer (Layer): Instance of the layer to which the weights belong
      odir (str): Output directory
docstr_tok: ["Write","a","weights","array","to","C++","header","files",".","Args",":","var","(","WeightVariable",")",":","Weight","to","write","layer","(","Layer",")",":","Instance","of","the","layer","to","which","the","weights","belong","odir","(","str",")",":","Output","directory"]
code: def print_array_to_cpp(self, var, layer, odir):
      """Write a weights array to C++ header files.
  
      Args:
          var (WeightVariable): Weight to write
          layer (Layer): Instance of the layer to which the weights belong
          odir (str): Output directory
      """
      h_file = open(f"{odir}/firmware/weights/{var.name}.h", "w")
  
      # meta data
      h_file.write(f"//Numpy array shape {var.shape}\n")
      h_file.write(f"//Min {np.min(var.min):.12f}\n")
      h_file.write(f"//Max {np.max(var.max):.12f}\n")
      h_file.write(f"//Number of zeros {var.nzeros}\n")
      h_file.write("\n")
  
      h_file.write(f"#ifndef {var.name.upper()}_H_\n")
      h_file.write(f"#define {var.name.upper()}_H_\n")
      h_file.write("\n")
  
      rf = int(layer.get_attr("reuse_factor", 1))
      weight_header = "#ifdef __INTELFPGA_COMPILER__\n"
  
      weight_size = 0
      if isinstance(layer, (Conv2D, Conv2DBatchnorm)):
          weight_size = (
              layer.get_attr("impl_filt_height")
              * layer.get_attr("impl_filt_width")
              * layer.get_attr("n_filt")
              * layer.get_attr("n_chan")
          )
      elif isinstance(layer, (Conv1D)):
          weight_size = (
              layer.get_attr("impl_filt_width")
              * layer.get_attr("n_filt")
              * layer.get_attr("n_chan")
          )
      elif isinstance(layer, (Dense)):
          weight_size = layer.get_attr("n_in") * layer.get_attr("n_out")
  
      if (
          rf == 1
          or var.name[0] == "b"
          or weight_size <= 2048
          or (var.name[0] == "w" and var.type.precision.width < 3)
      ):
          weight_header += "hls_init_on_powerup\n"
      else:
          block_factor = (
              layer.get_attr("n_in") * layer.get_attr("n_out")
          ) / rf
          nbanks = int(2 ** np.ceil(np.log2(block_factor)) / 2)
          var_width = int(np.ceil(var.type.precision.width / 8))
          bwidth = self.next_pow2(var_width)
          weight_header += f'hls_bankwidth({bwidth})\nhls_numbanks({nbanks})\nhls_max_replicates(1)\nhls_memory_impl("BLOCK_RAM")\n'
      weight_header += "#endif\n"
      if var.storage.lower() == "bram":
          weight_header += "static "
      else:
          weight_header += "static const "
      h_file.write(weight_header + var.definition_cpp() + " = {")
  
      # fill c++ array.
      # not including internal brackets for multidimensional case
      sep = ""
      for x in var:
          h_file.write(sep + x)
          sep = ", "
      h_file.write("};\n")
      h_file.write("\n#endif\n")
      h_file.close()
  
imports: import glob
  import os
  import tarfile
  from collections import OrderedDict
  from shutil import copyfile, copytree, rmtree
  import numpy
  import yaml
  from hls4ml.backends import get_backend
  from hls4ml.model.layers import Conv1D, Conv2D, Conv2DBatchnorm, Dense
  from hls4ml.utils.fixed_point_utils import FixedPointEmulator, ceil_log2, uint_to_binary
  from hls4ml.writer.writers import Writer
label_desc: Use image node_id 4 for calling the QuartusWriter obj's underlying member method code with example usage: obj.print_array_to_cpp(var, layer, odir) without return types