fpga第六章作业及答案

  1. 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
  2. 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
  3. 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。

第6章PPT课件作业

1.顺序语句和并行语句分别有哪些?顺序语句和并行语句主要有什么区别?

答:顺序执行语句是顺序执行的,只能出现在进程和子程序中,用于定义进程的算法。顺序描述语句主要有:信号赋值语句、变量赋值语句、if语句、case语句、wait语句和null语句。结构体中的并行语句主要有6种:并行信号赋值语句、进程语句、块语句、元件例化语句、生成语句、并行过程调用语句;

区别主要在于:在执行顺序上,顺序语句是顺序执行的,if语句一定要在顺序结构中,有优先级;并行语句在结构体内是并行执行的。在赋值上,顺序语句可对变量和信号赋值,并行语句的赋值目标必须为信号或端口,在结构体的进程之外使用。

2.阅读下面的程序,分析其实现的逻辑功能,并说明是时序逻辑还是组合逻辑

library ieee;

Use ieee.std_logic_1164.all;

Entity decoder is

Port (a : in std_logic_vector(9 downto 0);

c : out integer range 0 to

9);

end Entity decoder ;

architecture one of decoder is

begin

with a select

c<=0 when “0000000001” ,

1 when “0000000010” ,

2 when “0000000100” ,

3 when “0000001000” ,

4 when “0000010000” ,

5 when “0000100000” ,

6 when “0001000000” ,

7 when “0010000000” ,

8 when “010*******” ,

9 when “1000000000” ,

0 when others ;

end architecture one;

答:功能:是10位2进制的部分译码器。由1出现的位置来决定译码器输出的是数字几。当右边的第一位是一时,输出0,第二位是1时输出1,以此类推直到输出9.其余的编码都是输出0。由于没有用到ckl所以使用的是组合逻辑。

3.结构体的描述方式有几种方式?各有什么特点?

答:结构体有三种描述方式,即行为级描述:是对整个设计单元的数学模型描

述,属于一种高层次描述方式;数据流级描述:采用进程语句控制数据流在控

制流作用下被加工处理和存储的全过程;结构级描述:采用并行处理语句,使

用最基本的逻辑门单元来描述设计尸体内部的结构组织和元器件的连接关系。

4.下面是三人表决器的VHDL描述,分析其实现机制,并说明三个不同的结构体分别用

了什么描述方法。

library ieee;

Use ieee.std_logic_1164.all;

Entity voter3 is

Port (a,b,c : in bit;

m : out bit);

end Entity voter3 ;

结构体描述方法1:

architecture one of voter3 is

begin

with a&b&c select

m<=’1’ when “110”|“101”|“011”|“111”,’0’ when others;

end architecture one;

答:当投票的人数大于两个时输出的都是1,其他的输出0.采用的行为描述。

结构体描述方法2:

architecture two of voter3 is

begin

process(a,b,c)

constant lookuptable :bit_vector(0 to 7):= “00010111”;

variable index: natural;]

begin

index:=0;

if a=’1’ then index:= index+1; end if ;

if b=’1’ then index:= index+2; end if ;

if c=’1’ then index:= index+4; end if ;

m

end process;

end architecture two;

答:采用数据流描述。

结构体描述方法3:

architecture three of voter3 is

component and2 port (in1,in2: in bit; out1: out bit);

end component;

component or2 port (in1,in2,in3: in bit; out1: out bit);

end component;

signal w1,w2,w3:bit;

begin

gate1: and2 port map (a,b,w1);

gate2: and2 port map (b,c,w2);

gate3: and2 port map (a,c,w3);

gate4: or3 port map (w1,w2,w3,m);

end architecture three;

答:采用了原件例化的方式,调用了三个与门和或门来实现。

5.附加题:①分别用IF语句和WHEN ELSE语句描述全加器;

library ieee;

use ieee.STD_LOGIC_1164.ALL;

ENTITY h_adder IS

PORT (a,b ,c: IN STD_LOGIC;

co,so :OUT STD_LOGIC);

END ENTITY;

ARCHITECTURE fh1 OF h_adder is

BEGIN

process(a,b,c)

begin

if (a='0' and b='0' and c='0') then so<='0';co<='0'; elsif (a='0' and b='1' and c='0') then so<='1' ;co<='0'; elsif (a='1'and b='0' and c='0') then

so<='1';co<='0';

elsif (a='1' and b='1' and c='0') then

so<='0' ;co<='1';

elsif (a='0' and b='0' and c='1') then

so<='1' ;co<='0';

elsif (a='0' and b='1' and c='1') then

so<='0' ;co<='1';

elsif (a='1' and b='0' and c='1') then

so<='0' ;co<='1';

elsif (a='1' and b='1' and c='1') then so<='1' ;co<='1'; end if;

endprocess;

END ARCHITECTURE fh1;

②4位加法器的VHDL描述(元件例化的方法)。

相关文档
最新文档