• VHDL testbench 例子,包含向文件中写数据


    LIBRARY ieee;
    USE ieee.std_logic_1164.ALL;
    use std.textio.all;
    use ieee.std_logic_textio.all;
     
    ENTITY DFFNTest IS
    END DFFNTest;
     
    ARCHITECTURE behavior OF DFFNTest IS
     
        -- Component Declaration for the Unit Under Test (UUT)
     
        COMPONENT DFFN
        GENERIC ( INIT : bit := '0');
         PORT(
             Q  : OUT  std_logic;
             CLK  : IN  std_logic;
             D : IN  std_logic
            );
        END COMPONENT;
       

       --Inputs
       signal CLK : std_logic := '0';
       signal D : std_logic := '0';

         --Outputs
       signal Q : std_logic;
       file fh_w:text;
      
       
    BEGIN
     
       -- Instantiate the Unit Under Test (UUT)
        uut: DFFN PORT MAP (
              Q => Q,
              CLK => CLK,
              D => D
            );

        write_proc:process
            variable buf_w : line;
            begin
                wait for 91 ns;
                wrtData:LOOP
              wait for 10 ns;
              write(buf_w,CLK);
                write(buf_w,string'("  "));
                write(buf_w,D);
                 write(buf_w,string'("  "));
                 write(buf_w,Q);
                 writeline(fh_w,buf_w);
            END LOOP wrtData;
        end process;

        -- Stimulus process
        stim_proc: process
        variable fstatus:FILE_OPEN_STATUS;
        variable buf_wh:line;
    variable i :integer :=0;
        begin
        file_open(fstatus,fh_w,"DFFNtb_out.vrf",write_mode);
        write(buf_wh,string'("CLK D  Q"));
        writeline(fh_w,buf_wh);   
      
            wait for 100 ns;   
        loop1: while(i<50) loop
        wait for 10 ns;
            CLK <= not CLK;
            if((i rem 3) = 0) then    
             D <= not D;
          end if;
              i := i+1;
        end loop loop1;
        file_close(fh_w);
        wait;
       end process;

    END;

  • 相关阅读:
    2017级算法第二次上机-B.第k顺序统计量
    2017级算法第二次上机-B.女娲加农炮
    2017级算法第二次上机-A.ModricWang's Real QuickSort Query
    2017级算法第三次上机-G.ModricWang的导弹拦截系统
    2017级算法第三次上机-F. SkyLee炒股票
    2017级算法第三次上机-C.SkyLee组装电脑
    Objective-c快速入门
    [翻译] Android是怎样绘制视图的
    AnimationsDemo中的ZoomActivity代码分析
    getGlobalVisibleRect和getLocalVisibleRect
  • 原文地址:https://www.cnblogs.com/rednodel/p/4056125.html
Copyright © 2020-2023  润新知