[dv] Allow a test to have "simple" timestamps

Before this patch the clock phase was always randomised so, even if
you had a clock frequency that would give you a nice period (50MHz)
and no jitter, the time stamps would still look weird.

In a test with a single clock and the default reset strategy, the
clock phase was the sum of the time before reset (dly_ps in
apply_reset) and 0-10ps chosen at random in the driving block.

This patch changes wait_for_reset so that it always waits a whole
number of clock periods, decoupling the "reset at a random time" event
from the clock phase. It then lengthens the random delay in the
driving block from 0 -> 10ps to 0 -> clk_period. This should give the
same randomness in phase as before.

However, tests which only have one clock don't really need the random
clock phase and it makes the timestamps look odd in dumped waves. This
patch adds a "sole_clock" flag which disables the random delay, so the
clock ends up exactly in phase. The flag defaults to false, so the
default behaviour is as before.

You can now get simple timestamps in a given test. To do so:

  - Constrain the frequency. Since the frequency doesn't affect a
    non-gate-level test with only one clock, we may as well pick
    something helpful.

    If your test uses dv_lib, your <block>_env_cfg class, which
    derives from dv_base_env_cfg, should gain a constraint like:

      constraint clk_freq_50_c {
        clk_freq_mhz == ClkFreq50Mhz;
      }

    This will give a clock edge every 10ns. Other enum values that
    will look OK are ClkFreq25Mhz or ClkFreq100Mhz. If you don't force
    this, you might get a 24MHz or 48MHz clock, which looks a little
    weird.

  - Set the sole_clock flag. The easiest place to do this is the
    build_phase of the environment class. If <block>_env derives from
    dv_base_env, add something like this to its build_phase function:

      cfg.clk_rst_vif.set_sole_clock();

Signed-off-by: Rupert Swarbrick <rswarbrick@lowrisc.org>
1 file changed
tree: d0e8e21112816d33345a00f16158ad3505f445e4
  1. .github/
  2. ci/
  3. doc/
  4. hw/
  5. site/
  6. sw/
  7. test/
  8. util/
  9. .clang-format
  10. .dockerignore
  11. .flake8
  12. .gitignore
  13. .style.yapf
  14. _index.md
  15. apt-requirements.txt
  16. azure-pipelines.yml
  17. check_tool_requirements.core
  18. CLA
  19. COMMITTERS
  20. CONTRIBUTING.md
  21. LICENSE
  22. meson.build
  23. meson_init.sh
  24. meson_options.txt
  25. python-requirements.txt
  26. README.md
  27. tool_requirements.py
  28. toolchain.txt
README.md

OpenTitan

OpenTitan logo

About the project

OpenTitan is an open source silicon Root of Trust (RoT) project. OpenTitan will make the silicon RoT design and implementation more transparent, trustworthy, and secure for enterprises, platform providers, and chip manufacturers. OpenTitan is administered by lowRISC CIC as a collaborative project to produce high quality, open IP for instantiation as a full-featured product. See the OpenTitan site and OpenTitan docs for more information about the project.

About this repository

This repository contains hardware, software and utilities written as part of the OpenTitan project. It is structured as monolithic repository, or “monorepo”, where all components live in one repository. It exists to enable collaboration across partners participating in the OpenTitan project.

Documentation

The project contains comprehensive documentation of all IPs and tools. You can access it online at docs.opentitan.org.

How to contribute

Have a look at CONTRIBUTING for guidelines on how to contribute code to this repository.

Licensing

Unless otherwise noted, everything in this repository is covered by the Apache License, Version 2.0 (see LICENSE for full text).