1/8/2007 - l11 project step 5copyright 2006 - joanne degroat, ece, osu1 project step 5 step 2 in...

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

Upload: caroline-poole

Post on 01-Jan-2016

221 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: 1/8/2007 - L11 Project Step 5Copyright 2006 - Joanne DeGroat, ECE, OSU1 Project Step 5 Step 2 in behavioral modeling. Use of procedures

1/8/2007 - L11 Project Step 5 Copyright 2006 - Joanne DeGroat, ECE, OSU 1

Project Step 5Step 2 in behavioral modeling. Use of procedures.

Page 2: 1/8/2007 - L11 Project Step 5Copyright 2006 - Joanne DeGroat, ECE, OSU1 Project Step 5 Step 2 in behavioral modeling. Use of procedures

1/8/2007 - L11 Project Step 5

Copyright 2006 - Joanne DeGroat, ECE, OSU 2

The nature of the process Will still use P, K, and R to control the

operation. Previously have use Pctl to compute Pint,

Kctl to compute Ki, and then Rctl 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 have 1000,1111,1100 For op A + B have 0110,0001,0110

Page 3: 1/8/2007 - L11 Project Step 5Copyright 2006 - Joanne DeGroat, ECE, OSU1 Project Step 5 Step 2 in behavioral modeling. Use of procedures

1/8/2007 - L11 Project Step 5

Copyright 2006 - Joanne DeGroat, ECE, OSU 3

continued 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 “110011111100” => Zout <= A; Cout <= ‘0’; --op A WHEN “001111000110” => neg(A,Ztemp,CoutTemp); Zout <= Ztemp; Cout<= CoutTemp; -- Ztemp and CoutTemp are variables WHEN …

Page 4: 1/8/2007 - L11 Project Step 5Copyright 2006 - Joanne DeGroat, ECE, OSU1 Project Step 5 Step 2 in behavioral modeling. Use of procedures

1/8/2007 - L11 Project Step 5

Copyright 2006 - Joanne DeGroat, ECE, OSU 4

Note on operations For logical operation can do vector operations

Zout <= A AND B; Where A and B are the input bit vectors And the vectors must be of the same size for a bit-wise

vector operation 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

Page 5: 1/8/2007 - L11 Project Step 5Copyright 2006 - Joanne DeGroat, ECE, OSU1 Project Step 5 Step 2 in behavioral modeling. Use of procedures

1/8/2007 - L11 Project Step 5

Copyright 2006 - Joanne DeGroat, ECE, OSU 5

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 and write the procedure declaration.)

Page 6: 1/8/2007 - L11 Project Step 5Copyright 2006 - Joanne DeGroat, ECE, OSU1 Project Step 5 Step 2 in behavioral modeling. Use of procedures

1/8/2007 - L11 Project Step 5

Copyright 2006 - Joanne DeGroat, ECE, OSU 6

Addition Procedure 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). (right now size is 8 bits, later will use the procedure for 16 bit arguments).

Page 7: 1/8/2007 - L11 Project Step 5Copyright 2006 - Joanne DeGroat, ECE, OSU1 Project Step 5 Step 2 in behavioral modeling. Use of procedures

1/8/2007 - L11 Project Step 5

Copyright 2006 - 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, sum(i) := … -- compute carry out for position I into carry variable, carry := … END LOOP; -- assign cout from final value of carry - - I provide a lot but you must finish this

Page 8: 1/8/2007 - L11 Project Step 5Copyright 2006 - Joanne DeGroat, ECE, OSU1 Project Step 5 Step 2 in behavioral modeling. Use of procedures

1/8/2007 - L11 Project Step 5

Copyright 2006 - Joanne DeGroat, ECE, OSU 8

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 of the procedure are variables. These need

to be assigned to the appropriate signal. Need to use attribute for loop parameter as shown

If L declared (x downto 0) such that leftmost bit is the msb and highest index and are progressing 0 to x.

THEN L’REVERSE_RANGE has the designation 0 to x

Page 9: 1/8/2007 - L11 Project Step 5Copyright 2006 - Joanne DeGroat, ECE, OSU1 Project Step 5 Step 2 in behavioral modeling. Use of procedures

Now use the procedure in the case Within the main process

BEGIN … CASE opersw IS WHEN “110011111100” => Zout <= A; Cout <= ‘0’; --op A WHEN “0110xxxxxxxx” => --and add binaddd(a,b,cin,sum,vcout); zout <= sum; cout<= vcout; WHEN “xxxxxxxxxxxx” => …

1/8/2007 - L11 Project Step 5

Copyright 2006 - Joanne DeGroat, ECE, OSU 9

Page 10: 1/8/2007 - L11 Project Step 5Copyright 2006 - Joanne DeGroat, ECE, OSU1 Project Step 5 Step 2 in behavioral modeling. Use of procedures

1/8/2007 - L11 Project Step 5

Copyright 2006 - Joanne DeGroat, ECE, OSU 10

Overall look of code – where things go Same ENTITY as before

ARCHITECTURE v_3 OF adder_8 IS BEGIN

--A single process as just described PROCESS (sensitivity list)

**** PROCEDURES are declared here **** Local Variables

BEGIN opersw:= CASE opersw…….

END PROCESS; END v_3;