make main.cpp general-purpose (#define module)
[soc-cxxrtl-sim.git] / small_jtag_test / main.cpp
index 987b742e9f0ced6c2cb9c841ed53aad5f7974e57..d53126b993c556e6db0ce9eda97ba1d97f56731b 100644 (file)
@@ -14,7 +14,7 @@
 #include <iostream>
 #include <fstream>
 
-#include "add.cpp"
+#include CXX_FILE
 
 #define VCD
 
@@ -124,7 +124,7 @@ int read_handler(int fdread, char *buffer)
    indicates that receiver wants to know the status of TDO.
    "Q" means "quit socket".
 */
-int read_openocd_jtagremote(cxxrtl_design::p_add &top, int sock)
+int read_openocd_jtagremote(DESIGN &top, int sock)
 {
     char c;
     if (read_handler(sock, &c) != 1) {
@@ -133,13 +133,13 @@ int read_openocd_jtagremote(cxxrtl_design::p_add &top, int sock)
     printf ("read %c\n", c);
     if ((c >= '0') && (c <= '7'))
     {
-        top.p_tck.set<bool>(((c - '0') >> 2) & 1);
-        top.p_tms.set<bool>(((c - '0') >> 1) & 1);
-        top.p_tdi.set<bool>((c - '0')  & 1);
+        top.p_jtag__tck.set<bool>(((c - '0') >> 2) & 1);
+        top.p_jtag__tms.set<bool>(((c - '0') >> 1) & 1);
+        top.p_jtag__tdi.set<bool>((c - '0')  & 1);
     }
     if (c == 'R')
     {
-        uint8_t val = top.p_tdo.get<uint8_t>() + '0';
+        uint8_t val = top.p_jtag__tdo.get<uint8_t>() + '0';
         if(-1 == write(sock, &val, 1))
         {
             printf("Error writing on socket\n");
@@ -157,7 +157,7 @@ int read_openocd_jtagremote(cxxrtl_design::p_add &top, int sock)
 
 int main()
 {
-    cxxrtl_design::p_add top;
+    DESIGN top;
     int steps = 0;
 
 #ifdef VCD
@@ -185,12 +185,12 @@ int main()
 #endif
     while (true) {
 
-        top.p_clk.set<bool>(false);
+        top.p_sys__clk.set<bool>(false);
         top.step();
 #ifdef VCD
         vcd.sample(steps*2 + 0);
 #endif
-        top.p_clk.set<bool>(true);
+        top.p_sys__clk.set<bool>(true);
         top.step();
 #ifdef VCD
         vcd.sample(steps*2 + 1);
@@ -204,15 +204,6 @@ int main()
         /* read and process incoming jtag. sock set to -1 if disconnected */
         sock = read_openocd_jtagremote(top, sock);
 
-        // quick check that the output is correct (it's an adder: go figure)
-        /*
-        top.p_a.set<uint8_t>(5);
-        top.p_b.set<uint8_t>(3);
-        uint32_t f    = top.p_f.get<uint32_t>();
-
-        cout << "f " << f << endl;
-        */
-
         waves << vcd.buffer;
         vcd.buffer.clear();
     }