Practical Techniques for Verification and Validation of Robots
Kerstin Eder with a demo by Dejanira Araiza Illan
University of Bristol and Bristol Robotics Laboratory
Practical Techniques for Verification and Validation of Robots - - PowerPoint PPT Presentation
Practical Techniques for Verification and Validation of Robots Kerstin Eder with a demo by Dejanira Araiza Illan University of Bristol and Bristol Robotics Laboratory Would you swallow a robot? The Safety Challenge Autonomous Systems
University of Bristol and Bristol Robotics Laboratory
– Advances in control science – Focus on “making things work”
3
4 Pictures from www.wikipedia.org
– Advances in control science – Focus on “making things work”
– Can such systems be trusted?
5
6
– Safety is the property of avoiding harmful conditions. – Liveness requires that the system achieves its goals a.k.a. usefulness.
7
8
"Waterfall" by M.C Escher.
10 http://www.epsrc.ac.uk/ourportfolio/themes/engineering/activities/Pages/principlesofrobotics.aspx
11
User Requirements
High-level Specification
Optimizer
Design and Analysis (Simulink)
Controller (SW/HW)
e.g. C, C++, RTL (VHDL/Verilog)
Translate Implement
12
Verification and testing of mobile robot navigation algorithms: A case study in SPARK. IEEE/RSJ International Conference on Intelligent Robots and Systems (IROS).
http://dx.doi.org/10.1109/IROS.2014.6942753
13
§ Array and vector out-of-bounds accesses § Null pointer dereferencing § Accesses to uninitialized data
§ Integer and floating-point arithmetic errors § Mathematic functions domain errors § Dynamic memory allocation errors § Concurrency bugs
§ blocking inter-thread communication (non real-time)
14
15
16
Fabrication Specification Netlist Silicon Chip HW Design
18
Fabrication Specification Netlist Silicon Chip HW Design Verification Test
Tape out
19
http://anysilicon.com/overview-and-dynamics-of-scan-testing/
20
§ Three open-source implementations of navigation algorithms translated from C/C++ (2.7 kSLOC) to SPARK (3.5 kSLOC)
21
§ Explicit annotations are less than 5% of the code § SPARK code is on average 30% longer than C/C++
22
23
Number of discharged verification conditions and the running time of static analysis
abstract interpretation.
§ Up to 97% of the verification conditions discharged automatically by SMT solvers in less than 10 minutes § Performance of the SPARK and C/C++ code similar
24
Moral: If you want to make runtime errors an issue
language and dev env) wisely!
25
Verification and testing of mobile robot navigation algorithms: A case study in SPARK. IEEE/RSJ International Conference on Intelligent Robots and Systems (IROS).
http://dx.doi.org/10.1109/IROS.2014.6942753
26
User Requirements
High-level Specification
Optimizer
Design and Analysis (Simulink)
Controller (SW/HW)
e.g. C, C++, RTL (VHDL/Verilog)
Translate Implement Verification
27
Formal Verification of Control Systems’ Properties with Theorem Proving. International Conference on Control (CONTROL), pp. 244 – 249. IEEE, Jul 2014. http://dx.doi.org/10.1109/CONTROL.2014.6915147
Verification of Control Systems Implemented in Simulink with Assertion Checks and Theorem Proving: A Case Study. European Control Conference (ECC), pp. tbc. Jul 2015. http://arxiv.org/abs/1505.05699
28
§ An assertion is a statement that a particular property is required to be true.
– A property is a Boolean-valued expression
§ Assertions can be checked either during simulation or using a formal property checker. § Assertions have been used in SW design for a long time.
– assert() function is part of C #include <assert.h> – Used to detect NULL pointers, out-of-range data, ensure loop invariants, etc.
§ Revolution through Foster & Bening’s OVL for Verilog.
– Clever way of encoding re-usable assertion library in Verilog. J – > 30 checker types (assertion templates) – http://accellera.org/activities/working-groups/ovl
30
31
TYPE NAME PARAMETERS PORTS DESCRIPTION
Single-Cycle assert_always #(severity_level, property_type, msg, coverage_level) (clk, reset_n, test_expr) test_expr must always hold Two Cycles assert_always_on_edge #(severity_level, edge_type, property_type, msg, coverage_level) (clk, reset_n, sampling_event, test_expr) test_expr is true immediately following the specified edge (edge_type: 0=no-edge, 1=pos, 2=neg, 3=any) n-Cycles assert_change #(severity_level, width, num_cks, action_on_new_start, property_type, msg, coverage_level) (clk, reset_n, start_event, test_expr) test_expr must change within num_cks of start_event (action_on_new_start: 0=ignore, 1=restart, 2=error) n-Cycles assert_cycle_sequence #(severity_level, num_cks, necessary_condition, property_type, msg, coverage_level) (clk, reset_n, event_sequence) if the initial sequence holds, the final sequence must also hold (necessary_condition: 0=trigger-on-most, 1=trigger-on-first, 2=trigger-on-first- unpipelined) Two Cycles assert_decrement #(severity_level, width, value, property_type, msg, coverage_level) (clk, reset_n, test_expr) if test_expr changes, it must decrement by the value parameter (modulo 2^width) Two Cycles assert_delta #(severity_level, width, min, max, property_type, msg, coverage_level) (clk, reset_n, test_expr) if test_expr changes, the delta must be >=min and <=max Single Cycle assert_even_parity #(severity_level, width, property_type, msg, coverage_level) (clk, reset_n, test_expr) test_expr must have an even parity, i.e. an even number of bits asserted Two Cycles assert_fifo_index #(severity_level, depth, push_width, pop_width, property_type, msg, coverage_level, simultaneous_push_pop) (clk, reset_n, push, pop) FIFO pointers should never overflow or underflow n-Cycles assert_frame #(severity_level, min_cks, max_cks, action_on_new_start, property_type, msg, coverage_level) (clk, reset_n, start_event, test_expr) test_expr must not hold before min_cks cycles, but must hold at least once by max_cks cycles (action_on_new_start: 0=ignore, 1=restart, 2=error) n-Cycles assert_handshake #(severity_level, min_ack_cycle, max_ack_cycle, req_drop, deassert_count, max_ack_length, property_type, msg, coverage_level) (clk, reset_n, req, ack) req and ack must follow the specified handshaking protocol Single-Cycle assert_implication #(severity_level, property_type, msg, coverage_level) (clk, reset_n, antecedent_expr, consequent_expr) if antecedent_expr holds then consequent_expr must hold in the same cyle Two Cycles assert_increment #(severity_level, width, value, property_type, msg, coverage_level) (clk, reset_n, test_expr) if test_expr changes, it must increment by the value parameter (modulo 2^width) Single-Cycle assert_never #(severity_level, property_type, msg, coverage_level) (clk, reset_n, test_expr) test_expr must never hold Single-Cycle assert_never_unknown #(severity_level, width, property_type, msg, coverage_level) (clk, reset_n, qualifier, test_expr) test_expr must never be an unknown value, just boolean 0 or 1 Combinatorial assert_never_unknown_async #(severity_level, width, property_type, msg, coverage_level) (reset_n, test_expr) test_expr must never go to an unknown value asynchronously, it must remain boolean 0 or 1 n-Cycles assert_next #(severity_level, num_cks, check_overlapping, check_missing_start, property_type, msg, coverage_level) (clk, reset_n, start_event, test_expr) test_expr must hold num_cks cycles after start_event holds Two Cycles assert_no_overflow #(severity_level, width, min, max, property_type, msg, coverage_level) (clk, reset_n, test_expr) if test_expr is at max, in the next cycle test_expr must be >min and <=max Two Cycles assert_no_transition #(severity_level, width, property_type, msg, coverage_level) (clk, reset_n, test_expr, start_state, next_state) if test_expr==start_state, in the next cycle test_expr must not change to next_state Two Cycles assert_no_underflow #(severity_level, width, min, max, property_type, msg, coverage_level) (clk, reset_n, test_expr) if test_expr is at min, in the next cycle test_expr must be >=min and <max Single-Cycle assert_odd_parity #(severity_level, width, property_type, msg, coverage_level) (clk, reset_n, test_expr) test_expr must have an odd parity, i.e. an odd number of bits asserted Single-Cycle assert_one_cold #(severity_level, width, inactive, property_type, msg, coverage_level) (clk, reset_n, test_expr) test_expr must be one-cold i.e. exactly one bit set low (inactive: 0=also-all-zero, 1=also-all-ones, 2=pure-one-cold) Single-Cycle assert_one_hot #(severity_level, width, property_type, msg, coverage_level) (clk, reset_n, test_expr) test_expr must be one-hot i.e. exactly one bit set high Combinatorial assert_proposition #(severity_level, property_type, msg, coverage_level) (reset_n, test_expr) test_expr must hold asynchronously (not just at a clock edge) Two Cycles assert_quiescent_state #(severity_level, width, property_type, msg, coverage_level) (clk, reset_n, state_expr, check_value, sample_event) state_expr must equal check_value on a rising edge of sample_event (also checked on rising edge of `OVL_END_OF_SIMULATION) Single-Cycle assert_range #(severity_level, width, min, max, property_type, msg, coverage_level) (clk, reset_n, test_expr) test_expr must be >=min and <=max n-Cycles assert_time #(severity_level, num_cks, action_on_new_start, property_type, msg, coverage_level) (clk, reset_n, start_event, test_expr) test_expr must hold for num_cks cycles after start_event (action_on_new_start: 0=ignore, 1=restart, 2=error) Two Cycles assert_transition #(severity_level, width, property_type, msg, coverage_level) (clk, reset_n, test_expr, start_state, next_state) if test_expr changes from start_state, then it can only change to next_state n-Cycles assert_unchange #(severity_level, width, num_cks, action_on_new_start, property_type, msg, coverage_level) (clk, reset_n, start_event, test_expr) test_expr must not change within num_cks of start_event (action_on_new_start: 0=ignore, 1=restart, 2=error) n-Cycles assert_width #(severity_level, min_cks, max_cks, property_type, msg, coverage_level) (clk, reset_n, test_expr) test_expr must hold for between min_cks and max_cks cycles Event-bound assert_win_change #(severity_level, width, property_type, msg, coverage_level) (clk, reset_n, start_event, test_expr, end_event) test_expr must change between start_event and end_event Event-bound assert_window #(severity_level, property_type, msg, coverage_level) (clk, reset_n, start_event, test_expr, end_event) test_expr must hold after the start_event and up to (and including) the end_event Event-bound assert_win_unchange #(severity_level, width, property_type, msg, coverage_level) (clk, reset_n, start_event, test_expr, end_event); test_expr must not change between start_event and end_event Single-Cycle assert_zero_one_hot #(severity_level, width, property_type, msg, coverage_level) (clk, reset_n, test_expr) test_expr must be one-hot or zero, i.e. at most one bit set highPARAMETERS USING OVL DESIGN ASSERTIONS INPUT ASSUMPTIONS severity_level +define+OVL_ASSERT_ON Monitors internal signals & Outputs Restricts environment `OVL_FATAL +define+OVL_MAX_REPORT_ERROR=1 `OVL_ERROR +define+OVL_INIT_MSG Examples Examples `OVL_WARNING +define+OVL_INIT_COUNT=<tbench>.ovl_init_count * One hot FSM * One hot inputs `OVL_INFO * Hit default case items * Range limits e.g. cache sizes property_type
+libext+.v+.vlib
* FIFO / Stack * Stability e.g. cache sizes `OVL_ASSERT
* Counters (overflow/increment) * No back-to-back reqs `OVL_ASSUME
+incdir+<OVL_DIR>/std_ovl
* FSM transitions * Handshaking sequences `OVL_IGNORE * X checkers (assert_never_unknown) * Bus protocol msg descriptive string
OVL QUICK REFERENCE (www.eda.org/ovl) Last updated: 28th April 2006
32
System Architects Designers / Developers Verification Engineers IP Providers Standards
– Catch different interpretations between different designers.
faults:
is allowed § Implementation assertions can detect discrepancies between design assumptions and implementation.
understanding of functional intent.
testbenches.
checker, in some cases writing a block-level assertion can be much simpler.
§ Assertions are able to detect a significant percentage
Assertions should be an integral part of a verification methodology.
[Foster etal.: Assertion-Based Design. 2nd Edition, Kluwer, 2010.]
§ Simulating the control systems § Analysis techniques from control systems theory (e.g., stability) § Serve as requirements/specification § For (automatic) code generation
Code
Control systems design level Implementation level
37
Stability
High-level (abstract) control requirement
38
Stability Sub-requirements (parametrized) Matrix P > 0 (Lyapunov function) Matrix P−(A−BK)T P(A−BK) > 0 (Lyapunov function's difference) Equivalence
V(k)-V(k-1) = x(k-1)T [(A−BK)T P(A−BK)-P]x(k-1)
(Lyapunov's equation application) From control systems theory → Lyapunov's second method for stability: Propose Lyapunov function that is
39
Stability Matrix P > 0 (Lyapunov function) Equivalence
V(k)-V(k-1) = x(k-1)T [(A−BK)T P(A−BK)-P]x(k-1)
(Lyapunov's equation application) Add as assertions Capture control systems requirements Retain in code implementation Matrix P−(A−BK)T P(A−BK) > 0 (Lyapunov function's difference)
41
Stability Matrix P > 0 (Lyapunov function) Equivalence
V(k)-V(k-1) = x(k-1)T [(A−BK)T P(A−BK)-P]x(k-1)
(Lyapunov's equation application) Matrix P−(A−BK)T P(A−BK) > 0 (Lyapunov function's difference)
Test in simulation
42
Automatic theorem proving
First order logic theory of the Simulink diagram
Axiom: Bu = B * u ... … Goal: vdiff == vdiff_an
Estimators and controllers Stability Functional equivalence Feasibility (constraint satisfaction) Systems in series
Hybrid systems
44
Formal Verification of Control Systems’ Properties with Theorem Proving. International Conference on Control (CONTROL), pp. 244 – 249. IEEE, Jul 2014. http://dx.doi.org/10.1109/CONTROL.2014.6915147
Verification of Control Systems Implemented in Simulink with Assertion Checks and Theorem Proving: A Case Study. European Control Conference (ECC), pp. tbc. Jul 2015. http://arxiv.org/abs/1505.05699
45
46
Special thanks to Dejanira Araiza Illan, David Western, Arthur Richards, Jonathan Lawry, Trevor Martin, Piotr Trojanek, Yoav Hollander, Yaron Kashai, Mike Bartley, Tony Pipe and Chris Melhuish for their hard work, collaboration, inspiration and the many productive discussions we have had.