orca-sim
ProcessorBase.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_PROCESSORBASE_HPP_
27 #define ORCASIM_MODELING_INCLUDE_PROCESSORBASE_HPP_
28 
29 #include <string>
30 
31 #include "TimedModel.hpp"
32 #include "Memory.hpp"
33 #include "ProcessorState.hpp"
34 
38 
39 namespace orcasim::modeling {
40 
46 template <typename T>
47 class ProcessorBase : public TimedModel{
48  private:
54 
59 
60  public:
65  ProcessorBase(std::string name, MemoryAddr initial_pc, Memory* mem);
66 
69 
75  virtual SimulationTime Run() = 0;
76 
82 
87  Memory* GetMemory();
88 };
89 
90 // Some of the most used instances. More can be added later.
91 template class ProcessorBase<uint8_t>;
92 template class ProcessorBase<uint16_t>;
93 template class ProcessorBase<uint32_t>;
94 template class ProcessorBase<uint64_t>;
95 
96 // Some of the most used instances. More can be added later.
97 template class ProcessorBase<int8_t>;
98 template class ProcessorBase<int16_t>;
99 template class ProcessorBase<int32_t>;
100 template class ProcessorBase<int64_t>;
101 
102 } // namespace orcasim::modeling
103 #endif // ORCASIM_MODELING_INCLUDE_PROCESSORBASE_HPP_
This class models a TimedModel.
Definition: TimedModel.hpp:42
Memory * GetMemory()
This method returns a pointer to the object that models the memory core.
#define MemoryAddr
Definition: MemoryType.hpp:34
uint32_t SimulationTime
ProcessorState< T > * GetState()
This method returns the state model of the processor.
Defines a generic state model for use within processor models.
Memory * _memory
We assume that every processor is attached to a memory core.
struct ProcessorState< T > _state
struct that represent the state of a processor.
This class models a memory module.
Definition: Memory.hpp:55
virtual SimulationTime Run()=0
Run method from the base TimedModel class, overloaded.
This class implements the base operation for generic processor implementations.
ProcessorBase(std::string name, MemoryAddr initial_pc, Memory *mem)
Default constructor.