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

Subversion Repositories log_anal

[/] [log_anal/] [trunk/] [sw/] [la_view.vhd] - Blame information for rev 4

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 2 jamro
-- LOGIC ANALYSER VIEWER
2
-- this file is only for simulation !!!!!!!!!
3
-- this file allows for viewing data obtained by internal logic analyzer
4
-- file la_data.bin should be on your computer
5
-- this file is obtained by a log_anal.vhd component and others components loaded into a FPGA (virtex)
6
-- and a proper WISHBONE reads
7
-- readblock  la_data.bin adr_start adr_stop
8
-- where adr_start= LA_base_address, adr_stop= LA_base_address + 2^(adr_width-1) + (15)dec
9
-- the last 16 bytes of la_data.bin contains control registers
10
 
11
-- adjust data_width and  mem_adr_width !!!! to be the same as in the log_anal entity !!!
12
-- also define your own signals (the same which where connected to log_anal data input
13
-- and then assign these signals to proper d(index) data
14
 
15
library IEEE;
16
use IEEE.std_logic_1164.all;
17
library IEEE;
18
use IEEE.std_logic_arith.all;
19
 
20
entity la_view is
21
end;
22
 
23
architecture la_view_arch of la_view is
24
  -- constants - should be the same as generics in the log_anal entity !!!
25
  constant data_width: integer:= 16; -- width of the data that are analysed (must be power of 2)
26
  constant mem_adr_width: integer:= 9; -- internal memory address width  
27
  -- update the follows values if you want to watch triger
28
  constant trig_width: integer:= 8; -- updatate or no (the circuit can work properly with value 32 also
29
  constant trigger_same_as_data: boolean:= true; -- if the input to the entity log_anal 
30
          -- data is the same as trig, i.e. trig(trig_width-1 downto 0)= data(trig_width-1 downto 0) 
31
 
32
------------------------------------ internal LA logic do not change 
33
  constant mem_size: integer:= 2 ** mem_adr_width;
34
  constant file_name: string := "la_data.bin"; -- file name which contains acquired data
35
  constant file_length: integer:= 2**(mem_adr_width)*data_width/32;
36
                -- number of dwords (32-bits) in the file (excluding control registers)
37
  type la_mem_type is array (mem_size-1 downto 0) of std_logic_vector (data_width-1 downto 0);
38
 
39
 
40
procedure ReadControlReg(variable stop_count: out integer;
41
  signal trigger_value: out std_logic_vector(trig_width-1 downto 0) ) is -- read stop counter value form la_data.bin file
42
 
43
  variable DataIn: integer;
44
  variable trig_care: std_logic_vector(trig_width-1 downto 0);
45
  type BIT_VECTOR_FILE is file of integer;
46
  file Data_In_File : BIT_VECTOR_FILE;
47
begin
48
        FILE_OPEN (Data_In_File, file_name, READ_MODE);
49
        for i in 0 to file_length loop
50
           READ (Data_In_File, DataIn );
51
        end loop;
52
        -- Data_In contains status register (MSBs should be filled with zero
53
        assert DataIn<256
54
          report "Error. Incorrect data format in la_data.bin, check if the same generic values: data_width and mem_adr_width has been set in the log_anal and la_view entities or wrong read size"
55
          severity failure;
56
        assert DataIn<128
57
          report "Warning. The log_anal was still in run mode when acquired data were read"
58
          severity warning;
59
        assert DataIn>=64
60
          report "Warning. The log_anal has not finished data acquisition or file format error, check generic values seting and WISHBONE read size"
61
          severity warning;
62
 
63
        READ (Data_In_File, DataIn ); --  stop counter
64
        assert DataIn< 2**mem_adr_width
65
          report "Error. Incorect stop counter value in la_data.bin. Check if the same generic values: data_width and mem_adr_width has been set in the log_anal and la_view entities"
66
                  severity failure;
67
        stop_count:= DataIn;
68
 
69
        READ (Data_In_File, DataIn ); -- trig_value
70
        trigger_value<= conv_std_logic_vector(DataIn, trig_width);
71
        READ (Data_In_File, DataIn ); -- trig_care
72
        trig_care:= conv_std_logic_vector(DataIn, trig_width);
73
        for i in trig_width-1 downto 0 loop
74
                if trig_care(i)='0' then
75
                        trigger_value(i)<= '-';
76
                end if;
77
        end loop;
78
        FILE_CLOSE ( Data_In_File );
79
end ReadControlReg;
80
 
81
 
82
 
83
procedure ReadData(variable stop_count: in integer; signal mem : out la_mem_type ) is -- read recorded data from la_data.bin file
84
  variable DataIn : integer;
85
  variable Data32 : std_logic_vector(31 downto 0);
86
  variable address:integer;
87
  type BIT_VECTOR_FILE is file of integer;
88
  file DataInFile : BIT_VECTOR_FILE;
89
 
90
begin
91
        address:= (mem_size - stop_count) rem mem_size; -- the start address (rem is for stop_count=0)
92
        FILE_OPEN (DataInFile, file_name, READ_MODE);
93
        for i in 1 to file_length loop -- for every data in the file
94
          READ(DataInFile, DataIn);
95
          Data32:= conv_std_logic_vector(DataIn, 32);
96
          for j in 0 to (32/data_width) -1 loop
97
                  mem(address)<= Data32((j+1)*data_width-1 downto j*data_width);
98
                  address:= address + 1;
99
                  if address= mem_size then
100
                          address:= 0;
101
                  end if;
102
          end loop;
103
        end loop;
104
        FILE_CLOSE (DataInFile);
105
end;
106
 
107
  signal la_mem : la_mem_type; -- data read form la_data.bin file
108
  signal d: std_logic_vector(data_width-1 downto 0); -- data  recorder by the LA
109
  signal trigger_value: std_logic_vector(trig_width-1 downto 0); -- the value specified by writes to the trigger value and care registers
110
  signal trigger: std_logic; -- trigger condition is now satisfied
111
  signal clk: std_logic; -- data has been recoreded according to this clock activity
112
 
113
 -----------------------------------------------------------------------------------
114
 -- User area (changes can be done here)
115
  -- define here your signal names
116
 
117
  signal counter: std_logic_vector(data_width-1 downto 0);
118
 
119
begin
120
  -- write here which signal is assigned to which LA data bus (see log_anal instantiation)
121
  -- signal 'd' is the same as data input in the log_anal entity
122
  counter<= d;
123
 
124
 
125
  -- clk generation
126
  process begin
127
          wait for 10 ns; -- this value can be change freely
128
          clk<= '0';
129
          wait for 10 ns;
130
          clk<= '1';
131
  end process;
132
 
133
 
134
-------------------------------------------------------------------------------------------
135
-- Internal LA logic do not change it !!!
136
process
137
  variable Initialize : integer := 0;    -- initialisation flag
138
  variable stop_count : integer; -- the count points where the last data has been written to the LA memory
139
begin
140
        if Initialize=0 then     -- run only one time at the beginning
141
          ReadControlReg(stop_count, trigger_value);
142
          ReadData(stop_count, la_mem); -- read data recorded by the LA
143
          Initialize := 1;
144
          wait for 1000 ms;
145
    end if;
146
end process;
147
 
148
 
149
process(clk)
150
  variable i: integer:= 0;
151
  variable trigger_tmp: std_logic;
152
  variable d_tmp: std_logic_vector(data_width-1 downto 0);
153
begin
154
  if clk'event and clk='1' then
155
          d_tmp:= la_mem(i); -- data recorded in the LA
156
          d<= d_tmp;
157
          -- trigger logic
158
          if trigger_same_as_data=true  and trig_width <= data_width then
159
                trigger_tmp:= '1';
160
            for j in trig_width-1 downto 0 loop
161
                  if trigger_value(j)/= '-' then -- check only if not don't care
162
                          trigger_tmp:= trigger_tmp AND not (trigger_value(j) XOR d_tmp(j));
163
                  end if;
164
            end loop;
165
                trigger<= trigger_tmp;
166
          else -- do not show trigger because trigger data are different from watched data
167
                trigger<= 'Z';
168
          end if;
169
 
170
          i:= i +1;
171
          if i= mem_size then
172
                  i:= mem_size-1;
173
                  assert false
174
                report "O.K. All acquired data in the LA has already been shown"
175
                severity failure;
176
          end if;
177
  end if;
178
end process;
179
        assert data_width=32 or data_width=16 or data_width=8
180
          report "Error in la_view: constant data_width must be 8, 16 or 32"
181
                severity failure;
182
 
183
end la_view_arch;
184
 
185
-- logic analyser (LA) for FPGAs
186
-- ver 1.0
187
-- Author: Ernest Jamro
188
 
189
--//////////////////////////////////////////////////////////////////////
190
--//// Copyright (C) 2001 Authors and OPENCORES.ORG                 ////
191
--////                                                              ////
192
--//// This source file may be used and distributed without         ////
193
--/// restriction provided that this copyright statement is not    ////
194
--//// removed from the file and that any derivative work contains  ////
195
--//// the original copyright notice and the associated disclaimer. ////
196
--////                                                              ////
197
--//// This source file is free software; you can redistribute it   ////
198
--//// and/or modify it under the terms of the GNU Lesser General   ////
199
--//// Public License as published by the Free Software Foundation; ////
200
--//// either version 2.1 of the License, or (at your option) any   ////
201
--//// later version.                                               ////
202
--////                                                              ////
203
--//// This source is distributed in the hope that it will be       ////
204
--//// useful, but WITHOUT ANY WARRANTY; without even the implied   ////
205
--//// warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR      ////
206
--//// PURPOSE. See the GNU Lesser General Public License for more  ////
207
--//// details.                                                     ////
208
--////                                                              ////
209
--//// You should have received a copy of the GNU Lesser General    ////
210
--//// Public License along with this source; if not, download it   ////
211
--//// from <http://www.opencores.org/lgpl.shtml>                   ////

powered by: WebSVN 2.1.0

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