summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--bindings/galearn_pdm.cpp43
-rw-r--r--bindings/sim_cic3_pdm.cc15
2 files changed, 31 insertions, 27 deletions
diff --git a/bindings/galearn_pdm.cpp b/bindings/galearn_pdm.cpp
index 541ba1a..6952a7c 100644
--- a/bindings/galearn_pdm.cpp
+++ b/bindings/galearn_pdm.cpp
@@ -1,32 +1,37 @@
-#include <pybind11/pybind11.h>
#include <pybind11/numpy.h>
+#include <pybind11/pybind11.h>
-int pdm2pcm_cic3(const uint8_t *pdm, int pdm_length, int16_t *pcm, int pcm_length);
-
+int pdm2pcm_cic3(const uint8_t *pdm, int pdm_length, int16_t *pcm,
+ int pcm_length);
namespace py = pybind11;
-int process(py::array_t<uint8_t> arr1, py::array_t<int16_t> arr2) {
- // Check shapes or sizes if needed
- auto buf1 = arr1.request();
- auto buf2 = arr2.request();
+int
+process(py::array_t<uint8_t> arr1, py::array_t<int16_t> arr2)
+{
+ // Check shapes or sizes if needed
+ auto buf1 = arr1.request();
+ auto buf2 = arr2.request();
- if (buf1.ndim != 1 || buf2.ndim != 1) {
- throw std::runtime_error("Only 1D arrays supported");
- }
+ if (buf1.ndim != 1 || buf2.ndim != 1) {
+ throw std::runtime_error("Only 1D arrays supported");
+ }
- if (buf1.size < buf2.size) {
- throw std::runtime_error("Input 1 must be same or larger than input 2");
- }
+ if (buf1.size < buf2.size) {
+ throw std::runtime_error(
+ "Input 1 must be same or larger than input 2");
+ }
- uint8_t* in = static_cast<uint8_t*>(buf1.ptr);
- int16_t* out = static_cast<int16_t*>(buf2.ptr);
+ uint8_t *in = static_cast<uint8_t *>(buf1.ptr);
+ int16_t *out = static_cast<int16_t *>(buf2.ptr);
- int samples = pdm2pcm_cic3(in, arr1.size(), out, arr2.size());
+ int samples = pdm2pcm_cic3(in, arr1.size(), out, arr2.size());
- return samples;
+ return samples;
}
-PYBIND11_MODULE(galearn_pdm, m) {
- m.def("process", &process, "Process two numpy arrays (uint8 and int16)");
+PYBIND11_MODULE(galearn_pdm, m)
+{
+ m.def("process", &process,
+ "Process two numpy arrays (uint8 and int16)");
}
diff --git a/bindings/sim_cic3_pdm.cc b/bindings/sim_cic3_pdm.cc
index e21010b..0368217 100644
--- a/bindings/sim_cic3_pdm.cc
+++ b/bindings/sim_cic3_pdm.cc
@@ -5,22 +5,21 @@
#include "Vcic3_pdm.h"
#include "verilated.h"
-
int
pdm2pcm_cic3(const uint8_t *pdm, int pdm_length, int16_t *pcm, int pcm_length)
{
- // FIXME: verify that output buffer is large enough
+ // FIXME: verify that output buffer is large enough
VerilatedContext *cp = new VerilatedContext;
Vcic3_pdm *top = new Vcic3_pdm{cp};
- // Start clock off
+ // Start clock off
top->clk = 0;
- // Go through all the input data
- int pcm_sample = 0;
+ // Go through all the input data
+ int pcm_sample = 0;
for (int i = 0; i < pdm_length; i++) {
@@ -28,9 +27,9 @@ pdm2pcm_cic3(const uint8_t *pdm, int pdm_length, int16_t *pcm, int pcm_length)
top->clk = 1;
top->eval();
- if (top->pcm_valid) {
- pcm[pcm_sample++] = top->pcm_out;
- }
+ if (top->pcm_valid) {
+ pcm[pcm_sample++] = top->pcm_out;
+ }
top->clk = 0;
top->eval();