Хочу воспользоваться ЦАПом на Xilinx Spartan3E Starter Kit
пишу это так
Код
entity spi_out is
Port ( clk : in STD_LOGIC;
dr : in STD_LOGIC;
data : in STD_LOGIC_VECTOR (15 downto 0);
CS : out STD_LOGIC;
DCLK : out STD_LOGIC;
MOSI : out STD_LOGIC);
end spi_out;
architecture Behavioral of spi_out is
signal start : std_logic := '0';
signal counter : integer := 0;
signal data_out : std_logic_vector(31 downto 0) := (others => '0');
signal cs_loc : std_logic := '1';
signal dclk_loc : std_logic := '0';
signal mosi_loc : std_logic := '0';
begin
--cs <= cs_loc;
dclk <= dclk_loc;
mosi <= mosi_loc;
send_data : process(clk)
begin
if falling_edge(clk) then
if dr = '1' then
if start = '0' then
start <= '1';
cs <= '0';
counter <= 0;
data_out(15 downto 0) <= data;
data_out(19 downto 16) <= "0000";
data_out(23 downto 20) <= "0011";
data_out(31 downto 24) <= (others => '0');
report "SPI -> CS <='0'";
end if;
end if;
if start = '1' then
if (dclk_loc = '1') then
report "SPI -> falling_edge";
mosi_loc <= data_out(counter);
if counter = 31 then
report "SPI -> send finish";
start <= '0';
cs <= '1';
end if;
else
report "SPI -> rising_edge";
counter <= counter + 1;
dclk_loc <= '1';
end if;
dclk_loc <= not dclk_loc;
end if;
end if;
end process send_data;
end Behavioral;
Если кому-нибудь не лень - покритикуйте, что неправильно/неоптимально... И почему при оптимизации среда обрезает некоторые сигналы и потом при маппировании генерит ошибку что их нет... (http://electronix.ru/forum/index.php?showtopic=49831) т.к. я новичок - прошу более-менее понятно объяснить. Буду оч. благодарен