Initial commit of OpenSPARC T2 architecture model.
[OpenSPARC-T2-SAM] / sam-t2 / sam / cpus / vonk / ss / api / pli / src / SS_PliSocket.h
/*
* ========== Copyright Header Begin ==========================================
*
* OpenSPARC T2 Processor File: SS_PliSocket.h
* Copyright (c) 2006 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES.
*
* The above named program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public
* License version 2 as published by the Free Software Foundation.
*
* The above named program is distributed in the hope that it will be
* useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public
* License along with this work; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
*
* ========== Copyright Header End ============================================
*/
#ifndef __SS_PliSocket_h__
#define __SS_PliSocket_h__
#include <string>
#include <stdio.h>
#include <zlib.h>
#include "SS_Types.h"
class SS_PliSocket
{
public:
SS_PliSocket();
void debug( uint_t _debug_level, uint_t _reg_comp=1 )
{
debug_level = _debug_level;
reg_comp = _reg_comp;
}
uint_t debug() { return debug_level; }
int open_cosim( int socket_no );
int open_record( const std::string& record_fn );
int open_replay( const std::string& replay_fn );
int read( uint_t length );
int write( const char* s );
// functione to report error to RTL testbench
int write_err(char* format, va_list args);
int write_err( const char* s );
int flush();
int close();
uint8_t get8( uint_t ofs );
uint16_t get16( uint_t ofs );
uint32_t get32( uint_t ofs );
uint64_t get40( uint_t ofs );
uint64_t get48( uint_t ofs );
uint64_t get64( uint_t ofs );
void pli_stop()
{
if (pliok)
{
fprintf(stderr,"ERROR: encounter problem with pli-socket command\n");
pliok = false;
}
}
bool pli_ok() { return pliok; }
protected:
bool replay; // True when we are replaying a recorded pli command file
uint8_t buffer[256];
uint_t debug_level;
// reg_comp: 0 - do not compare register delta
// 1 - compare register delta, exit if miscompare
// others - compare register delta, do not exit even if miscompare
uint_t reg_comp;
FILE* write_file; // File associated with the socket output (or stdout in replay)
// For whom it concers. For reasons not fully clear to us, we can't use gzdopen when
// we launch an xterm to have the python prompt or better the python in dbx prompt.
// This is a python bug in our humble opinion as we also have to do setpgrp in the sims
// environment to get python up and above. To fix the issue for now we have two read
// file pointers, one FILE* for socket input, one gzFile* for replay input.
FILE* read_file; // File associated with the socket input
gzFile read_file_gz; // File associated with ref.inp.gz in replay mode
gzFile record_input; // File for recording socket input: commands: dut.inp.gz
gzFile record_output; // File for recording socket output: state deltas: dut.out.gz
gzFile check_file; // File for checking ouput during replay: ref.out.gz
bool pliok; // if 'false', skip all pli commands except 'step'
};
#endif