?? hdb3.txt
字號:
1. +V碼檢測模塊的VHDL程序設計
依據上述建模思想,編寫其VHDL程序如下:
LIBRARY IEEE;
use ieee.std_logic_1164.all;
use ieee.std_logic_unsigned.all;
use ieee.std_logic_arith.all;
entity Zv is --+V碼檢測器的實體名
port (fb,zb: IN std_logic;
zvout:out std_logic);
end ZV;
architecture bh of ZV is
signal M:std_logic_vector(2 downto 0);
begin
process(zb,fb)
begin
if fb='1' then M<="000";
elsif zb'event and zb='1' then
if M<2 then
M<=M+1;
end if;
end if;
end process;
process(fb,M)
begin
if fb='0' then
if M<2 then
zvout<='0';
else
zvout<=zb;
end if;
else
zvout<='0';
end if;
end process;
end bh;
2. -V碼檢測模塊的VHDL程序設計
依據上述建模思想,編寫其VHDL程序如下:
LIBRARY IEEE;
use ieee.std_logic_1164.all;
use ieee.std_logic_unsigned.all;
use ieee.std_logic_arith.all;
entity Fv is -- -V碼檢測器的實體名
port (fb,zb: IN std_logic;
Fvout:out std_logic);
end FV;
architecture hh of FV is
signal N:std_logic_vector(2 downto 0);
begin
process(zb,fb)
begin
if zb='1' then N<="000";
elsif fb'event and fb='1' then
if N<2 then
N<=N+1;
end if;
end if;
end process;
process(ZB,N)
begin
if ZB='0' then
if N<2 then
fvout<='0';
else
fvout<=fb;
end if;
else
fVOUT<='0';
end if;
end process;
end hh;
3.扣V扣B模塊程序設計
依據扣V扣B模塊的建模思想,編寫其VHDL程序如下:
LIBRARY IEEE;
USE IEEE.STD_LOGIC_1164.ALL;
ENTITY Kvb IS --扣V扣B模塊的實體名
PORT(CLK:IN STD_LOGIC;
V,datain:IN STD_LOGIC;
DECODE:OUT STD_LOGIC);
END Kvb;
ARCHITECTURE BEHAV OF Kvb IS
SIGNAL A0,A1,A2,A3:STD_LOGIC;
BEGIN
PROCESS(CLK,v)
BEGIN
IF CLK'EVENT AND CLK='1' THEN
IF (v='1') THEN
A0<='0';
A1<='0';
A2<='0';
A3<='0';
decode <=A0;
ELSIF (V='0') THEN
A3<=DATAIN;
A2<=A3;
A1<=A2;
A0<=A1;
DECODE<=A0;
END IF;
END IF;
END PROCESS;
END BEHAV;
4.加法器程序設計
library ieee;
use ieee.std_logic_1164.all;
entity or1 is --或門的實體名
port(a,b: in std_logic;c: out std_logic);
end entity or1;
architecture one of or1 is
begin
c<=a or b; --或門邏輯描述
end architecture one;
5. HDB3譯碼器的元件例化程序設計
library ieee;
use ieee.std_logic_1164.all;
entity DECODE is --譯碼器的實體名
port(FB,ZB,CLK: in std_logic;
DECODE,v2,v3: out std_logic);
end entity DECODE;
ARCHITECTURE HH OF DECODE IS
COMPONENT Kvb --kvb
PORT(CLK:IN STD_LOGIC;
V,datain:IN STD_LOGIC;
DECODE:OUT STD_LOGIC );
END COMPONENT Kvb;
COMPONENT or1 --or1
port(a,b: in std_logic;c: out std_logic);
end component or1;
COMPONENT Fv --fv
port (fb,zb: IN std_logic;
Fvout:out std_logic);
End component fv;
Component Zv --zv
port (fb,zb: IN std_logic;
zvout:out std_logic);
END COMPONENT zv ;
component v1
port(a,b: in std_logic;
v2,v3:out std_logic);
end component v1;
SIGNAL m,x,y,z:std_logic;
begin
t1: zv port map(fb=>fb,zb=>zb,zvout=>x);
t2: fv port map(fb=>fb,zb=>zb,fvout=>y);
t3: or1 port map(a=>y,b=>x,c=>z); -- v相加
t4: or1 port map(a=>fb,b=>zb,c=>m); -- B相加
t5:kvb port map(clk=>clk,v=>z,datain=>m,decode=>decode);
t6: v1 port map(a=>x,b=>y,v2=>v2,v3=>v3);
end architecture HH;
library ieee;
use ieee.std_logic_1164.all;
entity v1 is
port(a,b:in std_logic;
v2,v3: out std_logic);
end v1;
architecture one of v1 is
begin
v2<=a;
v3<=b;
end one;
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -