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

Subversion Repositories w11

[/] [w11/] [tags/] [w11a_V0.6/] [tools/] [src/] [librw11/] [Rw11.cpp] - Blame information for rev 36

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

Line No. Rev Author Line
1 19 wfjm
// $Id: Rw11.cpp 504 2013-04-13 15:37:24Z mueller $
2
//
3
// Copyright 2013- by Walter F.J. Mueller <W.F.J.Mueller@gsi.de>
4
//
5
// This program is free software; you may redistribute and/or modify it under
6
// the terms of the GNU General Public License as published by the Free
7
// Software Foundation, either version 2, or at your option any later version.
8
//
9
// This program is distributed in the hope that it will be useful, but
10
// WITHOUT ANY WARRANTY, without even the implied warranty of MERCHANTABILITY
11
// or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
12
// for complete details.
13
// 
14
// Revision History: 
15
// Date         Rev Version  Comment
16
// 2013-03-06   495   1.0    Initial version
17
// 2013-01-27   478   0.1    First draft
18
// ---------------------------------------------------------------------------
19
 
20
/*!
21
  \file
22
  \version $Id: Rw11.cpp 504 2013-04-13 15:37:24Z mueller $
23
  \brief   Implemenation of Rw11.
24
*/
25
 
26
#include "librtools/Rexception.hpp"
27
 
28
#include "librtools/RosFill.hpp"
29
#include "Rw11Cpu.hpp"
30
 
31
#include "Rw11.hpp"
32
 
33
using namespace std;
34
 
35
/*!
36
  \class Retro::Rw11
37
  \brief FIXME_docs
38
*/
39
 
40
// all method definitions in namespace Retro
41
namespace Retro {
42
 
43
//------------------------------------------+-----------------------------------
44
// constants definitions
45
 
46
const int      Rw11::kLam;
47
 
48
//------------------------------------------+-----------------------------------
49
//! Default constructor
50
 
51
Rw11::Rw11()
52
  : fspServ(),
53
    fNCpu(0),
54
    fStarted(false)
55
{}
56
 
57
//------------------------------------------+-----------------------------------
58
//! Destructor
59
 
60
Rw11::~Rw11()
61
{}
62
 
63
//------------------------------------------+-----------------------------------
64
//! FIXME_docs
65
 
66
void Rw11::SetServer(const boost::shared_ptr<RlinkServer>& spserv)
67
{
68
  fspServ = spserv;
69
  fspServ->AddAttnHandler(boost::bind(&Rw11::AttnHandler, this, _1),
70
                          uint16_t(1)<<kLam, (void*)this);
71
  return;
72
}
73
 
74
//------------------------------------------+-----------------------------------
75
//! FIXME_docs
76
 
77
void Rw11::AddCpu(const boost::shared_ptr<Rw11Cpu>& spcpu)
78
{
79
  if (fNCpu >= 4)
80
    throw Rexception("Rw11::AddCpu", "Bad state: already 4 cpus registered");
81
  if (fNCpu > 0 && fspCpu[0]->Type() != spcpu->Type())
82
    throw Rexception("Rw11::AddCpu", "Bad state: type mismatch, new is "
83
                     + spcpu->Type() + " first was " + fspCpu[0]->Type());
84
 
85
  fspCpu[fNCpu] = spcpu;
86
  fNCpu += 1;
87
  spcpu->Setup(this);
88
 
89
  return;
90
}
91
 
92
//------------------------------------------+-----------------------------------
93
//! FIXME_docs
94
 
95
Rw11Cpu& Rw11::Cpu(size_t ind) const
96
{
97
  return *fspCpu[ind];
98
}
99
 
100
//------------------------------------------+-----------------------------------
101
//! FIXME_docs
102
 
103
void Rw11::Start()
104
{
105
  if (fStarted)
106
    throw Rexception("Rw11::Start()","alread started");
107
 
108
  for (size_t i=0; i<fNCpu; i++) fspCpu[i]->Start();
109
 
110
  if (!Server().IsActive()) Server().Start();
111
 
112
  fStarted = true;
113
  return;
114
}
115
 
116
//------------------------------------------+-----------------------------------
117
//! FIXME_docs
118
 
119
void Rw11::Dump(std::ostream& os, int ind, const char* text) const
120
{
121
  RosFill bl(ind);
122
  os << bl << (text?text:"--") << "Rw11 @ " << this << endl;
123
 
124
  os << bl << "  fspServ:         " << fspServ.get() << endl;
125
  os << bl << "  fNCpu:           " << fNCpu << endl;
126
  os << bl << "  fspCpu[4]:       ";
127
  for (size_t i=0; i<4; i++) os << fspCpu[i].get() << " ";
128
  os << endl;
129
  os << bl << "  fStarted:        " << fStarted << endl;
130
  return;
131
}
132
 
133
//------------------------------------------+-----------------------------------
134
//! FIXME_docs
135
 
136
int Rw11::AttnHandler(const RlinkServer::AttnArgs& args)
137
{
138
  for (size_t i=0; i<fNCpu; i++) fspCpu[i]->W11AttnHandler();
139
  return 0;
140
}
141
 
142
} // end namespace Retro

powered by: WebSVN 2.1.0

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