orca-sim
ProcessorState.hpp
Go to the documentation of this file.
1 /******************************************************************************
2  * This file is part of project ORCA. More information on the project
3  * can be found at the following repositories at GitHub's website.
4  *
5  * http://https://github.com/andersondomingues/orca-sim
6  * http://https://github.com/andersondomingues/orca-software
7  * http://https://github.com/andersondomingues/orca-mpsoc
8  * http://https://github.com/andersondomingues/orca-tools
9  *
10  * Copyright (C) 2018-2020 Anderson Domingues, <ti.andersondomingues@gmail.com>
11  *
12  * This program is free software; you can redistribute it and/or modify
13  * it under the terms of the GNU General Public License as published by
14  * the Free Software Foundation; either version 2 of the License, or
15  * (at your option) any later version.
16  *
17  * This program is distributed in the hope that it will be useful,
18  * but WITHOUT ANY WARRANTY; without even the implied warranty of
19  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20  * GNU General Public License for more details.
21  *
22  * You should have received a copy of the GNU General Public License along
23  * with this program; if not, write to the Free Software Foundation, Inc.,
24  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
25 ******************************************************************************/
26 #ifndef ORCASIM_MODELING_INCLUDE_PROCESSORSTATE_HPP_
27 #define ORCASIM_MODELING_INCLUDE_PROCESSORSTATE_HPP_
28 
29 #define NUMBER_OF_REGISTERS 32
30 
31 #include <stdint.h>
32 
33 namespace orcasim::modeling {
34 
37 template <typename T>
39  // please note that register to from 0 to NUM_REGS, and
40  // the next reg (which would overflow the array size)
41  // falls in the PC instead. For example, for an arch with
42  // 32 register, the register number 33 is PC.
43  T regs[NUMBER_OF_REGISTERS]; // general purpose registers
44  T pc; // the value of pc in the current cycle
45  T pc_prev; // value of pc in the last cycle (zero if 1st)
46  T pc_next; // value of pc in the next cycle
47  T terminated; // indicate whether the cpu has aborted (abnormaly or not)
48 };
49 
50 // Some of the most used instances. More can be added later.
51 template struct ProcessorState<uint8_t>;
52 template struct ProcessorState<uint16_t>;
53 template struct ProcessorState<uint32_t>;
54 template struct ProcessorState<uint64_t>;
55 
56 // Some of the most used instances. More can be added later.
57 template struct ProcessorState<int8_t>;
58 template struct ProcessorState<int16_t>;
59 template struct ProcessorState<int32_t>;
60 template struct ProcessorState<int64_t>;
61 
62 } // namespace orcasim::modeling
63 #endif // ORCASIM_MODELING_INCLUDE_PROCESSORSTATE_HPP_
#define NUMBER_OF_REGISTERS
Defines a generic state model for use within processor models.