From ff9b8bb838ecdfbfc1dc81038fcf3b2a87636982 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20Zrounba?= <6691770+clement-z@users.noreply.github.com> Date: Sat, 30 Sep 2023 23:06:01 +0200 Subject: Initial release --- src/devices/pcm_device.h | 60 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 60 insertions(+) create mode 100644 src/devices/pcm_device.h (limited to 'src/devices/pcm_device.h') diff --git a/src/devices/pcm_device.h b/src/devices/pcm_device.h new file mode 100644 index 0000000..4510591 --- /dev/null +++ b/src/devices/pcm_device.h @@ -0,0 +1,60 @@ +#pragma once + +#include + +#include + +#include +#include +#include + +#include "specs.h" +#include "spx_module.h" + +class PCMElement : public spx_module { +public: + // Ports + spx::oa_port_in_type p_in; + spx::oa_port_out_type p_out; + + // Timed ports writers + OpticalOutputPort m_out_writer; + + // Auxiliary struct - stores tuples of value-time + typedef pair pulse_sample_t; + + // Member variables + double m_meltEnergy; + int m_state; + int m_nStates; + double m_transmission = 1; + double influence_time_ns = 1; + + /** Current information about the optical input, before any attenuation and phase shift. */ + double m_last_pulse_power; + std::map m_memory_in; + + + // Processes + void on_input_changed(); + bool phase_change(const vector &vec, const bool &local); + void update_transmission_local(); + + + // Constructor + PCMElement(sc_module_name name, + double meltEnergy = 0, + int nStates = 0, + int state = 0) + : spx_module(name) + , m_out_writer("out_delayed_writer", p_out) + , m_meltEnergy(meltEnergy) + , m_state(state) + , m_nStates(nStates) + { + SC_HAS_PROCESS(PCMElement); + + SC_THREAD(on_input_changed); + sensitive << p_in; + } +}; -- cgit v1.2.3