在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语句?
提前谢谢。
答案 0 :(得分:2)
问题是not imst_rd_n(0)
会返回std_logic
类型,而cur_stap1 = IDLE
会返回boolean
类型。没有and
运算符接受这两种类型,因此编译器尝试以另一种方式解决它:通过查找为您的自定义类型(状态)定义的=
运算符返回std_logic
,没有。因此错误。
而不是not imst_rd_n(0)
,您应该写imst_rd_n(0)='0'
,依此类推。这会返回boolean
,并定义boolean
and
运算符。 Imho它的可读性也更好。
然后,您应该在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;
等
对于返回=
的两个输入类型states
,我不会为运算符std_logic
编写函数,因为这可能会导致其他不需要的冲突。我建议从boolean
到std_logic
建立一个强制转换函数。 E.g:
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) <= to_std_logic(cur_stap1 = IDLE) AND (not imst_rd_n(0)) AND (not rxf_n) AND (not ibuf_ful(0));