/*
 * {{ soc_name }}_bindings_{{ chunk_idx }}.cpp
 * Generated by PeakRDL-pybind11
 * 
 * PyBind11 bindings for SystemRDL register map (chunk {{ chunk_idx }})
 */

#include <pybind11/pybind11.h>
#include <pybind11/functional.h>
#include <pybind11/stl.h>
#include "{{ soc_name }}_descriptors.hpp"

namespace py = pybind11;
using namespace {{ soc_name }};

void bind_registers_chunk_{{ chunk_idx }}(py::module& m) {
    {% for reg in regs %}
    // Register class: {{ reg.inst_name }}
    py::class_<{{ reg.inst_name }}_t, RegisterBase>(m, "{{ reg.inst_name }}_t"{% if reg.get_property('desc') %}, "{{ reg.get_html_desc() }}"{% endif %})
        .def(py::init<uint64_t>())
        {% for field in reg.fields() %}
        .def_readonly("{{ field.inst_name }}", &{{ reg.inst_name }}_t::{{ field.inst_name }})
        {% endfor %}
        ;
    
    {% for field in reg.fields() %}
    // Field class: {{ reg.inst_name }}.{{ field.inst_name }}
    py::class_<{{ reg.inst_name }}_t::{{ field.inst_name }}_field, FieldBase>(m, "{{ reg.inst_name }}_{{ field.inst_name }}_field"{% if field.get_property('desc') %}, "{{ field.get_html_desc() }}"{% endif %})
        .def("read", &{{ reg.inst_name }}_t::{{ field.inst_name }}_field::read, "Read field value")
        .def("write", &{{ reg.inst_name }}_t::{{ field.inst_name }}_field::write, "Write field value");
    {% endfor %}
    {% endfor %}
}
