初学VHDL,编写程序如下
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
use IEEE.STD_LOGIC_ARITH.ALL;
use IEEE.STD_LOGIC_UNSIGNED.ALL;
-- Uncomment the following lines to use the declarations that are
-- provided for instantiating Xilinx primitive components.
--library UNISIM;
--use UNISIM.VComponents.all;
entity d is
Port(din,cp : in std_logic;
q: out std_logic
);
end d;
architecture Beh of d is
begin
process(cp)
begin
if(cp'EVENTand cp='1' ) then
q<=din;
endif;
endprocess;
end Beh;
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
use IEEE.STD_LOGIC_ARITH.ALL;
use IEEE.STD_LOGIC_UNSIGNED.ALL;
entity y1 is
Port ( q0 : out std_logic_vector(7 downto 0);
s : in std_logic;
di,clk : in std_logic);
end y1;
architecture Behavioral of y1 is
componentd
Port(din,cp : in std_logic;
q : out std_logic
);
endcomponent;
signalz: std_logic_vector(8 downto 0);
begin
process(clk)
begin
ifs='0' then
z(0)<=di;
g1:fori in 0 to 7 generate
u1:d port map(z(i),clk,z(i+1));
endgenerate g1;
q0<=z(8downto 1);
else
z(8)<=di;
g2:fori in 7 to 0 generate
u2:d port map(z(i+1),clk,z(i));
endgenerate g2;
q0<=z(7downto 0);
endif;
end process;
end Behavioral;
运行会失败,虽然知道是生成语句不能用在process下的原因 但是不知道怎么改
还是说双向寄存器这种需要选择分支的本来就不能用并行语句来做呢
求指导