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 40

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

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

powered by: WebSVN 2.1.0

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