移存器的VHDL程序如下:
Library ieee
use ieee.std_logic_1164.all
use ieee.std_logic_unsigned.all--以上是定义集合包,是VHDL里面的包
entity yicunqi is--这是定义实体,就是定义器件的输入输出管角,和仔团名称为yicunqi
port(di ,clk :in std_logic --2个输入
q6,q5,q4,q3,q2,q1,q0:out_std_logic --7个逻辑输出
)
end yicunqi
architecture a of yicunqi is--定义结构体,名称为a,属于yicunqi
signal tmp : std_logic_vector(6 downto 0) 定义一个信号变量组,一共7个
begin
process(clk)--clk是触发程序的条件
begin
if (clk'event and clk='1') then --如果CLK有变化且是上升沿触发
tmp(6)<=di--首先赋值
for i in 1 to 6 loop
tmp(6-i)<=tmp(7-i)--循环赋值,将后一个值给前一个,这样就实现移位
end loop
end if
end process
q6<=not tmp(6)--将值取反付给Q6
q5<=tmp(5)
q4<=not tmp(4)
q3<=not tmp(3)
q2<=tmp(2)
q1<=tmp(1)
q0<=tmp(0)
end a
译码器:当七位移位寄存器输出的是“1111111”时,译码器输出就是“111”;有一位错码输出即七位输出中有一个是“0”的时候,译码器输出就是“110”,其它情况输出就为“000”。
译码器的VHDL源程序为:
library ieee
use ieee.std_logic_1164.all
use ieee.std_logic_unsigned.all
entity yimaqi is
port(a,b,c,d,e,f,g:in std_logic
selt :out std_logic_vector(2 downto 0))--输出是一个3位的
end yimaqi
architecture bh of yimaqi is
signal sel: std_logic_vector(6 downto 0)
begin
sel<=a&b&c&d&e&f&g--将abcdefg按位组成一个7位数组形式
process(sel)
begin
case sel is--case语句应该懂吧,C语言有的饿
when"0111111"=>selt<="110"--当sel满足when后面的条件时就把100赋值给selt,后面同
when"1011111"=>selt<="110"
when"1101111"=>selt<="110"
when"1110111"=>selt<="110"
when"1111011"=>selt<="110"
when"1111101"=>selt<="110"
when"1111110"=>selt<="110"
when"1111111"=>selt<="111"
when others=>selt<="000"
end case
end process
end bh
判决器的功能相当于一个比较器。
当巴克码识别器的输出大于等于自动门限的输出时,就输出一个“1”脉唤橘冲,否则就输出“0”脉冲。
判决器的VHDL源程序为:
library ieee
use ieee.std_logic_1164.all
use ieee.std_logic_unsigned.all
entity panjueqi is
port(a : in std_logic_vector(2 downto 0)
b :in std_logic_vector(2 downto 0)
c :buffer std_logic --定义的是数据buffer
)
end panjueqi
architecture bh of panjue is
begin
c<='戚岩1' when a>=b else '0'--当a>=b时c<='1',其他c<='0'
end bh
library ieeeuse std_logic_1164.all
entity temp is
port(a :in std_logic
b : in std_logic
c:out std_logic
d:out std_logic
)
end temp
archiecture str of temp is
begin
c <= a and b
d <=( a or b) and (not(a and b))
end str
亲,,你春念看看这对不对,,我灶脊试过了,,没错LIBRARY IEEE
USE IEEE.STD_LOGIC_1164.ALL
USE IEEE.STD_LOGIC_UNSIGNED.ALL
ENTITY RS_clk IS
PORT( S,R,res :IN std_logic
Q,NOT_Q:out std_logic)
END RS_clk
ARCHITECTURE behav OF RS_clk IS
signal sel1,sel2: std_logic
BEGIN
process(res,sel1,sel2)
begin
if res='0' then sel1<='0'
sel2<='隐森渗1'
elsif (S='1' and R='0') then sel1<='1'
sel2<='0'
elsif (S='0' and R='1') then sel1<='0'
sel2<='1'
elsif (S='0' and R='0') then sel1<=sel1
sel2<=sel2
end if
Q<=sel1
NOT_Q<=sel2
end process
END behav
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)