初级会员
- 积分
- 106
- 金钱
- 106
- 注册时间
- 2016-9-12
- 在线时间
- 35 小时
|
10金钱
LIBRARY IEEE;
USE IEEE.std_logic_1164.ALL;
USE IEEE.std_logic_unsigned.ALL;
use IEEE.STD_LOGIC_ARITH.ALL;
entity hexx is
port (
spi_dout : out STD_LOGIC;
spi_clk : in std_logic;
clk : in std_logic;
spi_rst : in std_logic;
spi_din : in STD_LOGIC
);
end hexx;
architecture behavior of hexx is
signal spi_clk_d1 : std_logic;
signal spi_clk_d2 : std_logic;
signal spi_clk_r_edge : std_logic;
signal spi_clk_f_edge : std_logic;
signal number : integer range 0 to 7;
signal tx_shift_reg : std_logic;
signal rx_shift_reg : std_logic;
begin
process(clk, spi_rst)
begin
if(spi_rst = '1') then
number <= 0;
spi_clk_d1 <= '0';
spi_clk_d2 <= '0';
tx_shift_reg <= (other =>'0');
rx_shift_reg <= (other =>'0');
spi_clk_r_edge <= '0';
spi_clk_f_edge <= '0';
elsif rising_edge(clk) then
spi_clk_d1 <= spi_clk;
spi_clk_d2 <= spi_clk_d1;
end if;
end process;
spi_clk_r_edge <= spi_clk_d1 and (not spi_clk_d2); --SPI CLK 信号上升沿
spi_clk_f_edge <= spi_clk_d2 and (not spi_clk_d1); --SPI CLK 信号下降沿
if(spi_clk_r_edge= '1') then
if(number = 7) then
number <= 0;
tx_shift_reg <= rx_shift_reg(6 downto 0) & spi_din;
spi_dout <= rx_shift_reg(7);
else
rx_shift_reg <= rx_shift_reg(6 downto 0) & spi_din;
number <= number + 1;
end if;
end if;
if(spi_clk_f_edge = '1') then
spi_dout <= tx_shift_reg(6);
tx_shift_reg <= tx_shift_reg(6 downto 0) & '0';
end if;
end behavior;
Error (10500): VHDL syntax error at hexx.vhd(45) near text "if"; expecting "end", or "(", or an identifier ("if" is a reserved keyword), or a concurrent statement
Error (10500): VHDL syntax error at hexx.vhd(45) near text "then"; expecting "<="
Error (10500): VHDL syntax error at hexx.vhd(46) near text "then"; expecting "<="
Error (10500): VHDL syntax error at hexx.vhd(51) near text "else"; expecting "end", or "(", or an identifier ("else" is a reserved keyword), or a concurrent statement
Error (10500): VHDL syntax error at hexx.vhd(54) near text "if"; expecting ";", or an identifier ("if" is a reserved keyword), or "architecture"
Error (10500): VHDL syntax error at hexx.vhd(57) near text "then"; expecting "<="
Error (10500): VHDL syntax error at hexx.vhd(61) near text "if"; expecting ";", or an identifier ("if" is a reserved keyword), or "architecture"
红字的是报的错误和报错的行。感觉有点莫名其妙,if和else对应,看了好久。谢谢大家了
|
最佳答案
查看完整内容[请看2#楼]
贴出修改后的正确的程序
library ieee;
USE IEEE.std_logic_1164.ALL;
USE IEEE.std_logic_unsigned.ALL;
use IEEE.STD_LOGIC_ARITH.ALL;
entity hexx is
port (
spi_dout : out STD_LOGIC;
spi_clk : in std_logic;
clk : in std_logic;
spi_rst : in std_logic;
spi_din : in STD_LOGIC
);
end hexx;
architecture behavior of hexx is
signal spi_clk_d1 : std_logic;
sig ...
|