The continuation of a grand tour of the language. Language Overview II The continuation of a grand tour of the language. 1/8/2007 - L7 Language Overview II Copyright 2006 - Joanne DeGroat, ECE, OSU
Copyright 2006 - Joanne DeGroat, ECE, OSU Elements Covered in II Reminder from I: Language overview lectures do not cover all aspects of the language. But they do cover a large portion of it. Concurrent Statements Sequential Statements In Part I covered: TYPES, Declarations, operators, and structural architectures, i.e., component instantiation – a concurrent statement 1/8/2007 - L7 Language Overview II Copyright 2006 - Joanne DeGroat, ECE, OSU
Copyright 2006 - Joanne DeGroat, ECE, OSU CONCURENT STATEMENTS Concurrent statements are those that can appear between the BEGIN and END of an architecture. With these statements you model the component or system to be modeled These statements execute independent of the order in which they appear in the model. 1/8/2007 - L7 Language Overview II Copyright 2006 - Joanne DeGroat, ECE, OSU
CONCURRENT STATEMENTS Component Instantiation Statement Prior to use the component must be declared and configured in the declarative region of the architecture. LABEL : component_name [generic_map_aspect] [port_map_aspect] (do not use the generic map aspect in this class) 1/8/2007 - L7 Language Overview II Copyright 2006 - Joanne DeGroat, ECE, OSU
Component Instantiation Consider that the following is already analyzed and in your library ENTITY wigit IS PORT(p1, p2 : IN BIT); END wigit; ARCHITECTURE Y OF wigit IS …..; ARCHITECTURE Z OF wigit IS …..; 1/8/2007 - L7 Language Overview II Copyright 2006 - Joanne DeGroat, ECE, OSU
Component Instantiation Then the declaration for use is ARCHITECTURE use_it OF xyz IS COMPONENT wigit PORT(p1, p2 : IN BIT); END COMPONENT: -- and the configuration is FOR C0 : wigit USE ENTITY work.wigit(y); FOR OTHERS : wigit USE ENTITY work.wigit(Z); 1/8/2007 - L7 Language Overview II Copyright 2006 - Joanne DeGroat, ECE, OSU
And use in the architecture SIGNAL A,B,C,D ; BIT; BEGIN CO : wigit PORT MAP (A, B); C1 : wigit PORT MAP (p1 =>C, p2=>D); Component Instantiation is a Concurrent Statement 1/8/2007 - L7 Language Overview II Copyright 2006 - Joanne DeGroat, ECE, OSU
Concurrent Statements BLOCK STATEMENT::= (the BNF) Block_label: block [guard expression] block_header block_declarative_part (do not use block statement begin in this class) block_statement_part end block [block_label]; 1/8/2007 - L7 Language Overview II Copyright 2006 - Joanne DeGroat, ECE, OSU
Copyright 2006 - Joanne DeGroat, ECE, OSU The block statement - 2 block_header::= [generic_clause [generic_map_aspect;]] [port_clause [port_map_aspect;]] block_declarative_part::= {block_declarative_item} block_statement_part::= {concurrent_statement} 1/8/2007 - L7 Language Overview II Copyright 2006 - Joanne DeGroat, ECE, OSU
Copyright 2006 - Joanne DeGroat, ECE, OSU Block example example_blk: BLOCK (clk= ‘1’ and clk’event) BEGIN Z <= guarded Q1; X <= guarded Q0 AND B; Y <= Q3; END BLOCK example_blk; Note that Z and X are guarded signal assignment statements Scheduling of a new value for Z and X occurs only when the guard is TRUE and a signal on the right hand side has an event while the guard is true 1/8/2007 - L7 Language Overview II Copyright 2006 - Joanne DeGroat, ECE, OSU
Concurrent Statements PROCESS STATEMENT [process_label:] process [ (sensitivity_list) ] process_declarative_part begin process_statement_part -- {sequential statement} end process [process_label]; 1/8/2007 - L7 Language Overview II Copyright 2006 - Joanne DeGroat, ECE, OSU
Copyright 2006 - Joanne DeGroat, ECE, OSU Process Statement process_declarative_part::= subprogram_body type_declaration subtype_declaration constant_declaration variable_declaration file_declaration alias_declaration attribute_declaration attribute_specification use_clause The contents of a process will be covered further in Sequential Statements (i.e. what goes between BEGIN-END) 1/8/2007 - L7 Language Overview II Copyright 2006 - Joanne DeGroat, ECE, OSU
Concurrent Statements Concurrent Procudure Call – covered later in course Concurrent Assertion Statement Concurrent Signal Assignment Statement Y <= [transport] A AND B OR C [AFTER 35 NS]; --where A, B, and C are type BIT K <= Q + L; --where K, Q, and L are of type integer 1/8/2007 - L7 Language Overview II Copyright 2006 - Joanne DeGroat, ECE, OSU
Concurrent Statements Examples of the concurrent signal assignment statement Y <= (NOT a AND NOT b AND x(0)) OR (NOT a AND b AND x(1)) OR (a AND NOT b AND x(2)) OR (a AND b AND x(3)); Is the same as Y <= NOT a AND NOT b AND x(0) OR NOT a AND b AND x(1) OR a AND NOT b AND x(2) OR a AND b AND x(3); 1/8/2007 - L7 Language Overview II Copyright 2006 - Joanne DeGroat, ECE, OSU
Concurrent Statements Compound Waveforms ; --ends the waveform , --separates waveform elements that are generated at the same time Z <= ‘0’ AFTER 4 NS, ‘1’ AFTER 10 NS, ‘0’ AFTER 14 NS, ‘1’ AFTER 20 NS; 1/8/2007 - L7 Language Overview II Copyright 2006 - Joanne DeGroat, ECE, OSU
Concurrent Statements Compound Waveforms ; --ends the waveform , --separates waveform elements that are generated at the same time Z <= ‘0’ AFTER 4 NS, ‘1’ AFTER 10 NS, ‘0’ AFTER 14 NS, ‘1’ AFTER 20 NS; 1/8/2007 - L7 Language Overview II Copyright 2006 - Joanne DeGroat, ECE, OSU
Concurrent Statements Conditional Signal Assignment Statement target <= waveform_1 WHEN condition_1 ELSE waveform_2 WHEN condition_2 ELSE waveform_3 WHEN condition_3 ELSE · · · waveform_n-1 WHEN condition_n-1 ELSE waveform_n; Waveforms 1 through n are only a single waveform. Compound waveforms not allowed. WHEN conditions are Boolean expressions 1/8/2007 - L7 Language Overview II Copyright 2006 - Joanne DeGroat, ECE, OSU
Concurrent Statements Selected Signal Assignment Statement with expression select target <= waveform 1 WHEN choice_list 1, waveform 2 WHEN choice_list 2, waveform 3 WHEN choice_list 3, · · · waveform N WHEN choice_list N; 1/8/2007 - L7 Language Overview II Copyright 2006 - Joanne DeGroat, ECE, OSU
Copyright 2006 - Joanne DeGroat, ECE, OSU example with A&B select R <= G0 WHEN “00”, G1 WHEN “01”, G2 WHEN “10”, G3 WHEN “11”; Versus conditional signal assignment description of the same semantics R <= G0 WHEN A&B = “00” else G1 WHEN A&B = “01” else G2 WHEN A&B = “10” else G3; 1/8/2007 - L7 Language Overview II Copyright 2006 - Joanne DeGroat, ECE, OSU
Sequential Statements Sequential Statements are like the statements of any procedural programming language. They are executed sequentially according to the control flow of the code. Time introduced using special language statements. 1/8/2007 - L7 Language Overview II Copyright 2006 - Joanne DeGroat, ECE, OSU
Sequential Statements Those statements allowable between the BEGIN and END of a PROCESS WAIT Statement wait [sensitivity_clause] [condition_clause] [timeout_clause] sensitivity_clause::= on sensitivity_list WAIT ON A,B; sensitivity_list::= signal_name {,signal_name} condition_clause::= until condition WAIT UNTIL A=‘1’; condition::= boolean_expression timeout_clause::= FOR time_expression WAIT FOR 20 NS; 1/8/2007 - L7 Language Overview II Copyright 2006 - Joanne DeGroat, ECE, OSU
Sequential Statements Assert Statement Signal Assignment Statement (Sequential) <= exactly like a concurrent one only context makes it sequential Variable Assignment Statement := Procedure Call Statement 1/8/2007 - L7 Language Overview II Copyright 2006 - Joanne DeGroat, ECE, OSU
Sequential Statements The next few statements are similar to their counterpart in procedural languages such as C IF STATEMENT if condition then sequence_of_statements {elsif condition then sequence_of_statements} [else sequence_of_statements] end if; IF a=‘1’ THEN y<=q; ELSIF b=‘1’ THEN y<=z AFTER 4 NS; ELSE y <= ‘0’; END IF; 1/8/2007 - L7 Language Overview II Copyright 2006 - Joanne DeGroat, ECE, OSU
Sequential Statements CASE STATEMENT case expression is when choices => sequence_of_statements; end case; CASE state IS WHEN “00” => state <= “01”; WHEN “01” => state <= “10”; WHEN others => state <= “11”; END CASE; 1/8/2007 - L7 Language Overview II Copyright 2006 - Joanne DeGroat, ECE, OSU
Sequential Statements LOOPS [loop_label:] [iteration_scheme] loop sequence_of_statements; end loop [loop_label]; iteration_scheme::= while condition | for loop_parameter_specification loop_parameter_specification::= identifier in discrete_range 1/8/2007 - L7 Language Overview II Copyright 2006 - Joanne DeGroat, ECE, OSU
Copyright 2006 - Joanne DeGroat, ECE, OSU Loop Examples while A /= ‘1’ loop sequence_of_statements; --at least one -- sets A end loop; my_loop : for I in 1 to 100 loop sequence_of_statements; end loop my_loop; for OP in OPAND to OPMOVE loop … 1/8/2007 - L7 Language Overview II Copyright 2006 - Joanne DeGroat, ECE, OSU
Sequential Statements NEXT STATEMENT NEXT [loop_label] [when condition]; If the condition is true causes termination of the current iteration of the loop and the start of the next iteration. EXIT STATEMENT EXIT [loop_label] [when condition]; Causes exit from the loop when the condition is true. 1/8/2007 - L7 Language Overview II Copyright 2006 - Joanne DeGroat, ECE, OSU
Copyright 2006 - Joanne DeGroat, ECE, OSU example for I in PARAMETER’RANGE loop stmt 1; stmt 2; next when C = ‘0’; exit when Q = ‘1’; end loop; J := A + B; 1/8/2007 - L7 Language Overview II Copyright 2006 - Joanne DeGroat, ECE, OSU
Sequential Statements RETURN STATEMENT RETURN [expression]; Used to complete the execution of a function or procedure A function must have a return statement to return a value A procedure can have a return statement but its return statement must not have a value expression NULL STATEMENT NULL; Does nothing but act as a placeholder. 1/8/2007 - L7 Language Overview II Copyright 2006 - Joanne DeGroat, ECE, OSU
Example of Process and Sequential Code ARCHITECTURE x of Y IS -- Entity had sig clk,reset,din: IN and qout:OUT -- td_reset and td_in are constants. BEGIN PROCESS (clk) --from Navabi p.45 IF (clk=‘0’ AND clk’event) THEN IF (reset =‘1’) THEN qout <=‘0’ AFTER td_reset; ELSE qout <= din AFTER td_in; END IF; END PROCESS; END x; 1/8/2007 - L7 Language Overview II Copyright 2006 - Joanne DeGroat, ECE, OSU