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

相关文章

Spring Boot 常用注解整理(最全收藏版)

《SpringBoot常用注解整理(最全收藏版)》本文系统整理了常用的Spring/SpringBoot注解,按照功能分类进行介绍,每个注解都会涵盖其含义、提供来源、应用场景以及代码示例,帮助开发... 目录Spring & Spring Boot 常用注解整理一、Spring Boot 核心注解二、Spr

基于Go语言实现Base62编码的三种方式以及对比分析

《基于Go语言实现Base62编码的三种方式以及对比分析》Base62编码是一种在字符编码中使用62个字符的编码方式,在计算机科学中,,Go语言是一种静态类型、编译型语言,它由Google开发并开源,... 目录一、标准库现状与解决方案1. 标准库对比表2. 解决方案完整实现代码(含边界处理)二、关键实现细

如何合理管控Java语言的异常

《如何合理管控Java语言的异常》:本文主要介绍如何合理管控Java语言的异常问题,具有很好的参考价值,希望对大家有所帮助,如有错误或未考虑完全的地方,望不吝赐教... 目录1、介绍2、Thorwable类3、Error4、Exception类4.1、检查异常4.2、运行时异常5、处理方式5.1. 捕获异常

C语言中的常见进制转换详解(从二进制到十六进制)

《C语言中的常见进制转换详解(从二进制到十六进制)》进制转换是计算机编程中的一个常见任务,特别是在处理低级别的数据操作时,C语言作为一门底层编程语言,在进制转换方面提供了灵活的操作方式,今天,我们将深... 目录1、进制基础2、C语言中的进制转换2.1 从十进制转换为其他进制十进制转二进制十进制转八进制十进

$在R语言中的作用示例小结

《$在R语言中的作用示例小结》在R语言中,$是一个非常重要的操作符,主要用于访问对象的成员或组件,它的用途非常广泛,不仅限于数据框(dataframe),还可以用于列表(list)、环境(enviro... 目录1. 访问数据框(data frame)中的列2. 访问列表(list)中的元素3. 访问jav

POI从入门到实战轻松完成EasyExcel使用及Excel导入导出功能

《POI从入门到实战轻松完成EasyExcel使用及Excel导入导出功能》ApachePOI是一个流行的Java库,用于处理MicrosoftOffice格式文件,提供丰富API来创建、读取和修改O... 目录前言:Apache POIEasyPoiEasyExcel一、EasyExcel1.1、核心特性

Python中模块graphviz使用入门

《Python中模块graphviz使用入门》graphviz是一个用于创建和操作图形的Python库,本文主要介绍了Python中模块graphviz使用入门,具有一定的参考价值,感兴趣的可以了解一... 目录1.安装2. 基本用法2.1 输出图像格式2.2 图像style设置2.3 属性2.4 子图和聚

C语言中位操作的实际应用举例

《C语言中位操作的实际应用举例》:本文主要介绍C语言中位操作的实际应用,总结了位操作的使用场景,并指出了需要注意的问题,如可读性、平台依赖性和溢出风险,文中通过代码介绍的非常详细,需要的朋友可以参... 目录1. 嵌入式系统与硬件寄存器操作2. 网络协议解析3. 图像处理与颜色编码4. 高效处理布尔标志集合

Go语言开发实现查询IP信息的MCP服务器

《Go语言开发实现查询IP信息的MCP服务器》随着MCP的快速普及和广泛应用,MCP服务器也层出不穷,本文将详细介绍如何在Go语言中使用go-mcp库来开发一个查询IP信息的MCP... 目录前言mcp-ip-geo 服务器目录结构说明查询 IP 信息功能实现工具实现工具管理查询单个 IP 信息工具的实现服

C 语言中enum枚举的定义和使用小结

《C语言中enum枚举的定义和使用小结》在C语言里,enum(枚举)是一种用户自定义的数据类型,它能够让你创建一组具名的整数常量,下面我会从定义、使用、特性等方面详细介绍enum,感兴趣的朋友一起看... 目录1、引言2、基本定义3、定义枚举变量4、自定义枚举常量的值5、枚举与switch语句结合使用6、枚