UART Получение данных в VHDL - PullRequest
0 голосов
/ 10 января 2019

Я пытаюсь создать простой код UART в коде VHDL, который получает символ, а затем отправляет его обратно на ПК. Моя программа на основе этого примера кода введите описание ссылки здесь . Передача UART работает нормально, но при приеме UART ничего не получено. После того, как синтез завершен, появилось несколько предупреждений о ff / latch, что делает «хранимые» данные постоянными.

WARNING:Xst:1293 - FF/Latch <store_2> has a constant value of 0 in block <uart>. This FF/Latch will be trimmed during the optimization process.
WARNING:Xst:1896 - Due to other FF/Latch trimming, FF/Latch <store_3> has a constant value of 0 in block <uart>. This FF/Latch will be trimmed during the optimization process.
WARNING:Xst:1896 - Due to other FF/Latch trimming, FF/Latch <store_4> has a constant value of 0 in block <uart>. This FF/Latch will be trimmed during the optimization process.
WARNING:Xst:1896 - Due to other FF/Latch trimming, FF/Latch <store_5> has a constant value of 0 in block <uart>. This FF/Latch will be trimmed during the optimization process.
WARNING:Xst:1896 - Due to other FF/Latch trimming, FF/Latch <store_6> has a constant value of 0 in block <uart>. This FF/Latch will be trimmed during the optimization process.
WARNING:Xst:1896 - Due to other FF/Latch trimming, FF/Latch <store_7> has a constant value of 0 in block <uart>. This FF/Latch will be trimmed during the optimization process.
WARNING:Xst:1896 - Due to other FF/Latch trimming, FF/Latch <state1_FSM_FFd8> has a constant value of 0 in block <uart>. This FF/Latch will be trimmed during the optimization process.
WARNING:Xst:1896 - Due to other FF/Latch trimming, FF/Latch <state1_FSM_FFd5> has a constant value of 0 in block <uart>. This FF/Latch will be trimmed during the optimization process.
WARNING:Xst:1896 - Due to other FF/Latch trimming, FF/Latch <state1_FSM_FFd7> has a constant value of 0 in block <uart>. This FF/Latch will be trimmed during the optimization process.
WARNING:Xst:1896 - Due to other FF/Latch trimming, FF/Latch <state1_FSM_FFd6> has a constant value of 0 in block <uart>. This FF/Latch will be trimmed during the optimization process.
WARNING:Xst:1896 - Due to other FF/Latch trimming, FF/Latch <state1_FSM_FFd4> has a constant value of 0 in block <uart>. This FF/Latch will be trimmed during the optimization process.
WARNING:Xst:1896 - Due to other FF/Latch trimming, FF/Latch <state1_FSM_FFd3> has a constant value of 0 in block <uart>. This FF/Latch will be trimmed during the optimization process.

Пожалуйста, помогите мне и спасибо заранее! И вот мой основной код:

library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
use IEEE.STD_LOGIC_ARITH.ALL;
use IEEE.STD_LOGIC_UNSIGNED.ALL;

entity uart is
port (   clk   : in   std_logic;
         rx    : in   std_logic;
         tx    : out  std_logic);

end uart;

architecture Behavioral of uart is
--fsm for transmission
type fsm  is (idle,b1,b2,b3,b4,b5,b6,b7,b8,b9);                         
signal state  : fsm  := idle;

--fsm for reception
type fsm1 is (idle1,b11,b21,b31,b41,b51,b61,b71,b81,b91);       
signal state1 : fsm1 := idle1;

signal start  : std_logic;
signal store  : std_logic_vector (7 downto 0) := "00000000"; 
--store received data

begin

--reception
process(clk)
variable i : integer := 0;  --baudtick
begin
if clk'event and clk = '1' then 
    i := i + 1;

    if state1 = idle1 then
    start <= rx;
    end if;
    if start = '0' then  --check start bit 0
    state1 <= b11;
    elsif start = '1' then
    state1 <= idle1;
    end if;

    --store 8 bits
    if (state1 = b11) then --1
    store(0) <= rx;
        if i = 26042 then
        state1 <= b21;
        i := 0;
        end if;
    end if;

    if (state1 = b21) then --2
    store(1) <= rx;
        if i = 26042 then
        state1 <= b31;
        i := 0;
        end if;
    end if;

    if (state1 = b31) then --3
    store(2) <= rx;
        if i = 26042 then
        state1 <= b41;
        i := 0;
        end if;
    end if;

    if (state1 = b41) then --4
    store(3) <= rx;
        if i = 26042 then
        state1 <= b51;
        i := 0;
        end if;
    end if;

    if (state1 = b51) then --5
    store(4) <= rx;
        if i = 26042 then
        state1 <= b61;
        i := 0;
        end if;
    end if;

    if (state1 = b61) then --6
    store(5) <= rx;
        if i = 26042 then
        state1 <= b71;
        i := 0;
        end if;
    end if;

    if (state1 = b71) then --7
    store(6) <= rx;
        if i = 26042 then
        state1 <= b81;
        i := 0;
        end if;
    end if;

    if (state1 = b81) then --8
    store(7) <= rx;
        if i = 26042 then
        state1 <= idle1;
        i := 0;
        end if;
    end if;     
  end if;
end process;

--transmission      
process(clk)
variable i : integer := 0;  --baudtick
begin
if clk'event and clk = '1' then 
    i := i + 1;

    if state = idle then
        if start = '0' then  --send start bit 0
        tx <= '0';
            if i = 26042 then
            state <= b1;
            i := 0;
            end if;
        elsif start = '1' then
        state <= idle;
        end if;
    end if;

    --send 8 bits
    if (state = b1) then --1
    tx <= store(0);
        if i = 26042 then
        state <= b2;
        i := 0;
        end if;
    end if;

    if (state = b2) then --2
    tx <= store(1);
        if i = 26042 then
        state <= b3;
        i := 0;
        end if;
    end if;

    if (state = b3) then --3
    tx <= store(2);
        if i = 26042 then
        state <= b4;
        i := 0;
        end if;
    end if;

    if (state = b4) then --4
    tx <= store(3);
        if i = 26042 then
        state <= b5;
        i := 0;
        end if;
    end if;

    if (state = b5) then --5
    tx <= store(4);
        if i = 26042 then
        state <= b6;
        i := 0;
        end if;
    end if;

    if (state = b6) then --6
    tx <= store(5);
        if i = 26042 then
        state <= b7;
        i := 0;
        end if;
    end if;

    if (state = b7) then --7
    tx <= store(6);
        if i = 26042 then
        state <= b8;
        i := 0;
        end if;
    end if;

    if (state = b8) then --8
    tx <= store(7);
        if i = 26042 then
        state <= b9;
        i := 0;
        end if;
    end if;

    if (state = b9) then --stop
    tx <= '1';
        if i = 26042 then
        state <= idle;
        i:= 0;
        end if;
    end if;
 end if;
 end  process;
 end Behavioral;

1 Ответ

0 голосов
/ 10 января 2019

Предупреждение о «Обрезке FF / Latch» указывает на то, что инструмент синтеза определил, что некоторая часть конструкции, в данном случае FF, не используется, и, следовательно, может быть удалена. Для конкретного кода это указывает на ошибку в проекте, так как все 8 бит store необходимы для правильной работы проекта.

При создании проекта для синтеза вам следует смоделировать код для обеспечения правильной функциональности, прежде чем пытаться заставить проект работать на аппаратном обеспечении (FPGA). Такая симуляция вашего дизайна покажет, что он работает не так, как ожидалось. Симулятор ModelSim предоставляется бесплатно в комплекте Intel Quartus для использования на небольших моделях.

Вам, вероятно, следует взглянуть на первые строки в процессе получения:

...
if state1 = idle1 then
    start <= rx;
end if;
if start = '0' then  --check start bit 0
    state1 <= b11;
...
...