USB 칩에 쓰기 위해이 VHDL 코드를 만들었습니다.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;
왜 그렇게 하시겠습니까? 코드를 필요한 것보다 훨씬 더 복잡하게 만듭니다. 코드에 문제가 있습니까? 당신은 어떤 식 으로든 그것을 최적화 할 필요가 있거나 단지 ....하기 때문에 그것을하고 싶습니까? – FarhadA
자기 자신을 반복하고 있기 때문에 쓰기 시퀀스에서 뭔가를 변경해야한다면 모든 쓰기 시퀀스에서 변경해야 할 것입니다. – JakobJ
[디자인을위한 VHDL 상태 머신 디자인 가능] (http://stackoverflow.com/questions/11937254/design-vhdl-state-machine-for-initialization) – bstpierre