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

Subversion Repositories openrisc

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

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 462 julius
class Or1200MonitorSC:public sc_core::sc_module {
48 6 julius
public:
49
 
50 462 julius
        // Constructor
51
        Or1200MonitorSC(sc_core::sc_module_name name,
52
                        OrpsocAccess * _accessor,
53
                        MemoryLoad * _memoryload, int argc, char *argv[]);
54 6 julius
 
55 462 julius
        // Method to check instructions
56
        void checkInstruction();
57 6 julius
 
58 462 julius
        // Methods to setup and output state of processor to a file
59
        void displayState();
60
        void displayStateBinary();
61 44 julius
 
62 462 julius
        // Methods to generate trace to stdout
63
        void printTrace();
64 51 julius
 
65 462 julius
        // Methods to generate the call and return list during execution
66
        void callLog();
67 49 julius
 
68 462 julius
        // Method to calculate performance of the sim
69
        void perfSummary();
70 49 julius
 
71 462 julius
        // Method to print out the command-line switches for this module's options  
72
        void printSwitches();
73 49 julius
 
74 462 julius
        // Method to print out the usage for each option
75
        void printUsage();
76 52 julius
 
77 462 julius
        // Method to dump simulation's RAM contents at finish
78
        void memdump();
79 63 julius
 
80 462 julius
        // Method used for monitoring and logging transactions on the system bus
81
        //void busMonitor();
82 66 julius
 
83 462 julius
        // Method to do simulator assisted printf'ing
84
        void simPrintf(uint32_t stackaddr, uint32_t regparam);
85 6 julius
 
86 462 julius
        // The ports
87
        sc_in < bool > clk;
88
 
89 6 julius
private:
90
 
91 63 julius
#define DEFAULT_EXEC_LOG_FILE "or1200_exec.log"
92 51 julius
#define DEFAULT_PROF_FILE "sim.profile"
93 52 julius
#define DEFAULT_MEMDUMP_FILE "vorpsoc_ram.dump"
94 63 julius
#define DEFAULT_BUS_LOG_FILE "bus_trans.log"
95 51 julius
 
96 462 julius
        // Special NOP instructions
97
        static const uint32_t NOP_NOP = 0;       //!< Normal nop instruction
98
        static const uint32_t NOP_EXIT = 1;     //!< End of simulation
99
        static const uint32_t NOP_REPORT = 2;   //!< Simple report
100
        static const uint32_t NOP_PRINTF = 3;   //!< Simprintf instruction
101
        static const uint32_t NOP_PUTC = 4;     //!< Putc instruction
102
        static const uint32_t NOP_CNT_RESET = 5;        //!< Reset statistics counters
103
        static const uint32_t NOP_GET_TICKS = 6;        //!< Get # ticks running
104
        static const uint32_t NOP_GET_PS = 7;   //!< Get picosecs/cycle
105 6 julius
 
106 462 julius
        static const uint32_t NOP_CNT_RESET1 = 16;      /* Reset statistics counter 1 */
107
        static const uint32_t NOP_CNT_RESET2 = 17;      /* Reset statistics counter 2 */
108
        static const uint32_t NOP_CNT_RESET3 = 18;      /* Reset statistics counter 3 */
109
        static const uint32_t NOP_MEM_STATS_RESET = 32; //!< Reset memory statistics counters
110
        static const uint32_t NOP_CNT_RESET_DIFFERENCE = 48;    //!< Reset stats counters, print 
111
 
112
        // Variables for processor status output
113
        ofstream statusFile;
114
        ofstream profileFile;
115
        bool profiling_enabled;
116
        bool trace_enabled;
117
        bool logging_enabled;
118
        bool logfile_name_provided;
119
        bool logging_regs;
120
        bool binary_log_format;
121
        bool perf_summary;
122
        bool monitor_for_crash;
123
        int lookslikewevecrashed_count, crash_monitor_buffer_head;
124 63 julius
#define CRASH_MONITOR_BUFFER_SIZE 32
125 462 julius
        uint32_t crash_monitor_buffer[CRASH_MONITOR_BUFFER_SIZE][2];    //PC, Insn
126
        bool wait_for_stall_cmd_response;
127
        unsigned long long insn_count, insn_count_rst;
128
        unsigned long long cycle_count, cycle_count_rst;
129
        unsigned long long cycles_1, cycles_2, cycles_3;        // Cycle counters for l.nop insns
130
        ofstream memdumpFile;
131
        string memdumpFileName;
132
        bool do_memdump;
133
        int memdump_start_addr, memdump_end_addr;
134
        bool bus_trans_log_enabled, bus_trans_log_name_provided,
135
            bus_trans_log_start_delay_enable;
136
        sc_time bus_trans_log_start_delay;
137
        enum busLogStates { BUS_LOG_IDLE, BUS_LOG_WAIT_FOR_ACK };
138
        ofstream busTransLog;
139 63 julius
 
140 462 julius
        //! Time measurement variable - for calculating performance of the sim
141
        clock_t start;
142 44 julius
 
143 462 julius
        //! The accessor for the Orpsoc instance
144
        OrpsocAccess *accessor;
145 6 julius
 
146 462 julius
        //! The memory loading object
147
        MemoryLoad *memoryload;
148 51 julius
 
149 462 julius
};                              // Or1200MonitorSC ()
150 6 julius
 
151 462 julius
#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.