《数字系统设计》总复习题 下载本文

内容发布更新时间 : 2024/5/6 8:29:48星期一 下面是文章的全部内容请认真阅读。

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;