Presentation is loading. Please wait.

Presentation is loading. Please wait.

Step 2 in behavioral modeling. Use of procedures.

Similar presentations


Presentation on theme: "Step 2 in behavioral modeling. Use of procedures."— Presentation transcript:

1 Step 2 in behavioral modeling. Use of procedures.
Project Step 5 Step 2 in behavioral modeling. Use of procedures. 1/8/ L11 Project Step 5 Copyright Joanne DeGroat, ECE, OSU

2 The nature of the process
Will still use P, K, and R to control the operation. Previously have use P to compute Pi, K to compute Ki, and then R to generate the final result. Now will use a combined P&K&R to choose the operation being performed For op A have P,K,R of 1100,1111,1100 For op A AND B hove 1000,1111,1100 1/8/ L11 Project Step 5 Copyright Joanne DeGroat, ECE, OSU

3 Copyright 2006 - Joanne DeGroat, ECE, OSU
continued For A + B have 0110,0001,0110 Then we can use a case statement on a variable that concatenates P&K&R to choose which operation to perform. opersw := P & K & R; --Note use of variable CASE opersw IS WHEN “ ” => Zout <= A; Cout <= ‘0’; --op A WHEN “ ” => neg(A,Ztemp,CoutTemp); Zout <= Ztemp; Cout<= CoutTemp; 1/8/ L11 Project Step 5 Copyright Joanne DeGroat, ECE, OSU

4 Copyright 2006 - Joanne DeGroat, ECE, OSU
Note on operations For logical operation can do vector operations Zout <= A AND B; Where A and B are the input bit vectors Both vectors must be of the same size Arithmetic operations will need procedures One for Add One for 2’s complement One for Subtract that can be an implementation of binary subtraction, or subtraction using 2’s complement addition 1/8/ L11 Project Step 5 Copyright Joanne DeGroat, ECE, OSU

5 Copyright 2006 - Joanne DeGroat, ECE, OSU
The procedures The procedures are to be declared in the declarative region of the process In the declarative region of the process can only declare a procedure body. And thus no procedure declaration part is done. Scope of procedure is limited to just this process. (We will later move these to a package.) 1/8/ L11 Project Step 5 Copyright Joanne DeGroat, ECE, OSU

6 Copyright 2006 - Joanne DeGroat, ECE, OSU
Addition BINADD A procedure for binary addition using sequential statements. Will make the arguments to the procedure unconstrained so that it will be capable of adding words of any length (constraint that both inputs are the same index range). 1/8/ L11 Project Step 5 Copyright Joanne DeGroat, ECE, OSU

7 Unconstrained declaration
PROCEDURE binadd (l,r : IN BIT_VECTOR; cin : IN BIT; sum : OUT BIT_VECTOR; cout : OUT BIT) IS VARIABLE carry : BIT: --internal variable carry BEGIN carry := cin; FOR i IN l’reverse_range LOOP -- compute sum for position I -- compute carry out for position I into carry variable END LOOP; -- assign cout from final value of carry 1/8/ L11 Project Step 5 Copyright Joanne DeGroat, ECE, OSU

8 Copyright 2006 - Joanne DeGroat, ECE, OSU
Highlights on the code Inputs are “unconstrained” – they can be any size We will later use these same procedures in a package and the data size will be 16 bits. Outputs are variables Need to use attribute for loop parameter If L declared (x downto 0) such that leftmost bit is the msb and highest index THEN L’REVERSE_RANGE has the designation 0 to x 1/8/ L11 Project Step 5 Copyright Joanne DeGroat, ECE, OSU

9 Copyright 2006 - Joanne DeGroat, ECE, OSU
Overall look of code Same ENTITY as before ARCHITECTURE v_3 OF adder_8 IS BEGIN --A single process as just described PROCESS (sensitivity list) PROCEDURES Local Variables opersw:= CASE opersw……. END; 1/8/ L11 Project Step 5 Copyright Joanne DeGroat, ECE, OSU


Download ppt "Step 2 in behavioral modeling. Use of procedures."

Similar presentations


Ads by Google