Initial commit of OpenSPARC T2 architecture model.
[OpenSPARC-T2-SAM] / sam-t2 / sam / cpus / vonk / ss / api / pli / src / SS_PliSocket.h
CommitLineData
920dae64
AT
1/*
2* ========== Copyright Header Begin ==========================================
3*
4* OpenSPARC T2 Processor File: SS_PliSocket.h
5* Copyright (c) 2006 Sun Microsystems, Inc. All Rights Reserved.
6* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES.
7*
8* The above named program is free software; you can redistribute it and/or
9* modify it under the terms of the GNU General Public
10* License version 2 as published by the Free Software Foundation.
11*
12* The above named program is distributed in the hope that it will be
13* useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
14* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15* General Public License for more details.
16*
17* You should have received a copy of the GNU General Public
18* License along with this work; if not, write to the Free Software
19* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
20*
21* ========== Copyright Header End ============================================
22*/
23
24#ifndef __SS_PliSocket_h__
25#define __SS_PliSocket_h__
26
27#include <string>
28#include <stdio.h>
29#include <zlib.h>
30#include "SS_Types.h"
31
32class SS_PliSocket
33{
34 public:
35 SS_PliSocket();
36
37 void debug( uint_t _debug_level, uint_t _reg_comp=1 )
38 {
39 debug_level = _debug_level;
40 reg_comp = _reg_comp;
41 }
42 uint_t debug() { return debug_level; }
43
44 int open_cosim( int socket_no );
45 int open_record( const std::string& record_fn );
46 int open_replay( const std::string& replay_fn );
47
48 int read( uint_t length );
49 int write( const char* s );
50 // functione to report error to RTL testbench
51 int write_err(char* format, va_list args);
52 int write_err( const char* s );
53 int flush();
54 int close();
55
56 uint8_t get8( uint_t ofs );
57 uint16_t get16( uint_t ofs );
58 uint32_t get32( uint_t ofs );
59 uint64_t get40( uint_t ofs );
60 uint64_t get48( uint_t ofs );
61 uint64_t get64( uint_t ofs );
62
63 void pli_stop()
64 {
65 if (pliok)
66 {
67 fprintf(stderr,"ERROR: encounter problem with pli-socket command\n");
68 pliok = false;
69 }
70 }
71 bool pli_ok() { return pliok; }
72
73 protected:
74 bool replay; // True when we are replaying a recorded pli command file
75 uint8_t buffer[256];
76 uint_t debug_level;
77 // reg_comp: 0 - do not compare register delta
78 // 1 - compare register delta, exit if miscompare
79 // others - compare register delta, do not exit even if miscompare
80 uint_t reg_comp;
81 FILE* write_file; // File associated with the socket output (or stdout in replay)
82
83 // For whom it concers. For reasons not fully clear to us, we can't use gzdopen when
84 // we launch an xterm to have the python prompt or better the python in dbx prompt.
85 // This is a python bug in our humble opinion as we also have to do setpgrp in the sims
86 // environment to get python up and above. To fix the issue for now we have two read
87 // file pointers, one FILE* for socket input, one gzFile* for replay input.
88
89 FILE* read_file; // File associated with the socket input
90 gzFile read_file_gz; // File associated with ref.inp.gz in replay mode
91
92 gzFile record_input; // File for recording socket input: commands: dut.inp.gz
93 gzFile record_output; // File for recording socket output: state deltas: dut.out.gz
94 gzFile check_file; // File for checking ouput during replay: ref.out.gz
95 bool pliok; // if 'false', skip all pli commands except 'step'
96};
97
98#endif
99
100
101
102
103
104
105
106