Forum: FPGA, VHDL & Co. mal wieder: bad synchronous description.


von Tim (Gast)


Lesenswert?

Hallo liebe Experten!

Ich bin Neuling in VHDL, würde aber gerne wissen, warum ich die 
Fehlermeldung
"Signal sreg_data_in<0> cannot be synthesized, bad synchronous 
description.
erhalte."
Könnt Ihr mir bitte bei dem SPI-Interface weiterhelfen? Die Daten kommen 
parallel und sollen per Load zum Senden losgeschickt werden.

1
library IEEE;
2
use IEEE.STD_LOGIC_1164.ALL;
3
use IEEE.STD_LOGIC_ARITH.ALL;
4
use IEEE.STD_LOGIC_UNSIGNED.ALL;
5
6
---- Uncomment the following library declaration if instantiating
7
---- any Xilinx primitives in this code.
8
--library UNISIM;
9
--use UNISIM.VComponents.all;
10
11
entity spi_exchange_unit is
12
   generic( --
13
            -- data width
14
            WIDTH : integer := 8
15
   );
16
   port( Slow_clk : in STD_LOGIC;
17
         Data_tx  : in STD_LOGIC_VECTOR (7 downto 0);
18
         Data_rx  : out STD_LOGIC_VECTOR (7 downto 0);
19
         Load     : in STD_LOGIC;
20
         Done     : out STD_LOGIC;
21
         SCK      : out STD_LOGIC;
22
         MOSI     : out STD_LOGIC;
23
         MISO     : in STD_LOGIC);
24
end spi_exchange_unit;
25
26
architecture Behavioral of spi_exchange_unit is
27
28
   signal sreg_data_in  : std_logic_vector(7 downto 0) := (others => '0');
29
   signal sreg_data_out : std_logic_vector(7 downto 0) := (others => '0');
30
   signal databit_in    : integer range 0 to 8 := 0;
31
   signal databit_out   : integer range 0 to 7 := 0;
32
33
begin
34
35
   SCK <= Slow_clk;
36
37
   exchange_data : process(Slow_clk, Load, Data_tx, sreg_data_out, sreg_data_in, databit_out, databit_in)
38
      begin
39
         if Load = '1' then
40
            Done <= '0';
41
            sreg_data_out <= Data_tx;
42
            databit_out <= WIDTH-1;
43
            databit_in <= WIDTH;
44
            MOSI <= Data_tx(WIDTH-1);
45
         end if;
46
         if falling_edge(Slow_clk) then
47
            if databit_out > 0 then
48
               MOSI <= sreg_data_out(databit_out-1);
49
               databit_out <= databit_out - 1;
50
            else
51
               Done <= '1';
52
               MOSI <= '0';
53
               Data_rx <= sreg_data_in(WIDTH-1 downto 0);
54
            end if;
55
         elsif rising_edge(Slow_clk) then
56
            if databit_in > 0 then
57
               sreg_data_in(databit_in-1) <= MISO;
58
               databit_in <= databit_in - 1;
59
            end if;
60
         end if;
61
      end process exchange_data;
62
63
end Behavioral;

Liebe Grüße
Tim

von Tim (Gast)


Lesenswert?

Problem gelöst. Hier auch für alle anderen:

1
entity spi_exchange_unit is
2
   generic( --
3
            -- data width
4
            WIDTH : integer := 8
5
   );
6
   port( Slow_clk : in STD_LOGIC;
7
         Data_tx  : in STD_LOGIC_VECTOR (7 downto 0);
8
         Data_rx  : out STD_LOGIC_VECTOR (7 downto 0);
9
         Load     : in STD_LOGIC;
10
         Done     : out STD_LOGIC;
11
         SCK      : out STD_LOGIC;
12
         MOSI     : out STD_LOGIC;
13
         MISO     : in STD_LOGIC
14
   );
15
end spi_exchange_unit;
16
17
architecture Behavioral of spi_exchange_unit is
18
19
   signal sreg_data_in  : std_logic_vector(7 downto 0) := (others => '0');
20
   signal sreg_data_out : std_logic_vector(7 downto 0) := (others => '0');
21
   signal databit_in    : integer range 0 to 8 := 0;
22
   signal databit_out   : integer range 0 to 8 := 0;
23
24
begin
25
26
   SCK <= Slow_clk;
27
   
28
   receive_data : process(Slow_clk, Load, sreg_data_in, databit_in)
29
   begin
30
      if Load = '1' then
31
         databit_in <= WIDTH;
32
      elsif rising_edge(Slow_clk) then
33
         if databit_in > 0 then
34
            sreg_data_in(databit_in-1) <= MISO;
35
            databit_in <= databit_in - 1;
36
         end if;
37
      end if;
38
   end process receive_data;
39
40
   send_data : process(Slow_clk, Load, Data_tx, sreg_data_out, databit_out)
41
   begin
42
      if Load = '1' then
43
         Done <= '0';
44
         sreg_data_out <= Data_tx;
45
         databit_out <= WIDTH-1;
46
         MOSI <= Data_tx(WIDTH-1);
47
      elsif falling_edge(Slow_clk) then
48
         if databit_out > 0 then
49
            MOSI <= sreg_data_out(databit_out-1);
50
            databit_out <= databit_out - 1;
51
         else
52
            Done <= '1';
53
            MOSI <= '0';
54
            Data_rx <= sreg_data_in(WIDTH-1 downto 0);
55
         end if;
56
      end if;
57
   end process send_data;
58
59
end Behavioral;

Gruß

von Lothar M. (Firma: Titel) (lkmiller) (Moderator) Benutzerseite


Lesenswert?

>> Signal ... cannot be synthesized, bad synchronous description.
> Hier auch für alle anderen:
Falls jemand mal wissen will, woran es gelegen hat...
1
         if falling_edge(Slow_clk) then
2
          :
3
         elsif rising_edge(Slow_clk) then
4
          :
5
         end if;
So ein Flipflop, das auf eine steigende und eine fallende Flanke 
reagieren kann, gibt es bestenfalls in den IO-Zellen (als DDR-FF).

> Problem gelöst.
Aber nur unsauber:
Mit dem asynchronen Reset kann eine Übertragung jederzeit undefiniert 
terminiert werden.

Besser wäre das SPI-Interface über ein Schieberegister statt mit einem 
Multiplexer realisiert worden. Denn SPI ist eigentlich nur ein 
gekoppeltes Schieberegister... :-/

Bitte melde dich an um einen Beitrag zu schreiben. Anmeldung ist kostenlos und dauert nur eine Minute.
Bestehender Account
Schon ein Account bei Google/GoogleMail? Keine Anmeldung erforderlich!
Mit Google-Account einloggen
Noch kein Account? Hier anmelden.