aboutsummaryrefslogtreecommitdiffstats
path: root/sim.cpp
diff options
context:
space:
mode:
authorGravatar Peter McGoron 2023-04-21 17:39:18 +0000
committerGravatar Peter McGoron 2023-04-21 17:39:18 +0000
commit619734f54eaa8ab12214174b97e3bfca5be9ca1a (patch)
tree5e081f59ff6b0ffe9abaa95dd40aea8048e86a4c /sim.cpp
parentlicense and bump version (diff)
add reset pinHEAD1.1master
Diffstat (limited to 'sim.cpp')
-rw-r--r--sim.cpp34
1 files changed, 24 insertions, 10 deletions
diff --git a/sim.cpp b/sim.cpp
index 7edf0bf..6195f09 100644
--- a/sim.cpp
+++ b/sim.cpp
@@ -29,14 +29,27 @@ static void run_clock() {
main_time++;
}
-static void run(word i, word j) {
+static void run(word i, word j, bool reset_in_middle) {
// Processor is twos-compliment
mod->a1 = i;
mod->a2 = j;
mod->arm = 1;
- while (!mod->fin)
- run_clock();
+ if (!reset_in_middle) {
+ while (!mod->fin)
+ run_clock();
+ } else {
+ int i = 0;
+ while (!mod->fin) {
+ if (i == 10) {
+ mod->rst_L = 0;
+ } else if (i == 20) {
+ mod->rst_L = 1;
+ }
+ run_clock();
+ i++;
+ }
+ }
dword expected = (dword) i * (dword) j;
if (mod->outn != expected) {
@@ -55,16 +68,17 @@ int main(int argc, char **argv) {
mod->clk = 0;
mod->arm = 0;
+ mod->rst_L = 1;
run_clock();
- run(minint, minint);
- run(minint, maxint);
- run(maxint, minint);
- run(maxint, maxint);
+ run(minint, minint, false);
+ run(minint, maxint, false);
+ run(maxint, minint, false);
+ run(maxint, maxint, false);
- for (word i = -20; i < 20; i++) {
- for (word j = - 20; j < 20; j++) {
- run(i, j);
+ for (word i = -40; i < 40; i++) {
+ for (word j = - 40; j < 40; j++) {
+ run(i, j, rand() % 1);
}
}