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

Subversion Repositories ssbcc

[/] [ssbcc/] [trunk/] [core/] [9x8/] [peripherals/] [trace.py] - Blame information for rev 12

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 2 sinclairrf
################################################################################
2
#
3 12 sinclairrf
# Copyright 2012-2015, Sinclair R.F., Inc.
4 2 sinclairrf
#
5
################################################################################
6
 
7
import re
8
 
9
from ssbccPeripheral import SSBCCperipheral
10
from ssbccUtil import SSBCCException;
11
 
12
class trace(SSBCCperipheral):
13
  """
14
  Generate a human readable printout of the processor execution.  The program
15
  counter and opcode are delayed so that they are aligned with the results of
16
  the opcode.\n
17
  Usage:
18
    PERIPHERAL trace\n
19
  The following values are displayed in this order during the execution:
20
    program counter
21
    numeric opcode
22
    human-readable opcode
23
    ':'
24
    data stack pointer
25
    next-to-top of the data stack
26
    top of the data stack
27
    ':'
28
    top of the return stack
29
    return stack pointer\n
30
  Example:  See core/9x8/tb/core which is used to validate correct operation of
31
            the core.
32
  """
33
 
34
  def __init__(self,peripheralFile,config,params,loc):
35
    # Use the externally provided file name for the peripheral
36
    self.peripheralFile = peripheralFile;
37
    config.functions['display_trace'] = True;
38
 
39
  def GenVerilog(self,fp,config):
40
    body = """
41
//
42
// Trace peripheral
43
//
44
generate
45
reg [C_PC_WIDTH-1:0] s__PC_s[1:0];
46
reg            [8:0] s__opcode_s = 9'h000;
47
reg        [7*8-1:0] s__opcode_name;
48 12 sinclairrf
reg                  s__interrupt_s = 1'b0;
49
reg                  s__interrupted_s = 1'b0;
50 2 sinclairrf
initial begin
51
  s__PC_s[0] = {(C_PC_WIDTH){1'b0}};
52
  s__PC_s[1] = {(C_PC_WIDTH){1'b0}};
53
end
54
always @ (posedge i_clk) begin
55
  s__PC_s[0] <= s_PC;
56
  s__PC_s[1] <= s__PC_s[0];
57 12 sinclairrf
  s__interrupt_s <= s_interrupt;
58
  s__interrupted_s <= s_interrupted;
59 2 sinclairrf
  s__opcode_s <= s_opcode;
60 12 sinclairrf
  display_trace({ s__interrupt_s, s__interrupted_s, s__PC_s[1], s__opcode_s, s_Np_stack_ptr, 1'b1, s_N, 1'b1, s_T, 1'b1, s_R, s_R_stack_ptr });
61 2 sinclairrf
end
62
endgenerate
63
""";
64 12 sinclairrf
    if not config.InterruptVector():
65
      for replace in ('s_interrupt','s_interrupted',):
66
        body = re.sub(replace+';','1\'b0;',body);
67 2 sinclairrf
    body = re.sub(r'\bs__','s__trace__',body);
68
    fp.write(body);

powered by: WebSVN 2.1.0

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