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

Subversion Repositories modular_oscilloscope

[/] [modular_oscilloscope/] [trunk/] [hdl/] [ctrl/] [trigger_manager.vhd] - Blame information for rev 33

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 32 budinero
-------------------------------------------------------------------------------------------------100
2
--| Modular Oscilloscope
3
--| UNSL - Argentine
4
--|
5
--| File: trigger_manager.vhd
6
--| Version: 0.1
7
--| Tested in: Actel A3PE1500
8
--|-------------------------------------------------------------------------------------------------
9
--| Description:
10
--|   CONTROL - Trigger manager
11
--|   
12
--|   
13
--|-------------------------------------------------------------------------------------------------
14
--| File history:
15
--|   0.1   | jul-2009 | First release
16
----------------------------------------------------------------------------------------------------
17 33 budinero
--| Copyright © 2009, Facundo Aguilera.
18 32 budinero
--|
19
--| This VHDL design file is an open design; you can redistribute it and/or
20
--| modify it and/or implement it after contacting the author.
21
----------------------------------------------------------------------------------------------------
22
 
23
 
24
--==================================================================================================
25
-- TODO
26
-- · (OK) Test offset sum
27
-- · Speed up
28
--==================================================================================================
29
 
30
library ieee;
31
use ieee.std_logic_1164.all;
32
--use IEEE.STD_LOGIC_UNSIGNED.ALL;
33
use IEEE.NUMERIC_STD.ALL;
34
 
35
 
36
entity trigger_manager is
37
  generic (
38
    MEM_ADD_WIDTH:  integer := 14;
39
    DATA_WIDTH:     integer := 10;
40
    CHANNELS_WIDTH: integer := 4
41
  );
42
  port (
43
    data_I:           in  std_logic_vector (DATA_WIDTH - 1 downto 0);
44
    channel_I:        in  std_logic_vector (CHANNELS_WIDTH -1 downto 0);
45
    trig_channel_I:   in  std_logic_vector (CHANNELS_WIDTH -1 downto 0);
46
    address_I:        in  std_logic_vector (MEM_ADD_WIDTH - 1 downto 0);
47
    final_address_I:  in  std_logic_vector (MEM_ADD_WIDTH - 1 downto 0);
48
    -- offset from trigger address (signed). MUST BE: -final_address_I < offset_I < final_address_I
49
    offset_I:         in std_logic_vector (MEM_ADD_WIDTH  downto 0);
50
    -- trigger level (from max to min, not signed)
51
    level_I:          in  std_logic_vector (DATA_WIDTH - 1 downto 0);
52
    -- use falling edge when falling_I = '1', else rising edge
53
    falling_I:        in  std_logic;
54
    clk_I:            in  std_logic;
55
    reset_I:          in  std_logic;
56
    enable_I:         in  std_logic;
57
    -- it is set when trigger condition occurs
58
    trigger_O:        out std_logic;
59
    -- address when trigger plus offset
60
    address_O:        out std_logic_vector (MEM_ADD_WIDTH - 1 downto 0)
61
  );
62
 
63
end entity trigger_manager;
64
 
65
architecture arch01_trigger of trigger_manager is
66
  -- trigger process signals
67
  signal higher, higher_reg: std_logic;
68
  signal pre_trigger: std_logic;
69
 
70
  -- signals for output address selection
71
  --signal final_address_sign: std_logic_vector (MEM_ADD_WIDTH downto 0);
72
  signal add_plus_off: unsigned (MEM_ADD_WIDTH downto 0);
73
  signal add_plus_off_plus_fa: unsigned (MEM_ADD_WIDTH downto 0);
74
  signal add_plus_off_sign: std_logic;
75
  signal add_plus_off_plus_fa_sign: std_logic;
76
  signal offset_sign: std_logic;
77
  signal truncate: std_logic;
78
  signal selected_address: std_logic_vector(MEM_ADD_WIDTH -1 downto 0);
79
  signal selected_address_reg: std_logic_vector(MEM_ADD_WIDTH -1 downto 0);
80
 
81
 
82
begin
83
 
84
  --------------------------------------------------------------------------------------------------
85
  -- Output address selection
86
 
87
  -- Output addess must be between 0 and final_address_I (buffer size), wich may be less than 
88
  -- (others -> '1'). For this reaeson, it must be truncated. 
89
 
90
  add_plus_off <= unsigned(address_I) + unsigned(offset_I);
91
  add_plus_off_sign <= add_plus_off(MEM_ADD_WIDTH);
92
  offset_sign <= offset_I(MEM_ADD_WIDTH);
93
 
94
  add_plus_off_plus_fa <= add_plus_off - unsigned(final_address_I) when offset_sign = '0' else
95
                           add_plus_off + unsigned(final_address_I);
96
 
97
 
98
  add_plus_off_plus_fa_sign <= add_plus_off_plus_fa (MEM_ADD_WIDTH);
99
 
100
  truncate <= (offset_sign and  add_plus_off_sign) or
101
              (not(offset_sign) and not(add_plus_off_plus_fa_sign));
102
 
103
 
104
  with truncate select
105
    selected_address <= std_logic_vector(add_plus_off_plus_fa(MEM_ADD_WIDTH - 1 downto 0))
106
                          when '1',
107
                        std_logic_vector(add_plus_off(MEM_ADD_WIDTH - 1 downto 0))
108
                          when others;
109
 
110
  address_O <=  selected_address_reg;
111
 
112
  --------------------------------------------------------------------------------------------------
113
  -- Trigger 
114
  higher <= '1' when data_I >= level_I else '0';
115
 
116
  P_trigger: process (clk_I, reset_I, enable_I, channel_I, trig_channel_I, higher_reg,
117
  falling_I, higher, address_I, offset_sign, selected_address)
118
  begin
119
    if clk_I'event and clk_I = '1' then
120
      if reset_I = '1' then
121
        pre_trigger <= '0';
122
        higher_reg <= '0';
123
        trigger_O <= '0';
124
        selected_address_reg <= (others => '0');
125
      elsif enable_I = '1' then
126
 
127
        if channel_I = trig_channel_I then
128
          if  (higher_reg = '0' xor falling_I = '1') and
129
              (higher = '1' xor falling_I = '1') and pre_trigger = '0'
130
              then -- trigger!
131
            pre_trigger <= '1';
132
            selected_address_reg <= selected_address;
133
            if offset_sign = '1' or unsigned(offset_I) = 0 then
134
              trigger_O <= '1';
135
            end if;
136
          end if;
137
          higher_reg <= higher;
138
        end if;
139
 
140
        if pre_trigger = '1' and selected_address_reg = address_I then
141
          -- if offset > 0 then trigger will wait until address_I equals trigger address plus offset
142
            trigger_O <= '1';
143
        end if;
144
 
145
      end if;
146
    end if;
147
  end process;
148
 
149
 
150
 
151
  -- t pt f /f xor1 xor2 and
152
  -- 000 1 0 1 
153
  -- 001 0 1 0 
154
  -- 010 1 0 0     
155
  -- 011 0 1 1 1 
156
  -- 100 1 1 1 1 
157
  -- 101 0 0 0  
158
  -- 110 1 1 0  
159
  -- 111 0 0 1  
160
 
161
 
162
 
163
 
164
 
165
 
166
 
167
 
168
 
169
 
170
 
171
 
172
end architecture;

powered by: WebSVN 2.1.0

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