如何从字符串生成串行信号?

发布于 2024-08-12 20:53:00 字数 161 浏览 6 评论 0原文

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

How do I send data represented by a binary string (e.g. "01011101000100111", length is variable) to an std_logic signal given either fixed delay or clock signal? I want this for a testbench so I'd want to be able to arbitrarily change the binary string with as little hassle as possible, so I'm thinking of using generate.

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

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

发布评论

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

评论(2

不如归去 2024-08-19 20:53:00

我谦虚地提出一个固定延迟版本(毕竟它是测试平台代码......)。我已经检查过了,它可以工作,但我更喜欢 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;

I humbly present a fixed-delay version (it is testbench code after all...). I've checked this and it works, but I'm more comfortable in verilog so this code may no be the nicest VHDL ever...

--
-- 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;
放肆 2024-08-19 20:53:00

要添加到 Marty 的好答案中:

要使其计时,请将 wait for 10 ns; 更改为 wait waiting_edge(clk);

To add to Marty's fine answer:

To make it clocked, change the wait for 10 ns;s to wait until rising_edge(clk);

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文