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

Subversion Repositories log_anal

[/] [log_anal/] [trunk/] [rtl/] [la_trigger.vhd] - Blame information for rev 6

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

Line No. Rev Author Line
1 2 jamro
-- logic analyser trigger -- ver 1.0
2
-- Author: Ernest Jamro
3
 
4
--//////////////////////////////////////////////////////////////////////
5
--//// Copyright (C) 2001 Authors and OPENCORES.ORG                 ////
6
--////                                                              ////
7
--//// This source file may be used and distributed without         ////
8
--/// restriction provided that this copyright statement is not    ////
9
--//// removed from the file and that any derivative work contains  ////
10
--//// the original copyright notice and the associated disclaimer. ////
11
--////                                                              ////
12
--//// This source file is free software; you can redistribute it   ////
13
--//// and/or modify it under the terms of the GNU Lesser General   ////
14
--//// Public License as published by the Free Software Foundation; ////
15
--//// either version 2.1 of the License, or (at your option) any   ////
16
--//// later version.                                               ////
17
--////                                                              ////
18
--//// This source is distributed in the hope that it will be       ////
19
--//// useful, but WITHOUT ANY WARRANTY; without even the implied   ////
20
--//// warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR      ////
21
--//// PURPOSE. See the GNU Lesser General Public License for more  ////
22
--//// details.                                                     ////
23
--////                                                              ////
24
--//// You should have received a copy of the GNU Lesser General    ////
25
--//// Public License along with this source; if not, download it   ////
26
--//// from <http://www.opencores.org/lgpl.shtml>                   ////
27
 
28
 
29
 
30
------------------------------------------------------------------------------------
31
------------------------------------------------------------------------------------
32
-- TRIGGER LOGIC (input trig_data when satisfies the trigger condition causes that the data recording starts)
33
 
34
library IEEE;
35
use IEEE.std_logic_1164.all;
36
use IEEE.std_logic_unsigned.all;
37
use IEEE.std_logic_misc.all; -- for AND gate
38
 
39
entity la_trigger is
40
        generic (trig_width: integer:= 8); -- width of the trig data 1<=trig_width<=32
41
        port (clk, arst: in std_logic;
42
        -- LA interface
43
        trig_data: in std_logic_vector(trig_width-1 downto 0); -- data that are alasysed for triger
44
        trig_now: out std_logic; -- triger data is now presented on the trig_data bus
45
        -- Control interface (to set and read triger values)
46
        wr: in std_logic; -- when 1 writes din to triger configuration registers
47
        adr: in std_logic_vector(3 downto 0);
48
        dout: out std_logic_vector(7 downto 0);
49
        din: in std_logic_vector(7 downto 0) );
50
end la_trigger;
51
 
52
architecture la_trigger_arch of la_trigger is
53
  signal trig_value: std_logic_vector(trig_width-1 downto 0); -- sets lewel for which reiger should be active
54
  signal trig_care: std_logic_vector(trig_width-1 downto 0); -- care / or do not care about the input value presented on trig_data
55
  signal trig_and: std_logic_vector(trig_width-1 downto 0); -- temporal value that goes to trig_width and gate
56
  signal trig_result: std_logic_vector(trig_width downto 0); -- result of the and gate
57
  signal dout32value, dout32care: std_logic_vector(31 downto 0); -- dout value extended with zeros
58
begin
59
 
60
  -- trig_value and care registers
61
t8: if trig_width<=8 generate
62
 process(clk, arst) begin
63
   if arst='1' then trig_value<= (others=>'0'); trig_care<= (others=>'0');
64
   elsif clk'event and clk='1' then
65
        if wr='1' then
66
           if adr="1000" then trig_value(trig_width-1 downto 0)<= din(trig_width-1 downto 0); end if;
67
           if adr="1100" then trig_care(trig_width-1 downto 0)<= din(trig_width-1 downto 0); end if;
68
        end if;
69
   end if;
70
 end process;
71
end generate;
72
 
73
t16: if trig_width<=16 and trig_width>8 generate
74
 process(clk, arst) begin
75
   if arst='1' then trig_value<= (others=>'0'); trig_care<= (others=>'0');
76
   elsif clk'event and clk='1' then
77
        if wr='1' then
78
           if adr="1000" then trig_value(7 downto 0)<= din; end if;
79
           if adr="1001" then trig_value(trig_width-1 downto 8)<= din(trig_width-8 downto 0); end if;
80
           if adr="1100" then trig_care(7 downto 0)<= din; end if;
81
           if adr="1101" then trig_care(trig_width-1 downto 8)<= din(trig_width-8 downto 0); end if;
82
         end if;
83
   end if;
84
 end process;
85
end generate;
86
 
87
t24: if trig_width<=24 and trig_width>16 generate
88
 process(clk, arst) begin
89
   if arst='1' then trig_value<= (others=>'0'); trig_care<= (others=>'0');
90
   elsif clk'event and clk='1' then
91
        if wr='1' then
92
           if adr="1000" then trig_value(7 downto 0)<= din; end if;
93
           if adr="1001" then trig_value(15 downto 8)<= din; end if;
94
           if adr="1010" then trig_value(trig_width-1 downto 16)<= din(trig_width-16 downto 0); end if;
95
           if adr="1100" then trig_care(7 downto 0)<= din; end if;
96
           if adr="1101" then trig_care(15 downto 8)<= din; end if;
97
           if adr="1110" then trig_care(trig_width-1 downto 16)<= din(trig_width-16 downto 0); end if;
98
         end if;
99
   end if;
100
 end process;
101
end generate;
102
 
103
t32: if trig_width>24 generate
104
 process(clk, arst) begin
105
   if arst='1' then trig_value<= (others=>'0'); trig_care<= (others=>'0');
106
   elsif clk'event and clk='1' then
107
        if wr='1' then
108
           if adr="1000" then trig_value(7 downto 0)<= din; end if;
109
           if adr="1001" then trig_value(15 downto 8)<= din; end if;
110
           if adr="1010" then trig_value(23 downto 16)<= din; end if;
111
           if adr="1011" then trig_value(trig_width-1 downto 24)<= din(trig_width-24 downto 0); end if;
112
           if adr="1100" then trig_care(7 downto 0)<= din; end if;
113
           if adr="1101" then trig_care(15 downto 8)<= din; end if;
114
           if adr="1110" then trig_care(23 downto 16)<= din; end if;
115
           if adr="1111" then trig_care(trig_width-1 downto 24)<= din(trig_width-24 downto 0); end if;
116
           end if;
117
   end if;
118
 end process;
119
end generate;
120
 
121
 
122
  -- trig_now logic
123
gi: for i in 0 to trig_width-1 generate
124
  -- trig_and flip-flop (introduces pipelining to speed up the ciruit frequency)
125
  process(clk, arst) begin
126
         if arst='1' then trig_and(i)<= '0';
127
         elsif clk'event and clk='1' then
128
                 trig_and(i)<= not trig_care(i) or not( trig_data(i) xor trig_value(i));
129
         end if;
130
  end process;
131
end generate;
132
 
133
  -- and gate and flip-flop
134
  process(clk, arst) begin
135
         if arst='1' then trig_now<= '0';
136
         elsif clk'event and clk='1' then
137
       trig_now<= AND_REDUCE(trig_and); -- correct trigger;
138
         end if;
139
  end process;
140
 
141
  -- dout multiplexer
142
  -- extend MSBs with zeros
143
  dout32value(trig_width-1 downto 0)<= trig_value;
144
  dout32care(trig_width-1 downto 0)<= trig_care;
145
  g31: if trig_width<32 generate
146
        dout32value(31 downto trig_width)<= (others=>'0');
147
        dout32care(31 downto trig_width)<= (others=>'0');
148
  end generate;
149
 
150
  dout<= dout32value(7 downto 0) when adr(2 downto 0)="000" else
151
         dout32value(15 downto 8) when adr(2 downto 0)="001" else
152
                 dout32value(23 downto 16) when adr(2 downto 0)="010" else
153
                 dout32value(31 downto 24) when adr(2 downto 0)="011" else
154
         dout32care(7 downto 0) when adr(2 downto 0)="100" else
155
         dout32care(15 downto 8) when adr(2 downto 0)="101" else
156
                 dout32care(23 downto 16) when adr(2 downto 0)="110" else
157
                 dout32care(31 downto 24) when adr(2 downto 0)="111" else (others=> '-');
158
end la_trigger_arch;
159
 
160
 

powered by: WebSVN 2.1.0

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