1/*****************************************************************************
2
3  Licensed to Accellera Systems Initiative Inc. (Accellera) under one or
4  more contributor license agreements.  See the NOTICE file distributed
5  with this work for additional information regarding copyright ownership.
6  Accellera licenses this file to you under the Apache License, Version 2.0
7  (the "License"); you may not use this file except in compliance with the
8  License.  You may obtain a copy of the License at
9
10    http://www.apache.org/licenses/LICENSE-2.0
11
12  Unless required by applicable law or agreed to in writing, software
13  distributed under the License is distributed on an "AS IS" BASIS,
14  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
15  implied.  See the License for the specific language governing
16  permissions and limitations under the License.
17
18 *****************************************************************************/
19
20/*****************************************************************************
21
22  a2901_alu.cpp --
23
24  Original Author: Martin Janssen, Synopsys, Inc., 2002-02-15
25
26 *****************************************************************************/
27
28/*****************************************************************************
29
30  MODIFICATION LOG - modifiers, enter your name, affiliation, date and
31  changes you are making here.
32
33      Name, Affiliation, Date:
34  Description of Modification:
35
36 *****************************************************************************/
37
38#include "a2901_alu.h"
39
40void
41a2901_alu::entry()
42{
43    int I53 = I.read().range(5,3);
44
45    R_ext_v = (I53 == 0x1) ? sc_int<5> (0xf & ~(RE.read()))
46                           : sc_int<5>( RE.read() );
47    S_ext_v = (I53 == 0x2) ? sc_int<5> (0xf & ~(S.read()) )
48                           : sc_int<5>( S.read() );
49    R_ext.write(R_ext_v);
50    S_ext.write(S_ext_v);
51
52    switch (I53) {
53    case 0x0:
54    case 0x1:
55    case 0x2:
56      result = R_ext_v + S_ext_v + C0.read();
57      break;
58    case 0x3:
59      result = R_ext_v | S_ext_v;
60      break;
61    case 0x4:
62      result = R_ext_v & S_ext_v;
63      break;
64    case 0x5:
65      result = ~(R_ext_v) & S_ext_v;
66      break;
67    case 0x6:
68      result = R_ext_v ^ S_ext_v;
69      break;
70    default:
71      result = ~(R_ext_v ^ S_ext_v);
72    }
73
74    F.write(result);
75    OVR.write(!(R_ext_v[3] ^ S_ext_v[3]) & (R_ext_v[3] ^ result[3]));
76    //C4.write(result[4]);
77    C4.write((bool)result[4]);
78    temp_p = R_ext_v | S_ext_v;
79    temp_g = R_ext_v & S_ext_v;
80    Pbar.write((temp_p[0] & temp_p[1] & temp_p[2] & temp_p[3]) ? 0 : 1);
81    Gbar.write((temp_g[3] |
82	       (temp_p[3] & temp_g[2]) |
83	       (temp_p[3] & temp_p[2] & temp_g[1]) |
84	       (temp_p[3] & temp_p[2] & temp_p[1] & temp_g[0])) ? 0 : 1);
85    //F3.write(result[3]);
86    F3.write((bool)result[3]);
87    F30.write((result[3] | result[2] | result[1] | result[0]) ? 0 : 1);
88}
89