【发布时间】:2012-08-25 18:46:04
【问题描述】:
我已经制作了这个用于写入 USB 芯片的 VHDL 代码。
这一切都在一个 case 语句中运行,其中实现了每个操作(写入、读取等)。
下面两个写寄存器段是相等的,只是地址和数据不同。
这可以使用程序或其他东西来简化吗?
-------- 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;
【问题讨论】:
-
你为什么要这样做?您将使代码比它需要的复杂得多。你的代码有问题吗?您是否需要以任何方式对其进行优化,或者您只是想这样做,因为......?
-
只是因为我在重复我自己,所以如果我需要在写入序列中更改某些内容,我将不得不在所有写入序列中进行更改。
标签: vhdl