Vhdl 在模拟中不显示波形而没有错误

Vhdl 在模拟中不显示波形而没有错误,vhdl,Vhdl,我在行为模型和RTL模型中都为16位ALU编写了代码。它没有任何编译或模拟错误,但当我点击波形窗口中的运行按钮时,它没有显示任何输入或输出,甚至没有显示时钟 以下是我为其创建的测试台: library IEEE; use IEEE.std_logic_1164.all; use IEEE.std_logic_arith.all; USE IEEE.STD_LOGIC_UNSIGNED.ALL; Use IEEE.NUMERIC_STD.UNSIGNED; use ieee.std_logic_

我在行为模型和RTL模型中都为16位ALU编写了代码。它没有任何编译或模拟错误,但当我点击波形窗口中的运行按钮时,它没有显示任何输入或输出,甚至没有显示时钟

以下是我为其创建的测试台:

library IEEE;
use IEEE.std_logic_1164.all;
use IEEE.std_logic_arith.all;
USE IEEE.STD_LOGIC_UNSIGNED.ALL;
Use IEEE.NUMERIC_STD.UNSIGNED;

use ieee.std_logic_textio.all;
USE WORK.ANU.ALL;

entity xalu_tb is
end xalu_tb;

architecture beh of xalu_tb is

  component bitalu
    Port (A, B, CIN              : in  STD_LOGIC_VECTOR(15 DOWNTO 0);
          CLK, RST               : IN  STD_LOGIC;
          OPCODE                 :     OPCODE1;
          RES                    : OUT STD_LOGIC_VECTOR (31 downto 0);
          CARRY, GT, LT, EQ, NEQ : OUT STD_LOGIC
          );
  end component;
  component alurtl
    port
      (
        data1, data2                    : in  std_logic_vector(15 downto 0);
        operation                       : in  bit_vector(3 downto 0);
        result                          : out std_logic_vector(31 downto 0);
        carry1, equal, nequal, grt, lrt : out std_logic
        );
  end component;
  signal A, B, CIN                       : STD_LOGIC_VECTOR(15 DOWNTO 0);
  signal clk, rst                        : STD_LOGIC;
  signal opcode                          : opcode1;
  signal res                             : STD_LOGIC_VECTOR (31 downto 0);
  signal CARRY, GT, LT, EQ, NEQ          : STD_LOGIC;
  signal data1, data2                    : std_logic_vector(15 downto 0);
  signal operation                       : bit_vector(3 downto 0);
  signal result                          : std_logic_vector(31 downto 0);
  signal carry1, equal, nequal, grt, lrt : std_logic;

  file InFile  : text open read_mode is "C:/Users/---/Desktop/response.txt";
  file OutFile : text open write_mode is "C:/Users/---/Desktop/response1.txt";
begin
  u_x : bitalu port map(A, B, CIN, CLK, RST, OPCODE, RES, CARRY, GT, LT, EQ, NEQ);

  u_xx : alurtl port map(data1, data2, operation, result, carry1, equal, nequal, grt, lrt);

  A     <= "0000000000001010";
  B     <= "0000000000000110";
  CIN   <= "0000000000000000";
  DATA1 <= "0000000000001010";
  DATA2 <= "0000000000000110";

  CREATE_CLOCK : process
  begin
    if (rst <= '1') then
      res    <= "00000000000000000000000000000000";
      result <= "00000000000000000000000000000000";
    else
      clk <= '1';
      wait for 5 ns;
      clk <= '0';
      wait for 5 ns;
    end if;
  end process;

  p1 : process
    variable res                                      : std_logic_vector(31 downto 0);
    variable result                                   : std_logic_vector(31 downto 0);
    variable lt, gt, eq, neq, lrt, grt, equal, nequal : std_logic;
    variable L1, L2                                   : line;

  begin
    wait until clk = '1' and clk'event;

    OPCODE    <= ADD;
    operation <= "0000";
    if(not (endfile(infile))) then
      readLine(infile, L1);
      readLine(infile, L2);
      read(L1, res);
      read(L2, result);
      assert(res(15 downto 0) = result(15 downto 0)) report "notmatch"severity error;
      write(L1, RES);
      writeline(outfile, L1);
      write(L2, result);
      writeline(outfile, L2);
    end if;
    wait for 10 ns;

    OPCODE    <= sub;
    operation <= "0001";
    if(not (endfile(infile))) then
      readLine(infile, L1);
      readLine(infile, L2);
      read(L1, res);
      read(L2, result);
      assert(res(15 downto 0) = result(15 downto 0)) report "notmatch"severity error;
      write(L1, RES);
      writeline(outfile, L1);
      write(L2, result);
      writeline(outfile, L2);
    end if;
    wait for 10 ns;
    OPCODE    <= mul;
    operation <= "0010";
    if(not (endfile(infile))) then
      readLine(infile, L1);
      readLine(infile, L2);
      read(L1, res);
      read(L2, result);
      assert(res(15 downto 0) = result(15 downto 0)) report "notmatch"severity error;
      write(L1, RES);
      writeline(outfile, L1);
      write(L2, result);
      writeline(outfile, L2);
    end if;
    wait for 10 ns;
    OPCODE    <= comp;
    operation <= "0011";
    if(res(16) = '1') then
      if(not (endfile(infile))) then
        readLine(infile, L1);
        readLine(infile, L2);
        read(L1, lt);
        read(L2, lrt);
        assert(lt = lrt) report "notmatch"severity error;
        write(L1, lt);
        writeline(outfile, L1);
      end if;
    elsif(res = "0000000000000000") then
      if(not (endfile(infile))) then
        readLine(infile, L1);
        readLine(infile, L2);
        read(L1, eq);
        read(L2, equal);
        assert(eq = equal) report "notmatch"severity error;
        write(L1, eq);
        writeline(outfile, L1);
      end if;
    else
      if(not (endfile(infile))) then
        readLine(infile, L1);
        readLine(infile, L2);
        read(L1, gt);
        read(L2, grt);
        assert(gt = grt) report "notmatch"severity error;
        write(L1, gt);
        writeline(outfile, L1);
      end if;
    end if;

    wait for 10ns;
    OPCODE    <= and16;
    operation <= "0100";
    if(not (endfile(infile))) then
      readLine(infile, L1);
      readLine(infile, L2);
      read(L1, res);
      read(L2, result);
      assert(res(15 downto 0) = result(15 downto 0)) report "notmatch"severity error;
      write(L1, RES);
      writeline(outfile, L1);
      write(L2, result);
      writeline(outfile, L1);
    end if;

    wait for 10 ns;
    OPCODE    <= or16;
    operation <= "0101";
    if(not (endfile(infile))) then
      readLine(infile, L1);
      readLine(infile, L2);
      read(L1, res);
      read(L2, result);
      assert(res(15 downto 0) = result(15 downto 0)) report "notmatch"severity error;
      write(L1, RES);
      writeline(outfile, L1);
      write(L2, result);
      writeline(outfile, L2);
    end if;

    wait for 10 ns;
    OPCODE    <= not16;
    operation <= "0110";
    if(not (endfile(infile))) then
      readLine(infile, L1);
      readLine(infile, L2);
      read(L1, res);
      read(L2, result);
      assert(res(15 downto 0) = result(15 downto 0)) report "notmatch"severity error;
      write(L1, RES);
      writeline(outfile, L1);
      write(L2, result);
      writeline(outfile, L2);
    end if;

    wait for 10 ns;
    OPCODE    <= xor16;
    operation <= "0111";
    if(not (endfile(infile))) then
      readLine(infile, L1);
      readLine(infile, L2);
      read(L1, res);
      read(L2, result);
      assert(res(15 downto 0) = result(15 downto 0)) report "notmatch"severity error;
      write(L1, RES);
      writeline(outfile, L1);
      write(L2, result);
      writeline(outfile, L2);
    end if;


    wait for 10 ns;
    OPCODE    <= srl16;
    operation <= "1000";
    if(not (endfile(infile))) then
      readLine(infile, L1);
      readLine(infile, L2);
      read(L1, res);
      read(L2, result);
      assert(res(15 downto 0) = result(15 downto 0)) report "notmatch"severity error;
      write(L1, RES);
      writeline(outfile, L1);
      write(L2, result);
      writeline(outfile, L1);
    end if;

    wait for 10 ns;
    OPCODE    <= sll16;
    operation <= "1001";
    if(not (endfile(infile))) then
      readLine(infile, L1);
      readLine(infile, L2);
      read(L1, res);
      read(L2, result);
      assert(res(15 downto 0) = result(15 downto 0)) report "notmatch"severity error;
      write(L1, RES);
      writeline(outfile, L1);
      write(L2, result);
      writeline(outfile, L2);
    end if;

    wait for 10 ns;
    OPCODE    <= sra16;
    operation <= "1010";
    if(not (endfile(infile))) then
      readLine(infile, L1);
      readLine(infile, L2);
      read(L1, res);
      read(L2, result);
      assert(res(15 downto 0) = result(15 downto 0)) report "notmatch"severity error;
      write(L1, RES);
      writeline(outfile, L1);
      write(L2, result);
      writeline(outfile, L2);
    end if;

    wait for 10 ns;
    operation <= "1011";
    OPCODE    <= sla16;
    if(not (endfile(infile))) then
      readLine(infile, L1);
      readLine(infile, L2);
      read(L1, res);
      read(L2, result);
      assert(res(15 downto 0) = result(15 downto 0)) report "notmatch"severity error;
      write(L1, RES);
      writeline(outfile, L1);
      write(L2, result);
      writeline(outfile, L2);


    end if;
    wait for 10 ns;

  end process;

end beh;
IEEE库;
使用IEEE.std_logic_1164.all;
使用IEEE.std_logic_arith.all;
使用IEEE.STD_LOGIC_UNSIGNED.ALL;
使用IEEE.NUMERIC_STD.UNSIGNED;
使用ieee.std_logic_textio.all;
使用WORK.ANU.ALL;
实体xalu_tb是
结束xalu_tb;
xalu_tb的架构是
成分比塔卢
端口(A、B、CIN:标准逻辑向量(15到0);
时钟,RST:标准逻辑中;
操作码:操作码1;
RES:输出标准逻辑向量(31向下至0);
进位、GT、LT、EQ、NEQ:输出标准逻辑
);
端部元件;
成分铝
港口
(
数据1、数据2:标准逻辑向量(15到0);
操作:在位_向量中(3到0);
结果:输出标准逻辑向量(31到0);
carry1,相等,nequal,grt,lrt:输出标准逻辑
);
端部元件;
信号A、B、CIN:STD_逻辑_向量(15到0);
信号时钟,rst:STD_逻辑;
信号操作码:操作码1;
信号分辨率:标准逻辑向量(31至0);
信号进位,GT,LT,EQ,NEQ:STD_逻辑;
信号数据1、数据2:标准逻辑向量(15到0);
信号操作:位_矢量(3到0);
信号结果:标准逻辑向量(31到0);
信号载波1,相等,nequal,grt,lrt:标准逻辑;
文件填充:文本打开读取模式为“C:/Users/--/Desktop/response.txt”;
文件输出文件:文本打开写入模式为“C:/Users/--/Desktop/response1.txt”;
开始
u_x:bitalu端口图(A、B、CIN、CLK、RST、操作码、RES、进位、GT、LT、EQ、NEQ);
u_xx:alurtl端口图(数据1、数据2、操作、结果、carry1、相等、nequal、grt、lrt);

原因是该试验台代码部分:

CREATE_CLOCK : process
begin
  if (rst <= '1') then
    res    <= "00000000000000000000000000000000";
    result <= "00000000000000000000000000000000";
  else
    ... (code with wait statement)
  end if;
end process;
或者稍后的时间和增量,那么原因可能是没有 从未执行等待的敏感度列表,如:

process is
begin
  if FALSE then
    wait;
    ...
或者一个无止境的循环,比如:

while TRUE loop
  ...
ModelSim不会报告任何警告(如“可能无限循环:进程 不包含等待语句。“)或类似上述代码的错误,以及
模拟器甚至可能很难通过停止和中断GUI交互来停止。

原因是此测试台代码部分:

CREATE_CLOCK : process
begin
  if (rst <= '1') then
    res    <= "00000000000000000000000000000000";
    result <= "00000000000000000000000000000000";
  else
    ... (code with wait statement)
  end if;
end process;
或者稍后的时间和增量,那么原因可能是没有 从未执行等待的敏感度列表,如:

process is
begin
  if FALSE then
    wait;
    ...
或者一个无止境的循环,比如:

while TRUE loop
  ...
ModelSim不会报告任何警告(如“可能无限循环:进程 不包含等待语句。“)或类似上述代码的错误,以及
模拟器甚至可能很难通过停止和中断GUI交互来停止运行。

我阅读了以下示例:

  CREATE_CLOCK : process
  begin
    if (rst <= '1') then
至少它能让电路从复位中恢复

其他一些评论:

  • 丢失非标准库use子句,改用numeric_std

    使用IEEE.std\u logic\u arith.all
    使用IEEE.STD\u LOGIC\u UNSIGNED.ALL

  • 布尔表达式周围不需要括号。它们只是杂乱无章的东西,可能是从C继承来的。以下是等效的:

    如果(不是(endfile(infle)),则
    
    如果不是endfile(infle),则

  • 通过将公共部分粘贴到一个过程中并多次调用,可以改进重复的测试台代码。如果它被声明为进程的本地(在变量声明之后),那么它可以看到所有进程状态,或者您可以向它传递任何想要的参数

  • 看起来好像
    opcode
    operation
    可能是重复的或具有相同的功能。如果是这样的话,最好取消一个(最好是“操作”),或者至少将它们联系在一起:例如
    常量运算:标准逻辑向量(3到0)的数组(Opcode1):=(
    添加=>“0000”,
    Sub=>“0001”,…)


    operation我阅读了这个示例:

      CREATE_CLOCK : process
      begin
        if (rst <= '1') then
    
    至少它能让电路从复位中恢复

    其他一些评论:

  • 丢失非标准库use子句,改用numeric_std

    使用IEEE.std\u logic\u arith.all
    使用IEEE.STD\u LOGIC\u UNSIGNED.ALL

  • 布尔表达式周围不需要括号。它们只是杂乱无章的东西,可能是从C继承来的。以下是等效的:

    如果(不是(endfile(infle)),则
    
    如果不是endfile(infle),则

  • 通过将公共部分粘贴到一个过程中并多次调用,可以改进重复的测试台代码。如果它被声明为进程的本地(在变量声明之后),那么它可以看到所有进程状态,或者您可以向它传递任何想要的参数

  • 看起来好像
    opcode
    operation
    可能是重复的或具有相同的功能。如果是这样的话,最好取消一个(最好是“操作”),或者至少将它们联系在一起:例如
    常量运算:标准逻辑向量(3到0)的数组(Opcode1):=(
    添加=>“0000”,
    Sub=>“0001”,…)


    操作是的,你是对的错误是我做了一个信号分配,即如果res是的,你是对的错误是我做了一个信号分配,即如果resIf在编译或模拟中没有错误,并且如果你尝试了一切,那么一定是你的模拟器有缺陷。尽管如此,我还是建议您尝试更好地格式化代码,并告诉我们