-
Notifications
You must be signed in to change notification settings - Fork 0
/
Logic.hpp
47 lines (44 loc) · 897 Bytes
/
Logic.hpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
#pragma once
#include <algorithm>
#include <cassert>
#include <cstdint>
#include <vector>
#include <cstdio>
class SeqLogic{
public:
SeqLogic(){
all.push_back(this);
}
~SeqLogic(){
auto it = std::find(all.begin(), all.end(), this);
if(it != all.end()) all.erase(it);
else assert(0);
}
static std::vector<SeqLogic*>& get_all_Logics(){
return all;
}
static void clock_step(){
for(auto& m : all){
m->eval();
}
for(auto& m : all){
m->update();
}
cycs += 1;
}
static inline uint64_t cycs=0;
protected:
virtual void eval()=0;
virtual void update()=0;
private:
static inline std::vector<SeqLogic*> all;
};
class ComLogic: public SeqLogic{
protected:
void eval() override{
return;
}
void update() override{
return;
}
};