【问题标题】:Error (10327): can't determine definition of operator ""="" -- found 0 possible definitions错误 (10327): 无法确定运算符 ""="" 的定义 -- 找到 0 个可能的定义
【发布时间】:2018-01-13 19:04:03
【问题描述】:

在 VHDL '93 中,编译器告诉我它为运算符“=”找到了 0 个可能的定义。 它会导致错误并显示以下错误消息:

Error (10327): VHDL error at mst_fifo_fsm.vhd(171): can't determine definition of operator ""="" -- found 0 possible definitions

第 171 行是 ifsm_cond(0) 的第一个赋值:

process(clk, rst_n) 
begin
if (rst_n = '0') then
    ifsm_cond <= "0000";
elsif (rising_edge(clk)) then
    if (mltcn = '0') then
        ifsm_cond(0) <= (cur_stap1 = IDLE) AND (not imst_rd_n(0)) AND (not rxf_n) AND (not ibuf_ful(0));
        ifsm_cond(1) <= (cur_state = MTRD) AND ( imst_rd_n(0)  OR (rxf_n  AND (not rxf_n_p1))  OR ibuf_ful(0)) ;
        ifsm_cond(2) <= (cur_state = MDLE) AND (not imst_wr_n(0)) AND (not txe_n)& (ibuf_nep(0)  OR stren OR w_1byte) AND (not w_1flag);
        ifsm_cond(3) <= (cur_stap3 = MTWR) AND ( imst_wr_n(0)  OR (txe_n  AND (not txe_n_p1))  OR r_oobe OR ((not ififonempt(0)) AND (not stren) AND (not prefnempt(0))));
    else
        ifsm_cond(0) <= (not imst_rd_n(conv_integer(ichannel))) AND (not irxf_n(conv_integer(ichannel))) AND (not ibuf_ful(conv_integer(ichannel))) AND (cur_stap3 = IDLE);
        ifsm_cond(1) <= ( imst_rd_n(conv_integer(ichannel))  OR (rxf_n & (not rxf_n_p1)) OR ibuf_ful(conv_integer(ichannel))) AND (cur_state = MTRD);
        ifsm_cond(2) <= (not imst_wr_n(conv_integer(ichannel))) AND (not itxe_n(conv_integer(ichannel)))  AND (ibuf_nep(conv_integer(ichannel)) OR stren) AND (cur_stap3 = MDLE);
        ifsm_cond(2) <= (not imst_wr_n(conv_integer(ichannel))) AND (not itxe_n(conv_integer(ichannel)))  AND (ibuf_nep(conv_integer(ichannel)) OR stren) AND (cur_stap3 = MDLE);
        ifsm_cond(3) <= ( imst_wr_n(conv_integer(ichannel))  OR (rxf_n AND 
        (not rxf_n_p1)) OR ((not ififonempt(conv_integer(ichannel)) AND (not stren) 
        AND (not prefnempt(conv_integer(ichannel)))))) AND (cur_stap3 = MTWR);
        end if;
    end if;
end process;

我猜它在语句中 (cur_stap1 = IDLE)。

cur_stap1 是一个用户定义的信号,声明如下:

type states is (IDLE, MTRD, MDLE, MTWR);
signal cur_state, next_statem, cur_stap1, cur_stap2, cur_stap3, cur_stap4 : 
states;       

如果 cur_stap1 为 IDLE,我想一种可能的解决方案首先在条件并发信号分配中澄清,并将其分配给替换 (cur_stap1 = IDLE) 的信号。但我还有一些其他类似这样的陈述。

有没有更好的解决方案来解决这个问题?这种并发信号分配是在一个进程中完成的。我是否应该为整行尝试使用 IF ELSIF END IF 语句?

提前谢谢你。

【问题讨论】:

  • 提供一个Minimal, Complete and Verifiable example,包括上下文子句/项目和声明。完整的错误消息也很有帮助。否则,在不知道更好的情况下 cur_stap = IDLE 似乎会返回一个布尔值。 not rxf_n 之类的,类型为 rxf_n 的值被声明为。没有预定义的逻辑运算符混合布尔值和不同类型作为操作数。考虑学习运算符优先级,不需要任何表达式括号。
  • 是的,您可以在那里使用该运算符。但是你必须确保一个匹配的= 函数声明是可见的。将其设为minimal reproducible example,我们将能够看到错误。但是要么 NO = 是可见的(你正在比较不同的类型或返回错误的类型......布尔值你需要 std_logic 的地方)或者两个或更多是可见的(也许你写了你自己的 = 并且也有一个内在的) .
  • @BrianDrummond 我在上面的帖子中进行了编辑。我想我需要 std_logic 但 (cur_stap1 = IDLE) 会给我一个布尔返回类型。匹配 = 函数声明是什么意思?
  • @JHBonarius 我把它改成了想要的信息。
  • 现在我们有了声明,我们可以看到没有与参数和返回类型匹配的= 函数,具体来说,没有function "=" (L,R : states) return std_logic;,而这段代码需要一个。不一定推荐这种方法(除了作为理解 VHDL 的练习),但是:没有什么可以阻止你写一个。

标签: vhdl


【解决方案1】:

问题是not imst_rd_n(0) 返回一个std_logic 类型,而cur_stap1 = IDLE 返回一个boolean 类型。没有接受这两种类型的and 运算符,因此编译器尝试以另一种方式解决它:通过查找为您的自定义类型(状态)定义的返回std_logic= 运算符,但没有.因此出现错误。

你应该写imst_rd_n(0)='0'而不是not imst_rd_n(0)等等。这将返回一个 boolean 并定义了一个 boolean and 运算符。恕我直言,它的可读性也更好。 然后你应该在if 语句中写下你的任务。

If [boolean expression] then
    [Signal] <= '1';
Else
    [Signal] <= '0';
End if;

也尝试设计一个输出简单的状态机:

Case [current_state] is
    When [state 1] =>
        If ....
    When ....
End case;

您可以使用默认分配。 示例:

if rising_edge(clk) then
    ifsm_cond <= (others => '0'); -- default assignment
    case cur_state is
        when IDLE =>
            if imst_rd_n(0)='0' AND rxf_n='0' AND ibuf_ful='0' then
                ifsm_cond(0) <= '1';
            end if;
        when MTRD =>
            if imst_rd_n(0)='1'  OR (rxf_n='1'  AND rxf_n_p1='0')  OR ibuf_ful(0)='1' then
                ifsm_cond(1) <= '1';
            end if;

等等


我不会为运算符= 编写返回std_logic 的两个输入类型states 的函数,因为这可能会导致其他不必要的冲突。相反,我建议从booleanstd_logic 进行转换功能。例如:

function to_std_logic(input : boolean) return std_ulogic is
begin
    if input then
        return '1';
    end if;
    return '0';
end function;

使用示例:ifsm_cond(0) &lt;= to_std_logic(cur_stap1 = IDLE) AND (not imst_rd_n(0)) AND (not rxf_n) AND (not ibuf_ful(0));

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2015-09-25
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多