【FPGA学习笔记】VHDL程序包:work、std_logic_1164、std_logic_arith、std_logic_unsigned 、std_logic_signed

简介

std_logic_1164、std_logic_arith、std_logic_unsigned 、std_logic_signed是位于IEEE库中的数据包。

std_logic_1164

这个包声明了std_logic、std_logic_vector等还有一些逻辑函数。如果需要做逻辑运算,就要use这个包。

std_logic_arith

要进行算数运算的话,就要use 这个包。

std_logic_unsigned 、std_logic_signed

若算数运算操作数是std_logic_vector类型的话,若是带符号运算,就要use std_logic_signed,若是无符号运算,就要use std_logic_unsigned。

无符号和带符号的区别:
signal a : std_logic_vector( n-1 downto 0),
a为无符号:表示的范围是 0~2^n-1,
a为带符号:表示的范围是-2^(n-1)~ 2^(n-1)。

  • 11
    点赞
  • 48
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
好的,以下是一个简单的 test bench 文件,可以用于验证你的 UART 模块的接收与发送功能。请将该代码保存为 tb_my_uart.vhd 文件,与你的 my_uart.vhd 文件一起在 ModelSim 中进行仿真。 ``` library ieee; use ieee.std_logic_1164.all; entity tb_my_uart is end tb_my_uart; architecture behavior of tb_my_uart is -- Component declaration for DUT component my_uart is port( clk_in : in std_logic; rx : in std_logic; tx : out std_logic; tcmd : in std_logic; tx_done : out std_logic; rx_ready : out std_logic; t_data : in std_logic_vector(7 downto 0); r_data : out std_logic_vector(7 downto 0) ); end component; -- Inputs signal clk_in : std_logic := '0'; signal rx : std_logic := '0'; signal tcmd : std_logic := '0'; signal t_data : std_logic_vector(7 downto 0) := (others => '0'); -- Outputs signal tx : std_logic; signal tx_done : std_logic; signal rx_ready : std_logic; signal r_data : std_logic_vector(7 downto 0); -- Clock period definitions constant clk_period : time := 10 ns; begin -- Instantiate the DUT uut: my_uart port map ( clk_in => clk_in, rx => rx, tx => tx, tcmd => tcmd, tx_done => tx_done, rx_ready => rx_ready, t_data => t_data, r_data => r_data ); -- Clock process definitions clk_process :process begin clk_in <= '0'; wait for clk_period/2; clk_in <= '1'; wait for clk_period/2; end process; -- Stimulus process stim_proc: process begin -- Send a test character t_data <= "01010101"; tcmd <= '1'; wait for 500 ns; tcmd <= '0'; wait for 1000 ns; -- Send another test character t_data <= "10101010"; tcmd <= '1'; wait for 500 ns; tcmd <= '0'; wait for 1000 ns; -- Wait for a received character wait until rx_ready = '1'; assert r_data = "11110000" report "Received incorrect data" severity error; wait; end process; end behavior; ``` 请注意,该 test bench 只是一个简单的示例,可能需要根据你的具体需求进行修改。在仿真过程中,你可以观察模拟波形,以验证你的 UART 模块是否正常工作。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值