OpenCores
URL https://opencores.org/ocsvn/openrisc_2011-10-31/openrisc_2011-10-31/trunk

Subversion Repositories openrisc_2011-10-31

[/] [openrisc/] [trunk/] [orpsocv2/] [bench/] [sysc/] [include/] [Or1200MonitorSC.h] - Blame information for rev 167

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

Line No. Rev Author Line
1 6 julius
// ----------------------------------------------------------------------------
2
 
3
// SystemC OpenRISC 1200 Monitor: definition
4
 
5
// Copyright (C) 2008  Embecosm Limited <info@embecosm.com>
6
 
7
// Contributor Jeremy Bennett <jeremy.bennett@embecosm.com>
8 44 julius
// Contributor Julius Baxter <jb@orsoc.se>
9 6 julius
 
10
// This file is part of the cycle accurate model of the OpenRISC 1000 based
11
// system-on-chip, ORPSoC, built using Verilator.
12
 
13
// This program is free software: you can redistribute it and/or modify it
14
// under the terms of the GNU Lesser General Public License as published by
15
// the Free Software Foundation, either version 3 of the License, or (at your
16
// option) any later version.
17
 
18
// This program is distributed in the hope that it will be useful, but WITHOUT
19
// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
20
// FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public
21
// License for more details.
22
 
23
// You should have received a copy of the GNU Lesser General Public License
24
// along with this program.  If not, see <http://www.gnu.org/licenses/>.
25
 
26
// ----------------------------------------------------------------------------
27
 
28 51 julius
// $Id$
29 6 julius
 
30
#ifndef OR1200_MONITOR_SC__H
31
#define OR1200_MONITOR_SC__H
32
 
33 44 julius
#include <fstream>
34
#include <ctime>
35
 
36 6 julius
#include "systemc.h"
37
 
38
#include "OrpsocAccess.h"
39 51 julius
#include "MemoryLoad.h"
40 6 julius
 
41
//! Monitor for special l.nop instructions
42
 
43
//! This class is based on the or1200_monitor.v of the Verilog test bench. It
44
//! wakes up on each posedge clock to check for "special" l.nop instructions,
45
//! which need processing.
46
 
47
class Or1200MonitorSC
48
  : public sc_core::sc_module
49
{
50
public:
51
 
52
  // Constructor
53
  Or1200MonitorSC (sc_core::sc_module_name  name,
54 49 julius
                   OrpsocAccess            *_accessor,
55 51 julius
                   MemoryLoad              *_memoryload,
56 49 julius
                   int argc,
57
                   char *argv[]);
58 6 julius
 
59
  // Method to check instructions
60
  void  checkInstruction();
61
 
62 44 julius
  // Methods to setup and output state of processor to a file
63
  void displayState();
64 63 julius
  void displayStateBinary();
65 44 julius
 
66 51 julius
  // Methods to generate the call and return list during execution
67
  void callLog();
68
 
69
  // Method to calculate performance of the sim
70 49 julius
  void perfSummary();
71
 
72 51 julius
  // Method to print out the command-line switches for this module's options  
73 49 julius
  void printSwitches();
74
 
75 51 julius
  // Method to print out the usage for each option
76 49 julius
  void printUsage();
77 52 julius
 
78
  // Method to dump simulation's RAM contents at finish
79
  void memdump();
80 49 julius
 
81 63 julius
  // Method used for monitoring and logging transactions on the system bus
82
  void busMonitor();
83 66 julius
 
84
  // Method to do simulator assisted printf'ing
85
  void simPrintf(uint32_t stackaddr, uint32_t regparam);
86 52 julius
 
87 63 julius
 
88 66 julius
 
89 6 julius
  // The ports
90
  sc_in<bool>   clk;
91
 
92
private:
93
 
94 63 julius
#define DEFAULT_EXEC_LOG_FILE "or1200_exec.log"
95 51 julius
#define DEFAULT_PROF_FILE "sim.profile"
96 52 julius
#define DEFAULT_MEMDUMP_FILE "vorpsoc_ram.dump"
97 63 julius
#define DEFAULT_BUS_LOG_FILE "bus_trans.log"
98 51 julius
 
99 6 julius
  // Special NOP instructions
100
  static const uint32_t NOP_NOP    = 0x15000000;  //!< Normal nop instruction
101
  static const uint32_t NOP_EXIT   = 0x15000001;  //!< End of simulation
102
  static const uint32_t NOP_REPORT = 0x15000002;  //!< Simple report
103
  static const uint32_t NOP_PRINTF = 0x15000003;  //!< Simprintf instruction
104
  static const uint32_t NOP_PUTC   = 0x15000004;  //!< Putc instruction
105 63 julius
  static const uint32_t NOP_CNT_RESET = 0x15000005; //!< Reset statistics counters
106 64 julius
  static const uint32_t NOP_CNT_RESET1 = 0x15000007;        /* Reset statistics counter 1 */
107
  static const uint32_t NOP_CNT_RESET2 = 0x15000008;        /* Reset statistics counter 2 */
108
  static const uint32_t NOP_CNT_RESET3 = 0x15000009;        /* Reset statistics counter 3 */
109 63 julius
  static const uint32_t NOP_MEM_STATS_RESET  = 0x15000010; //!< Reset memory statistics counters
110
  static const uint32_t NOP_CNT_RESET_DIFFERENCE = 0x15000006; //!< Reset stats counters, print 
111 6 julius
 
112 44 julius
  // Variables for processor status output
113
  ofstream statusFile;
114 51 julius
  ofstream profileFile;
115 63 julius
  bool profiling_enabled;
116
  bool logging_enabled;
117
  bool logfile_name_provided;
118
  bool logging_regs;
119
  bool binary_log_format;
120
  bool exit_perf_summary_enabled;
121
  bool monitor_for_crash;
122
  int lookslikewevecrashed_count, crash_monitor_buffer_head;
123
#define CRASH_MONITOR_BUFFER_SIZE 32
124
  uint32_t crash_monitor_buffer[CRASH_MONITOR_BUFFER_SIZE][2]; //PC, Insn
125
  bool wait_for_stall_cmd_response;
126
  unsigned long long insn_count, insn_count_rst;
127
  unsigned long long cycle_count, cycle_count_rst;
128 64 julius
  unsigned long long cycles_1, cycles_2, cycles_3; // Cycle counters for l.nop insns
129 52 julius
  ofstream memdumpFile;
130
  string memdumpFileName;
131 63 julius
  bool do_memdump;
132
  int memdump_start_addr, memdump_end_addr;
133
  bool bus_trans_log_enabled, bus_trans_log_name_provided, bus_trans_log_start_delay_enable;
134
  sc_time bus_trans_log_start_delay;
135
  enum busLogStates { BUS_LOG_IDLE, BUS_LOG_WAIT_FOR_ACK };
136
  ofstream busTransLog;
137
 
138 51 julius
  //! Time measurement variable - for calculating performance of the sim
139 44 julius
  clock_t start;
140
 
141 6 julius
  //! The accessor for the Orpsoc instance
142
  OrpsocAccess *accessor;
143
 
144 51 julius
  //! The memory loading object
145 63 julius
  MemoryLoad *memoryload;
146 51 julius
 
147 6 julius
};      // Or1200MonitorSC ()
148
 
149
#endif  // OR1200_MONITOR_SC__H

powered by: WebSVN 2.1.0

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