我不太擅长VHDL。
我正在尝试使用VHDL中的9600 BAUD 8-n-1
创建UART。当我尝试通过USB通信时,我目前收到来自CoolTerm的成帧错误并崩溃。
我尝试将数组中的位数更改为9,并将完成的位仅设置为空闲状态。它仍然给我错误。
Transfer : process (Start_Tx, Osc, Value) is
variable Count : integer range 0 to 10416 ; -- Baud rate is calculated by OSC/Baud giving 10417 cycles
variable Iterator : integer range 0 to 9 ; -- The iteration variable to control which bit is shown
begin
if rising_edge(Osc) then -- on a rising edge
case (Current_State) is -- determine the current state
when IDLE =>
-- During the idle state the TX line should be held high, the done bit is also idle high
Tx_Out <= '1';
Tx_Done <= '1';
-- Start TX is a button input that when pressed will start the transfer
if(Start_Tx = '1')
then Current_State <= TRANSMIT ;
Tx_Done <= '0';
else Current_State <= IDLE;
end if;
when TRANSMIT =>
-- the transfer array is used to hold the values to be TX ( currently holding a dummy value for testing)
-- the value is as follows 'Start bit' "00010010" transfer data 'Stop Bit'
Transfer_Array <= "0000100101";
-- Transfer out starts with a value of Transfer_Array(0)
-- and will be iterated through every 10417 cycles for 9600 Baud
Tx_Out <= Transfer_Array(Iterator); -- Show digit
-- if the count is full Reset and check/ increment the Iterator and change states
-- if not increment the counter
if (Count = 10416)
then Count := 0 ;
if (Iterator = 9)
then Iterator := 0 ;
Current_State <= IDLE;
else Current_State <= TRANSMIT;
Iterator := Iterator +1;
end if;
else Count := Count + 1 ;
end if;
end case;
end if;
end process;
end Behavioral;