2016-11-06 21:13:13 +00:00
|
|
|
//
|
|
|
|
// Acorn.hpp
|
|
|
|
// Clock Signal
|
|
|
|
//
|
|
|
|
// Created by Thomas Harte on 06/11/2016.
|
2018-05-13 19:19:52 +00:00
|
|
|
// Copyright 2016 Thomas Harte. All rights reserved.
|
2016-11-06 21:13:13 +00:00
|
|
|
//
|
|
|
|
|
2024-01-17 04:34:46 +00:00
|
|
|
#pragma once
|
2016-11-06 21:13:13 +00:00
|
|
|
|
|
|
|
#include "TapeParser.hpp"
|
2020-01-20 04:14:35 +00:00
|
|
|
#include "../../../Numeric/CRC.hpp"
|
2017-09-23 02:39:23 +00:00
|
|
|
#include "../../Disk/DPLL/DigitalPhaseLockedLoop.hpp"
|
2016-11-06 21:13:13 +00:00
|
|
|
|
2023-05-10 21:02:18 +00:00
|
|
|
namespace Storage::Tape::Acorn {
|
2016-11-06 21:13:13 +00:00
|
|
|
|
2020-01-12 22:25:21 +00:00
|
|
|
class Shifter {
|
2017-07-16 23:24:01 +00:00
|
|
|
public:
|
|
|
|
Shifter();
|
|
|
|
|
|
|
|
void process_pulse(const Storage::Tape::Tape::Pulse &pulse);
|
|
|
|
|
|
|
|
class Delegate {
|
|
|
|
public:
|
|
|
|
virtual void acorn_shifter_output_bit(int value) = 0;
|
|
|
|
};
|
|
|
|
void set_delegate(Delegate *delegate) {
|
|
|
|
delegate_ = delegate;
|
|
|
|
}
|
|
|
|
|
|
|
|
void digital_phase_locked_loop_output_bit(int value);
|
|
|
|
|
|
|
|
private:
|
2020-01-12 22:25:21 +00:00
|
|
|
Storage::DigitalPhaseLockedLoop<Shifter, 15> pll_;
|
2017-07-16 23:24:01 +00:00
|
|
|
bool was_high_;
|
|
|
|
|
|
|
|
unsigned int input_pattern_;
|
|
|
|
|
|
|
|
Delegate *delegate_;
|
|
|
|
};
|
|
|
|
|
2016-11-06 21:13:13 +00:00
|
|
|
enum class SymbolType {
|
|
|
|
One, Zero
|
|
|
|
};
|
|
|
|
|
2023-05-16 20:40:09 +00:00
|
|
|
class Parser: public Storage::Tape::Parser<SymbolType>, public Shifter::Delegate {
|
2016-11-06 21:13:13 +00:00
|
|
|
public:
|
|
|
|
Parser();
|
|
|
|
|
|
|
|
int get_next_bit(const std::shared_ptr<Storage::Tape::Tape> &tape);
|
|
|
|
int get_next_byte(const std::shared_ptr<Storage::Tape::Tape> &tape);
|
2017-10-18 02:34:49 +00:00
|
|
|
unsigned int get_next_short(const std::shared_ptr<Storage::Tape::Tape> &tape);
|
|
|
|
unsigned int get_next_word(const std::shared_ptr<Storage::Tape::Tape> &tape);
|
2016-11-06 21:13:13 +00:00
|
|
|
void reset_crc();
|
2021-03-08 01:49:40 +00:00
|
|
|
uint16_t get_crc() const;
|
2016-11-06 21:13:13 +00:00
|
|
|
|
|
|
|
private:
|
2021-03-07 20:56:58 +00:00
|
|
|
void acorn_shifter_output_bit(int value) override;
|
|
|
|
void process_pulse(const Storage::Tape::Tape::Pulse &pulse) override;
|
|
|
|
|
2017-07-16 23:24:01 +00:00
|
|
|
bool did_update_shifter(int new_value, int length);
|
2018-07-11 00:01:31 +00:00
|
|
|
CRC::Generator<uint16_t, 0x0000, 0x0000, false, false> crc_;
|
2017-07-16 23:24:01 +00:00
|
|
|
Shifter shifter_;
|
2016-11-06 21:13:13 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
}
|