VHDL语言100例详解

源代码在线查看: 61_logic.vhd

软件大小: 105 K
上传用户: __catcher
关键词: VHDL 100 语言
下载地址: 免注册下载 普通下载 VIP

相关代码

				library IEEE;				use IEEE.std_logic_1164.all;								package logic_pack is				  				  function resolve(s : std_ulogic_vector) return std_ulogic;								  SUBTYPE logic is resolve std_ulogic;								  TYPE logic_vector IS ARRAY (NATURAL RANGE ) OF logic;								  TYPE std_logic_array IS ARRAY (NATURAL RANGE ,NATURAL RANGE ) OF std_logic;								end logic_pack;												package body logic_pack is								    TYPE stdlogic_table IS ARRAY(std_ulogic, std_ulogic) OF std_ulogic;								    -------------------------------------------------------------------    				    -- resolution function				    -------------------------------------------------------------------    				    CONSTANT resolve_table : stdlogic_table := (				    --      ---------------------------------------------------------				    --      |  U    X    0    1    Z    W    L    H    -        |   |  				    --      ---------------------------------------------------------				            ( 'U', 'U', 'U', 'U', 'U', 'U', 'U', 'U', 'U' ), -- | U |				            ( 'U', 'X', 'X', 'X', 'X', 'X', 'X', 'X', 'X' ), -- | X |				            ( 'U', 'X', '0', '0', '0', '0', '0', '0', 'X' ), -- | 0 |				            ( 'U', 'X', '0', '1', '1', '1', '1', '1', 'X' ), -- | 1 |				            ( 'U', 'X', '0', '1', 'Z', 'W', 'L', 'H', 'X' ), -- | Z |				            ( 'U', 'X', '0', '1', 'W', 'W', 'W', 'W', 'X' ), -- | W |				            ( 'U', 'X', '0', '1', 'L', 'W', 'L', 'W', 'X' ), -- | L |				            ( 'U', 'X', '0', '1', 'H', 'W', 'W', 'H', 'X' ), -- | H |				            ( 'U', 'X', 'X', 'X', 'X', 'X', 'X', 'X', 'X' )  -- | - |				        );				        				    FUNCTION resolve ( s : std_ulogic_vector ) RETURN std_ulogic IS				        VARIABLE result : std_ulogic := 'Z';  -- weakest state default				    BEGIN				        -- the test for a single driver is essential otherwise the				        -- loop would return 'X' for a single driver of '-' and that				        -- would conflict with the value of a single driver unresolved				        -- signal.				        IF    (s'LENGTH = 1) THEN    RETURN s(s'LOW);				        ELSE				            FOR i IN s'RANGE LOOP				                result := resolve_table(result, s(i));				            END LOOP;				        END IF;				        RETURN result;				    END resolve;				end logic_pack;							

相关资源