Download Packages - HDL Design - Lecture Slides and more Slides Verilog and VHDL in PDF only on Docsity! Project Step 6 Step 3 in behavioral modeling. Use of packages. Docsity.com So far • Modeled the ALU structurally with dataflow models of the leaf units. • Modeled the structure exactly in the first behavioral architecture. Code=Structure • 2nd Behavioral model used a combined P&K&R to choose the operation – For op A have P,K,R of 1100,1111,1100 – For op A AND B have 1000,1111,1100 etc. – AND incorporated procedures, declared in the declarative region of the process, for the arithmetic functions. Docsity.com Type Operations • Type OPERATIONS was declared in the declarative region of the ARCHITECTURE of the testbench. • The scope of TYPE operations is limited to the ARCHITECTURE in which it is declared. • So how can this ENTITY declaration use it? – IT CAN’T -- SO • Move the declaration to a PACKAGE – that both the testbench ARCHITECTURE and this ENTITY can use it. • So declare a package declarative part and package body. TYPE operations is moved to the package declarative part. Docsity.com Modifications • In the testbench – Before the ARCHITECTURE must have a USE clause to see the declaration. • In the ALU ENTITY – Before the entity have a USE clause. Docsity.com The Procedures • The procedures for binary addition, subtraction and two’s complement are also moved to the package body. • What is needed in the package declarative part??? Docsity.com Using it in the ENTITY – USE work.step6_package.all; – ENTITY alu_8bit_v4 IS … – PORT ( …………. • The USE clause prior to the ENTITY makes all the declarations in this package visible to the ENTITY and all ARCHITECTURES of the ENTITY. Docsity.com The Procedures • Move the procedures declared in the process declarative region out to the package body. • Add declarations for them in the package declarative part. (but the code from before goes in the package body) • The declaration can be cut and pasted. Docsity.com Within the ALU • Within the alu the CASE statement switch on a concatenation of P,K, and R. • Now switch on oper with is of TYPE operations which has values of opa,opb,… Docsity.com