Vhdl 将std_逻辑_向量与多个常量进行比较

Vhdl 将std_逻辑_向量与多个常量进行比较,vhdl,Vhdl,我有一个if子句,其中我想比较一个6位std_逻辑_向量和多个常量任意(即不运行的数字)6位值。我知道我可以在case结构中使用“|”,但是有没有办法在保留if语句的同时缩短以下内容?我不是100%确定,但我认为设计的其余部分使用的是VHDL 93 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 d

我有一个if子句,其中我想比较一个6位std_逻辑_向量和多个常量任意(即不运行的数字)6位值。我知道我可以在case结构中使用“|”,但是有没有办法在保留if语句的同时缩短以下内容?我不是100%确定,但我认为设计的其余部分使用的是VHDL 93

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

VHDL允许您在更高的级别编写它,在该级别中,您对所有指令进行“设置”,然后检查信号是否具有这些指令之一的值,例如沿着以下行:

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
  ...
subtype inst是标准逻辑向量(5到0);
常数LDSB:inst:=“000000”——只是一些价值
...
类型inst_数组是inst的数组(自然范围);
常量指令集:指令数组:=(LDSB,…);
...
集合(sig:inst;集合:inst\U数组)中的函数返回布尔值为
变量res_v:布尔值;
开始
res_v:=假;
对于设置范围循环中的idx
res_v:=res_v或(sig=set(idx));
端环;
返回resu v;
末端功能;
...
如果不是((仪表(31至30)=FMT3)和
在设置中(安装(24至19),安装设置),然后
...

VHDL允许您在更高的级别编写它,在该级别中,您对所有指令进行“设置”,然后检查信号是否具有这些指令之一的值,例如沿着以下行:

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
  ...
subtype inst是标准逻辑向量(5到0);
常数LDSB:inst:=“000000”——只是一些价值
...
类型inst_数组是inst的数组(自然范围);
常量指令集:指令数组:=(LDSB,…);
...
集合(sig:inst;集合:inst\U数组)中的函数返回布尔值为
变量res_v:布尔值;
开始
res_v:=假;
对于设置范围循环中的idx
res_v:=res_v或(sig=set(idx));
端环;
返回resu v;
末端功能;
...
如果不是((仪表(31至30)=FMT3)和
在设置中(安装(24至19),安装设置),然后
...

亲爱的downvoter,如果您留下了一条评论,并给出了进行downvoter的理由,那就太好了,这样问题就可以改进了。亲爱的downvoter,如果您留下了一条评论,并给出了进行downvoter的理由,那么问题就可以改进了。谢谢,这很有效,而且看起来比我最初的方法优雅得多:)谢谢,这样做很有效,只是看起来比我最初的方法优雅得多:)