首页 > 解决方案 > 将循环语句添加到每一位 VHDL

问题描述

大家好,我只是想问一下是否可以在这段代码上添加一个循环语句来打印每一位?如果可能怎么办?

这是代码。

library ieee;
use ieee.std_logic_1164.all;

entity T10_StdLogicTb is
end entity;

architecture sim of T10_StdLogicTb is
    signal Signal1 : std_logic := '0';    --initial value of Signal1 is 0
    signal Signal2 : std_logic;

    signal Signal3 : std_logic;
begin
    process is
        
    begin
              
        wait for 10 ns;  --remember no process can be left without the wake statement
        Signal1 <= not Signal1;
    end process;
    
     
 
end architecture;

标签: vhdlmodelsim

解决方案


您不能循环访问各个位Signal1和。但是您可以将这三个转换为可以循环的 3 位。Signal2Signal3std_logic_vector

假设您所有的三位都在一个名为my_vector. 使用report语句打印值,带有类型的'image属性std_logic

for i in my_vector'range loop
    report std_logic'image( my_vector(i) );
end loop;

推荐阅读