VHDL Compare 不能在硬件中工作,但可以在模拟中工作

发布于 2024-12-13 16:14:45 字数 1306 浏览 0 评论 0原文

大家好,我有以下 VHDL,它在硬件中没有实现预期的功能,但在模拟中确实有效。基本上我有一个计数器,根据我想要输出某些数据的计数,我实现了多路复用器,如下所示:

write_data  <=  
('1' & '0' & "1111"                                                              )  when (data_cnt_r < 1)  else             
('0' & '0' & "1111"                                                              ) when (data_cnt_r >= 1 and data_cnt_r < 2 ) else
('0' & '0' & "0000"                                                              ) when (data_cnt_r >= 2 and data_cnt_r < 3 ) else  
('0' & '0' & data_reg                                                        ) when (data_cnt_r >= 3  and data_cnt_r < 1027 ) else
('0' & '1' & CRC16_o(63) & CRC16_o(47) & CRC16_o(31) & CRC16_o(15) ) when (data_cnt_r >= 1027  and data_cnt_r < 1043 ) else 
('0' & '0' & "1111");   

我遇到的问题是,当计数为 1043 时,我看到 CRC 输出,而不是最后看到“1111”代码中的行。在模拟中,它的工作原理正如我所期望的那样。有更好的方法来写这个吗?有什么想法为什么会出现差异吗?

*根据要求编辑更多详细信息:

我使用的

   use IEEE.STD_LOGIC_UNSIGNED.ALL; 

data_cnt 是一个免费运行的计数器,一切都是 std_logic_vector 或 std_logic

    signal data_cnt_r       : std_logic_vector(11 downto 0); -- 12 bit counter

write_data 进入 BUFIO,它也是一个标准逻辑向量

Hi guys I have the following VHDL which isn't doing what it suppose to in hardware but it does work in simulation. Basically I have a counter and depending on the count I want certain data to be output I implemented the mux as following:

write_data  <=  
('1' & '0' & "1111"                                                              )  when (data_cnt_r < 1)  else             
('0' & '0' & "1111"                                                              ) when (data_cnt_r >= 1 and data_cnt_r < 2 ) else
('0' & '0' & "0000"                                                              ) when (data_cnt_r >= 2 and data_cnt_r < 3 ) else  
('0' & '0' & data_reg                                                        ) when (data_cnt_r >= 3  and data_cnt_r < 1027 ) else
('0' & '1' & CRC16_o(63) & CRC16_o(47) & CRC16_o(31) & CRC16_o(15) ) when (data_cnt_r >= 1027  and data_cnt_r < 1043 ) else 
('0' & '0' & "1111");   

The problem I am getting is that when the count is 1043 I see the CRC output instead of seeing "1111" for the last line in the code. In the simulation it works like I would expect. Is there a better way to write this? Any ideas why the discrepancy?

*EDIT More details as requested:

I'm using

   use IEEE.STD_LOGIC_UNSIGNED.ALL; 

data_cnt is a free runnig counter, everything is std_logic_vector or std_logic

    signal data_cnt_r       : std_logic_vector(11 downto 0); -- 12 bit counter

write_data goes to a BUFIO and it is also a standard logic vector

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

世俗缘 2024-12-20 16:14:45

你的其他转变附近发生了什么? (1027, 3, 2, 1)
这是在进程块中还是异步?
data_cnt_r 是无符号的吗? data_reg 和 CRC 值怎么样?我假设两个 std_logic_vectors?

我们需要更多的上下文,

您可以尝试显式添加一个转换,看看它是否有帮助:

('0' & '1' & CRC_stor)  when (data_cnt_r >= 1027 and data_cnt_r < 1043 ) else 
('0' & '0' & "1111"  )  when (data_cnt_r = 1043) else
('0' & '0' & "1111"  );

如果这实际上是在时钟进程块中,您可能会在一个时钟周期后看到 write_data 中的 CRC 值,但您也会看到这个问题你的其他转换(它们都会更新 data_cnt_r 后面的一个周期)

如果它位于非时钟进程块中,你可能会遇到意外的逻辑错误

另外,这更容易阅读。

CRC_stor <= CRC16_o(63) & CRC16_o(47) & CRC16_o(31) & CRC16_o(15)

write_data  <=  
   ('1' & '0' & "1111"  )  when (data_cnt_r = 0) else             
   ('0' & '0' & "1111"  )  when (data_cnt_r = 1) else
   ('0' & '0' & "0000"  )  when (data_cnt_r = 2) else  
   ('0' & '0' & data_reg)  when (data_cnt_r >= 3    and data_cnt_r < 1027 ) else
   ('0' & '1' & CRC_stor)  when (data_cnt_r >= 1027 and data_cnt_r < 1043 ) else 
   ('0' & '0' & "1111"  );

What is happening near your other transitions? (1027, 3, 2, 1)
is this in a process block or is it asynch?
is data_cnt_r an unsigned? What about data_reg and CRC values? I assume both std_logic_vectors?

We need a little more context

you could try explicitly adding a transition to see if it helps ala:

('0' & '1' & CRC_stor)  when (data_cnt_r >= 1027 and data_cnt_r < 1043 ) else 
('0' & '0' & "1111"  )  when (data_cnt_r = 1043) else
('0' & '0' & "1111"  );

if this is actually in a clocked process block you might see the CRC values in write_data a clock cycle later but then you would also see this problem around your other transitions (they would all update a cycle behind data_cnt_r)

You might be getting unexpected logical errors if its in an unclocked process block

Also this is a little easier to read.

CRC_stor <= CRC16_o(63) & CRC16_o(47) & CRC16_o(31) & CRC16_o(15)

write_data  <=  
   ('1' & '0' & "1111"  )  when (data_cnt_r = 0) else             
   ('0' & '0' & "1111"  )  when (data_cnt_r = 1) else
   ('0' & '0' & "0000"  )  when (data_cnt_r = 2) else  
   ('0' & '0' & data_reg)  when (data_cnt_r >= 3    and data_cnt_r < 1027 ) else
   ('0' & '1' & CRC_stor)  when (data_cnt_r >= 1027 and data_cnt_r < 1043 ) else 
   ('0' & '0' & "1111"  );
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文