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 {
|
2024-12-02 02:44:14 +00:00
|
|
|
public:
|
|
|
|
Shifter();
|
2017-07-16 23:24:01 +00:00
|
|
|
|
2024-12-02 02:44:14 +00:00
|
|
|
void process_pulse(const Storage::Tape::Tape::Pulse &);
|
2017-07-16 23:24:01 +00:00
|
|
|
|
2024-12-02 02:44:14 +00:00
|
|
|
struct Delegate {
|
|
|
|
virtual void acorn_shifter_output_bit(int value) = 0;
|
|
|
|
};
|
|
|
|
void set_delegate(Delegate *delegate) {
|
|
|
|
delegate_ = delegate;
|
|
|
|
}
|
2017-07-16 23:24:01 +00:00
|
|
|
|
2024-12-02 02:44:14 +00:00
|
|
|
void digital_phase_locked_loop_output_bit(int value);
|
2017-07-16 23:24:01 +00:00
|
|
|
|
2024-12-02 02:44:14 +00:00
|
|
|
private:
|
|
|
|
Storage::DigitalPhaseLockedLoop<Shifter, 15> pll_;
|
|
|
|
bool was_high_;
|
2017-07-16 23:24:01 +00:00
|
|
|
|
2024-12-02 02:44:14 +00:00
|
|
|
unsigned int input_pattern_;
|
2017-07-16 23:24:01 +00:00
|
|
|
|
2024-12-02 02:44:14 +00:00
|
|
|
Delegate *delegate_;
|
2017-07-16 23:24:01 +00:00
|
|
|
};
|
|
|
|
|
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 {
|
2024-12-02 02:44:14 +00:00
|
|
|
public:
|
|
|
|
Parser();
|
|
|
|
|
|
|
|
int get_next_bit(const std::shared_ptr<Storage::Tape::Tape> &);
|
|
|
|
int get_next_byte(const std::shared_ptr<Storage::Tape::Tape> &);
|
|
|
|
unsigned int get_next_short(const std::shared_ptr<Storage::Tape::Tape> &);
|
|
|
|
unsigned int get_next_word(const std::shared_ptr<Storage::Tape::Tape> &);
|
|
|
|
void reset_crc();
|
|
|
|
uint16_t get_crc() const;
|
|
|
|
|
|
|
|
private:
|
|
|
|
void acorn_shifter_output_bit(int value) override;
|
|
|
|
void process_pulse(const Storage::Tape::Tape::Pulse &) override;
|
|
|
|
|
|
|
|
bool did_update_shifter(int new_value, int length);
|
|
|
|
CRC::Generator<uint16_t, 0x0000, 0x0000, false, false> crc_;
|
|
|
|
Shifter shifter_;
|
2016-11-06 21:13:13 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
}
|