📄 local-pack.vhd
字号:
package LOCAL is constant N: INTEGER := 4; procedure BITSLICE( A, B: in BIT_VECTOR(3 downto 0); CIN: in BIT; signal S: out BIT_VECTOR(3 downto 0); signal GP, GG: out BIT); procedure PG( A, B: in BIT_VECTOR(3 downto 0); P, G: out BIT_VECTOR(3 downto 0)); function SUM(A, B, C: BIT_VECTOR(3 downto 0)) return BIT_VECTOR; procedure CLA( P, G: in BIT_VECTOR(3 downto 0); CIN: in BIT; C: out BIT_VECTOR(3 downto 0); signal GP, GG: out BIT);end LOCAL;package body LOCAL is ----------------------------------------------- -- compute sum and group outputs from a, b, cin ----------------------------------------------- procedure BITSLICE( A, B: in BIT_VECTOR(3 downto 0); CIN: in BIT; signal S: out BIT_VECTOR(3 downto 0); signal GP, GG: out BIT) is variable P, G, C: BIT_VECTOR(3 downto 0); begin PG(A, B, P, G); CLA(P, G, CIN, C, GP, GG); S <= SUM(A, B, C); end; ------------------------------------------------- -- compute propagate and generate from input bits ------------------------------------------------- procedure PG(A, B: in BIT_VECTOR(3 downto 0); P, G: out BIT_VECTOR(3 downto 0)) isbegin P := A or B; G := A and B; end; -------------------------------------------------- -- Compute sum from the input bits and the carries -------------------------------------------------- function SUM(A, B, C: BIT_VECTOR(3 downto 0)) return BIT_VECTOR is begin return(A xor B xor C); end; ------------------------------ -- 4-bit carry-lookahead block ------------------------------ procedure CLA( P, G: in BIT_VECTOR(3 downto 0); CIN: in BIT; C: out BIT_VECTOR(3 downto 0); signal GP, GG: out BIT) is variable TEMP_GP, TEMP_GG, LAST_C: BIT; begin TEMP_GP := P(0); TEMP_GG := G(0); LAST_C := CIN; C(0) := CIN; for I in 1 to N-1 loop TEMP_GP := TEMP_GP and P(I); TEMP_GG := (TEMP_GG and P(I)) or G(I); LAST_C := (LAST_C and P(I-1)) or G(I-1); C(I) := LAST_C; end loop; GP <= TEMP_GP; GG <= TEMP_GG; end;end LOCAL;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -