文字列からシリアル信号を生成する方法は?
質問
バイナリ文字列(例:" 01011101000100111"
、長さは可変)で表されるデータを、固定遅延またはクロック信号のいずれかが指定されたstd_logic信号に送信するにはどうすればよいですか?テストベンチ用にこれが欲しいので、できるだけ手間をかけずにバイナリ文字列を任意に変更できるようにしたいので、 generate
を使用することを考えています。
解決
固定遅延バージョンを謙虚に提示します(結局テストベンチコードです...)。これを確認しましたが、動作しますが、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;
他のヒント
マーティのすばらしい答えに追加するには:
時刻を合わせるには、 wait for 10 ns;
s to wait until rising_edge(clk);
所属していません StackOverflow