-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathCharybdis.java
74 lines (63 loc) · 4 KB
/
Charybdis.java
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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
//------------------------------------------------------------------------------
// A chip that transforms a register and then reloads it in a never ending cycle
// Philip R Brenan at appaapps dot com, Appa Apps Ltd Inc., 2024
//------------------------------------------------------------------------------
package com.AppaApps.Silicon; // Design, simulate and layout digital a binary tree on a silicon chip.
/*
ÏÏÎ¯Ï Î¼á½²Î½ Î³á½°Ï ÏαÏÎει, ÏÏá½¶Ï Î´' á¼Î¾ÎµÎ¼ÎÏÏÏιν á¼
ÏανÏα, δεινὸν κÏ
κÏÏαÏα· Î¸Îµá½¸Ï ÏÎÏÎ±Ï Îµá¼°ÏοÏάαÏθαι.
Three times a day she sucks the dark water down, and three times she spits it up, a terror to behold.
*/
//D1 Construct // A chip that transforms a register and then reloads it in a never ending cycle
public class Charybdis extends Chip // A chip that transforms a register and then reloads it in a never ending cycle
{final Register register; // The register that will be transformed
final Pulse pulse; // The pulse that will update the register at the end of the cycle
final Bits update; // Set this bit bus to load the register with its latest value
final int delay; // The time it takes for the register to reset
final int width; // Width of the register in bits
final int on; // How many steps we need to wait for the correct response
Charybdis(String Name, int Width, int On) // Create a new Charybdis chip
{super(Name);
width = Width;
on = On;
delay = logTwo(width);
pulse = pulse (n(Name, "pulse")).period(2*on).delay(on).on(on).start(2).b();
register = new Register(n(Name, "register"), width, pulse).anneal();
update = register.inputBits;
}
//D0 // Tests
static void test_shift_left()
{final int W = 2;
Charybdis c = new Charybdis("c", W, W);
Bits s = c.shiftLeftConstantFillWithOnes("shift", c.register, 1).anneal();
c.subBits(c.update.name, s, 2, W);
c.executionTrace = c.new ExecutionTrace()
{String title() {return "p Reg";}
String trace() {
say(c);
return String.format("%s %s %s", c.pulse, s, c.register);}
};
c.simulationSteps(20*W);
c.simulate();
//r.ok(A);
c.printExecutionTrace(); stop();
c.executionTrace.ok("""
""");
}
static void oldTests() // Tests thought to be in good shape
{test_shift_left();
}
static void newTests() // Tests being worked on
{//oldTests();
test_shift_left();
}
public static void main(String[] args) // Test if called as a program
{try // Get a traceback in a format clickable in Geany if something goes wrong to speed up debugging.
{if (github_actions) oldTests(); else newTests(); // Tests to run
testSummary(); // Summarize test results
}
catch(Exception e) // Get a traceback in a format clickable in Geany
{System.err.println(e);
System.err.println(fullTraceBack(e));
}
}
}