<!doctype html>
<html lang="en">
  <head>
    <!-- Required meta tags -->
    <meta charset="utf-8" />
    <meta
      name="viewport"
      content="width=device-width, initial-scale=1, shrink-to-fit=no"
    />

    <!-- Bootstrap CSS -->
    <link
      href="https://cdn.jsdelivr.net/npm/bootstrap@5.0.2/dist/css/bootstrap.min.css"
      rel="stylesheet"
      integrity="sha384-EVSTQN3/azprG1Anm3QDgpJLIm9Nao0Yz1ztcQTwFspd3yD65VohhpuuCOmLASjC"
      crossorigin="anonymous"
    />

    <style>
      .disabled-checkbox {
        opacity: 0.5; /* Make the checkbox semi-transparent */
        pointer-events: none; /* Disable mouse events on the checkbox */
      }

      .disabled-checkbox + label {
        color: #808080; /* Change label color to gray */
      }
    </style>

    <title>MNT Bench</title>
    <link
      rel="shortcut icon"
      href="{{ url_for('static', filename='favicon.ico') }}"
    />
  </head>
  <body onload="disable_all()">
    <!-- Image and text -->
    <nav class="navbar navbar-expand-lg navbar-light bg-light fixed-top">
      <a class="navbar-brand" href="/mntbench">
        <img
          src="{{ url_for('static', filename='tum_logo.svg') }}"
          alt=""
          width="50"
          height="24"
          class="d-inline-block align-text-top"
        />
        MNT Bench
      </a>
      <button
        class="navbar-toggler"
        type="button"
        data-toggle="collapse"
        data-target="#navbarNavAltMarkup"
        aria-controls="navbarNavAltMarkup"
        aria-expanded="false"
        aria-label="Toggle navigation"
      >
        <span class="navbar-toggler-icon"></span>
      </button>
      <div class="collapse navbar-collapse" id="navbarNavAltMarkup">
        <div class="navbar-nav">
          <a class="nav-item nav-link active" href="index">Benchmarks</a>
          <a class="nav-item nav-link" href="description"
            >Level and File Descriptions</a
          >
          <a
            class="nav-item nav-link"
            href="https://www.cda.cit.tum.de/research/fcn/"
            target="_blank"
            >More on our Work</a
          >
          <a class="nav-item nav-link" href="legal">Legal Information</a>
        </div>
      </div>
    </nav>

    <div class="col-md-12" style="height: 80px"></div>
    <p align="center">
      <img src="{{ url_for('static', filename='mnt_dark.svg')}}" width="20%" />
    </p>
    <div class="container">
      <h1>Welcome to the Munich Nanotech Benchmark Library (MNT Bench)!</h1>
      <p>
        The development and improvement of physical design tools for
        <em>Field-coupled Nanocomputing</em> (FCN) is critical to the success of
        this emerging technology. To compare the results of new physical design
        algorithms, this benchmark suite provides common benchmark functions in
        the field combined with state-of-the-art layouts. In addition to layouts
        using different gate sets, such as the <em>QCA ONE</em> gate library for
        <em>Quantum-dot Cellular Automata</em> (QCA) or <em>Bestagon</em> for
        <em>Silicon Dangling Bonds</em> (SiDBS), the following benchmark library
        also differentiates between different underlying clocking schemes such
        as <em>2DDWave</em>, <em>USE</em>, <em>RES</em>, <em>ESR</em> or
        <em>ROW</em>. Furthermore, all layouts have been verified using
        <a href="https://github.com/cda-tum/fiction" target="_blank"
          ><em>fiction</em></a
        >'s equivalence checker.
      </p>
      <p>
        All layouts can be downloaded as fiction gate-level layouts files (<span
          style="font-family: monospace"
          >.fgl</span
        >), which can be parsed and generated by
        <a href="https://github.com/cda-tum/fiction" target="_blank"
          ><em>fiction</em></a
        >.
      </p>

      <p>
        In order to create a benchmark set according to your needs, simply fill
        out the form below.
      </p>
    </div>
    <form
      method="POST"
      class="form-inline"
      role="form"
      action="download"
      id="benchmark_form"
      onchange="checks_on_change()"
    >
      <div class="container">
        <div class="row">
          <h4>Benchmark Selection</h4>
          <p class="text-justify">
            Please select the desired benchmarks from the set of all available
            ones or select all
            <input
              class="form-check-input"
              type="checkbox"
              value="true"
              id="all_benchmarks"
              name="all_benchmarks"
              onchange="toggleAllSelection()"
            />.
          </p>
        </div>
        <div class="row border border-secondary">
          <div class="row"></div>
          <div class="row d-flex"></div>
          <div class="col-md-6">
            <h6 style="margin-bottom: 0px">
              <a
                href="https://ieeexplore.ieee.org/document/7724048"
                target="_blank"
                >Trindade16</a
              >
              Benchmarks
              <input
                class="form-check-input"
                type="checkbox"
                value="true"
                id="trindade16_benchmarks"
                name="trindade16_benchmarks"
                onchange="toggleTrindade16Selection()"
              />:
            </h6>

            {% for benchmark_trindade in trindade %}

            <div>
              <div class="col-md-12">
                <input
                  class="form-check-input"
                  type="checkbox"
                  value="{{ benchmark_trindade.name }}"
                  id="selectBench_{{ benchmark_trindade.id }}"
                  name="selectBench_{{ benchmark_trindade.id }}"
                />
                {{ benchmark_trindade.name }}
              </div>
            </div>
            {% endfor %}
          </div>

          <div class="col-md-6">
            <h6 style="margin-bottom: 0px">
              <a
                href="https://ieeexplore.ieee.org/document/8351001"
                target="_blank"
                >Fontes18</a
              >
              Benchmarks
              <input
                class="form-check-input"
                type="checkbox"
                value="true"
                id="fontes18_benchmarks"
                name="fontes18_benchmarks"
                onchange="toggleFontes18Selection()"
              />:
            </h6>

            {% for benchmark_fontes in fontes %}

            <div>
              <div class="col-md-12">
                <input
                  class="form-check-input"
                  type="checkbox"
                  value="{{ benchmark_fontes.name }}"
                  id="selectBench_{{ benchmark_fontes.id }}"
                  name="selectBench_{{ benchmark_fontes.id }}"
                />
                {{ benchmark_fontes.name }}
              </div>
            </div>

            {% endfor %}
          </div>

          <div class="col-md-6">
            <h6 style="margin-bottom: 0px">
              <a
                href="https://www.researchgate.net/publication/273775783_A_neutral_netlist_of_10_combinational_benchmark_circuits_and_a_targeted_translator_in_FORTRAN"
                target="_blank"
                >ISCAS85</a
              >
              Benchmarks
              <input
                class="form-check-input"
                type="checkbox"
                value="true"
                id="iscas85_benchmarks"
                name="iscas85_benchmarks"
                onchange="toggleISCAS85Selection()"
              />:
            </h6>

            {% for benchmark_iscas in iscas %}

            <div>
              <div class="col-md-12">
                <input
                  class="form-check-input"
                  type="checkbox"
                  value="{{ benchmark_iscas.name }}"
                  id="selectBench_{{ benchmark_iscas.id }}"
                  name="selectBench_{{ benchmark_iscas.id }}"
                />
                {{ benchmark_iscas.name }}
              </div>
            </div>

            {% endfor %}
          </div>

          <div class="col-md-6">
            <h6 style="margin-bottom: 0px">
              <a
                href="https://www.epfl.ch/labs/lsi/page-102566-en-html/benchmarks/"
                target="_blank"
                >EPFL</a
              >
              Benchmarks
              <input
                class="form-check-input"
                type="checkbox"
                value="true"
                id="epfl_benchmarks"
                name="epfl_benchmarks"
                onchange="toggleEPFLSelection()"
              />:
            </h6>

            {% for benchmark_epfl in epfl %}

            <div>
              <div class="col-md-12">
                <input
                  class="form-check-input"
                  type="checkbox"
                  value="{{ benchmark_epfl.name }}"
                  id="selectBench_{{ benchmark_epfl.id }}"
                  name="selectBench_{{ benchmark_epfl.id }}"
                />
                {{ benchmark_epfl.name }}
              </div>
            </div>

            {% endfor %}
          </div>
        </div>

        <div class="col-md-12" style="height: 20px"></div>
        <h4>Technology Selection</h4>
        <p class="text-justify" style="margin: 0px">
          Next, technological specifications for the selected benchmarks must be
          chosen. The gate library defines the selection of gates that can be
          used, while the clocking scheme defines the underlying arrangement of
          clock zones on the layout. For details, see
          <a href="description" target="_blank">the level description</a>.
        </p>
      </div>

      <div class="col-md-12" style="height: 20px"></div>
      <div class="container">
        <div class="row">
          <div
            class="col border border-secondary"
            style="width: 25%; min-width: 200px; margin: 1px"
          >
            <h6>Abstraction Level</h6>
            <p class="text-justify" style="margin: 0px">
              Select the abstraction level:
            </p>
            <div class="d-flex">
              <div class="col-md-6 align-items-center">
                <input
                  class="form-check-input"
                  type="checkbox"
                  id="network"
                  name="network"
                  value="true"
                />
                <label for="network">Network</label>
              </div>

              <div class="col-md-6 align-items-center">
                <input
                  class="form-check-input"
                  type="checkbox"
                  id="gate"
                  name="gate"
                  value="true"
                />
                <label for="gate">Gate-level</label>
              </div>
            </div>
          </div>

          <div
            class="col border border-secondary"
            style="width: 25%; min-width: 200px; margin: 1px"
          >
            <h6>Gate Library</h6>
            <p class="text-justify" style="margin: 0px">
              Select the used gate library:
            </p>
            <div class="d-flex">
              <div class="col-md-6 align-items-center">
                <input
                  class="form-check-input"
                  type="checkbox"
                  id="one"
                  name="one"
                  value="true"
                />
                <label for="one">QCA ONE</label>
              </div>

              <div class="col-md-6 align-items-center">
                <input
                  class="form-check-input"
                  type="checkbox"
                  id="bestagon"
                  name="bestagon"
                  value="true"
                />
                <label for="bestagon">Bestagon</label>
              </div>
            </div>
          </div>

          <div
            class="col border border-secondary"
            style="width: 25%; min-width: 200px; margin: 1px"
          >
            <h6>Clocking Scheme</h6>

            <p class="text-justify" style="margin: 0px">
              Select the underlying clocking scheme:
            </p>
            <div class="row">
              <div class="col-md-12 align-items-center">
                <div class="form-group">
                  <input
                    class="form-check-input"
                    type="checkbox"
                    value="true"
                    id="twoddwave"
                    name="twoddwave"
                  />
                  <label for="twoddwave">2DDWave</label>
                </div>
                <div class="form-group">
                  <input
                    class="form-check-input"
                    type="checkbox"
                    value="true"
                    id="use"
                    name="use"
                  />
                  <label for="use">USE</label>
                </div>
                <div class="form-group">
                  <input
                    class="form-check-input"
                    type="checkbox"
                    value="true"
                    id="res"
                    name="res"
                  />
                  <label for="res">RES</label>
                </div>
                <div class="form-group">
                  <input
                    class="form-check-input"
                    type="checkbox"
                    value="true"
                    id="esr"
                    name="esr"
                  />
                  <label for="esr">ESR</label>
                </div>
                <div class="form-group">
                  <input
                    class="form-check-input"
                    type="checkbox"
                    value="true"
                    id="row"
                    name="row"
                  />
                  <label for="row">Row</label>
                </div>
              </div>
            </div>
          </div>
        </div>
        <div class="col-md-12" style="height: 20px"></div>
        <h4>Download</h4>
        <p class="text-justify"></p>
        <div class="d-flex">
          <div class="same_row">Number of selected benchmarks: &nbsp;</div>
          <div class="same_row" id="num_benchmarks">0</div>
        </div>
        After the download button is clicked, all benchmark functions provided
        as <span style="font-family: monospace">.v</span> files and selected
        layouts provided as
        <span style="font-family: monospace">.fgl</span> files are downloaded as
        a <em>.zip</em> archive. Details of the
        <a href="description" target="_blank">file format</a> are provided.
        Alternatively, a pre-generated archive with <em>all</em> benchmarks can
        be <a href="get_pre_gen">downloaded</a>.

        <div class="text-center">
          <button
            type="submit"
            class="btn btn-primary btn-lg mx-auto text-center"
            id="downloadButton"
            disabled
            value="submit"
          >
            Download selected Benchmarks
          </button>
        </div>
      </div>
    </form>

    <div class="col-md-12" style="height: 20px"></div>

    <div class="container">
      <p>
        In case you have any problems or questions feel free to contact us via
        <a href="mailto:nanotech.cda@xcit.tum.de">nanotech.cda@xcit.tum.de</a>.
        More on our work on nanotechnologies is summarized on
        <a href="https://www.cda.cit.tum.de/research/fcn" target="_blank"
          >this page</a
        >.
      </p>
    </div>

    <!-- Optional JavaScript -->
    <!-- jQuery first, then Popper.js, then Bootstrap JS -->
    <script
      src="https://code.jquery.com/jquery-3.3.1.min.js"
      integrity="sha256-FgpCb/KJQlLNfOu91ta32o/NMZxltwRo8QtmkMRdAu8="
      crossorigin="anonymous"
    ></script>
    <script
      src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.12.9/umd/popper.min.js"
      integrity="sha384-ApNbgh9B+Y1QKtv3Rn7W3mgPxhU9K/ScQsAP7hUibX39j7fakFPskvXusvfa0b4Q"
      crossorigin="anonymous"
    ></script>
    <script
      src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/js/bootstrap.min.js"
      integrity="sha384-JZR6Spejh4U02d8jOt6vLEHfe/JQGiRRSQQxSfFWpi1MquVdAyjUar5+76PVCmYl"
      crossorigin="anonymous"
    ></script>

    <script>
      function toggleAllSelection() {
          var ids = {{trindade | length}}+{{fontes | length }}+{{iscas | length }}+{{epfl | length }}
          for (let i = 1; i <= ids; i++) {
              document.getElementById("selectBench_" + i).checked = all_benchmarks.checked
          }
      }

      function toggleTrindade16Selection() {
          var start = 1
          var ids = {{trindade | length}}
          for (let i = start; i <= ids; i++) {
              document.getElementById("selectBench_" + i).checked = trindade16_benchmarks.checked
          }
      }

      function toggleFontes18Selection() {
          var start = {{trindade | length}}+1
          var ids = {{trindade | length}}+{{fontes | length }}
          for (let i = start; i <= ids; i++) {
              document.getElementById("selectBench_" + i).checked = fontes18_benchmarks.checked
          }
      }

      function toggleISCAS85Selection() {
          var start = {{trindade | length}}+{{fontes | length }}+1
          var ids = {{trindade | length}}+{{fontes | length }}+{{iscas | length }}
          for (let i = start; i <= ids; i++) {
              document.getElementById("selectBench_" + i).checked = iscas85_benchmarks.checked
          }
      }

      function toggleEPFLSelection() {
          var start = {{trindade | length}}+{{fontes | length }}+{{iscas | length }}+1
          var ids = {{trindade | length}}+{{fontes | length }}+{{iscas | length }}+{{epfl | length }}
          for (let i = start; i <= ids; i++) {
              document.getElementById("selectBench_" + i).checked = epfl_benchmarks.checked
          }
      }

      function checks_on_change() {
          enable_level()
          check_col_if_all_selected()
          check_col_if_trindade16_selected()
          check_col_if_fontes18_selected()
          check_col_if_iscas85_selected()
          check_col_if_epfl_selected()
          get_num_benchs()
      }

      function setCheckboxState(id, checked, disabled, update) {
          var checkboxElement = document.getElementById(id);
          if (update) {
              checkboxElement.checked = checked;
          }
          checkboxElement.disabled = disabled;
          if (disabled) {
              checkboxElement.classList.add("disabled-checkbox");
          } else {
              checkboxElement.classList.remove("disabled-checkbox");
          }
      }

      function enable_level() {
          var ids = {{trindade | length}}+{{fontes | length }}+{{iscas | length }}+{{epfl | length }}
          var at_least_one = false;
          for (let i = 1; i <= ids; i++) {
              if (document.getElementById("selectBench_" + i).checked) {
                  at_least_one = true;
              }
          }
          if (at_least_one){
            setCheckboxState("network", false, false, false);
            setCheckboxState("gate", false, false, false);
            enable_gate_library_selection();
          }
          else {
            disable_all();
          }
      }

      function enable_gate_library_selection(){
          if (document.getElementById("gate").checked) {
              setCheckboxState("one", false, false, false);
              setCheckboxState("bestagon", false, false, false);
              enable_clocking_schemes();
          }
          else {
              disable_gate_libraries();
              disable_clocking_schemes(one=true, bestagon=true);
          }
      }

      function enable_clocking_schemes(){
          if (document.getElementById("one").checked) {
              setCheckboxState("twoddwave", false, false, false);
              setCheckboxState("use", false, false, false);
              setCheckboxState("res", false, false, false);
              setCheckboxState("esr", false, false, false);
          }
          else {
              disable_clocking_schemes(one=true, bestagon=false);
          }
          if (document.getElementById("bestagon").checked) {
              if (!document.getElementById("one").checked) {
                  setCheckboxState("row", true, false, true);
              }
              else {
                setCheckboxState("row", true, false, false);
              }
          }
          else {
              disable_clocking_schemes(one=false, bestagon=true);
          }
      }

      function disable_all(){
        disable_levels();
        disable_gate_libraries();
        disable_clocking_schemes(one=true, bestagon=true);
      }

      function disable_levels() {
          setCheckboxState("network", false, true, true);
          setCheckboxState("gate", false, true, true);
      }

      function disable_gate_libraries() {
          setCheckboxState("one", false, true, true);
          setCheckboxState("bestagon", false, true, true);
      }

      function disable_clocking_schemes(one, bestagon){
          if (one) {
              setCheckboxState("twoddwave", false, true, true);
              setCheckboxState("use", false, true, true);
              setCheckboxState("res", false, true, true);
              setCheckboxState("esr", false, true, true);
          }

          if (bestagon) {
              setCheckboxState("row", false, true, true);
          }
      }

      function get_num_benchs() {
          const form = document.getElementById("benchmark_form");
          const formData = new FormData(form);
          fetch('./get_num_benchmarks', {
              method: 'POST',
              body: formData,
              dataType: 'json',
          }).then(response => response.json())
              .then(response => {
                  document.getElementById("num_benchmarks").innerHTML = response.num_selected;

                          if (num_benchmarks.innerHTML > 0) {
                              downloadButton.disabled = false;
                          }
                          if (num_benchmarks.innerHTML == 0) {
                              downloadButton.disabled = true;
                          }
              });

      }

      function check_col_if_all_selected() {
          var ids = {{trindade | length}}+{{fontes | length }}+{{iscas | length }}+{{epfl | length }}
          var check_all_selected = true;
          for (let i = 1; i <= ids; i++) {
              if (!document.getElementById("selectBench_" + i).checked) {
                  all_benchmarks.checked = false;
                  check_all_selected = false;
              }
          }
          if (check_all_selected) {
              all_benchmarks.checked = true;
          }
      }

      function check_col_if_trindade16_selected() {
          var start = 1
          var ids = {{trindade | length}}
          var check_trindade16_selected = true;
          for (let i = start; i <= ids; i++) {
              if (!document.getElementById("selectBench_" + i).checked) {
                  trindade16_benchmarks.checked = false;
                  check_trindade16_selected = false;
              }
          }
          if (check_trindade16_selected) {
              trindade16_benchmarks.checked = true;
          }
      }

      function check_col_if_fontes18_selected() {
          var start = {{trindade | length}}+1
          var ids = {{trindade | length}}+{{fontes | length }}
          var check_fontes18_selected = true;
          for (let i = start; i <= ids; i++) {
              if (!document.getElementById("selectBench_" + i).checked) {
                  fontes18_benchmarks.checked = false;
                  check_fontes18_selected = false;
              }
          }
          if (check_fontes18_selected) {
              fontes18_benchmarks.checked = true;
          }
      }

      function check_col_if_iscas85_selected() {
          var start = {{trindade | length}}+{{fontes | length }}+1
          var ids = {{trindade | length}}+{{fontes | length }}+{{iscas | length }}
          var check_iscas85_selected = true;
          for (let i = start; i <= ids; i++) {
              if (!document.getElementById("selectBench_" + i).checked) {
                  iscas85_benchmarks.checked = false;
                  check_iscas85_selected = false;
              }
          }
          if (check_iscas85_selected) {
              iscas85_benchmarks.checked = true;
          }
      }

      function check_col_if_epfl_selected() {
          var start = {{trindade | length}}+{{fontes | length }}+{{iscas | length }}+1
          var ids = {{trindade | length}}+{{fontes | length }}+{{iscas | length }}+{{epfl | length }}
          var check_epfl_selected = true;
          for (let i = start; i <= ids; i++) {
              if (!document.getElementById("selectBench_" + i).checked) {
                  epfl_benchmarks.checked = false;
                  check_epfl_selected = false;
              }
          }
          if (check_epfl_selected) {
              epfl_benchmarks.checked = true;
          }
      }
    </script>
  </body>
</html>
