0

I have made this VHDL code for writing to a USB-chip.

It all runs inside a case statement, where each operation (write, read, ect.) is implemented.

The two write register sections below are equal, only different by the address and data.

Can this be simplified using a procedure or something?

            -------- 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;
4

2 回答 2

1

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

设计用于初始化的 VHDL 状态机

于 2012-09-03T14:57:16.283 回答
0

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

于 2012-09-03T11:13:08.217 回答