2016-10-28 2 views
1

私は6ビットのstd_logic_vectorを複数の定数の任意の(つまり実行していない)6ビットの値と比較したいif節を持っています。私は "|"ケースストラクチャでは、しかしifステートメントを維持しながら、次のことを短縮する方法がありますか?私は100%確信していませんが、残りのデザインはVHDL93を使用していると思います。std_logic_vectorを複数の定数と比較する

if not (de_inst(31 downto 30) = FMT3 and (
    de_inst(24 downto 19) = LDSB or 
    de_inst(24 downto 19) = LDSH or 
    de_inst(24 downto 19) = LDUB or 
    de_inst(24 downto 19) = LDUH or 
    de_inst(24 downto 19) = LD or 
    de_inst(24 downto 19) = LDD or 
    de_inst(24 downto 19) = STB or 
    de_inst(24 downto 19) = STH or 
    de_inst(24 downto 19) = ST or 
    de_inst(24 downto 19) = ISTD or 
    de_inst(24 downto 19) = IAND or 
    de_inst(24 downto 19) = ANDN or 
    de_inst(24 downto 19) = IOR or 
    de_inst(24 downto 19) = ORN or 
    de_inst(24 downto 19) = IXOR or 
    de_inst(24 downto 19) = IXNOR or 
    de_inst(24 downto 19) = ISLL or 
    de_inst(24 downto 19) = ISRL or 
    de_inst(24 downto 19) = ISRA or 
    de_inst(24 downto 19) = IADD or 
    de_inst(24 downto 19) = ISUB or 
    de_inst(24 downto 19) = UMUL or 
    de_inst(24 downto 19) = SMUL or 
    de_inst(24 downto 19) = UDIV or 
    de_inst(24 downto 19) = SDIV)) then 
+0

親愛なるdownvoter、downvoteを与えるための理由でコメントを残したので、それは問題を改善することができます。 –

答えて

0

VHDLは、あなたの線に沿って、たとえば、あなたはすべての命令の「セット」を作るより高いレベル、でそれを書き、その後、信号はこれらの命令の1つの値を持っているかどうかを確認することができます:

subtype inst_t is std_logic_vector(5 downto 0); 
constant LDSB : inst_t := "000000"; -- Just some value 
... 
type inst_array_t is array(natural range <>) of inst_t; 
constant INST_SET : inst_array_t := (LDSB, ...); 
... 
function in_set(sig : inst_t; set : inst_array_t) return boolean is 
    variable res_v : boolean; 
begin 
    res_v := FALSE; 
    for idx in set'range loop 
    res_v := res_v or (sig = set(idx)); 
    end loop; 
    return res_v; 
end function; 
... 
if not ((de_inst(31 downto 30) = FMT3) and 
     in_set(de_inst(24 downto 19), INST_SET)) then 
    ... 
+0

ありがとう、これは動作し、私の最初のアプローチよりもはるかにエレガントに見えます:) – IngWer

関連する問題