aboutsummaryrefslogtreecommitdiffstats
path: root/testsuite/gna/issue1913/i2c_tb.vhdl
blob: 0bdbafa3893dbbadfc91de554c6bb9e6a4001549 (plain)
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
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
-----------------------------------------------------------------------------------
-- * Libs
-----------------------------------------------------------------------------------
LIBRARY IEEE;
USE IEEE.STD_LOGIC_1164.ALL;
USE IEEE.NUMERIC_STD.ALL;

LIBRARY STD;
USE     STD.TEXTIO.ALL;
USE     STD.ENV.FINISH; -- use of vhdl-2008

-----------------------------------------------------------------------------------
-- * Entity
-----------------------------------------------------------------------------------
ENTITY i2c_tb IS
  GENERIC (
    G_LOG_FILE  : string
  );
END i2c_tb;

-----------------------------------------------------------------------------------
-- * Architecture Begins
-----------------------------------------------------------------------------------
ARCHITECTURE str_tb OF i2c_tb IS
  -----------------------------------------------------------------------------------
  -- * Constants
  -----------------------------------------------------------------------------------
  constant C_CLK_PERIOD  : time := 20 ns; -- 50 Mhz

 -----------------------------------------------------------------------------------
  -- * Types
  -----------------------------------------------------------------------------------

  -----------------------------------------------------------------------------------
  -- * File
  -----------------------------------------------------------------------------------
  file fd_log : text;
  
  -----------------------------------------------------------------------------------
  -- * Components Declaration
  -----------------------------------------------------------------------------------

  -----------------------------------------------------------------------------------
  -- * Signals
  -----------------------------------------------------------------------------------
    -- ** Structure  (Interconnections)
    -----------------------------------------------------------------------------------

    -- ** Stimulus/Testbench Logic
    -----------------------------------------------------------------------------------
    signal s_clk          : std_logic := '1';
    signal s_rstn         : std_logic := '0';

  -----------------------------------------------------------------------------------
  -- * Procedures
  -----------------------------------------------------------------------------------

  -----------------------------------------------------------------------------------
  -- * Architecture Structure Testbench
  -----------------------------------------------------------------------------------
BEGIN
  -----------------------------------------------------------------------------------
  -- * Clock and Reset generation
  -----------------------------------------------------------------------------------
  clk_gen:
    s_clk <= not s_clk after C_CLK_PERIOD/2;

  rst_gen :
      s_rstn <=
      '1' after (1 us);

  -----------------------------------------------------------------------------------
  -- * Process
  -----------------------------------------------------------------------------------
    -- ** Stimulus
    -----------------------------------------------------------------------------------
    stimulus: process
    -- + Variables
      variable v_rand : integer :=0;
    -- + Process begin
    begin

      file_open(fd_log, G_LOG_FILE, write_mode); -- open log file
      wait until s_rstn='1';
      write(output, LF & " ===========================================" & LF
                       & " +--      Starting  Test      --+" & LF
                       & " ===========================================" & LF & LF);

      --=================================================================================

      wait until rising_edge(s_clk);  
       
      v_rand := integer'value("cucuc");

      --=================================================================================
      
      write(output, LF & " +--  Test has finished sucessfully!!" & LF);
      write(output, LF & " ===========================================" & LF
                       & " +--      Starting  Test      --+" & LF
                       & " ===========================================" & LF & LF);
      file_close(fd_log);  -- close log file
      finish;
    end process;

  -----------------------------------------------------------------------------------
  -- * Components Instatiation
  -----------------------------------------------------------------------------------

-----------------------------------------------------------------------------------
-- * Architecture Ends
-----------------------------------------------------------------------------------
END str_tb;