aboutsummaryrefslogtreecommitdiffstats
path: root/testsuite/gna/issue1588/tent.vhdl
blob: 12cead8a4762860092f9994c5c938868286127ed (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
library ieee;
use ieee.std_logic_1164.all;

entity tent is
  port(
    rst_n : in std_logic;
    clk   : in std_logic;
    period : in integer;
    clk_o : out std_logic;
    op1 : out integer;
    op2 : out integer
    );
    
begin

  clk_mon: process(clk)
    variable tl : time := 0 ns;
    variable td : time;
    variable lp : time;
  begin
    if(clk'event) then
      --report "" & time'image(now);
      if clk = '1' then
        td := now - tl;
        tl := now;
        if lp /= td then
          report "clk period is: " & time'image(td);
          lp := td;
        end if;
      end if;
      
    end if;
  end process;
  
end entity tent;

architecture rtl of tent is

  signal bv : bit_vector(15 downto 0) := (others => '1');
  signal stdv : std_logic_vector(15 downto 0);
  signal clk1  : std_logic := '1';
  
  signal cnt : integer := 0;
  signal cnt1 : integer := 0;
  
  signal operiod : time;
  
begin

  --operiod <= period * 1 ns;

  clock : process(clk)
    variable clk_v : std_logic := '0';
  begin
    if clk'event and clk = '1' then
      clk_v := not clk_v;
      clk_o <= clk_v;
    end if;
    if cnt > 20 then
      report "END  SIM ..." severity failure;
    end if;
  end process clock;

  process(clk)
  begin
    if clk'event and clk = '1' then
      cnt <= cnt + 1;
      --report "clk event ...";
      op1 <= cnt;
      clk1 <= not clk1;
    end if;
  end process;

  process(clk1)
  begin
    if(clk1'event and clk1 = '1') then
      cnt1 <= 2 ** cnt;
      --report "clk1 event ...";
      op2 <= cnt1;
    end if;
  end process;

end rtl;


architecture bhv of tent is

  signal bv : bit_vector(15 downto 0) := (others => '1');
  signal stdv : std_logic_vector(15 downto 0);
  signal clk1  : std_logic := '1';
  
  signal cnt : integer := 0;
  signal cnt1 : integer := 0;
  
  signal operiod : time;
  
begin

  process
  begin
    report "BHV ...";
    wait;
  end process;

  clock : process(clk)
    variable clk_v : std_logic := '0';
  begin
    if clk'event and clk = '1' then
      clk_v := not clk_v;
      clk_o <= clk_v;
    end if;
    if cnt > 20 then
      report "END  SIM ..." severity failure;
    end if;
  end process clock;

  process(clk)
  begin
    if clk'event and clk = '1' then
      cnt <= cnt + 1;
      --report "clk event ...";
      op1 <= cnt;
      clk1 <= not clk1;
    end if;
  end process;

  process(clk1)
  begin
    if(clk1'event and clk1 = '1') then
      cnt1 <= 2 ** cnt;
      --report "clk1 event ...";
      op2 <= cnt1;
    end if;
  end process;

end bhv;