1 / 24

学习情景七

学习情景七. 1 位二进制全加器的设计. 并行语句 (Concurrent Statements). 进程语句 (Process Statements) 。 块语句 (Block Statements) 。 并行信号赋值语句 (Concurrent Signal Assignments) 。 简单信号赋值语句 选择信号赋值语句 条件信号赋值语句 元件例化语句 (Component Instantiations) ,其中包括类属配置语句。 生成语句 (Generate Statements) 。. 并行语句在结构体中的使用格式如下:

brilliant
Download Presentation

学习情景七

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. 学习情景七 1位二进制全加器的设计

  2. 并行语句(Concurrent Statements) 进程语句(Process Statements)。 块语句(Block Statements)。 并行信号赋值语句(Concurrent Signal Assignments)。 简单信号赋值语句 选择信号赋值语句 条件信号赋值语句 元件例化语句(Component Instantiations),其中包括类属配置语句。 生成语句(Generate Statements)。

  3. 并行语句在结构体中的使用格式如下: ARCHITECTURE 结构体名 OF 实体名 IS 说明语句 BEGIN 并行语句 END ARCHITECTURE 结构体名

  4. 1 块语句结构(BLOCK) BLOCK 语句的表达格式如下: 块标号: BLOCK [(块保护表达式)] 接口说明 类属说明 BEGIN 并行语句 END BLOCK 块标号;

  5. 块语句结构(BLOCK) ... b1 : BLOCK SIGNAL s1: BIT ; BEGIN S1 <= a AND b ; b2 : BLOCK SIGNAL s2: BIT ; BEGIN s2 <= c AND d ; b3 : BLOCK BEGIN Z <= s2 ; END BLOCK b3 ; END BLOCK b2 ; y <= s1 ; END BLOCK b1 ; ...

  6. 全加器 LIBRARY IEEE; USE IEEE. std_logic_1164.ALL; ENTITY f_adder IS PORT ( ain, bin , cin : IN std_logic; sum, cout : OUT std_logic ); END f_adder; ARCHITECTURE e_ad OF f_adder IS SIGNAL so1, co1, co2 : std_logic; BEGIN h_adder1 : BLOCK --半加器u1 BEGIN PROCESS( ain,bin ) BEGIN so1<=NOT(ain XOR (NOT bin)); co1<= ain AND bin; END PROCESS; END BLOCK h_adder1; h_adder2: BLOCK --半加器u2 SIGNAL so2 : std_logic; BEGIN so2 <= NOT(so1 XOR (NOT cin)) ; co2<=so1 and cin ; sum<=so2; END BLOCK h_adder2; or2 : BLOCK --或门u3 BEGIN PROCESS (co2, co1) BEGIN cout<= co2 OR co1; END PROCESS; END BLOCK or2; END e_ad;

  7. 例中的RTL电路图(Synplify综合)

  8. 2 进程语句 进程语句不是单条语句。而是由顺序语句组成的程序结构,其基本格式如下: [进程标号]:process[(敏感信号表)] [is] [进程说明语句] begin 顺序语句 end process[进程标号]; 可见,进程语句结构主要包括三个部分:进程说明部分和 顺序语句描述部分、敏感信号表。

  9. 在进程说明语句中可以定义一些局部量,包括数据类型、变量、常数、属性、子程序等。这些定义只在本进程中有效。在进程说明语句中可以定义一些局部量,包括数据类型、变量、常数、属性、子程序等。这些定义只在本进程中有效。 顺序语句说明部分可以使用前面一节中介绍的顺序语句对电路功能进行描述。进程中的顺序语句往往具有顺序/并行双重特性。 敏感信号表中需列出用语本进程的信号名,一旦其中任意一个信号发生变化,进城就被启动,进程中的语句就执行一遍。 进程只有两种状态:即执行状态和等待状态。进程是否进入执行状态取决于敏感信号,一旦敏感信号发生变化,即进入执行状态,遇到end process语句后即停止执行,重新进入等待状态。

  10. Entity mul is Port(a,b,selx,sely:in bit; data_out:out bit); End mul; Architecture ex of mul is signal tmp: bit; Begin Pa: process(a,b,selx) begin if selx=‘0’ then tmp<=a; else tmp<=b; end if; End process pa; Pb: process(tmp,c,sely) begin if sely=‘0’ then data_out<=tmp; else data_out<=c; end if; End process pb; End ex;

  11. 3并行信号赋值语句 1. 简单信号赋值语句 赋值目标= 表达式 ARCHITECTURE curt OF bc1 IS SIGNAL s1, e, f, g, h : STD_LOGIC ; BEGIN output1 <= a AND b ; output2 <= c + d ; g <= e OR f ; h <= e XOR f ; s1 <= g ; END ARCHITECTURE curt;

  12. 2. 条件信号赋值语句 赋值目标 <= 表达式 WHEN 赋值条件 ELSE 表达式 WHEN 赋值条件 ELSE ... 表达式 ; ENTITY mux IS PORT ( a,b,c : IN BIT ; p1,p2 : IN BIT ; z : OUT BIT ); END; ARCHITECTURE behv OF mux IS BEGIN z <= a WHEN p1 = '1' ELSE b WHEN p2 = '1' ELSE c ; END;

  13. 3. 选择信号赋值语句 WITH 选择表达式 SELECT 赋值目标信号 <= 表达式 WHEN 选择值 表达式 WHEN 选择值 ... 表达式 WHEN 选择值;

  14. 【例3-11】 LIBRARY IEEE; USE IEEE.STD_LOGIC_1164.ALL; USE IEEE.STD_LOGIC_UNSIGNED.ALL; ENTITY decoder IS PORT ( a,b,c : IN STD_LOGIC; data1,data2 : IN STD_LOGIC; dataout : OUT STD_LOGIC ); END decoder; ARCHITECTURE concunt OF decoder IS SIGNAL instruction : STD_LOGIC_VECTOR(2 DOWNTO 0) ; BEGIN instruction <= c & b & a ; WITH instruction SELECT dataout <= data1 AND data2 WHEN "000" , data1 OR data2 WHEN "001" , data1 NAND data2 WHEN "010" , data1 NOR data2 WHEN "011" , data1 XOR data2 WHEN "100" , data1 XNOR data2 WHEN "101" , 'Z' WHEN OTHERS ; END concunt ;

  15. 3. 选择信号赋值语句 ... WITH selt SELECT muxout <= a WHEN 0|1 , -- 0或1 b WHEN 2 TO 5 , -- 2或3,或4或5 c WHEN 6 , d WHEN 7 , 'Z' WHEN OTHERS ; ...

  16. 4 元件例化语句 COMPONENT 元件名 IS GENERIC (类属表); -- 元件定义语句 PORT (端口名表); END COMPONENT 文件名; 例化名 :元件名 PORT MAP( -- 元件例化语句 [端口名 =>] 连接端口名,...) ;

  17. 5 生成语句 生成语句是一种复制作用,能用来在结构中产生多个相同的结构或逻辑描述。生成语句有两种形式,一种是for-generate形式: [标号]:for 循环变量 in 取值范围 generate 生成语句 end generate[标号]; 另一种是if-generate 形式 [标号] if 条件 generate 生成语句 end generate[标号];

  18. Note(通报) 报告出错信息,可以通过编译 Warning(警告) 报告出错信息,可以通过编译 Error(错误) 报告出错信息,暂停编译 Failure(失败) 报告出错信息,暂停编译 其他语句 断言语句 断言语句的书写格式如下: ASSERT<条件表达式> REPORT<出错信息> SEVERITY<错误级别> ; 表预定义错误等级

  19. 半加器h_adder电路图及其真值表

  20. 全加器f_adder电路图及其实体模块

  21. 例4-3一位半加器 library ieee; use ieee.std_logic_1164.all; entity h_adder is port(a,b:in std_logic; co,so:out std_logic); end entity h_adder; architecture fh1 of h_adder is begin so<=not(a xor (not b)); co<=a and b; end architecture fh1;

  22. 或门的逻辑描述 library ieee; use ieee.std_logic_1164.all; entity or2a is port(a,b:in std_logic; c:out std_logic); end entity or2a; architecture behav of or2a is begin c<=a or b; end architecture behav;

  23. 1位全加器的顶层文件(结构描述) library ieee; use ieee.std_logic_1164.all; entity f_adder is port(ain,bin,cin: in std_logic; cout,sum: out std_logic); end entity f_adder; architecture fd1 of f_adder is component h_adder port(a,b:in std_logic; co,so:out std_logic); end component; component or2a port(a,b:in std_logic; c: out std_logic); end component; signal d,e,f:std_logic; begin u1:h_adder port map(a=>ain,b=>bin,co=>d,so=>e); u2:h_adder port map(a=>e,b=>cin,co=>f,so=>sum); u3: or2a port map(a=>d,b=>f,c=>cout); end architecture fd1;

  24. 此例中包含三个程序,其中半加器和或门属于底层文件,全加器是顶层文件,在顶层文件中通过元件例化方式对底层文件进行调用。在实际使用中,这三个文件是各自独立的,需要分别通过编译,通常应保存在同一个文件夹内。此例中包含三个程序,其中半加器和或门属于底层文件,全加器是顶层文件,在顶层文件中通过元件例化方式对底层文件进行调用。在实际使用中,这三个文件是各自独立的,需要分别通过编译,通常应保存在同一个文件夹内。

More Related