添加VHDL或者Verilog文件
自己手动新建vhdl或者verilog文件,写好实体名,编译,便会自动生产实体并且绑定文件。
VHDL中process语句执行顺序详解
Process语句中是顺序执行和并行执行皆有,对于信号,<=的赋值是同时进行赋值的,而且信号的<=会自带一个小延迟 δ \delta δ,因此对于
a<= c_i;
b<= a;
c_o<=b;
类型的赋值,都是变化前的值,即 δ \delta δ之前的值。可以理解为,a要在 δ \delta δ之后才会被赋值吃c_i,因此b的赋值是变化前的a,c_o的赋值是变化前的b。电路实现就是寄存器,b得到的是寄存器中a变化前的值,同理c_o。
对于变量,他的赋值:=的立即进行的,因此process中的顺序执行就是把变量全部处理完之后进行的赋值。变量只能声明在process中,可以把变量理解成“预编译”,他只是方便设计的,经过预先的计算后需要落实到电路图上,而电路图是没有串行的说法的。
library ieee;
use ieee.std_logic_1164.all;
use ieee.std_logic_arith.all;
use ieee.std_logic_unsigned.all;
entity test is
port(
clk: in std_logic;
c_i: in std_logic;
c_o: out std_logic
);
end test;
architecture test1 of test is
begin
process(clk)
variable a, b: std_logic;
begin
if(clk'event and clk = '1')then
a:= c_i;
b:= a;
c_o<=b;
end if;
end process;
end test1;
library ieee;
use ieee.std_logic_1164.all;
use ieee.std_logic_arith.all;
use ieee.std_logic_unsigned.all;
entity test is
port(
clk: in std_logic;
c_i: in std_logic;
c_o: out std_logic
);
end test;
architecture test1 of test is
signal a, b: std_logic;
begin
-- process(clk)
-- variable a, b: std_logic;
-- begin
-- if(clk'event and clk = '1')then
-- a:= c_i;
-- b:= a;
-- c_o<=b;
-- end if;
-- end process;
process(clk)
begin
if(clk'event and clk = '1')then
a<= c_i;
b<= a;
c_o<=b;
end if;
end process;
end test1;
最后,注意组合逻辑和时序逻辑的区别,组合逻辑的敏感信号就是右边赋值的信号,可以看成一根电线,电线左边变了,右边能不变化吗。时序逻辑就是以触发器为基础的,具有寄存器性质的电路,不完整的if语句会产生时序电路。
library ieee;
use ieee.std_logic_1164.all;
use ieee.std_logic_arith.all;
use ieee.std_logic_unsigned.all;
entity test is
port(
clk: in std_logic;
c_i1: in std_logic;
c_i2: in std_logic;
c_o: out std_logic
);
end test;
architecture test1 of test is
signal a, b: std_logic;
begin
-- process(clk)
-- variable a, b: std_logic;
-- begin
-- if(clk'event and clk = '1')then
-- a:= c_i;
-- b:= a;
-- c_o<=b;
-- end if;
-- end process;
-- process(clk)
-- begin
-- if(clk'event and clk = '1')then
-- a<= c_i;
-- b<= a;
-- c_o<=b;
-- end if;
-- end process;
--a<=c_i1 and c_i2;
--b<=c_i2 or c_i1;
--c_o<=a and b;
process(a,b,c_i1,c_i2)
begin
a<=c_i1 and c_i2;
b<=c_i2 or c_i1;
c_o<=a and b;
end process;
end test1;
以上代码的组合逻辑部分产生的电路没有区别。Process中的敏感信号必须写全,否则就会产生时序逻辑!