Contur 2
Educational OS kernel simulator
Loading...
Searching...
No Matches
cpu.h
Go to the documentation of this file.
1
7
8#pragma once
9
10#include <memory>
11
12#include "contur/cpu/i_cpu.h"
14
15namespace contur {
16
29 class Cpu final : public ICPU
30 {
31 public:
34 explicit Cpu(IMemory &memory);
35
37 ~Cpu() override;
38
39 // Non-copyable, movable
40 Cpu(const Cpu &) = delete;
41 Cpu &operator=(const Cpu &) = delete;
43 Cpu(Cpu &&) noexcept;
44
46 Cpu &operator=(Cpu &&) noexcept;
47
49 [[nodiscard]] Interrupt step(RegisterFile &regs) override;
50
52 void reset() noexcept override;
53
59 [[nodiscard]] RegisterValue flags() const noexcept;
60
61 private:
62 struct Impl;
63 std::unique_ptr<Impl> impl_;
64 };
65
66} // namespace contur
Cpu(const Cpu &)=delete
void reset() noexcept override
Resets the CPU's internal state (flags, etc.).
Cpu(Cpu &&) noexcept
Move-constructs CPU state.
~Cpu() override
Destroys CPU.
RegisterValue flags() const noexcept
Returns the current comparison flags.
Cpu & operator=(const Cpu &)=delete
std::unique_ptr< Impl > impl_
Definition cpu.h:63
Interrupt step(RegisterFile &regs) override
Performs a single fetch-decode-execute cycle.
Cpu(IMemory &memory)
Constructs a CPU connected to the given memory.
ICPU()=default
Abstract interface for linear addressable memory.
Definition i_memory.h:19
The CPU's register bank — holds REGISTER_COUNT (16) registers.
ICPU — abstract interface for the CPU simulation.
IMemory interface — abstract linear addressable memory.
Definition block.h:15
Interrupt
Interrupt codes used by the CPU and kernel.
Definition interrupt.h:17
std::int32_t RegisterValue
Value stored in a CPU register.
Definition types.h:21