diff options
| author | Julian Blake Kongslie | 2022-06-26 21:48:45 -0700 |
|---|---|---|
| committer | Julian Blake Kongslie | 2022-06-26 22:06:21 -0700 |
| commit | e7c2eeb6c82d5341019cbb00cfefc55c8a27f232 (patch) | |
| tree | d8293bce0cb5323133f849390e60419c16636b18 /fib | |
| parent | Significant changes, and a working "ISA" that just computes fib(n). (diff) | |
| download | issim-e7c2eeb6c82d5341019cbb00cfefc55c8a27f232.tar.xz | |
Move a bunch of code from headers to separate compilation units.
Diffstat (limited to '')
| -rw-r--r-- | fib/fib.cpp (renamed from isa/fib/fib.h) | 41 | ||||
| -rw-r--r-- | fib/fib.d | 1 | ||||
| -rw-r--r-- | fib/fib.h | 34 |
3 files changed, 53 insertions, 23 deletions
diff --git a/isa/fib/fib.h b/fib/fib.cpp index 13801c8..8ff7718 100644 --- a/isa/fib/fib.h +++ b/fib/fib.cpp | |||
| @@ -1,30 +1,17 @@ | |||
| 1 | #pragma once | ||
| 2 | |||
| 3 | #include <fmt/core.h> | 1 | #include <fmt/core.h> |
| 4 | #include <memory> | 2 | #include <memory> |
| 5 | #include <optional> | 3 | #include <optional> |
| 6 | #include <string> | 4 | #include <string> |
| 5 | #include <type_traits> | ||
| 7 | #include <utility> | 6 | #include <utility> |
| 8 | #include <vector> | 7 | #include <vector> |
| 9 | 8 | ||
| 10 | #include "aisa/aisa.h" | 9 | #include "aisa/aisa.h" |
| 10 | #include "fib/fib.h" | ||
| 11 | 11 | ||
| 12 | namespace isa::fib { | 12 | namespace fib { |
| 13 | 13 | ||
| 14 | namespace Reg { | 14 | namespace Reg { |
| 15 | enum { | ||
| 16 | ENV_TOP, | ||
| 17 | ENV_FIB, | ||
| 18 | |||
| 19 | AREG, | ||
| 20 | ATMP, | ||
| 21 | |||
| 22 | PC, | ||
| 23 | |||
| 24 | A, | ||
| 25 | B, | ||
| 26 | Q, | ||
| 27 | }; | ||
| 28 | 15 | ||
| 29 | const char *disasm(aisa::regnum_t x) | 16 | const char *disasm(aisa::regnum_t x) |
| 30 | { | 17 | { |
| @@ -40,6 +27,7 @@ namespace isa::fib { | |||
| 40 | default: return "???"; | 27 | default: return "???"; |
| 41 | } | 28 | } |
| 42 | } | 29 | } |
| 30 | |||
| 43 | } | 31 | } |
| 44 | 32 | ||
| 45 | struct StepAdd : public aisa::Step { | 33 | struct StepAdd : public aisa::Step { |
| @@ -277,12 +265,19 @@ namespace isa::fib { | |||
| 277 | } | 265 | } |
| 278 | }; | 266 | }; |
| 279 | 267 | ||
| 280 | template<unsigned int WORD=1> struct Fib : public aisa::ISA { | 268 | template<unsigned int WORD> std::pair<std::unique_ptr<const aisa::Task>, aisa::regval_t> Fib<WORD>::initial_task() const |
| 281 | std::pair<std::unique_ptr<const aisa::Task>, aisa::regval_t> initial_task() const override | 269 | { |
| 282 | { | 270 | auto t = std::make_unique<TaskTop<WORD>>(); |
| 283 | auto t = std::make_unique<TaskTop<WORD>>(); | 271 | return {std::move(t), 0}; |
| 284 | return {std::move(t), 0}; | 272 | } |
| 285 | } | 273 | |
| 286 | }; | 274 | template struct Fib<1>; |
| 275 | template struct Fib<2>; | ||
| 276 | template struct Fib<3>; | ||
| 277 | template struct Fib<4>; | ||
| 278 | template struct Fib<5>; | ||
| 279 | template struct Fib<6>; | ||
| 280 | template struct Fib<7>; | ||
| 281 | template struct Fib<8>; | ||
| 287 | 282 | ||
| 288 | } | 283 | } |
diff --git a/fib/fib.d b/fib/fib.d new file mode 100644 index 0000000..a6d18cc --- /dev/null +++ b/fib/fib.d | |||
| @@ -0,0 +1 @@ | |||
| fib_SODEPS += build/libaisa.so | |||
diff --git a/fib/fib.h b/fib/fib.h new file mode 100644 index 0000000..6719d06 --- /dev/null +++ b/fib/fib.h | |||
| @@ -0,0 +1,34 @@ | |||
| 1 | #pragma once | ||
| 2 | |||
| 3 | #include <memory> | ||
| 4 | #include <utility> | ||
| 5 | |||
| 6 | #include "aisa/aisa.h" | ||
| 7 | |||
| 8 | namespace fib { | ||
| 9 | |||
| 10 | namespace Reg { | ||
| 11 | |||
| 12 | enum { | ||
| 13 | ENV_TOP, | ||
| 14 | ENV_FIB, | ||
| 15 | |||
| 16 | AREG, | ||
| 17 | ATMP, | ||
| 18 | |||
| 19 | PC, | ||
| 20 | |||
| 21 | A, | ||
| 22 | B, | ||
| 23 | Q, | ||
| 24 | }; | ||
| 25 | |||
| 26 | const char *disasm(aisa::regnum_t x); | ||
| 27 | |||
| 28 | } | ||
| 29 | |||
| 30 | template<unsigned int WORD=1> struct Fib : public aisa::ISA { | ||
| 31 | std::pair<std::unique_ptr<const aisa::Task>, aisa::regval_t> initial_task() const override; | ||
| 32 | }; | ||
| 33 | |||
| 34 | } | ||
