Sequential Statements (Lecture 2) Osman Hasan COEN 313
Outline If statement Case Statement For loop Statement
If Statement Sequential Conditional Statement in VHDL Syntax if boolean_expr_1 then sequential_statements; elsif boolean_expr_2 then elsif boolean_expr_3 then . . . else end if; Safety critical system failure could cause human life. Commercial critical systems: great financial loss if the product is recalled or is found to contain bugs Examples of undetected errors – Ariane 5 rocket explosion, 1996 (exception occurred when converting 64-bit floating number to a 16-bit integer) – Pentium bug (multiplier table not fully verified) – many more …. Somehow make debugging happen earlier where it is cheaper 3 3
If Statement – Conceptual implementation Safety critical system failure could cause human life. Commercial critical systems: great financial loss if the product is recalled or is found to contain bugs Examples of undetected errors – Ariane 5 rocket explosion, 1996 (exception occurred when converting 64-bit floating number to a 16-bit integer) – Pentium bug (multiplier table not fully verified) – many more …. Somehow make debugging happen earlier where it is cheaper 4 4
If Statement – Comparison to conditional signal assignment If statement is more flexible Multiple Statements may share the same Boolean Condition Nesting Safety critical system failure could cause human life. Commercial critical systems: great financial loss if the product is recalled or is found to contain bugs Examples of undetected errors – Ariane 5 rocket explosion, 1996 (exception occurred when converting 64-bit floating number to a 16-bit integer) – Pentium bug (multiplier table not fully verified) – many more …. Somehow make debugging happen earlier where it is cheaper 5 5
If Statement – “sharing” Boolean condition Example Safety critical system failure could cause human life. Commercial critical systems: great financial loss if the product is recalled or is found to contain bugs Examples of undetected errors – Ariane 5 rocket explosion, 1996 (exception occurred when converting 64-bit floating number to a 16-bit integer) – Pentium bug (multiplier table not fully verified) – many more …. Somehow make debugging happen earlier where it is cheaper 6 6
Quiz 1: Maximum of 3 numbers c VHDL (Using If statemets) max Safety critical system failure could cause human life. Commercial critical systems: great financial loss if the product is recalled or is found to contain bugs Examples of undetected errors – Ariane 5 rocket explosion, 1996 (exception occurred when converting 64-bit floating number to a 16-bit integer) – Pentium bug (multiplier table not fully verified) – many more …. Somehow make debugging happen earlier where it is cheaper 7 7
Common Mistakes! Incomplete Branch Equality Checker ‘0’
Common Mistakes! Incomplete Signal Assignment Equality/Inequality Checker
Outline If statement Case Statement For loop Statement 10 10
Case Statement Sequential Conditional Statement in VHDL Syntax case case_expression is when choice_1 => sequential statements; when choice_2 => . . . when choice_n => end case; Safety critical system failure could cause human life. Commercial critical systems: great financial loss if the product is recalled or is found to contain bugs Examples of undetected errors – Ariane 5 rocket explosion, 1996 (exception occurred when converting 64-bit floating number to a 16-bit integer) – Pentium bug (multiplier table not fully verified) – many more …. Somehow make debugging happen earlier where it is cheaper 11 11
Case Statement – Conceptual implementation Safety critical system failure could cause human life. Commercial critical systems: great financial loss if the product is recalled or is found to contain bugs Examples of undetected errors – Ariane 5 rocket explosion, 1996 (exception occurred when converting 64-bit floating number to a 16-bit integer) – Pentium bug (multiplier table not fully verified) – many more …. Somehow make debugging happen earlier where it is cheaper 12 12
Example: 4x1 Mux Safety critical system failure could cause human life. Commercial critical systems: great financial loss if the product is recalled or is found to contain bugs Examples of undetected errors – Ariane 5 rocket explosion, 1996 (exception occurred when converting 64-bit floating number to a 16-bit integer) – Pentium bug (multiplier table not fully verified) – many more …. Somehow make debugging happen earlier where it is cheaper 13 13
Example: 2x4 Binary Decoder Safety critical system failure could cause human life. Commercial critical systems: great financial loss if the product is recalled or is found to contain bugs Examples of undetected errors – Ariane 5 rocket explosion, 1996 (exception occurred when converting 64-bit floating number to a 16-bit integer) – Pentium bug (multiplier table not fully verified) – many more …. Somehow make debugging happen earlier where it is cheaper 14 14
Example: 4-to-4 Priority Encoder Safety critical system failure could cause human life. Commercial critical systems: great financial loss if the product is recalled or is found to contain bugs Examples of undetected errors – Ariane 5 rocket explosion, 1996 (exception occurred when converting 64-bit floating number to a 16-bit integer) – Pentium bug (multiplier table not fully verified) – many more …. Somehow make debugging happen earlier where it is cheaper 15 15
Common Mistakes! Incomplete Branch not possible Incomplete Signal Assignment
Common Mistakes! Incomplete Signal Assignment Solution 1
Common Mistakes! Incomplete Signal Assignment Solution 2
Outline If statement Case Statement For loop Statement 19 19
For-Loop Statement Looping in VHDL Syntax for index in loop_range loop sequential statements; end loop; Safety critical system failure could cause human life. Commercial critical systems: great financial loss if the product is recalled or is found to contain bugs Examples of undetected errors – Ariane 5 rocket explosion, 1996 (exception occurred when converting 64-bit floating number to a 16-bit integer) – Pentium bug (multiplier table not fully verified) – many more …. Somehow make debugging happen earlier where it is cheaper 20 20
For-Loop Statement – Conceptual implementation For loop should be treated as “shorthand” for repetitive statements E.g., bit-wise xor Safety critical system failure could cause human life. Commercial critical systems: great financial loss if the product is recalled or is found to contain bugs Examples of undetected errors – Ariane 5 rocket explosion, 1996 (exception occurred when converting 64-bit floating number to a 16-bit integer) – Pentium bug (multiplier table not fully verified) – many more …. Somehow make debugging happen earlier where it is cheaper 21 21
Summary Concurrent statements Sequential statements Have clear, direct mapping to physical structures Difficult to represent complex behaviors Sequential statements Flexible and versatile Resulting hardware may not be very straight forward at times Can be easily abused 22