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

Subversion Repositories scarm

[/] [scarm/] [trunk/] [src/] [scWB.cpp] - Blame information for rev 8

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 5 zhong
// scWB.cpp: implementation of the scWB class.
2
/*                            -------------------
3
    begin                : Oct 2 2002
4
    copyright            : (C) 2002 UESTC
5
    author               : Zhong Tao
6
    email                : zhong@opencores.org
7
 ***************************************************************************/
8
 
9
/***************************************************************************
10
 *                                                                         *
11
 *   This program is free software; you can redistribute it and/or modify  *
12
 *   it under the terms of the GNU General Public License as published by  *
13
 *   the Free Software Foundation; either version 2 of the License, or     *
14
 *   (at your option) any later version.                                   *
15
 *                                                                         *
16
 ***************************************************************************/
17
#include "scWB.h"
18
//#define DEBUG
19
//////////////////////////////////////////////////////////////////////
20
// Construction/Destruction
21
//////////////////////////////////////////////////////////////////////
22
 
23
scWB::scWB(sc_module_name name_):sc_module(name_)
24
{
25
        m_Rn=REGS(13);
26
        m_Rd=REGS(13);
27
        m_n_Rn=0;
28
        m_n_Rd=0;
29
        m_b_excute=false;
30
        m_b_write=false;
31
        m_b_wb=false;
32
    SC_METHOD(entry);
33
        sensitive_pos<<in_b_Clock;
34
        SC_METHOD(out_delay);
35
        SC_METHOD(delay1);
36
}
37
 
38
scWB::~scWB()
39
{
40
 
41
}
42
 
43
void scWB::entry()
44
{
45
 
46
        m_Rd=in_Rd;
47
        m_Rn=in_Rn;
48
        m_n_Rd=in_n_Result;
49
        m_n_Rn=in_n_Rn;
50
    m_b_excute=in_b_excute;
51
        m_b_write=in_b_W_Rd;
52
        m_b_wb=in_b_WB;
53
if(m_b_excute)
54
{
55
 
56
 
57
  if((m_Rd!=R_PC)&&m_b_write)
58
  {
59
 
60
    inout_n_Data1=m_n_Rd;
61
  }
62
 
63
     if(m_b_wb)//write back
64
  {
65
 
66
    inout_n_Data2=m_n_Rn;
67
  }
68
  //regs();
69
 
70
}//if excute
71
trigger_wb1.notify(SC_ZERO_TIME);
72
}
73
 
74
 
75
void scWB::regs()
76
{
77
                //read CPSR
78
      uint32_t R=0;
79
                //      out_b_RW=0;
80
                out_REG1=R_PC;
81
                R=inout_n_Data1;
82
          cout<<"       PC:"<<R;//0100
83
                //out_b_RW=0;
84
                out_REG1=R_CPSR;
85
                R=inout_n_Data1;
86
          cout<<" CPSR:";//0100
87
  // Bit masks for CPSR
88
    if((R&N_FLAG)==N_FLAG) cout<<"N";else cout<<"n";
89
    if((R&Z_FLAG)==Z_FLAG) cout<<"Z"; else cout<<"z";
90
    if((R&C_FLAG)==C_FLAG) cout<<"C"; else cout<<"c";
91
    if((R&V_FLAG)==V_FLAG) cout<<"V"; else cout<<"v";
92
        cout<<"  "<<endl;
93
        //cout<<"WB"<<endl;
94
 
95
         cout<<"        ";
96
                for(int i=0;i<15;i++)
97
                {
98
 
99
                     //out_b_RW1=0;
100
                     out_REG1=REGS(i);
101
                     R=inout_n_Data1;
102
                         cout<<"r"<<i<<"="<<R<<" ";
103
                         if((i==4)||(i==9)) cout<<endl<<"       ";
104
                }
105
                cout<<endl;
106
}
107
 
108
void scWB::out_delay()
109
{
110
  next_trigger(trigger_wb1);
111
  if(m_b_excute)
112
{
113
 
114
   if((m_Rd!=R_PC)&&m_b_write)
115
   {
116
 
117
      //cout<<"R"<<m_Rd<<"="<<m_n_Rd<<endl;
118
          out_b_RW1=1;
119
      out_REG1=m_Rd;
120
          inout_n_Data1=m_n_Rd;
121
   }
122
 
123
     if(m_b_wb)//write back
124
  {
125
       out_b_RW2=1;
126
           out_REG2=m_Rn;
127
           //cout<<"m_n_Rn="<<m_n_Rn<<endl;
128
       inout_n_Data2=m_n_Rn;
129
         }
130
}
131
 //regs();
132
  //trigger_wb2.notify(SC_ZERO_TIME);
133
 
134
}
135
 
136
void scWB::delay1()
137
{
138
  next_trigger(trigger_wb2);
139
         out_REG2=REGS(0);
140
  uint32_t temp=inout_n_Data2;
141
  cout<<"       wb r0="<<temp;
142
    out_REG2=REGS(1);
143
   temp=inout_n_Data2;
144
  cout<<" wb r1="<<temp;
145
      out_REG2=REGS(2);
146
   temp=inout_n_Data2;
147
  cout<<" wb r2="<<temp;
148
    out_REG2=REGS(3);
149
   temp=inout_n_Data2;
150
  cout<<" wb r3="<<temp<<endl;
151
}

powered by: WebSVN 2.1.0

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