summaryrefslogtreecommitdiff
path: root/testsuite/gna/ticket89/project/tb/partial_test_tb.vhd
blob: 29673466cbbd5b3da9796f3d7a19ad50843dd073 (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
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
--========================================================================================================================
-- Copyright (c) 2015 by Bitvis AS.  All rights reserved.
-- A free license is hereby granted, free of charge, to any person obtaining
-- a copy of this VHDL code and associated documentation files (for 'Bitvis Utility Library'),
-- to use, copy, modify, merge, publish and/or distribute - subject to the following conditions:
--  - This copyright notice shall be included as is in all copies or substantial portions of the code and documentation
--  - The files included in Bitvis Utility Library may only be used as a part of this library as a whole
--  - The License file may not be modified
--  - The calls in the code to the license file ('show_license') may not be removed or modified.
--  - No other conditions whatsoever may be added to those of this License

-- BITVIS UTILITY LIBRARY AND ANY PART THEREOF ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
-- INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
-- IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
-- WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH BITVIS UTILITY LIBRARY.
--========================================================================================================================

------------------------------------------------------------------------------------------
-- VHDL unit     : Bitvis Utility Library : partial_test_tb
--
-- Description   : Parts of the testbench used for testing the Bitvis Utility Library
------------------------------------------------------------------------------------------


library IEEE;
use IEEE.std_logic_1164.all;
use IEEE.numeric_std.all;

library STD;
use std.textio.all;

library work;
use work.types_pkg.all;
use work.string_methods_pkg.all;
use work.adaptations_pkg.all;
use work.methods_pkg.all;
use work.bfm_common_pkg.all;

library ieee_proposed;
use ieee_proposed.standard_additions.all;       -- Used for to_string(real)
use ieee_proposed.std_logic_1164_additions.all; -- Used for to_string(std_logic)


entity partial_test_tb is
end entity;


architecture func of partial_test_tb is

  signal sl       : std_logic                     := '0';
  signal clk100M      : std_logic;
  signal clk100M_ena  : boolean := true;

  signal clk200M      : std_logic;
  signal clk200M_ena  : boolean := true;

  signal clk50M      : std_logic;

  constant C_CLK100M_PERIOD : time := 10 ns;

begin

  ------------------------------------------------
  -- Process: clock generator
  ------------------------------------------------
  -- Overloaded version with enable signal as argument
  clock_generator(clk100M, clk100M_ena, C_CLK100M_PERIOD, "Clk100M");

  ------------------------------------------------
  -- PROCESS: p_main
  ------------------------------------------------
  p_main: process
    constant C_SCOPE     : string  := "TB seq";

    -- Log overloads for simplification
    procedure log(
      msg   : string) is
    begin
      log(ID_SEQUENCER, msg, C_SCOPE);
    end;



  begin
    set_alert_file_name("alertlog.txt");
    set_log_file_name("testlog.txt");


    set_alert_stop_limit(WARNING, 0);
    set_alert_stop_limit(ERROR, 0);    -- 0 = Never stop
    wait for 1 ns;

   
   
    -- ####################### BLOCK 1 - Causes "internal error: delayed" ##########################

    -- FROM_NOW, FROM_NOW
    await_stable(sl, 50 ns, FROM_NOW, 100 ns, FROM_NOW, ERROR, "sl: Stable FROM_NOW, FROM_NOW, OK after 50 ns", C_SCOPE);

    sl <= transport not sl after 30 ns;
    await_stable(sl, 50 ns, FROM_NOW, 100 ns, FROM_NOW, ERROR, "sl: Stable FROM_NOW, FROM_NOW, OK after 80 ns", C_SCOPE);

    sl <= transport not sl after 30 ns;
    await_stable(sl, 50 ns, FROM_NOW, 60 ns, FROM_NOW, ERROR, "sl: Not stable FROM_NOW, FROM_NOW, Fail after 30 ns", C_SCOPE);
    increment_expected_alerts(ERROR, 1);

    await_stable(sl, 50 ns, FROM_NOW, 1 ns, FROM_NOW, ERROR, "sl: Timeout before stable_req, FROM_NOW, FROM_NOW, Fail immediately", C_SCOPE);
    increment_expected_alerts(ERROR, 1);

    await_stable(sl, 0 ns, FROM_NOW, 0 ns, FROM_NOW, ERROR, "sl: stable for 0 ns, FROM_NOW, FROM_NOW, OK after 0 ns", C_SCOPE);


    -- FROM_LAST_EVENT, FROM_NOW
    sl <= not sl;
    log("NOTE: ERROR HAPPENS AFTER HERE");
    wait for 10 ns; 
    log("NOTE: ERROR HAPPENS BEFORE HERE");
    
    -- ####################### END OF BLOCK 1 ##########################
    
    
    
        
    -- ####################### BLOCK 2 - Code works if this is removed ##########################
    
    -- Pulse a certain number of clock periods
    clk100M_ena <= true; -- Clock must be running
    sl <= '0';
    wait for 0 ns;  -- Wait for signal to update
    gen_pulse(sl, clk100M, 10, "Test pulse 10 clk periods");
    check_value(sl'delayed(0 ns)'last_event, 10*C_CLK100M_PERIOD, ERROR, "Check start of pulse");
    wait for 0 ns; -- Wait for signal to be updated
    check_value(sl, '0', ERROR, "pulse for 10 clk periods, pulse done", C_SCOPE);
    check_value(sl'last_event, 0 ns, ERROR, "pulse for 10 clk periods. Check that it actually pulsed for a delta cycle", C_SCOPE);
    check_value(sl'last_value, '1', ERROR, "pulse for 10 clk periods, check that it actually pulsed for a delta cycle", C_SCOPE);
    wait for 100 ns;
    
    -- ####################### END OF BLOCK 2 ##########################

    --==================================================================================================
    -- Ending the simulation
    --------------------------------------------------------------------------------------
    wait for 1000 ns;  -- to allow some time for completion
    report_alert_counters(INTERMEDIATE);
    report_alert_counters(FINAL);
    log(ID_LOG_HDR,"SIMULATION COMPLETED", C_SCOPE);
    assert false
      report "End of simulation.  (***Ignore this failure. Was provoked to stop the simulation.)"
      severity failure;
    wait;  -- to stop completely


  end process p_main;

end func;