diff --git a/hw_html/CMakeLists.txt b/hw_html/CMakeLists.txt
index cc6e897..ae7da73 100644
--- a/hw_html/CMakeLists.txt
+++ b/hw_html/CMakeLists.txt
@@ -1,7 +1,8 @@
cmake_minimum_required(VERSION 3.0)
project(hw_html CXX)
add_definitions(-g)
-add_executable(${PROJECT_NAME} html.cpp main.cpp mcureg.cpp)
+add_executable(${PROJECT_NAME} html.cpp main.cpp mcubase.cpp bit.cpp
+ mcureg.cpp)
add_library(xmlParser xmlParser/xmlParser.cpp)
add_subdirectory(CTML)
target_include_directories(xmlParser PUBLIC xmlParser)
diff --git a/hw_html/bit.cpp b/hw_html/bit.cpp
new file mode 100644
index 0000000..0381b59
--- /dev/null
+++ b/hw_html/bit.cpp
@@ -0,0 +1,16 @@
+#include
+#include
+
+bit::bit(const std::string &name, const std::string &access,
+ const std::string &pos) :
+ mcubase(name, access),
+ off(get(pos))
+{
+}
+
+struct bit::off bit::get(const std::string &pos)
+{
+ struct off off = {0};
+ std::cout << pos + "\n";
+ return off;
+}
diff --git a/hw_html/bit.hpp b/hw_html/bit.hpp
new file mode 100644
index 0000000..b912540
--- /dev/null
+++ b/hw_html/bit.hpp
@@ -0,0 +1,20 @@
+#ifndef BIT_HPP
+#define BIT_HPP
+
+#include
+#include
+
+class bit : public mcubase
+{
+public:
+ bit(const std::string &name, const std::string &access,
+ const std::string &pos);
+ virtual ~bit() = default;
+
+protected:
+ const struct off {unsigned int upper, lower;} off;
+ static struct off get(const std::string &pos);
+ std::string comment;
+};
+
+#endif /* BIT_HPP */
diff --git a/hw_html/html.cpp b/hw_html/html.cpp
index dee58ce..9f2b3f4 100644
--- a/hw_html/html.cpp
+++ b/hw_html/html.cpp
@@ -1,4 +1,5 @@
-#include "html.hpp"
+#include
+#include
#include
#include
#include
@@ -41,3 +42,8 @@ html::error html::open(const char *const path)
return html::OK;
}
+
+html::error html::add(const mcubase ®)
+{
+ return html::OK;
+}
diff --git a/hw_html/html.hpp b/hw_html/html.hpp
index f9f1c29..103e588 100644
--- a/hw_html/html.hpp
+++ b/hw_html/html.hpp
@@ -1,4 +1,8 @@
+#ifndef HTML_HPP
+#define HTML_HPP
+
#include
+#include
#include
class html
@@ -15,7 +19,10 @@ public:
html();
virtual ~html();
error open(const char *path);
+ error add(const mcubase ®);
protected:
FILE *f;
};
+
+#endif /* HTML_HPP */
diff --git a/hw_html/main.cpp b/hw_html/main.cpp
index 1c90b27..20f374d 100644
--- a/hw_html/main.cpp
+++ b/hw_html/main.cpp
@@ -1,5 +1,6 @@
#include "html.hpp"
#include "mcureg.hpp"
+#include "bit.hpp"
#include
#include
#include
@@ -58,11 +59,13 @@ int main(const int argc, const char *const argv[])
{
const XMLNode reg = module.getChildNode("reg", &n);
const char *const name = reg.getAttribute("name");
+ const char *const access = reg.getAttribute("protect");
- if (!name)
+ if (!name || !access)
continue;
printf("\treg %s\n", name);
+ mcureg mcureg(name, access);
int n = 0;
@@ -70,41 +73,17 @@ int main(const int argc, const char *const argv[])
{
const XMLNode bits = reg.getChildNode("bits", &n);
const char *const name = bits.getAttribute("name");
- mcureg::access access = mcureg::UNDEF;
- const char *const access_cs = bits.getAttribute("access");
+ const char *const access = bits.getAttribute("access");
+ const char *const pos = bits.getAttribute("pos");
+ const char *const rst = bits.getAttribute("rst");
- if (!access_cs)
+ printf("\t\tbit=%s, access=%s, pos=%s, rst=%s\n",
+ name, access, pos, rst);
+
+ if (!name || !access || !pos || !rst)
continue;
- const std::string access_s = access_cs;
-
- if (access_s == "rsv")
- access = mcureg::RSV;
- else if (access_s == "w1c")
- access = mcureg::W1C;
- else if (access_s == "w1s")
- access = mcureg::W1S;
- else if (access_s == "rc")
- access = mcureg::RC;
- else if (access_s == "rs")
- access = mcureg::RS;
- else if (access_s == "rw")
- access = mcureg::RW;
- else if (access_s == "c")
- access = mcureg::C;
- else if (access_s == "s")
- access = mcureg::S;
- else if (access_s == "r")
- access = mcureg::R;
- else if (access_s == "w")
- access = mcureg::W;
-
- if (access == mcureg::UNDEF)
- fprintf(stderr, "%s: undefined access\n", name);
- else
- {
- printf("\t\t%s, access %s\n", name, access_cs);
- }
+ mcureg.add(bit(name, access, pos));
}
}
}
diff --git a/hw_html/mcubase.cpp b/hw_html/mcubase.cpp
index f894d42..25be27f 100644
--- a/hw_html/mcubase.cpp
+++ b/hw_html/mcubase.cpp
@@ -1,5 +1,36 @@
-#include "mcureg.hpp"
+#include "mcubase.hpp"
+#include
+#include
-mcureg::mcureg(mcureg::access access)
+mcubase::mcubase(const std::string &name, const std::string &access) :
+ name(name),
+ acc(get(access)),
+ rst(0)
{
}
+
+mcubase::access mcubase::get(const std::string &access)
+{
+ if (access == "rsv")
+ return mcubase::RSV;
+ else if (access == "w1c")
+ return mcubase::W1C;
+ else if (access == "w1s")
+ return mcubase::W1S;
+ else if (access == "rc")
+ return mcubase::RC;
+ else if (access == "rs")
+ return mcubase::RS;
+ else if (access == "rw")
+ return mcubase::RW;
+ else if (access == "c")
+ return mcubase::C;
+ else if (access == "s")
+ return mcubase::S;
+ else if (access == "r")
+ return mcubase::R;
+ else if (access == "w")
+ return mcubase::W;
+
+ return mcubase::UNDEF;
+}
diff --git a/hw_html/mcubase.hpp b/hw_html/mcubase.hpp
index 8d99de2..556c55a 100644
--- a/hw_html/mcubase.hpp
+++ b/hw_html/mcubase.hpp
@@ -1,8 +1,23 @@
-class mcureg
+#ifndef MCUBASE_HPP
+#define MCUBASE_HPP
+
+#include
+#include
+
+class mcubase
{
public:
enum access {UNDEF, C, R, S, W, RC, RS, RW, RSV, W1C, W1S};
+ mcubase(const std::string &name, const std::string &access);
- explicit mcureg(access access);
- virtual ~mcureg() = default;
+protected:
+ mcubase() = default;
+ const std::string &name;
+ const access acc;
+ uint32_t rst;
+
+private:
+ static access get(const std::string &access);
};
+
+#endif /* MCUBASE_HPP */
diff --git a/hw_html/mcureg.cpp b/hw_html/mcureg.cpp
new file mode 100644
index 0000000..a8db587
--- /dev/null
+++ b/hw_html/mcureg.cpp
@@ -0,0 +1,15 @@
+#include
+#include
+#include
+#include
+#include
+
+mcureg::mcureg(const std::string &name, const std::string &access) :
+ mcubase(name, access)
+{
+}
+
+void mcureg::add(const bit &bit)
+{
+ bits.push_back(bit);
+}
diff --git a/hw_html/mcureg.hpp b/hw_html/mcureg.hpp
new file mode 100644
index 0000000..6abd265
--- /dev/null
+++ b/hw_html/mcureg.hpp
@@ -0,0 +1,20 @@
+#ifndef MCUREG_HPP
+#define MCUREG_HPP
+
+#include
+#include
+#include
+#include
+
+class mcureg : public mcubase
+{
+public:
+ mcureg(const std::string &name, const std::string &access);
+ virtual ~mcureg() = default;
+ void add(const bit &);
+
+protected:
+ std::list bits;
+};
+
+#endif /* MCUREG_HPP */