FlyingDutch
Advanced Member level 1
- Joined
- Dec 16, 2017
- Messages
- 458
- Helped
- 45
- Reputation
- 92
- Reaction score
- 55
- Trophy points
- 1,308
- Location
- Bydgoszcz - Poland
- Activity points
- 6,318
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
use IEEE.STD_LOGIC_UNSIGNED.ALL;
entity top_spi is
Port (
clk_iT : in STD_LOGIC;
en_i_LowT : in STD_LOGIC;
data_ready_oT : out STD_LOGIC;
cs_oT : out STD_LOGIC;
sclk_oT : out STD_LOGIC;
mosi_oT : out STD_LOGIC;
miso_iT : in STD_LOGIC
);
end top_spi;
architecture Behavioral of top_spi is
component lw_spi_master is
generic (
c_clkfreq : integer := 12_000_000;
c_sclkfreq : integer := 5_000_000;
c_cpol : std_logic := '0';
c_cpha : std_logic := '0'
);
Port (
clk_i : in STD_LOGIC;
en_i_Low : in STD_LOGIC;
mosi_data_i : in STD_LOGIC_VECTOR (7 downto 0);
miso_data_o : out STD_LOGIC_VECTOR (7 downto 0);
data_ready_o : out STD_LOGIC;
cs_o : out STD_LOGIC;
sclk_o : out STD_LOGIC;
mosi_o : out STD_LOGIC;
miso_i : in STD_LOGIC
);
end component;
signal in_data : std_logic_vector (7 downto 0) := (others => '0');
signal out_data : std_logic_vector (7 downto 0) := (others => '0');
signal cnt: std_logic_vector(7 downto 0) := (others=>'0');
signal en_i_INT : std_logic := '0';
signal valid : boolean := False;
type byte_array is array (0 to 8) of std_logic_vector(7 downto 0);
signal dane_spi : byte_array;
begin
dane_spi(0)<= x"AA"; --170
dane_spi(1)<= x"FF"; --255
dane_spi(2)<= x"08"; --8
dane_spi(3)<= x"01"; --1
dane_spi(4)<= x"C2"; --194
dane_spi(5)<= x"A4"; --164
dane_spi(6)<= x"11"; --17
dane_spi(7)<= x"66"; --146
SPI_MAS : lw_spi_master
generic map(
c_clkfreq => 27_000_000,
c_sclkfreq => 5_000_000,
c_cpol => '0',
c_cpha => '0'
)
port map(
clk_i => clk_iT,
en_i_Low => en_i_LowT,
mosi_data_i => in_data,
miso_data_o => out_data,
data_ready_o => data_ready_oT,
cs_o => cs_oT,
sclk_o => sclk_oT,
mosi_o => mosi_oT,
miso_i => miso_iT
);
---------------------------------------------------
Change_data: process
begin
for I in 0 to 8 loop
in_data <= dane_spi(I);
end loop;
end process;
end Behavioral;
type byte_array is array (0 to 8) of std_logic_vector(7 downto 0);
signal dane_spi : byte_array;
begin
dane_spi(0)<= x"AA"; --170
dane_spi(1)<= x"FF"; --255
dane_spi(2)<= x"08"; --8
dane_spi(3)<= x"01"; --1
dane_spi(4)<= x"C2"; --194
dane_spi(5)<= x"A4"; --164
dane_spi(6)<= x"11"; --17
dane_spi(7)<= x"66"; --146
Change_data: process
begin
for I in 0 to 8 loop
in_data <= dane_spi(I);
end loop;
end process;
Check_data: process (in_data)
begin
and here some code
end process;
Change_data: process
begin
for I in 0 to 8 loop
in_data <= dane_spi(I);
end loop;
end process;
in_data <= dane_spi(8);
Hello,Is effectively performingCode:Change_data: process begin for I in 0 to 8 loop in_data <= dane_spi(I); end loop; end process;
the assignments of dane_spi(0) to dane_spi(7) are immediately overwritten and have no effect.Code:in_data <= dane_spi(8);
In other words, the code demonstrates a basic lack of understanding sequential HDL code "execution".
It is nothing to do with delta zero time. You need to separate between code meant to settle at compile time and final code passed for synthesis. The compiler has a mind of its own...Hello,
It is just as I thought. I assumed that this code is performed in delta zero time and has no effect.
Thanks for confirmation.
Best Regards
Hi,Hi,
so it´s not the FPGA´s intention to do task step by step or clock cycle by clock cycle.
It´s the person´s job who writes the VHDL code.
.. like: do something "on every rising edge of clock"
So on the first clock edge edge it does something .. on the next clock edge it does something ... and so on.
I guess you should have a look at some tutorial videos
Klaus
technically, this explanation is not right. but in practice, we could say that yes, the last assignment has "priority"It is nothing to do with delta zero time. You need to separate between code meant to settle at compile time and final code passed for synthesis. The compiler has a mind of its own...
The compiler sees that you want to drive a target in a loop from multiple sources. Which one? Priority is given to last statement when you unroll the loop.
It is correct. The code, as written (and corrected to have a sensitivity list) will assing the same bit over and over in the same delta from the different bits of dane_spi. Because the last one is always assigned when the process suspends, then dane_spi(8) is always assigned.technically, this explanation is not right. but in practice, we could say that yes, the last assignment has "priority"
Take it easy mate...it is not a mystery. The compiler deletes what it sees as meaningless and doesn't pass it to next stage. No need to keep digging in this trivial issue. Be practical. The compiler is done by human like you and is not a mystery.overwritten? yes. priority? no. they are all the same type of assignment. there is no notion of one assignment being stronger than others, which then would imply priority.
The FPGA vendors are very keen to fit logic in their devices and achieve speed rather than stuff it up. So a lot of effort is done at compile time to reduce and optimise unnecessary statements including extreme cases when nothing is left for target device in some Uni projects.Hi,
in my understanding (I may be wrong..)
the above FOR ... LOOP does exist only in the source file.
The compiler does the preprocessing and finds out that only dane_spi(8) is assigned and thus all the others are ignored.
The compiler processes it in the order like in the source code, but the silicon doesn´t know about loop states 0..7 because they are removed (useless).
Consequently on the silicon there is "no time" for the loop 0..7, because it is not processed at all.
***
I wonder if one really can do an unclocked 0..8 loop on the silicon.
Klaus
Change_data: process
begin
in_data <= default_value;
for I in 0 to 8 loop
if condition(I) then
in_data <= dane_spi(I);
end if;
end loop;
end process;
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?