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

Subversion Repositories log_anal

[/] [log_anal/] [trunk/] [sw/] [la_view.vhd] - Diff between revs 2 and 4

Only display areas with differences | Details | Blame | View Log

Rev 2 Rev 4
-- LOGIC ANALYSER VIEWER
-- LOGIC ANALYSER VIEWER
-- this file is only for simulation !!!!!!!!!
-- this file is only for simulation !!!!!!!!!
-- this file allows for viewing data obtained by internal logic analyzer
-- this file allows for viewing data obtained by internal logic analyzer
-- file la_data.bin should be on your computer
-- file la_data.bin should be on your computer
-- this file is obtained by a log_anal.vhd component and others components loaded into a FPGA (virtex)
-- this file is obtained by a log_anal.vhd component and others components loaded into a FPGA (virtex)
-- and a proper WISHBONE reads
-- and a proper WISHBONE reads
-- readblock  la_data.bin adr_start adr_stop
-- readblock  la_data.bin adr_start adr_stop
-- where adr_start= LA_base_address, adr_stop= LA_base_address + 2^(adr_width-1) + (15)dec
-- where adr_start= LA_base_address, adr_stop= LA_base_address + 2^(adr_width-1) + (15)dec
-- the last 16 bytes of la_data.bin contains control registers
-- the last 16 bytes of la_data.bin contains control registers
 
 
-- adjust data_width and  mem_adr_width !!!! to be the same as in the log_anal entity !!!
-- adjust data_width and  mem_adr_width !!!! to be the same as in the log_anal entity !!!
-- also define your own signals (the same which where connected to log_anal data input
-- also define your own signals (the same which where connected to log_anal data input
-- and then assign these signals to proper d(index) data
-- and then assign these signals to proper d(index) data
 
 
library IEEE;
library IEEE;
use IEEE.std_logic_1164.all;
use IEEE.std_logic_1164.all;
library IEEE;
library IEEE;
use IEEE.std_logic_arith.all;
use IEEE.std_logic_arith.all;
 
 
entity la_view is
entity la_view is
end;
end;
 
 
architecture la_view_arch of la_view is
architecture la_view_arch of la_view is
  -- constants - should be the same as generics in the log_anal entity !!!
  -- constants - should be the same as generics in the log_anal entity !!!
  constant data_width: integer:= 16; -- width of the data that are analysed (must be power of 2)
  constant data_width: integer:= 16; -- width of the data that are analysed (must be power of 2)
  constant mem_adr_width: integer:= 9; -- internal memory address width  
  constant mem_adr_width: integer:= 9; -- internal memory address width  
  -- update the follows values if you want to watch triger
  -- update the follows values if you want to watch triger
  constant trig_width: integer:= 8; -- updatate or no (the circuit can work properly with value 32 also
  constant trig_width: integer:= 8; -- updatate or no (the circuit can work properly with value 32 also
  constant trigger_same_as_data: boolean:= true; -- if the input to the entity log_anal 
  constant trigger_same_as_data: boolean:= true; -- if the input to the entity log_anal 
          -- data is the same as trig, i.e. trig(trig_width-1 downto 0)= data(trig_width-1 downto 0) 
          -- data is the same as trig, i.e. trig(trig_width-1 downto 0)= data(trig_width-1 downto 0) 
 
 
------------------------------------ internal LA logic do not change 
------------------------------------ internal LA logic do not change 
  constant mem_size: integer:= 2 ** mem_adr_width;
  constant mem_size: integer:= 2 ** mem_adr_width;
  constant file_name: string := "la_data.bin"; -- file name which contains acquired data
  constant file_name: string := "la_data.bin"; -- file name which contains acquired data
  constant file_length: integer:= 2**(mem_adr_width)*data_width/32;
  constant file_length: integer:= 2**(mem_adr_width)*data_width/32;
                -- number of dwords (32-bits) in the file (excluding control registers)
                -- number of dwords (32-bits) in the file (excluding control registers)
  type la_mem_type is array (mem_size-1 downto 0) of std_logic_vector (data_width-1 downto 0);
  type la_mem_type is array (mem_size-1 downto 0) of std_logic_vector (data_width-1 downto 0);
 
 
 
 
procedure ReadControlReg(variable stop_count: out integer;
procedure ReadControlReg(variable stop_count: out integer;
  signal trigger_value: out std_logic_vector(trig_width-1 downto 0) ) is -- read stop counter value form la_data.bin file
  signal trigger_value: out std_logic_vector(trig_width-1 downto 0) ) is -- read stop counter value form la_data.bin file
 
 
  variable DataIn: integer;
  variable DataIn: integer;
  variable trig_care: std_logic_vector(trig_width-1 downto 0);
  variable trig_care: std_logic_vector(trig_width-1 downto 0);
  type BIT_VECTOR_FILE is file of integer;
  type BIT_VECTOR_FILE is file of integer;
  file Data_In_File : BIT_VECTOR_FILE;
  file Data_In_File : BIT_VECTOR_FILE;
begin
begin
        FILE_OPEN (Data_In_File, file_name, READ_MODE);
        FILE_OPEN (Data_In_File, file_name, READ_MODE);
        for i in 0 to file_length loop
        for i in 0 to file_length loop
           READ (Data_In_File, DataIn );
           READ (Data_In_File, DataIn );
        end loop;
        end loop;
        -- Data_In contains status register (MSBs should be filled with zero
        -- Data_In contains status register (MSBs should be filled with zero
        assert DataIn<256
        assert DataIn<256
          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"
          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"
          severity failure;
          severity failure;
        assert DataIn<128
        assert DataIn<128
          report "Warning. The log_anal was still in run mode when acquired data were read"
          report "Warning. The log_anal was still in run mode when acquired data were read"
          severity warning;
          severity warning;
        assert DataIn>=64
        assert DataIn>=64
          report "Warning. The log_anal has not finished data acquisition or file format error, check generic values seting and WISHBONE read size"
          report "Warning. The log_anal has not finished data acquisition or file format error, check generic values seting and WISHBONE read size"
          severity warning;
          severity warning;
 
 
        READ (Data_In_File, DataIn ); --  stop counter
        READ (Data_In_File, DataIn ); --  stop counter
        assert DataIn< 2**mem_adr_width
        assert DataIn< 2**mem_adr_width
          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"
          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"
                  severity failure;
                  severity failure;
        stop_count:= DataIn;
        stop_count:= DataIn;
 
 
        READ (Data_In_File, DataIn ); -- trig_value
        READ (Data_In_File, DataIn ); -- trig_value
        trigger_value<= conv_std_logic_vector(DataIn, trig_width);
        trigger_value<= conv_std_logic_vector(DataIn, trig_width);
        READ (Data_In_File, DataIn ); -- trig_care
        READ (Data_In_File, DataIn ); -- trig_care
        trig_care:= conv_std_logic_vector(DataIn, trig_width);
        trig_care:= conv_std_logic_vector(DataIn, trig_width);
        for i in trig_width-1 downto 0 loop
        for i in trig_width-1 downto 0 loop
                if trig_care(i)='0' then
                if trig_care(i)='0' then
                        trigger_value(i)<= '-';
                        trigger_value(i)<= '-';
                end if;
                end if;
        end loop;
        end loop;
        FILE_CLOSE ( Data_In_File );
        FILE_CLOSE ( Data_In_File );
end ReadControlReg;
end ReadControlReg;
 
 
 
 
 
 
procedure ReadData(variable stop_count: in integer; signal mem : out la_mem_type ) is -- read recorded data from la_data.bin file
procedure ReadData(variable stop_count: in integer; signal mem : out la_mem_type ) is -- read recorded data from la_data.bin file
  variable DataIn : integer;
  variable DataIn : integer;
  variable Data32 : std_logic_vector(31 downto 0);
  variable Data32 : std_logic_vector(31 downto 0);
  variable address:integer;
  variable address:integer;
  type BIT_VECTOR_FILE is file of integer;
  type BIT_VECTOR_FILE is file of integer;
  file DataInFile : BIT_VECTOR_FILE;
  file DataInFile : BIT_VECTOR_FILE;
 
 
begin
begin
        address:= (mem_size - stop_count) rem mem_size; -- the start address (rem is for stop_count=0)
        address:= (mem_size - stop_count) rem mem_size; -- the start address (rem is for stop_count=0)
        FILE_OPEN (DataInFile, file_name, READ_MODE);
        FILE_OPEN (DataInFile, file_name, READ_MODE);
        for i in 1 to file_length loop -- for every data in the file
        for i in 1 to file_length loop -- for every data in the file
          READ(DataInFile, DataIn);
          READ(DataInFile, DataIn);
          Data32:= conv_std_logic_vector(DataIn, 32);
          Data32:= conv_std_logic_vector(DataIn, 32);
          for j in 0 to (32/data_width) -1 loop
          for j in 0 to (32/data_width) -1 loop
                  mem(address)<= Data32((j+1)*data_width-1 downto j*data_width);
                  mem(address)<= Data32((j+1)*data_width-1 downto j*data_width);
                  address:= address + 1;
                  address:= address + 1;
                  if address= mem_size then
                  if address= mem_size then
                          address:= 0;
                          address:= 0;
                  end if;
                  end if;
          end loop;
          end loop;
        end loop;
        end loop;
        FILE_CLOSE (DataInFile);
        FILE_CLOSE (DataInFile);
end;
end;
 
 
  signal la_mem : la_mem_type; -- data read form la_data.bin file
  signal la_mem : la_mem_type; -- data read form la_data.bin file
  signal d: std_logic_vector(data_width-1 downto 0); -- data  recorder by the LA
  signal d: std_logic_vector(data_width-1 downto 0); -- data  recorder by the LA
  signal trigger_value: std_logic_vector(trig_width-1 downto 0); -- the value specified by writes to the trigger value and care registers
  signal trigger_value: std_logic_vector(trig_width-1 downto 0); -- the value specified by writes to the trigger value and care registers
  signal trigger: std_logic; -- trigger condition is now satisfied
  signal trigger: std_logic; -- trigger condition is now satisfied
  signal clk: std_logic; -- data has been recoreded according to this clock activity
  signal clk: std_logic; -- data has been recoreded according to this clock activity
 
 
 -----------------------------------------------------------------------------------
 -----------------------------------------------------------------------------------
 -- User area (changes can be done here)
 -- User area (changes can be done here)
  -- define here your signal names
  -- define here your signal names
 
 
  signal counter: std_logic_vector(data_width-1 downto 0);
  signal counter: std_logic_vector(data_width-1 downto 0);
 
 
begin
begin
  -- write here which signal is assigned to which LA data bus (see log_anal instantiation)
  -- write here which signal is assigned to which LA data bus (see log_anal instantiation)
  -- signal 'd' is the same as data input in the log_anal entity
  -- signal 'd' is the same as data input in the log_anal entity
  counter<= d;
  counter<= d;
 
 
 
 
  -- clk generation
  -- clk generation
  process begin
  process begin
          wait for 10 ns; -- this value can be change freely
          wait for 10 ns; -- this value can be change freely
          clk<= '0';
          clk<= '0';
          wait for 10 ns;
          wait for 10 ns;
          clk<= '1';
          clk<= '1';
  end process;
  end process;
 
 
 
 
-------------------------------------------------------------------------------------------
-------------------------------------------------------------------------------------------
-- Internal LA logic do not change it !!!
-- Internal LA logic do not change it !!!
process
process
  variable Initialize : integer := 0;    -- initialisation flag
  variable Initialize : integer := 0;    -- initialisation flag
  variable stop_count : integer; -- the count points where the last data has been written to the LA memory
  variable stop_count : integer; -- the count points where the last data has been written to the LA memory
begin
begin
        if Initialize=0 then     -- run only one time at the beginning
        if Initialize=0 then     -- run only one time at the beginning
          ReadControlReg(stop_count, trigger_value);
          ReadControlReg(stop_count, trigger_value);
          ReadData(stop_count, la_mem); -- read data recorded by the LA
          ReadData(stop_count, la_mem); -- read data recorded by the LA
          Initialize := 1;
          Initialize := 1;
          wait for 1000 ms;
          wait for 1000 ms;
    end if;
    end if;
end process;
end process;
 
 
 
 
process(clk)
process(clk)
  variable i: integer:= 0;
  variable i: integer:= 0;
  variable trigger_tmp: std_logic;
  variable trigger_tmp: std_logic;
  variable d_tmp: std_logic_vector(data_width-1 downto 0);
  variable d_tmp: std_logic_vector(data_width-1 downto 0);
begin
begin
  if clk'event and clk='1' then
  if clk'event and clk='1' then
          d_tmp:= la_mem(i); -- data recorded in the LA
          d_tmp:= la_mem(i); -- data recorded in the LA
          d<= d_tmp;
          d<= d_tmp;
          -- trigger logic
          -- trigger logic
          if trigger_same_as_data=true  and trig_width <= data_width then
          if trigger_same_as_data=true  and trig_width <= data_width then
                trigger_tmp:= '1';
                trigger_tmp:= '1';
            for j in trig_width-1 downto 0 loop
            for j in trig_width-1 downto 0 loop
                  if trigger_value(j)/= '-' then -- check only if not don't care
                  if trigger_value(j)/= '-' then -- check only if not don't care
                          trigger_tmp:= trigger_tmp AND not (trigger_value(j) XOR d_tmp(j));
                          trigger_tmp:= trigger_tmp AND not (trigger_value(j) XOR d_tmp(j));
                  end if;
                  end if;
            end loop;
            end loop;
                trigger<= trigger_tmp;
                trigger<= trigger_tmp;
          else -- do not show trigger because trigger data are different from watched data
          else -- do not show trigger because trigger data are different from watched data
                trigger<= 'Z';
                trigger<= 'Z';
          end if;
          end if;
 
 
          i:= i +1;
          i:= i +1;
          if i= mem_size then
          if i= mem_size then
                  i:= mem_size-1;
                  i:= mem_size-1;
                  assert false
                  assert false
                report "O.K. All acquired data in the LA has already been shown"
                report "O.K. All acquired data in the LA has already been shown"
                severity failure;
                severity failure;
          end if;
          end if;
  end if;
  end if;
end process;
end process;
        assert data_width=32 or data_width=16 or data_width=8
        assert data_width=32 or data_width=16 or data_width=8
          report "Error in la_view: constant data_width must be 8, 16 or 32"
          report "Error in la_view: constant data_width must be 8, 16 or 32"
                severity failure;
                severity failure;
 
 
end la_view_arch;
end la_view_arch;
 
 
-- logic analyser (LA) for FPGAs
-- logic analyser (LA) for FPGAs
-- ver 1.0
-- ver 1.0
-- Author: Ernest Jamro
-- Author: Ernest Jamro
 
 
--//////////////////////////////////////////////////////////////////////
--//////////////////////////////////////////////////////////////////////
--//// Copyright (C) 2001 Authors and OPENCORES.ORG                 ////
--//// Copyright (C) 2001 Authors and OPENCORES.ORG                 ////
--////                                                              ////
--////                                                              ////
--//// This source file may be used and distributed without         ////
--//// This source file may be used and distributed without         ////
--/// restriction provided that this copyright statement is not    ////
--/// restriction provided that this copyright statement is not    ////
--//// removed from the file and that any derivative work contains  ////
--//// removed from the file and that any derivative work contains  ////
--//// the original copyright notice and the associated disclaimer. ////
--//// the original copyright notice and the associated disclaimer. ////
--////                                                              ////
--////                                                              ////
--//// This source file is free software; you can redistribute it   ////
--//// This source file is free software; you can redistribute it   ////
--//// and/or modify it under the terms of the GNU Lesser General   ////
--//// and/or modify it under the terms of the GNU Lesser General   ////
--//// Public License as published by the Free Software Foundation; ////
--//// Public License as published by the Free Software Foundation; ////
--//// either version 2.1 of the License, or (at your option) any   ////
--//// either version 2.1 of the License, or (at your option) any   ////
--//// later version.                                               ////
--//// later version.                                               ////
--////                                                              ////
--////                                                              ////
--//// This source is distributed in the hope that it will be       ////
--//// This source is distributed in the hope that it will be       ////
--//// useful, but WITHOUT ANY WARRANTY; without even the implied   ////
--//// useful, but WITHOUT ANY WARRANTY; without even the implied   ////
--//// warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR      ////
--//// warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR      ////
--//// PURPOSE. See the GNU Lesser General Public License for more  ////
--//// PURPOSE. See the GNU Lesser General Public License for more  ////
--//// details.                                                     ////
--//// details.                                                     ////
--////                                                              ////
--////                                                              ////
--//// You should have received a copy of the GNU Lesser General    ////
--//// You should have received a copy of the GNU Lesser General    ////
--//// Public License along with this source; if not, download it   ////
--//// Public License along with this source; if not, download it   ////
--//// from <http://www.opencores.org/lgpl.shtml>                   ////
--//// 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.