Sequential Statements: RTL Hardware Design by P. Chu 1
Sequential Statements: RTL Hardware Design by P. Chu 1
Chapter 5
Outline
1. 2. 3. 4. 5. 6. VHDL process Sequential signal assignment statement Variable assignment statement If statement Case statement Simple for loop statement
Chapter 5
1. VHDL Process
Contains a set of sequential statements to be executed sequentially The whole process is a concurrent statement Can be interpreted as a circuit part enclosed inside of a black box May or may not be able to be mapped to physical hardware
RTL Hardware Design by P. Chu Chapter 5 3
Chapter 5
A process is activated when a signal in the sensitivity list changes its value Its statements will be executed sequentially until the end of the process
Chapter 5
For a combinational circuit, all input should be included in the sensitivity list
RTL Hardware Design by P. Chu Chapter 5 7
A process can has multiple wait statements Process with sensitivity list is preferred for synthesis
RTL Hardware Design by P. Chu Chapter 5 9
E.g.,
process(a,b,c,d) begin y <= a or c; y <= a and b; y <= c and d; end process; -- yentry := y -- yexit := a or c; -- yexit := a and b; -- yexit := c and d; -- y <= yexit
It is same as
process(a,b,c,d) begin y <= c and d; end process;
Assignment takes effect immediately No time dimension (i.e., no delay) Behave like variables in C Difficult to map to hardware (depending on context)
Chapter 5 12
E.g.,
process(a,b,c) variable tmp: std_logic; begin tmp := '0'; tmp := tmp or a; tmp := tmp or b; y <= tmp; end process;
Chapter 5
13
end process;
Chapter 5
14
Same as:
process(a,b,c,tmp) begin tmp <= tmp or b; end process;
RTL Hardware Design by P. Chu Chapter 5 15
4. IF statement
Syntax Examples Comparison to conditional signal assignment Incomplete branch and incomplete signal assignment Conceptual Implementation
Chapter 5
16
Syntax
if boolean_expr_1 then sequential_statements; elsif boolean_expr_2 then sequential_statements; elsif boolean_expr_3 then sequential_statements; ... else sequential_statements; end if;
RTL Hardware Design by P. Chu Chapter 5 17
Chapter 5
18
Chapter 5
19
Chapter 5
20
Chapter 5
21
Chapter 5
22
Chapter 5
23
Chapter 5
24
Chapter 5
25
Chapter 5
26
Chapter 5
27
Chapter 5
28
Incomplete branch
E.g.,
It implies
Chapter 5
29
fix
Chapter 5
30
Chapter 5
31
Fix #1:
Fix #2
Chapter 5
32
Conceptual implementation
Same as conditional signal assignment statement if the if statement consists of
One output signal One sequential signal assignment in each branch Multiple sequential statements can be constructed recursively
Chapter 5
33
e.g.
Chapter 5
34
e.g.
Chapter 5
35
Chapter 5
36
5. Case statement
Syntax Examples Comparison to selected signal assignment statement Incomplete signal assignment Conceptual Implementation
Chapter 5
37
Syntax
case case_expression is when choice_1 => sequential statements; when choice_2 => sequential statements; ... when choice_n => sequential statements; end case;
RTL Hardware Design by P. Chu Chapter 5 38
Chapter 5
39
Chapter 5
40
Chapter 5
41
Chapter 5
42
Chapter 5
43
Chapter 5
44
Chapter 5
45
Fix #1:
Chapter 5
46
Fix #2:
Chapter 5
47
Conceptual implementation
Same as selected signal assignment statement if the case statement consists of
One output signal One sequential signal assignment in each branch Multiple sequential statements can be constructed recursively
Chapter 5
48
e.g.
Chapter 5
49
Chapter 5
50
Chapter 5
51
VHDL provides a variety of loop constructs Only a restricted form of loop can be synthesized Syntax of simple for loop:
for index in loop_range loop sequential statements; end loop;
loop_range must be static Index assumes value of loop_range from left to right
RTL Hardware Design by P. Chu Chapter 5 52
Chapter 5
53
E.g., reduced-xor
Chapter 5
54
Conceptual implementation
Unroll the loop For loop should be treated as shorthand for repetitive statements E.g., bit-wise xor
Chapter 5
55
E.g., reduced-xor
Chapter 5
56
Sequential statements
Intended to describe behavior Flexible and versatile Can be difficult to be realized in hardware Can be easily abused
RTL Hardware Design by P. Chu Chapter 5 57
Chapter 5
58