vhdl test benches how to simulate vhdl code
play

VHDL Test benches How to simulate VHDL code Use a simulation - PowerPoint PPT Presentation

VHDL Test benches How to simulate VHDL code Use a simulation tool like e.g. ModelSim Test bench to apply stimuli/test inputs to the VHDL code Visual inspection through graphical output (waveform) Self checking test


  1. VHDL – Test benches

  2. How to simulate VHDL code • Use a simulation tool like e.g. ModelSim • Test bench to apply stimuli/test inputs to the VHDL code • Visual inspection through graphical output (waveform) • Self checking test benches (add code to check and verify result)

  3. Test benches Basic concept : Add a stimuli (input) to the design • under test and observe the outputs to verify correct behavior/functionality A characteristic of VHDL: test bench can be written • in same language as the design to be verified. A VHDL TB can of course also contain errors • introduced by the TB designer! • Test benches are not to be synthesized, and can therefore use the entire VHDL language (e.g. after, wait for, write etc. ) For proper simulation of FPGAs: • often more lines of verification code than for design source – can be more time consuming than design – Yet, often less effort spent on verification strategies and – documentation! Partly adopted from: FPGA development best practice course by Espen Tallaksen, www.bitvis.no

  4. The most basic test bench ”template” library ieee; Only test sequencer use ieee.std_logic_1164.all; entity test_UUT is -- empty entity (UUT = Unit Under Test) end test_UUT architecture testbenk_arch of test_UUT is Component UUT: port ( Component declaration ………………… ); end component; Defines a signal for each port in signal ………. the UUT signal ………. :=’0’; -- start value for inputs begin U1: UUT Component instantiation port map (………..); STIMULI: process begin Test sequencer to provide stimuli ……. wait; end process; end architecture;

  5. Example of input signal/stimuli Remember to initialize clk otherwise std_logic_vector à U Alternatively

  6. Basic test bench Example design

  7. Test benches • Different levels / complexity – Generate input stimuli à manual verification of output – Generate input stimuli à automatic verification of output – Use of verification components (advanced) • Objective when writing a test bench – Verify design requirements for device under test – Sufficient functional coverage with minimum effort – Simple to write, understand and modify (by anyone) • Modularity – Simple to execute, debug and understand reports • Scripting, and well structured and meaningful log and alert functionality Partly adopted from: FPGA development best practice course by Espen Tallaksen, www.bitvis.no

  8. Test bench concepts General needed features: • Logging mechanism – informative, no attention required, progress reporting • Alert handling – Messages that need attention (severity levels) • Verbosity control – Enable or disable logging output • String handling and randomisation • Checks and awaits Project specific • test sequencer • support procedures/processes

  9. Basic test bench architecture Test sequencer Support DUT processes Support Procedures & functions Minimum required support • – Logging – Alert handing & reports Additional support • – Continuous actions not handled by sequencer (e.g. clock generator) Partly adopted from: FPGA development best practice course by Espen Tallaksen, www.bitvis.no

  10. Example of basic check functionality label: assert boolean_condition [ report string ] [ severity name ]; When the specified condition is false, the ASSERT statement triggers and the report is issued

  11. Assert statement example • Used to print messages at the simulation console when specified runtime conditions are met • Defines one of four severity levels – Note : information about condition to the user – Warning : alerts conditions that are not expected but not fatal – Error : alert conditions that will cause the model to work incorrectly – Failure : alert conditions that are fatal Will abort simulation

  12. Attributes • Attributes extract additional information about and object (signal, variable , type, component) • ‘image(x) and ‘value(s) simplifies reporting through text I/O Now : predefined function that returns simulation time

  13. Predefine attributes NOT all supported by synthesis tools

  14. Attributes Can for example be to check for setup violation clk A 5 ns

  15. TB support procedures (Ex. of check) Example of checking for an expected value of an object of type unsigned

  16. TEXTIO • Provides declarations and subprograms for handling text (ASCII) files in VHDL (e.g. for logging) • Three types of basic operation – Declaration of a file and its type – Opening and closing a file of a specified type – Reading and writing a file • Data types to assist in text handling – Line : text buffer used to interface VHDL I/O and the file – File of type text: may only contains ASCII characters

  17. File I/O Declaration and open file File_open() File_close() File for storing ASCII Alternative: Implicit file open read_mode / append_mode Writing

  18. Example logging procedure write is overloaded VHDL is strongly typed: Need to specify type of Characters enclosed in “ ”.

  19. Self-testing test benches Contains a number of support procedures/process to improve efficiency • of test bench and perform automatic checks of relevant signals Alerts and relevant results should be clearly indicated • Write to file Status / summary should be reported at the end • Structured and readability: use procedures to hide details • Visual inspection of timing diagrams often not needed (saves time) • Other people can more easily maintain the code • However , it is a demanding task to make a self-testing test bench! • – If possible, write for reuse of procedures If available, consider using already available libraries •

  20. UVVM utility library An open source library – available to anyone • – More info at: • https://uvvm.org – Can be downloaded from: • https://github.com/UVVM – Easy to integrate into your project Supports the most fundamental functionality of • any structured VHDL test bench – Sufficient for simple test benches – Platform for more advanced TBs Purpose: standarize and qualify a set of good • procedures => improve quality and efficiency

  21. Some available and helpful procedures report_global_ctrl() • report_msg_id_panel() • enable_log_msg() • disable_log_msg() • increment_expected_alerts() • log() • check_value() • check_value_in_range() • check_stable() • alert() • report_alert_counters() • to_string() • await_value() • await_change() • random() • https://github.com/UVVM/UVVM/blob/master/uvvm_util/doc/util_quick_ref.pdf

  22. Basic example UVVM Basic test bench

  23. Output when using UVVM

  24. Output when using UVVM

Download Presentation
Download Policy: The content available on the website is offered to you 'AS IS' for your personal information and use only. It cannot be commercialized, licensed, or distributed on other websites without prior consent from the author. To download a presentation, simply click this link. If you encounter any difficulties during the download process, it's possible that the publisher has removed the file from their server.

Recommend


More recommend