szuEDA复试第一套

lib rary ieee;
use ieee.std_logic_1164.all;
use ieee.std_logic_unsigned.all;
entity szu is
port{x1,x2,x3,clk : in std_logic;
d:out std_logic};
end entity szu;
architecture s 0f szu is
signal q0,q1,q2 : std_logic; --链接不同元器件进行通信,signal具有无方向性,既可以被赋值,也可以赋值
begin
q0<=x1 and x2; --门电路一般使用并发信号赋值语句
q2<=q1 or x3; --并发信号的启动运行的标志为表达式中的信号发生变化
process(q0,clk) begin
if clk’event and clk =‘1’ then --if后面的表达式为一个布尔类型的判断,如果为真继续
q1<=q0;
end if;
end process;
process(q2,clk) begin --当敏感信号不尽相同时,另起进程
if clk’event and clk=‘1’ then
d<=q2;
end if;
end process;
end s;

第二题
当wl为高电平时,mos管打开,数据bl与电容连接,反之,mos管断开,电容存储数据。因为在截止时,mos管仍有微小的漏电流的存在,所以电容中存储的电荷会从mos管一点点漏光,数据也随之消失。

第三题

第四题
有两种思路:
一:
library ieee;
use ieee.std_logic_1164.all;
use ieee.std_logic_unsigned.all;
entity four_adder is
port{x1,x2 :in std_logic_vector(3 downto 0);
cin: in std_logic;
cout: out std_loogic_vector(3 downto 0);
cn: out std_logic };
end four_adder;
architecture four of four_adder is
signal sm: std_logic_vector(4 downto 0); --方便操作,在此程序中起到中间量的作用,但程序中并没有使用进程所以定义了signal;有进位
begin
sm<=x1+x2+cin;
cout<=sm(3 downto 0);
cn<=sm(4);
end four;

第五题
序列检测 11100 一共,会有n+1个状态,所以会有6个状态,因为序列前面有总有一个隐形的0,有两种思路,一种使用状态机,一种不使用,下面用状态机编写
library ieee;
use ieee.std_logic_1164.all;
use ieee.std_logic_unsigned.all;
entity detect is
port{shuru,clk : std_logic; --每次来一个数据
an: out std_logic};
end detect;
architecture det of detect is
type state is(s0,s1,s2,s3,s4,s5); --定义state是这八种状态,nexsstate和presenstate属于这八种状态
signal nexstate,presenstate : state:=s0; --状态之间类似于元器件之间的信号相连,并且定义初值状态为s0
begin
transfer: process(clk) is begin --进程标号为transfer,由时钟控制的电路
if clk’event and clk =‘1’ then
presenstate<=nexstate; 11100
if presenstate=s7 then
an=‘1’;
else
an=‘0’;
end if;
end if; --时序部分结束
end process;
generatenext:process(presenstate,shuru) is begin
case presenstate is
when s0=> if shuru=‘1’ then
nexstate<=s1;
else
nexstate=s0;
end if;
when s1=>if shuru=‘1’ then
nexstate<=s2;
else
nexstate<=s0;
end if;
when s2=>if shuru=‘1’ then
nexstate<=s3;
else
nexstate<=s0;
end if;
when s3=>if shuru=‘0’ then
nexstate<=s4;
else
nexstate<=s3;
end if;
when s4=>if shuru=‘0’ then
nexstate<=s5;
else
nexstate<=s1;
end if;
when s5=>if shuru=‘1’ then
nexstate<=s1;
else
nexstate<=s0;
when others=> null;
end case;
end process;
end det;

猜你喜欢

转载自blog.csdn.net/weixin_44404722/article/details/88406133