VHDL语言入门整理

2024-06-09 04:48
文章标签 语言 入门 整理 vhdl

本文主要是介绍VHDL语言入门整理,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!

1.2选1多路选择器
Library ieee;
Use ieee.std_logic_1164.all;
Entity L1 is
Port
(
a,b,s:in std_logic;
y:out std_logic
);
End L1;
Architecture one of L1 is
Begin
Process(a,b,s)begin
If(s='0')then
y<=a;
Else
y<=b;
End if;
End process;
End one;
仿真结果:


2.4选1多路选择器
library ieee;
use ieee.std_logic_1164.all;
entity L2 is
port
(
a,b,c,d,s0,s1 : in std_logic;
y : out std_logic
);
end L2;
architecture two of L2 is
signal s : std_logic_vector(1 downto 0);
begin
s <= s1 & s0;
process(s1,s0) begin
case(s) is
when "00"=>y<=a;
when "01"=>y<=b;
when "10"=>y<=c;
when "11"=>y<=d;
when others=>null;
end case;
end process;
end two;

仿真结果:

3.半加器


VHDL语言描述:
library ieee;
use ieee.std_logic_1164.all;
entity L3 is
port(
A,B:in std_logic;
so,co:out std_logic
);
end L3;
architecture three of L3 is
begin
so<=A xor B;
co<=A and B;
end three;
仿真结果:

4.8位加法器
library ieee;
use ieee.std_logic_1164.all;
use ieee.std_logic_unsigned.all;
entity L6 is
port(
A,B:in std_logic_vector(7 downto 0);
CIN:in std_logic;
COUT:out std_logic;
DOUT:out std_logic_vector(7 downto 0)
);
end L6;
architecture abc of L6 is
signal DATA:std_logic_vector(8 downto 0);
begin
DATA<=('0'&A)+('0'&B)+("00000000"&CIN);
COUT<=DATA(8);
DOUT<=DATA(7 downto 0);
end abc;
仿真结果:

5.D触发器的vhdl描述
library ieee;
use ieee.std_logic_1164.all;
entity L7 is
port
(
clk,D:in std_logic;
Q:out std_logic
);
end L7;
architecture abc of L7 is
signal Q1:std_logic;
begin
process(clk,Q1) begin
if clk'event and clk='1'
then Q1<=D;
end if;
end process;
Q<=Q1;
end abc;
仿真结果:

6.统计向量中1的个数
library ieee;
use ieee.std_logic_1164.all;
use ieee.std_logic_unsigned.all;
entity L7 is
port
(
DIN:in std_logic_vector(7 downto 0);
CNTH:out std_logic_vector(3 downto 0)
);
end L7;
architecture abc of L7 is
begin
process(DIN)
variable Q:std_logic_vector(3 downto 0);
begin
Q:="0000";
for n in 0 to 7 loop
if(DIN(n)='1') then
Q:=Q+1;
end if;
end loop;
CNTH<=Q;
end process;
end abc;

7.双向端口
library ieee;
use ieee.std_logic_1164.all;
entity L7 is
port
(
control :in std_logic;
in1:in std_logic_vector(7 downto 0);
q:inout std_logic_vector(7 downto 0);
x:out std_logic_vector(7 downto 0)
);
end L7;
architecture abc of L7 is
begin
process(control,q,in1)begin
if(control='0')then
x<=q;
else
q<=in1;
x<="11111111";
end if;
end process;
end abc;

仿真结果:


这篇关于VHDL语言入门整理的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!



http://www.chinasem.cn/article/1044258

相关文章

从入门到精通详解Python虚拟环境完全指南

《从入门到精通详解Python虚拟环境完全指南》Python虚拟环境是一个独立的Python运行环境,它允许你为不同的项目创建隔离的Python环境,下面小编就来和大家详细介绍一下吧... 目录什么是python虚拟环境一、使用venv创建和管理虚拟环境1.1 创建虚拟环境1.2 激活虚拟环境1.3 验证虚

GO语言短变量声明的实现示例

《GO语言短变量声明的实现示例》在Go语言中,短变量声明是一种简洁的变量声明方式,使用:=运算符,可以自动推断变量类型,下面就来具体介绍一下如何使用,感兴趣的可以了解一下... 目录基本语法功能特点与var的区别适用场景注意事项基本语法variableName := value功能特点1、自动类型推

GO语言中函数命名返回值的使用

《GO语言中函数命名返回值的使用》在Go语言中,函数可以为其返回值指定名称,这被称为命名返回值或命名返回参数,这种特性可以使代码更清晰,特别是在返回多个值时,感兴趣的可以了解一下... 目录基本语法函数命名返回特点代码示例命名特点基本语法func functionName(parameters) (nam

Go语言连接MySQL数据库执行基本的增删改查

《Go语言连接MySQL数据库执行基本的增删改查》在后端开发中,MySQL是最常用的关系型数据库之一,本文主要为大家详细介绍了如何使用Go连接MySQL数据库并执行基本的增删改查吧... 目录Go语言连接mysql数据库准备工作安装 MySQL 驱动代码实现运行结果注意事项Go语言执行基本的增删改查准备工作

Java List 使用举例(从入门到精通)

《JavaList使用举例(从入门到精通)》本文系统讲解JavaList,涵盖基础概念、核心特性、常用实现(如ArrayList、LinkedList)及性能对比,介绍创建、操作、遍历方法,结合实... 目录一、List 基础概念1.1 什么是 List?1.2 List 的核心特性1.3 List 家族成

Go语言使用Gin处理路由参数和查询参数

《Go语言使用Gin处理路由参数和查询参数》在WebAPI开发中,处理路由参数(PathParameter)和查询参数(QueryParameter)是非常常见的需求,下面我们就来看看Go语言... 目录一、路由参数 vs 查询参数二、Gin 获取路由参数和查询参数三、示例代码四、运行与测试1. 测试编程路

Go语言使用net/http构建一个RESTful API的示例代码

《Go语言使用net/http构建一个RESTfulAPI的示例代码》Go的标准库net/http提供了构建Web服务所需的强大功能,虽然众多第三方框架(如Gin、Echo)已经封装了很多功能,但... 目录引言一、什么是 RESTful API?二、实战目标:用户信息管理 API三、代码实现1. 用户数据

MyBatis的xml中字符串类型判空与非字符串类型判空处理方式(最新整理)

《MyBatis的xml中字符串类型判空与非字符串类型判空处理方式(最新整理)》本文给大家介绍MyBatis的xml中字符串类型判空与非字符串类型判空处理方式,本文给大家介绍的非常详细,对大家的学习或... 目录完整 Hutool 写法版本对比优化为什么status变成Long?为什么 price 没事?怎

c++日志库log4cplus快速入门小结

《c++日志库log4cplus快速入门小结》文章浏览阅读1.1w次,点赞9次,收藏44次。本文介绍Log4cplus,一种适用于C++的线程安全日志记录API,提供灵活的日志管理和配置控制。文章涵盖... 目录简介日志等级配置文件使用关于初始化使用示例总结参考资料简介log4j 用于Java,log4c

史上最全MybatisPlus从入门到精通

《史上最全MybatisPlus从入门到精通》MyBatis-Plus是MyBatis增强工具,简化开发并提升效率,支持自动映射表名/字段与实体类,提供条件构造器、多种查询方式(等值/范围/模糊/分页... 目录1.简介2.基础篇2.1.通用mapper接口操作2.2.通用service接口操作3.进阶篇3