diff options
| author | Clément Zrounba <6691770+clement-z@users.noreply.github.com> | 2023-09-30 23:06:01 +0200 |
|---|---|---|
| committer | Clément Zrounba <6691770+clement-z@users.noreply.github.com> | 2023-09-30 23:26:46 +0200 |
| commit | ff9b8bb838ecdfbfc1dc81038fcf3b2a87636982 (patch) | |
| tree | 21f27be782ce11c6d00b96ce100a2bff88141b2e /src/devices/pcm_device.h | |
| download | specs-ff9b8bb838ecdfbfc1dc81038fcf3b2a87636982.tar.gz specs-ff9b8bb838ecdfbfc1dc81038fcf3b2a87636982.zip | |
Initial release
Diffstat (limited to 'src/devices/pcm_device.h')
| -rw-r--r-- | src/devices/pcm_device.h | 60 |
1 files changed, 60 insertions, 0 deletions
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 <vector> + +#include <systemc.h> + +#include <spx_module.h> +#include <optical_output_port.h> +#include <optical_signal.h> + +#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<double,double> 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<uint32_t,OpticalSignal::field_type> m_memory_in; + + + // Processes + void on_input_changed(); + bool phase_change(const vector<pulse_sample_t> &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; + } +}; |
