docstr: Write the main architecture header file (myproject.h)
  
  Args:
      model (ModelGraph): the hls4ml model.
docstr_tok: ["Write","the","main","architecture","header","file","(","myproject.h",")","Args",":","model","(","ModelGraph",")",":","the","hls4ml","model","."]
code: def write_project_header(self, model):
      """Write the main architecture header file (myproject.h)
  
      Args:
          model (ModelGraph): the hls4ml model.
      """
  
      project_name = model.config.get_project_name()
  
      filedir = os.path.dirname(os.path.abspath(__file__))
      f = open(
          os.path.join(
              filedir, "../templates/quartus/firmware/myproject.h"
          )
      )
      fout = open(
          f"{model.config.get_output_dir()}/firmware/{project_name}.h",
          "w",
      )
  
      model_inputs = model.get_input_variables()
      model_outputs = model.get_output_variables()
      model_brams = [
          var
          for var in model.get_weight_variables()
          if var.storage.lower() == "bram"
      ]
  
      # io_parallel and io_stream instantiate the top-level function differently
      io_type = model.config.get_config_value("IOType")
      indent = "    "
      brams_str = ", \n".join(
          [
              indent + b.definition_cpp(as_reference=False)
              for b in model_brams
          ]
      )
  
      for line in f.readlines():
          if "MYPROJECT" in line:
              newline = line.replace(
                  "MYPROJECT", format(project_name.upper())
              )
  
          elif "myproject" in line:
              newline = line.replace("myproject", project_name)
  
          elif (
              "// hls-fpga-machine-learning instantiate GCC top-level"
              in line
          ):
              newline = line
              # For io_stream, input and output are passed by reference; see myproject.h & myproject.cpp for more details
  
              if io_type == "io_stream":
                  newline += f"void {project_name}(\n"
                  for inp in model_inputs:
                      newline += (
                          indent
                          + f"stream_in<{inp.type.name}> &{inp.name}_stream,\n"
                      )
                  for out in model_outputs:
                      newline += (
                          indent
                          + f"stream_out<{out.type.name}> &{out.name}_stream,\n"
                      )
                  newline = newline[:-2]  # Remove the tailing ',\n'
                  if model_brams:
                      newline += ",\n" + brams_str
                  newline += "\n);\n"
              # In io_parallel, a struct is returned; see myproject.h & myproject.cpp for more details
              else:
                  newline += f"output_data {project_name}(\n"
                  newline += indent + "input_data inputs"
                  if model_brams:
                      newline += ",\n" + brams_str
                  newline += "\n);\n"
  
          # Similar to GCC instantiation, but with the keyword 'component'
          elif (
              "// hls-fpga-machine-learning instantiate HLS top-level"
              in line
          ):
              newline = line
              if io_type == "io_stream":
                  newline += f"component void {project_name}(\n"
                  for inp in model_inputs:
                      newline += (
                          indent
                          + f"stream_in<{inp.type.name}> &{inp.name}_stream,\n"
                      )
                  for out in model_outputs:
                      newline += (
                          indent
                          + f"stream_out<{out.type.name}> &{out.name}_stream,\n"
                      )
                  newline = newline[:-2]  # Remove the tailing ',\n'
                  if model_brams:
                      newline += ",\n" + brams_str
                  newline += "\n);\n"
              else:
                  newline += f"component output_data {project_name}(\n"
                  newline += indent + "input_data inputs"
                  if model_brams:
                      newline += ",\n" + brams_str
                  newline += "\n);\n"
  
          elif "// hls-fpga-machine-learning insert cpragmas" in line:
              newline = line
              if io_type == "io_parallel":
                  newline += "hls_max_concurrency(0)\n"
                  newline += f"hls_component_ii({self.get_max_reuse_factor(model)})\n"
              clock_mhz = 1000 / (
                  model.config.get_config_value("ClockPeriod")
              )
              newline += f"hls_scheduler_target_fmax_mhz({np.ceil(clock_mhz).astype(int)})\n"
  
          # For io_stream, no inputs/outputs are instantiated, as they are passed by reference
          # For io_parallel, input/output structs are required
          elif "// hls-fpga-machine-learning insert inputs" in line:
              newline = line
              if io_type != "io_stream":
                  newline += "struct input_data { \n"
                  for inp in model_inputs:
                      newline += indent + inp.definition_cpp() + ";\n"
                  newline += "};\n"
          elif "// hls-fpga-machine-learning insert outputs" in line:
              newline = line
              if io_type != "io_stream":
                  newline += "struct output_data { \n"
                  for out in model_outputs:
                      newline += indent + out.definition_cpp() + ";\n"
                  newline += "};\n"
          # Simply copy line, if no inserts are required
          else:
              newline = line
  
          fout.write(newline)
  
      f.close()
      fout.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 7 for calling the QuartusWriter obj's underlying member method code with example usage: obj.write_project_header(model) without return types