ÄÚÈÝ·¢²¼¸üÐÂʱ¼ä : 2026/3/23 20:09:08ÐÇÆÚÒ» ÏÂÃæÊÇÎÄÕµÄÈ«²¿ÄÚÈÝÇëÈÏÕæÔĶÁ¡£
use ieee.std_logic_1164.all; entity mux16 is
port( d0, d1, d2, d3: in std_logic_vector(15 downto 0);
sel: in std_logic_vector( 6 downto 0); y: out std_logic_vector(15 downto 0)); end;
architecture one of mux16 is begin
with select y <= d0 when \ d1 when \ d2 when \
d3 when ; end;
(ËÄ) ÔÚÏÂÃæºáÏßÉÏÌîÉϺÏÊʵÄÓï¾ä£¬Íê³Éjk´¥·¢Æ÷µÄÉè¼Æ¡£
˵Ã÷£ºÉè¼ÆÒ»¸öÒì²½¸´Î»/ÖÃλjk´¥·¢Æ÷£¬ÆäÕæÖµ±íÈçÏ£º input output pset clr 0 1 0 1 1 1 1 1 0 0 1 1 1 1 clk x x x j k x x x x x x q 1 0 ²»¶¨ 0 1 ·×ª ±£³Ö ÉÏÉýÑØ 0 1 ÉÏÉýÑØ 1 0 ÉÏÉýÑØ 1 1 ÉÏÉýÑØ 0 0 library ieee;
use ieee.std_logic_1164.all; entity jkff1 is
port (pset,clr,clk,j,k : in std_logic; q : out std_logic); end jkff1;
architecture maxpld of jkff1 is signal temp:std_logic; begin
process(pset,clr,clk) begin
if (pset='0'and clr='1' ) then temp<='1'; elsif (pset='1'and clr='0' ) then temp<='0'; elsif (pset='0'and clr='0' ) then null;
(clk'event and clk='1') then
(j='0' and k='0') then temp<=temp; elsif (j='0' and k='1') then temp<='0';
elsif (j='1' and k='0') then temp<='1';
elsif (j='1' and k='1') then temp<= ;
end if; end if; end process; q<=temp; end ;
(Îå) ÔÚÏÂÃæºáÏßÉÏÌîÉϺÏÊʵÄÓï¾ä£¬Íê³É¼ÆÊýÆ÷µÄÉè¼Æ¡£
˵Ã÷£ºÉèµç·µÄ¿ØÖƶ˾ùΪ¸ßµçƽÓÐЧ£¬Ê±ÖÓ¶Ëclk,µç·µÄÔ¤ÖÃÊý¾ÝÊäÈë¶ËΪ4λd£¬¼ÆÊýÊä³ö¶ËҲΪ4λq£¬´øÍ¬²½Ê¼ÄÜen¡¢Òì²½¸´Î»clrºÍÔ¤ÖÿØÖÆldµÄÁù½øÖƼõ·¨¼ÆÊýÆ÷¡£ library ieee;
use ieee.std_logic_1164.all; use ieee.std_logic_arith.all; use ieee.std_logic_unsigned.all; entity cnt6 is
port(en,clr,ld,clk:in std_logic;
d: in std_logic_vector(3 downto 0); q:out std_logic_vector(3 downto 0)); end cnt6;
architecture beha of cnt6 is
signal qtemp:std_logic_vector(3 downto 0); begin
process(clk,clr,ld) begin
if clr='1' then qtemp<=\ --clr=1ÇåÁã
elsif (clk'event and clk='1') then --ÅжÏÊÇ·ñÉÏÉýÑØ
if ld='1' then qtemp<= ; --ÅжÏÊÇ·ñÖÃλ
elsif en='1' then --ÅжÏÊÇ·ñÔÊÐí¼ÆÊý if qtemp=\ ; --µÈÓÚ0£¬¼ÆÊýÖµÖÃ5 else qtemp<= ; --·ñÔò£¬¼ÆÊýÖµ¼õ1 end if;
end if;
end if; q<=qtemp; end process; end beha;
(Áù) ÔÚÏÂÃæºáÏßÉÏÌîÉϺÏÊʵÄÓï¾ä£¬Íê³É״̬»úµÄÉè¼Æ¡£
˵Ã÷£ºÉè¼ÆÒ»¸öË«½ø³Ì״̬»ú£¬×´Ì¬0ʱÈç¹ûÊäÈ롱10¡±ÔòתΪÏÂһ״̬£¬·ñÔòÊä³ö¡±1001¡±£»×´Ì¬1ʱÈç¹ûÊäÈ롱11¡±ÔòתΪÏÂһ״̬£¬·ñÔòÊä³ö¡±0101¡±£»×´Ì¬2ʱÈç¹ûÊäÈ롱01¡±ÔòתΪÏÂһ״̬£¬·ñÔòÊä³ö¡±1100¡±£»×´Ì¬3ʱÈç¹ûÊäÈ롱00¡±ÔòתΪ״̬0£¬·ñÔòÊä³ö¡±0010¡±¡£¸´Î»Ê±Îª×´Ì¬0¡£
library ieee;
use ieee.std_logic_1164.all; use ieee.std_logic_unsigned.all; entity moore1 is
port (datain: in std_logic_vector(1 downto 0); clk, rst:in std_logic;
q: out std_logic_vector(3 downto 0)); end;
architecture one of moore1 is
type st_type is (st0, st1, st2, st3); --¶¨Òå4¸ö״̬
signal cst, nst: st_type; --¶¨ÒåÁ½¸öÐźţ¨ÏÖ̬ºÍ´Î̬£© signal q1:std_logic_vector(3 downto 0); begin
reg: process(clk, rst) --Ö÷¿ØÊ±Ðò½ø³Ì begin
if rst='1' then cst<= ; --Òì²½¸´Î»Îª×´Ì¬0 elsif clk'event and clk='1' then
cst<= ; --ÏÖ̬=´Î̬ end if; end process;
com: process(cst, datain) begin
case cst is when st0 => if datain=\
else nst<=st0; q1<=\when st1 => if datain=\
else nst<=st1; q1<=\when st2 => if datain=\
else nst<=st2; q1<=\when st3 => if datain=\
else nst<=st3; q1<=\ ; end process; q<=q1; end;
(Æß) ÔÚÏÂÃæºáÏßÉÏÌîÉϺÏÊʵÄÓï¾ä£¬Íê³É¼õ·¨Æ÷µÄÉè¼Æ¡£ ÓÉÁ½¸ö1λµÄ°ë¼õÆ÷×é³ÉÒ»¸ö1λµÄÈ«¼õÆ÷ --1λ°ë¼õÆ÷µÄÃèÊö library ieee;
use ieee.std_logic_1164.all; entity half_sub is
port(a,b : in std_logic;
diff,cout : out std_logic); end half_sub;
architecture art of half_sub is begin
cout<= ; --½èλ
diff<= ; --²î end ;
--1λȫ¼õÆ÷ÃèÊö library ieee;
use ieee.std_logic_1164.all; entity falf_sub is
port(a,b,cin: in std_logic;
diff,cout : out std_logic); end falf_sub;
architecture art of falf_sub is
component half_sub port(a,b : in std_logic;
diff,cout : out std_logic); end component;
t0,t1,t2:std_logic;
begin u1: half_sub port map(a,b, ,t1);
u2: half_sub port map(t0, , ,t2); cout<= ; end ;
(°Ë) ÔÚÏÂÃæºáÏßÉÏÌîÉϺÏÊʵÄÓï¾ä£¬Íê³É·ÖƵÆ÷µÄÉè¼Æ¡£ ˵Ã÷£ºÕ¼¿Õ±ÈΪ1£º2µÄ8·ÖƵÆ÷ library ieee;
use ieee.std_logic_1164.all; use ieee.std_logic_unsigned.all; entity clkdiv8_1to2 is
port(clk:in std_logic;
clkout:out std_logic ); end clkdiv8_1to2;
architecture two of clkdiv8_1to2 is
signal cnt:std_logic_vector(1 downto 0); signal ck:std_logic; begin
process(clk) begin
if rising_edge( ) then if cnt=\cnt<=\
ck<= ;
else cnt<= ; end if; end if; clkout<=ck;
end process; end;
(¾Å) ÔÚÏÂÃæºáÏßÉÏÌîÉϺÏÊʵÄÓï¾ä£¬Íê³É60½øÖƼõ¼ÆÊýÆ÷µÄÉè¼Æ¡£
library ieee;
use ieee.std_logic_1164.all; use ieee.std_logic_unsigned.all;
entity count is
port(clk: in std_logic;
h,l: out std_logic_vector(3 downto 0) ); end count;
architecture bhv of count is begin
process(clk)
variable hh,ll: std_logic_vector(3 downto 0); begin
if clk'event and clk='1' then if ll=0 and hh=0 then
hh:=\ elsif ll=0 then ll:= ; hh:= ; else
ll:= ; end if; end if; h<=hh; l<=ll; end process; end bhv;
£¨Ê®£© ÔÚÏÂÃæºáÏßÉÏÌîÉϺÏÊʵÄÓï¾ä£¬Íê³É4-2ÓÅÏȱàÂëÆ÷µÄÉè¼Æ¡£ library ieee;
use ieee.std_logic_1164.all; entity code4 is
port(a,b,c,d : in std_logic; y0,y1 : out std_logic); end code4;