【问题标题】:optimizing VHDL code [closed]优化 VHDL 代码
【发布时间】: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


【解决方案1】:

是的,使用程序。这不是你在这里问的吗?

Design VHDL state machine for initialization

【讨论】:

    【解决方案2】:

    我建议您使用寄存器来存储地址和数据值。然后你要描述实际写的只有一个,其他的都只是寄存器内容的变化。这可以在你开始写作之前的状态下完成......

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2022-11-23
      • 2011-12-21
      相关资源
      最近更新 更多