ALU(算术逻辑运算单元)的设计
更新时间:2023-04-24 06:18:01 阅读量: 实用文档 文档下载
EDA技术与应用 实验报告(四)
实验名称: ALU(算术逻辑运算单元)的设
计
姓 名: 学 号: 班 级: 时 间:
南京理工大学紫金学院电光系
陈丹 100401202 电信(2)班 2012.12.11
一、 实验目的
1、学习包集和元件例化语句的使用。 2、学习ALU电路的设计。
二、 实验原理
1、ALU原理 ALU的电路原理图如图1 所示,主要由算术运算单元、逻辑单元、选择单元构成。
图1 表
1
ALU功能表如表1 所示。
2、元件、包集
在结构体的层次化设计中,采用结构描述方法就是通过调用库中的元件或者已经设计好
的模块来完成相应的设计。在这种结构体中,功能描述就像网表一样来表示模块和模块之间的互联。如ALU 是由算术单元、逻辑单元、多路复用器互相连接而构成。而以上三个模块是由相应的VHDL 代码产生的,在VHDL 输入方式下,如果要将三个模块连接起来,就要用到元件例化语句。元件例化语句分为元件声明和元件例化。 1、元件声明
在VHDL 代码中要引入设计好的模块,首先要在结构体的说明部分对要引入的模块进行说明。然后使用元件例化语句引入模块。
元件声明语句格式:
component 引入的元件(或模块)名
port(端口说明);
end component;
注意:元件说明语句要放在“architecture”和“begin”之间。
2、元件例化语句
为将引入的元件正确地嵌入到高一层的结构体描述中,就必须将被引用的元件端口信号与结构体相应端口信号正确地连接起来,元件例化语句可以实现该功能。 元件例化语句格式:
标号名:元件名(模块名) port map(端口映射);
标号名是元件例化语句的唯一标识,且结构体中的标识必须是唯一的;端口映射分为:位置映射、
名称映射。
位置映射指 port map 中实际信号的书写顺序与component 中端口说明中的信号书写顺序一致,位置映射对书写顺序要求很严格,不能颠倒;名称映射指port map 中将引用的元件的端口信号名称赋予结构体中要使用元件的各个信号,名称映射的书写顺序要求不严格,顺序可以颠倒。 3 包集
在实体及结构体中定义的对象、数据类型,对另外代码的实体是不能使用的。但是在同一工程的不同VHDL 文件中,有些对象、数据类型、子程序等常常被重复使用。为方便VHDL 代码的编写,简化电路设计,故引入包集。包集也称为程序包。
包集主要由两部分组成:程序包说明和程序包体。其中,程序包体是可选的,一般程序包说明列出所有项的名称,而程序包体给出各项的细节。
程序包说明中包含的内容很多,只要是通用的全局量,都可以在程序包中加以说明。主要内容如下:
★ 对象(常量、变量、信号)的数据类型说明。
★ 对象(常量、变量、信号)子类型的数值范围说明。 ★ 函数与过程说明。 ★ 元件语句说明。
程序包说明的书写格式如下: package 程序包名 is 说明语句;
end 程序包名;
程序包名:设计者自定义便于记忆的标识符。说明语句:包括各种类型的说明语句。 程序包体书写格式如下: package body 程序包名 is
52
顺序语句;
end 程序包名;
注意:程序包定义的内容不是自动可见的,不是自动被使用。若某个实体及结构体设计需要使用程序包,可以使用use 语句制定要使用的程序包。 如:use work.程序包名.all;
三、 实验内容
1、 算术单元 arith_unit
library ieee;
use ieee.std_logic_1164.all; use ieee.std_logic_unsigned.all; entity arith_unit is
port(a,b:in std_logic_vector(7 downto 0); sel:in std_logic_vector(2 downto 0);
cin:in std_logic;
x:out std_logic_vector(7 downto 0));
end;
architecture rhg of arith_unit is begin
with sel select x<=a when"000",
a+1 when"001", a-1 when"010", b when"011", b+1 when"100", b-1 when"101", a+b when"110",
a+b+cin when others; end rhg; 仿真结果:
2、逻辑单元 logic_unit library ieee;
use ieee.std_logic_1164.all;
use ieee.std_logic_unsigned.all;
entity logic_unit is port(a,b:in std_logic_vector(7 downto 0); sel:in std_logic_vector(2 downto 0);
x:out std_logic_vector(7 downto 0));
end;
architecture rhg of logic_unit is begin with sel select
x<=not a when"000", not b when"001",
a and b when"010", a or b when"011", a nand b when"100", a nor b when"101", a xor b when"110", not(a xor b) when others;
end rhg; 仿真结果:
3、 多路复用器 sel
library ieee;
use ieee.std_logic_1164.all; entity sel is port(sel:in std_logic;
arith:in std_logic_vector(7 downto 0);
logic:in std_logic_vector(7 downto 0);
y:out std_logic_vector(7 downto 0)); end;
architecture rhg of sel is begin with sel select
y<=arith when '0',
logic when others;
end; 仿真结果:
4、 包集 package alu
library ieee;
use ieee.std_logic_1164.all;
package alu is component arith_unit is port(a,b:in std_logic_vector(7 downto 0); sel:in std_logic_vector(2 downto 0);
cin:in std_logic;
x:out std_logic_vector(7 downto 0));
end component; component logic_unit is
port(a,b:in std_logic_vector(7 downto 0); sel:in std_logic_vector(2 downto 0); x:out std_logic_vector(7 downto 0));
end component ; component sel is
port(sel:in std_logic;
arith:in std_logic_vector(7 downto 0);
logic:in std_logic_vector(7 downto 0); y:out std_logic_vector(7 downto 0)); end component;
component clk_4 is port(clk:in std_logic;
y:buffer std_logic_vector(3 downto 0)); end component; end alu; 5、 clk_4
library ieee;
use ieee.std_logic_1164.all; use ieee.std_logic_unsigned.all; entity clk_4 is port(clk:in std_logic;
y:buffer std_logic_vector(3 downto 0)); end;
architecture rhg of clk_4 is begin
process(clk) variable s:std_logic_vector(3 downto 0); begin
if clk'event and clk='1' then
if s="1111" then
s:="0000"; else
s:=s+1; end if; end if;
y<=s; end process; end rhg; 仿真结果:
6、 主程序 alu_unit
library ieee;
use ieee.std_logic_1164.all; use work.alu.all;
entity alu_unit is port(a,b:in std_logic_vector(7 downto 0);
clk:in std_logic;
cin:in std_logic;
selout:out std_logic_vector(3 downto 0); y:out std_logic_logic_vector(7 downto 0)); end;
architecture thg of alu_unit is signal x1,x2:std_logic_vector(7 downto 0);
signal x3:std_logic_vector(7 downto 0); begin u1:arith_unit port map(a,b,x3(2 downto 0),cin,x1); u2:logic_unit port map(a,b,x3(2 downto 0),x2); u3:sel port map(x3(3),x1,x2,y); u4:clk_4 port map(clk,x3); selout<=x3; end; 仿真结果:
管脚配置:
四、 小结与体会
通过这次实验我知道了什么是顺序关联法和名称关联法以及他们的区别。
在VHDL代码中要引入设计好的模块,首先要在结构体的说明部分对要引入的模块进行说明。然后使用元件例化语句引入模块。掌握了如何使用多个模块编译代码,掌握了如何使用包集。
注意每次运行检验的时候都要将文件置顶,否则编译无法通过。
正在阅读:
ALU(算术逻辑运算单元)的设计04-24
1,村级“两委”班子联席会议制度09-15
NVIDIA显卡驱动怎么安装?02-10
服务礼仪--周思敏05-14
庆祖国60华诞故事会10-20
《神峰通考》中八字分析(十)10-31
班主任工作会议记录 - 图文10-20
2018年**村支部述职报告09-27
第八章 硅中的杂质 - 图文04-20
- 教学能力大赛决赛获奖-教学实施报告-(完整图文版)
- 互联网+数据中心行业分析报告
- 2017上海杨浦区高三一模数学试题及答案
- 招商部差旅接待管理制度(4-25)
- 学生游玩安全注意事项
- 学生信息管理系统(文档模板供参考)
- 叉车门架有限元分析及系统设计
- 2014帮助残疾人志愿者服务情况记录
- 叶绿体中色素的提取和分离实验
- 中国食物成分表2020年最新权威完整改进版
- 推动国土资源领域生态文明建设
- 给水管道冲洗和消毒记录
- 计算机软件专业自我评价
- 高中数学必修1-5知识点归纳
- 2018-2022年中国第五代移动通信技术(5G)产业深度分析及发展前景研究报告发展趋势(目录)
- 生产车间巡查制度
- 2018版中国光热发电行业深度研究报告目录
- (通用)2019年中考数学总复习 第一章 第四节 数的开方与二次根式课件
- 2017_2018学年高中语文第二单元第4课说数课件粤教版
- 上市新药Lumateperone(卢美哌隆)合成检索总结报告
- 算术
- 运算
- 单元
- 逻辑
- 设计
- ALU
- XX市国土资源局“两整治一改革”专项行动自查自纠阶段研判报告
- 火力发电厂的安全预评价
- 新版pep三年级英语下册unit5B Let's talk
- 初二完形填空练习题1
- 三年级下册《书法练习指导》教案
- 2014人教版英语八年级下册1单元词组
- 免费留学360:低GPA成功逆袭美国名校被纽约州立大学宾汉姆顿大学
- 高级程序员修炼之道-Android培训系列课程之Thread
- 2006年全国小学生英语竞赛(NECPS)六年级组竞赛样题
- 大班社会活动教案《合理用钱》含反思
- 初中物理远程学结样本实用版4篇
- 2009考研英语阅读真题翻译
- 美国最地道最高频的300习惯用语
- 普通话测试流程及录音软件说明
- 吸收马氏链在供应链优化判断中的应用
- 填料吸收塔的操作及其Kya的测定实验讲义
- 美国医疗保险照顾计划及其对我国的启示
- 液压挖掘机的液压泵及其电控系统
- 黄山导游词英文对照翻译
- 中华全国律师协会律师办理国有企业改制与公司治理业务操作指引