如果给定固定延迟或时钟信号,如何将二进制字符串表示的数据(例如" 01011101000100111" ,长度可变)发送到std_logic信号?我希望这个用于测试平台,所以我希望能够以尽可能少的麻烦随意更改二进制字符串,所以我正在考虑使用 generate

有帮助吗?

解决方案

我谦卑地提出了一个固定延迟版本(毕竟它是testbench代码......)。我已经检查了这个并且它有效,但我在verilog中更舒服,所以这段代码可能不是最好的VHDL ......

--
-- Clocking out bitstream
--

library ieee;
use ieee.std_logic_1164.all;

entity stackoverflow_strings is
end stackoverflow_strings;

-- this is testbench code, so we can use "wait"s inside a "for" loop.
architecture rtl of stackoverflow_strings is
signal my_output : std_ulogic;
begin

shift_data : process is
constant my_bits : std_logic_vector := B"100101010000100010101";
begin
   my_output <= '0';
   wait for 10 ns; 
   for i in my_bits'range loop
      my_output <= my_bits(i);
      wait for 10 ns;
   end loop; 

   wait;
end process shift_data;

end rtl;

其他提示

添加Marty的好答案:

要使其计时,请将等待10 ns; s更改为等到rising_edge(clk);

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top