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

Subversion Repositories w11

[/] [w11/] [tags/] [w11a_V0.7/] [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 28 wfjm
// $Id: Rw11.cpp 625 2014-12-30 16:17:45Z mueller $
2 19 wfjm
//
3 28 wfjm
// Copyright 2013-2014 by Walter F.J. Mueller <W.F.J.Mueller@gsi.de>
4 19 wfjm
//
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 28 wfjm
// 2014-12-30   625   1.1    adopt to Rlink V4 attn logic
17 19 wfjm
// 2013-03-06   495   1.0    Initial version
18
// 2013-01-27   478   0.1    First draft
19
// ---------------------------------------------------------------------------
20
 
21
/*!
22
  \file
23 28 wfjm
  \version $Id: Rw11.cpp 625 2014-12-30 16:17:45Z mueller $
24 19 wfjm
  \brief   Implemenation of Rw11.
25
*/
26
 
27
#include "librtools/Rexception.hpp"
28
 
29
#include "librtools/RosFill.hpp"
30
#include "Rw11Cpu.hpp"
31
 
32
#include "Rw11.hpp"
33
 
34
using namespace std;
35
 
36
/*!
37
  \class Retro::Rw11
38
  \brief FIXME_docs
39
*/
40
 
41
// all method definitions in namespace Retro
42
namespace Retro {
43
 
44
//------------------------------------------+-----------------------------------
45
// constants definitions
46
 
47
const int      Rw11::kLam;
48
 
49
//------------------------------------------+-----------------------------------
50
//! Default constructor
51
 
52
Rw11::Rw11()
53
  : fspServ(),
54
    fNCpu(0),
55
    fStarted(false)
56
{}
57
 
58
//------------------------------------------+-----------------------------------
59
//! Destructor
60
 
61
Rw11::~Rw11()
62
{}
63
 
64
//------------------------------------------+-----------------------------------
65
//! FIXME_docs
66
 
67
void Rw11::SetServer(const boost::shared_ptr<RlinkServer>& spserv)
68
{
69
  fspServ = spserv;
70
  fspServ->AddAttnHandler(boost::bind(&Rw11::AttnHandler, this, _1),
71
                          uint16_t(1)<<kLam, (void*)this);
72
  return;
73
}
74
 
75
//------------------------------------------+-----------------------------------
76
//! FIXME_docs
77
 
78
void Rw11::AddCpu(const boost::shared_ptr<Rw11Cpu>& spcpu)
79
{
80
  if (fNCpu >= 4)
81
    throw Rexception("Rw11::AddCpu", "Bad state: already 4 cpus registered");
82
  if (fNCpu > 0 && fspCpu[0]->Type() != spcpu->Type())
83
    throw Rexception("Rw11::AddCpu", "Bad state: type mismatch, new is "
84
                     + spcpu->Type() + " first was " + fspCpu[0]->Type());
85
 
86
  fspCpu[fNCpu] = spcpu;
87
  fNCpu += 1;
88
  spcpu->Setup(this);
89
 
90
  return;
91
}
92
 
93
//------------------------------------------+-----------------------------------
94
//! FIXME_docs
95
 
96
Rw11Cpu& Rw11::Cpu(size_t ind) const
97
{
98
  return *fspCpu[ind];
99
}
100
 
101
//------------------------------------------+-----------------------------------
102
//! FIXME_docs
103
 
104
void Rw11::Start()
105
{
106
  if (fStarted)
107
    throw Rexception("Rw11::Start()","alread started");
108
 
109
  for (size_t i=0; i<fNCpu; i++) fspCpu[i]->Start();
110
 
111
  if (!Server().IsActive()) Server().Start();
112
 
113
  fStarted = true;
114
  return;
115
}
116
 
117
//------------------------------------------+-----------------------------------
118
//! FIXME_docs
119
 
120
void Rw11::Dump(std::ostream& os, int ind, const char* text) const
121
{
122
  RosFill bl(ind);
123
  os << bl << (text?text:"--") << "Rw11 @ " << this << endl;
124
 
125
  os << bl << "  fspServ:         " << fspServ.get() << endl;
126
  os << bl << "  fNCpu:           " << fNCpu << endl;
127
  os << bl << "  fspCpu[4]:       ";
128
  for (size_t i=0; i<4; i++) os << fspCpu[i].get() << " ";
129
  os << endl;
130
  os << bl << "  fStarted:        " << fStarted << endl;
131
  return;
132
}
133
 
134
//------------------------------------------+-----------------------------------
135
//! FIXME_docs
136
 
137 28 wfjm
int Rw11::AttnHandler(RlinkServer::AttnArgs& args)
138 19 wfjm
{
139 28 wfjm
  Server().GetAttnInfo(args);
140
 
141 19 wfjm
  for (size_t i=0; i<fNCpu; i++) fspCpu[i]->W11AttnHandler();
142
  return 0;
143
}
144
 
145
} // end namespace Retro

powered by: WebSVN 2.1.0

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