OpenCores
URL https://opencores.org/ocsvn/lateq/lateq/trunk

Subversion Repositories lateq

[/] [lateq/] [trunk/] [hdl_various_types/] [src/] [ex1_proc_tb.vhd] - Blame information for rev 2

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 2 wzab
-------------------------------------------------------------------------------
2
-- Title      : Testbench for design "ex1_proc"
3
-- Project    : 
4
-------------------------------------------------------------------------------
5
-- File       : ex1_proc_tb.vhd
6
-- Author     : Wojciech M. Zabolotny  <wzab@wzdell.nasz.dom>
7
-- Company    : 
8
-- License    : BSD
9
-- Created    : 2015-09-09
10
-- Last update: 2015-09-23
11
-- Platform   : 
12
-- Standard   : VHDL'93/02
13
-------------------------------------------------------------------------------
14
-- Description: 
15
-------------------------------------------------------------------------------
16
-- Copyright (c) 2015 
17
-------------------------------------------------------------------------------
18
-- Revisions  :
19
-- Date        Version  Author  Description
20
-- 2015-09-09  1.0      wzab    Created
21
-------------------------------------------------------------------------------
22
 
23
library ieee;
24
use ieee.std_logic_1164.all;
25
use IEEE.NUMERIC_STD.all;
26
use ieee.math_real.all;
27
library work;
28
use work.lateq_pkg.all;
29
use work.ex1_pkg.all;
30
use work.ex1_trees_pkg.all;
31
-------------------------------------------------------------------------------
32
 
33
entity ex1_proc_tb is
34
 
35
end entity ex1_proc_tb;
36
 
37
-------------------------------------------------------------------------------
38
 
39
architecture test of ex1_proc_tb is
40
 
41
  -- component ports
42
  signal din        : T_INPUT_DATA := C_INPUT_DATA_INIT;
43
  signal position   : T_POS_INT;
44
  signal wgt_charge : T_CALC_DATA;
45
  signal charge     : T_CALC_DATA;
46
  signal rst_p      : std_logic    := '1';
47
 
48
  -- clock
49
  signal clk : std_logic := '1';
50
 
51
begin  -- architecture test
52
 
53
  -- component instantiation
54
  DUT : entity work.ex1_proc
55
    port map (
56
      din        => din,
57
      position   => position,
58
      wgt_charge => wgt_charge,
59
      charge     => charge,
60
      clk        => clk,
61
      rst_p      => rst_p);
62
 
63
  -- clock generation
64
  Clk <= not Clk after 10 ns;
65
 
66
  -- waveform generation
67
  WaveGen_Proc : process
68
 
69
    procedure clean_ins is
70
    begin  -- procedure clean_ins
71
      din <= C_INPUT_DATA_INIT;
72
    end procedure clean_ins;
73
 
74
  begin
75
    -- insert signal assignments here
76
 
77
    wait until Clk = '1';
78
    rst_p   <= '0';
79
    wait until rising_edge(Clk);
80
    wait until rising_edge(Clk);
81
    wait until rising_edge(Clk);
82
    din(13) <= to_signed(20, C_DATA_WIDTH);
83
    din(14) <= to_signed(80, C_DATA_WIDTH);
84
    din(15) <= to_signed(100, C_DATA_WIDTH);
85
    din(16) <= to_signed(40, C_DATA_WIDTH);
86
    din(17) <= to_signed(10, C_DATA_WIDTH);
87
    wait until rising_edge(Clk);
88
    clean_ins;
89
    wait until rising_edge(Clk);
90
    wait until rising_edge(Clk);
91
    wait until rising_edge(Clk);
92
    din(23) <= to_signed(5, C_DATA_WIDTH);
93
    din(24) <= to_signed(30, C_DATA_WIDTH);
94
    din(25) <= to_signed(100, C_DATA_WIDTH);
95
    din(26) <= to_signed(90, C_DATA_WIDTH);
96
    din(27) <= to_signed(40, C_DATA_WIDTH);
97
    wait until rising_edge(Clk);
98
    clean_ins;
99
    wait until rising_edge(Clk);
100
    wait until rising_edge(Clk);
101
    wait until rising_edge(Clk);
102
    din     <= C_INPUT_DATA_INIT;
103
    wait until rising_edge(Clk);
104
    wait until rising_edge(Clk);
105
    wait;
106
  end process WaveGen_Proc;
107
 
108
  -- printing of the results
109
  r1 : process (clk) is
110
    variable f_charge     : real := 0.0;
111
    variable f_wgt_charge : real := 0.0;
112
    variable f_position   : real := 0.0;
113
  begin  -- process r1
114
    if clk'event and clk = '1' then     -- rising clock edge
115
      if rst_p = '1' then               -- synchronous reset (active high)
116
        null;
117
      else
118
        if charge > 10 then
119
          f_charge     := real(to_integer(charge));
120
          f_wgt_charge := real(to_integer(wgt_charge));
121
          f_position   := real(position);
122
          f_position   := f_position + f_wgt_charge/f_charge;
123
          report "Hit with charge: " & real'image(f_charge) & " at " & real'image(f_position) severity note;
124
        end if;
125
      end if;
126
    end if;
127
  end process r1;
128
 
129
end architecture test;
130
 
131
-------------------------------------------------------------------------------
132
 
133
configuration ex1_proc_tb_test_cfg of ex1_proc_tb is
134
  for test
135
  end for;
136
end ex1_proc_tb_test_cfg;
137
 
138
-------------------------------------------------------------------------------

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.