VHDL 入门 01编程步骤

本文通过一个具体的比较器设计实例,介绍了VHDL语言的基本结构化编程思想。包括顶层设计的端口定义、器件级组件声明、内部信号声明以及实例化端口映射等关键步骤。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

VHDL 语言入门

结构化编程思想 Structural Modeling

本篇以一个比较器例,展示VHDL代码的架构,书写。

Step0 代码总览

entity my_compare is 
port(  A_IN : in std_logic_vector(2 downto 0) ;
       B_IN : in std_logic_vector(2 downto 0) ;
       EQ_OUT : out std_logic);
end my_compare;  

architecture structural of my_compare is  
------------------- component declarations  --------------------
    component big_xnor is  
    port ( A,B: in std_logic;
        F:   out std_logic);
    end component;

    component big_and3 is  
    port (A,B,C: in std_logic;
        F    : out std_logic);
    end component;
-----------------Internal signal declarations ----------------- 
    signal p1_out, p2_out, p3_out: std_logic;
begin
----------------Create instances of components and map ----------
 	x1: big_xnor port map(A=> A_IN(2), B=> B_IN(2), F => p1_out);
    x2: big_xnor port map(A=> A_IN(1), B=> B_IN(1), F => p2_out);
    x3: big_xnor port map(A=> A_IN(0), B=> B_IN(0), F => p3_out);
    a1: big_and3 port map(A=> p1_out, B =>p2_out, C=>p3_out, F=> EQ_OUT)
end structural; 

Step1 顶层设计 Generate top-level entity declaration

设计输入输出端口

entity my_compare is 
port(  A_IN : in std_logic_vector(2 downto 0) ;
       B_IN : in std_logic_vector(2 downto 0) ;
       EQ_OUT : out std_logic);
end my_compare;

step2 器件声明 Declare the lower-level design units used

  • Prepare the component declarations by replacing entity with component
    以前写的同或门等是采用顶层设计entity 来写的,现在要将其作为一个component在比较器这个entity来使用,需要进行声明。
component big_xnor is  
port ( A,B: in std_logic;
       F:   out std_logic);
end component;

component big_and3 is  
port (A,B,C: in std_logic;
      F    : out std_logic);
end component;

Step3 内部变量声明 Declare internal signals

除了总输入输出,每个模块中间会有一些临时数据输入输出。
这需要定义内部变量来存放。
注意它放在component后,在begin 前。

architecture structural of my_compare is  
-- component declarations  
    component big_xnor is  
    port ( A,B: in std_logic;
        F:   out std_logic);
    end component;

    component big_and3 is  
    port (A,B,C: in std_logic;
        F    : out std_logic);
    end component;
------- internal signal declarations--------------------------  
    signal p1_out, p2_out, p3_out: std_logic;
begin
  -- ......
end structural;

Step4 构建器件实例Create instances of components and map

构建实例端口对应,需将General A,B,F换成=>实际的输入输出。

begin  
    x1: big_xnor port map(A=> A_IN(2), B=> B_IN(2), F => p1_out);
    x2: big_xnor port map(A=> A_IN(1), B=> B_IN(1), F => p2_out);
    x3: big_xnor port map(A=> A_IN(0), B=> B_IN(0), F => p3_out);
    a1: big_and3 port map(A=> p1_out, B =>p2_out, C=>p3_out, F=> EQ_OUT)
    
VHDL语言100例 VHDL学习资料VHDL 编程要点VHDL编程心得体会: 100vhdl例子 VHDL 编程要注意问题.doc VHDL——按键消抖.doc VHDL电路简化.doc VHDL编程心得体会.pdf vhd开发的官方手册.pdf 第1例 带控制端口的加法器 第2例 无控制端口的加法器 第3例 乘法器 第4例 比较器 第5例 二路选择器 第6例 寄存器 第7例 移位寄存器 第8例 综合单元库 第9例 七值逻辑与基本数据类型 第10例 函数 第11例 七值逻辑线或分辨函数 第12例 转换函数 第13例 左移函数 第14例 七值逻辑程序包 第15例 四输入多路器 第16例 目标选择器 第17例 奇偶校验器 第18例 映射单元库及其使用举 第19例 循环边界常数化测试 第20例 保护保留字 第21例 进程死锁 第22例 振荡与死锁 第23例 振荡电路 第24例 分辨信号与分辨函数 第25例 信号驱动源 第26例 属性TRANSACTION分辨信号 第27例 块保护及属性EVENT, 第28例 形式参数属性的测试 第29例 进程并发语句 第30例 信号发送与接收 第31例 中断处理优先机制建模 第32例 过程限定 第33例 整数比较器及其测试 第34例 数据总线的读 第35例 基于总线的数据通道 第36例 基于多路器的数据通道 第37例 四值逻辑函数 第38例 四值逻辑向量按位或运算 第39例 生成语句描述规则结构 第40例 带类属的译码器描述 第41例 带类属的测试平台 第42例 行为与结构的混合描述 第43例 四位移位寄存器 第44例 寄存/计数器 第45例 顺序过程调用 第46例 VHDL中generic缺省值的使用 第47例 无输入元件的模拟 第48例 测试激励向量的编 第49例 delta延迟例释 第50例 惯性延迟分析 第51例 传输延迟驱动优先 第52例 多倍(次)分频器 第53例 三位计数器与测试平台 第54例 分秒计数显示器的行为描述6 第55例 地址计数器 第56例 指令预读计数器 第57例 加.c减.c乘指令的译码操作 第58例 2-4译码器结构描述 第59例 2-4译码器行为描述 第60例 转换函数在元件例示中的应用 第61例 基于同一基类型的两分辨类型的赋值相容问题 第62例 最大公约数的计算 第63例 最大公约数七段显示器编码 第64例 交通灯控制器 第65例 空调系统有限状态自动机 第66例 FIR滤波器 第67例 五阶椭圆滤波器 第68例 闹钟系统的控制 第69例 闹钟系统的译码 第70例 闹钟系统的移位寄存器 第71例 闹钟系统的闹钟寄存器时间计数器 第72例 闹钟系统的显示驱动器 第73例 闹钟系统的分频器 第74例 闹钟系统的整体组装 第75例 存储器 第76例 电机转速控制器 第77例 神经元计算机 第78例ccAm2901四位微处理器的ALU输入 第79例ccAm2901四位微处理器的ALU 第80例ccAm2901四位微处理器的RAM 第81例ccAm2901四位微处理器的寄存器 第82例ccAm2901四位微处理器的输出与移位 第83例ccAm2910四位微程序控制器中的多路选择器 第84例ccAm2910四位微程序控制器中的计数器/寄存器 第85例ccAm2910四位微程序控制器的指令计数器 第86例ccAm2910四位微程序控制器的堆栈 第87例 Am2910四位微程序控制器的指令译码器 第88例 可控制计数器 第89例 四位超前进位加法器 第90例 实现窗口搜索算法的并行系统(1)——协同处理器 第91例 实现窗口搜索算法的并行系统(2)——序列存储器 第92例 实现窗口搜索算法的并行系统(3)——字符串存储器 第93例 实现窗口搜索算法的并行系统(4)——顶层控制器 第94例 MB86901流水线行为描述组成框架 第95例 MB86901寄存器文件管理的描述 第96例 MB86901内ALU的行为描述 第97例 移位指令的行为描述 第98例 单周期指令的描述 第99例 多周期指令的描述 第100例 MB86901流水线行为模型
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值