Nguyên văn bởi naigia88
Xem bài viết
USE IEEE.std_logic_1164.all;
USE IEEE.std_logic_unsigned.all;
ENTITY adder8 is port(
a: in std_logic_vector(7 DOWNTO 0);
b: in std_logic_vector(7 DOWNTO 0);
ci,clk,set,reset: in std_logic;
co: out std_logic;
s: out std_logic_vector(7 DOWNTO 0));
end adder8;
architecture equation of adder8 is
begin
process(clk,set,reset)
variable mid: std_logic_vector(8 DOWNTO 0);
begin
if (reset = '1') then
mid := (others => '0');
elsif (set = '1') then
mid := (others => '1');
elsif ((clk = '1') and (clk'EVENT)) then
mid := ('0'&a)+('0'&b)+ci;
co <= mid(8);
s <= mid(7 DOWNTO 0);
end if;
end process;
end equation;
---
Đã lâu rồi tôi kô viết VHDL, nhưng căn bản là ở architecture, bạn chỉ có thể dùng concurrent statement. "if" là sequential statement nên chỉ có thể dùng trong "process" với sensitivity list.
tvd
Leave a comment: