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

Subversion Repositories zpu

[/] [zpu/] [trunk/] [zpu/] [zpu4/] [src/] [trace.vhd] - Blame information for rev 93

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 93 oharboe
-- ZPU
2
--
3
-- Copyright 2004-2008 oharboe - Øyvind Harboe - oyvind.harboe@zylin.com
4
-- 
5
-- The FreeBSD license
6
-- 
7
-- Redistribution and use in source and binary forms, with or without
8
-- modification, are permitted provided that the following conditions
9
-- are met:
10
-- 
11
-- 1. Redistributions of source code must retain the above copyright
12
--    notice, this list of conditions and the following disclaimer.
13
-- 2. Redistributions in binary form must reproduce the above
14
--    copyright notice, this list of conditions and the following
15
--    disclaimer in the documentation and/or other materials
16
--    provided with the distribution.
17
-- 
18
-- THIS SOFTWARE IS PROVIDED BY THE ZPU PROJECT ``AS IS'' AND ANY
19
-- EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
20
-- THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
21
-- PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
22
-- ZPU PROJECT OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
23
-- INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
24
-- (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
25
-- OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
26
-- HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
27
-- STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28
-- ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
29
-- ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30
-- 
31
-- The views and conclusions contained in the software and documentation
32
-- are those of the authors and should not be interpreted as representing
33
-- official policies, either expressed or implied, of the ZPU Project.
34
 
35
library ieee;
36
use ieee.std_logic_1164.all;
37
use ieee.numeric_std.all;
38
 
39
use std.textio.all;
40
 
41
library work;
42
use work.zpu_config.all;
43
use work.zpupkg.all;
44
use work.txt_util.all;
45
 
46
 
47
entity trace is
48
  generic (
49
           log_file:       string  := "trace.txt"
50
          );
51
  port(
52
        clk         : in std_logic;
53
        begin_inst  : in std_logic;
54
        pc          : in std_logic_vector(maxAddrBitIncIO downto 0);
55
                opcode          : in std_logic_vector(7 downto 0);
56
                sp                      : in std_logic_vector(maxAddrBitIncIO downto 2);
57
                memA            : in std_logic_vector(wordSize-1 downto 0);
58
                memB            : in std_logic_vector(wordSize-1 downto 0);
59
                busy  : in std_logic;
60
                intSp           : in std_logic_vector(stack_bits-1 downto 0)
61
                );
62
end trace;
63
 
64
 
65
architecture behave of trace is
66
 
67
 
68
file            l_file          : TEXT open write_mode is log_file;
69
 
70
 
71
begin
72
 
73
 
74
-- write data and control information to a file
75
 
76
receive_data: process
77
 
78
variable l: line;
79
variable t      : std_logic_vector(wordSize-1 downto 0);
80
variable t2     : std_logic_vector(maxAddrBitIncIO downto 0);
81
variable counter : unsigned(63 downto 0);
82
 
83
 
84
 
85
begin
86
 
87
        t:= (others => '0');
88
        t2:= (others => '0');
89
 
90
counter := (others => '0');
91
   -- print header for the logfile
92
   print(l_file, "#pc,opcode,sp,top_of_stack ");
93
   print(l_file, "#----------");
94
   print(l_file, " ");
95
 
96
        wait until clk = '1';
97
        wait until clk = '0';
98
 
99
   while true loop
100
 
101
                counter := counter + 1;
102
                if begin_inst = '1' then
103
                        t(maxAddrBitIncIO downto 2):=sp;
104
                        t2:=pc;
105
                print(l_file, "0x" & hstr(t2) & " 0x" & hstr(opcode) & " 0x" & hstr(t) & " 0x" & hstr(memA) & " 0x" & hstr(memB) & " 0x" & hstr(intSp) & " 0x" & hstr(std_logic_vector(counter)));
106
                end if;
107
 
108
        wait until clk = '0';
109
 
110
   end loop;
111
 
112
 end process receive_data;
113
 
114
 
115
 
116
end behave;
117
 

powered by: WebSVN 2.1.0

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