我已经制作了用于写入USB芯片的VHDL代码。
这一切都在case语句中运行,其中实现了每个操作(write,read等)。
下面的两个写寄存器部分是相同的,只是地址和数据不同。
这可以通过程序或其他方式简化吗?
-------- WRITE REGISTER ---------
when s10 =>
-- Txd Cmd
txdata(7 downto 6) <= "10"; -- CMD = register write
txdata(5 downto 0) <= "000100"; -- address
state := s11;
when s11 =>
-- write reg
if nxt = '1' then
txdata <= X"45"; -- output on clock rising edge when nxt is high
stp <= '1';
state := s12;
end if;
when s12 =>
stp <= '0';
txdata <= "00000000"; -- idle
state := s20;
-------- WRITE REGISTER ---------
when s20 =>
-- Txd Cmd
txdata(7 downto 6) <= "10"; -- CMD = register write
txdata(5 downto 0) <= "110101"; -- address
state := s21;
when s21 =>
-- write reg
if nxt = '1' then
txdata <= X"04";
stp <= '1';
state := s22;
end if;
when s22 =>
stp <= '0';
txdata <= "00000000"; -- idle
state := s30;
答案 0 :(得分:1)
是的,请使用一个程序。这不是你在这里问过的吗?
答案 1 :(得分:0)
我建议您使用寄存器来获取地址和数据值。然后你必须描述实际写作只有一个,其他一切只是注册内容的变化。这可以在你开始写作之前的某个州完成......