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

Subversion Repositories w11

[/] [w11/] [tags/] [w11a_V0.6/] [tools/] [src/] [librw11/] [Rw11Cpu.hpp] - Blame information for rev 19

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

Line No. Rev Author Line
1 19 wfjm
// $Id: Rw11Cpu.hpp 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-04-12   504   1.0    Initial version
17
// 2013-01-27   478   0.1    First draft
18
// ---------------------------------------------------------------------------
19
 
20
 
21
/*!
22
  \file
23
  \version $Id: Rw11Cpu.hpp 504 2013-04-13 15:37:24Z mueller $
24
  \brief   Declaration of class Rw11Cpu.
25
*/
26
 
27
#ifndef included_Retro_Rw11Cpu
28
#define included_Retro_Rw11Cpu 1
29
 
30
#include <string>
31
#include <vector>
32
 
33
#include "boost/utility.hpp"
34
#include "boost/shared_ptr.hpp"
35
#include "boost/thread/locks.hpp"
36
#include "boost/thread/condition_variable.hpp"
37
 
38
#include "librtools/Rstats.hpp"
39
#include "librtools/RerrMsg.hpp"
40
#include "librlink/RlinkConnect.hpp"
41
 
42
#include "Rw11Probe.hpp"
43
 
44
#include "librtools/Rbits.hpp"
45
#include "Rw11.hpp"
46
 
47
namespace Retro {
48
 
49
  class Rw11Cntl;                           // forw decl to avoid circular incl
50
 
51
  class Rw11Cpu : public Rbits, private boost::noncopyable {
52
    public:
53
      typedef std::map<std::string, boost::shared_ptr<Rw11Cntl>> cmap_t;
54
      typedef cmap_t::iterator         cmap_it_t;
55
      typedef cmap_t::const_iterator   cmap_cit_t;
56
      typedef cmap_t::value_type       cmap_val_t;
57
 
58
      explicit      Rw11Cpu(const std::string& type);
59
      virtual      ~Rw11Cpu();
60
 
61
      void          Setup(Rw11* pw11);
62
      Rw11&         W11() const;
63
      RlinkServer&  Server() const;
64
      RlinkConnect& Connect() const;
65
      RlogFile&     LogFile() const;
66
 
67
      const std::string&   Type() const;
68
      size_t        Index() const;
69
      uint16_t      Base() const;
70
 
71
      void          AddCntl(const boost::shared_ptr<Rw11Cntl>& spcntl);
72
      bool          TestCntl(const std::string& name) const;
73
      void          ListCntl(std::vector<std::string>& list) const;
74
      Rw11Cntl&     Cntl(const std::string& name) const;
75
 
76
      void          Start();
77
 
78
      std::string   NextCntlName(const std::string& base) const;
79
 
80
      int           AddIbrb(RlinkCommandList& clist, uint16_t ibaddr);
81
      int           AddRibr(RlinkCommandList& clist, uint16_t ibaddr);
82
      int           AddWibr(RlinkCommandList& clist, uint16_t ibaddr,
83
                            uint16_t data);
84
 
85
      bool          MemRead(uint16_t addr, std::vector<uint16_t>& data,
86
                            size_t nword, RerrMsg& emsg);
87
      bool          MemWrite(uint16_t addr, const std::vector<uint16_t>& data,
88
                             RerrMsg& emsg);
89
 
90
      bool          ProbeCntl(Rw11Probe& dsc);
91
 
92
      bool          LoadAbs(const std::string& fname, RerrMsg& emsg,
93
                            bool trace=false);
94
      bool          Boot(const std::string& uname, RerrMsg& emsg);
95
 
96
      void          SetCpuGoUp();
97
      void          SetCpuGoDown(uint16_t stat);
98
      double        WaitCpuGoDown(double tout);
99
      bool          CpuGo() const;
100
      uint16_t      CpuStat() const;
101
 
102
      void          W11AttnHandler();
103
 
104
      const Rstats& Stats() const;
105
      virtual void  Dump(std::ostream& os, int ind=0, const char* text=0) const;
106
 
107
    // some constants (also defined in cpp)
108
      static const uint16_t  kCp_addr_conf  = 0x0000; //!< 
109
      static const uint16_t  kCp_addr_cntl  = 0x0001; //!< 
110
      static const uint16_t  kCp_addr_stat  = 0x0002; //!< 
111
      static const uint16_t  kCp_addr_psw   = 0x0003; //!< 
112
      static const uint16_t  kCp_addr_al    = 0x0004; //!< 
113
      static const uint16_t  kCp_addr_ah    = 0x0005; //!< 
114
      static const uint16_t  kCp_addr_mem   = 0x0006; //!< 
115
      static const uint16_t  kCp_addr_memi  = 0x0007; //!< 
116
      static const uint16_t  kCp_addr_r0    = 0x0008; //!< 
117
      static const uint16_t  kCp_addr_pc    = 0x000f; //!< 
118
      static const uint16_t  kCp_addr_ibrb  = 0x0010; //!< 
119
      static const uint16_t  kCp_addr_ibr   = 0x0080; //!< 
120
 
121
      static const uint16_t  kCp_func_noop  = 0x0000; //!< 
122
      static const uint16_t  kCp_func_start = 0x0001; //!< 
123
      static const uint16_t  kCp_func_stop  = 0x0002; //!< 
124
      static const uint16_t  kCp_func_cont  = 0x0003; //!< 
125
      static const uint16_t  kCp_func_step  = 0x0004; //!< 
126
      static const uint16_t  kCp_func_reset = 0x000f; //!<
127
 
128
      static const uint16_t  kCp_stat_m_cpurust = 0x00f0;  //!<
129
      static const uint16_t  kCp_stat_v_cpurust = 4;       //!<
130
      static const uint16_t  kCp_stat_b_cpurust = 0x000f;  //!<
131
      static const uint16_t  kCp_stat_m_cpuhalt = kWBit03; //!<
132
      static const uint16_t  kCp_stat_m_cpugo   = kWBit02; //!<
133
      static const uint16_t  kCp_stat_m_cmdmerr = kWBit01; //!<
134
      static const uint16_t  kCp_stat_m_cmderr  = kWBit00; //!<
135
 
136
      static const uint16_t  kCp_cpurust_init   = 0x0;  //!< cpu in init state
137
      static const uint16_t  kCp_cpurust_halt   = 0x1;  //!< cpu executed HALT
138
      static const uint16_t  kCp_cpurust_reset  = 0x2;  //!< cpu was reset
139
      static const uint16_t  kCp_cpurust_stop   = 0x3;  //!< cpu was stopped
140
      static const uint16_t  kCp_cpurust_step   = 0x4;  //!< cpu was stepped
141
      static const uint16_t  kCp_cpurust_susp   = 0x5;  //!< cpu was suspended
142
      static const uint16_t  kCp_cpurust_runs   = 0x7;  //!< cpu running
143
      static const uint16_t  kCp_cpurust_vecfet = 0x8;  //!< vector fetch halt
144
      static const uint16_t  kCp_cpurust_recrsv = 0x9;  //!< rec red-stack halt
145
      static const uint16_t  kCp_cpurust_sfail  = 0xa;  //!< sequencer failure
146
      static const uint16_t  kCp_cpurust_vfail  = 0xb;  //!< vmbox failure
147
 
148
    private:
149
                    Rw11Cpu() {}            //!< default ctor blocker
150
 
151
    protected:
152
      Rw11*         fpW11;
153
      std::string   fType;
154
      size_t        fIndex;
155
      uint16_t      fBase;
156
      bool          fCpuGo;
157
      uint16_t      fCpuStat;
158
      boost::mutex               fCpuGoMutex;
159
      boost::condition_variable  fCpuGoCond;
160
      cmap_t        fCntlMap;               //!< name->cntl map
161
      Rstats        fStats;                 //!< statistics
162
  };
163
 
164
} // end namespace Retro
165
 
166
#include "Rw11Cpu.ipp"
167
 
168
#endif

powered by: WebSVN 2.1.0

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