SILICON
Loading...
Searching...
No Matches
siliconWaveform.hpp
Go to the documentation of this file.
1/*
2 Copyright (c) 2026. Giulio Cocconi
3
4 This program is free software: you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation, either version 3 of the License, or
7 (at your option) any later version.
8
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
13
14 You should have received a copy of the GNU General Public License
15 along with this program. If not, see <http://www.gnu.org/licenses/>.
16 */
17
18#pragma once
19
20#include <cstdint>
21#include <span>
22#include <string>
23#include <string_view>
24#include <vector>
25
27#include <core/wire.hpp>
28
29namespace SILICON::waveform {
30
31struct Signal {
32 std::string name;
33 std::size_t width = 1;
34};
35
36struct Sample {
37 uint64_t time = 0;
38 std::vector<core::BusValue> values;
39};
40
41struct Trace {
42 std::vector<Signal> signalDefinitions;
43 std::vector<Sample> samples;
44 int inputCount = 0;
45};
46
47void resetTrace(Trace& trace, std::vector<Signal> signalDefinitions, int inputCount);
48
49void appendSnapshot(Trace& trace, uint64_t time, std::vector<core::BusValue> values);
50
51void appendSnapshots(Trace& trace, std::span<const Sample> samples);
52
53[[nodiscard]] std::size_t signalWidth(const Trace& trace, int signalIndex);
54
55void rebuildEditableTrace(Trace& trace, uint64_t duration);
56
57void applyEditInterval(Trace& trace, uint64_t duration, int signalIndex,
58 uint64_t startTime, uint64_t endTime,
59 const core::BusValue& rawValue);
60
61[[nodiscard]] std::vector<Sample> editedInputSamples(const Trace& trace);
62
63} // namespace SILICON::waveform
64
65namespace SILICON::waveform::fst {
66
67void writeTrace(std::string_view fileName, const waveform::Trace& trace);
68
69void writeTrace(std::string_view fileName, const waveform::Trace& trace,
70 TraceWriter::Options options);
71
72} // namespace SILICON::waveform::fst
std::vector< State > BusValue
Definition wire.hpp:120
void writeTrace(std::string_view fileName, const Trace &trace)
void appendSnapshot(Trace &trace, const uint64_t time, std::vector< core::BusValue > values)
std::vector< Sample > editedInputSamples(const Trace &trace)
void applyEditInterval(Trace &trace, uint64_t duration, int signalIndex, uint64_t startTime, uint64_t endTime, const core::BusValue &rawValue)
void rebuildEditableTrace(Trace &trace, const uint64_t duration)
void resetTrace(Trace &trace, std::vector< Signal > signalDefinitions, const int inputCount)
std::size_t signalWidth(const Trace &trace, const int signalIndex)
void appendSnapshots(Trace &trace, std::span< const Sample > snapshots)
std::vector< core::BusValue > values
std::vector< Signal > signalDefinitions
std::vector< Sample > samples