verilator/ runs the core on the host with the shared FM-7 / Apple-IIgs sim framework: windowed (ImGui/SDL2) or --headless, typing on a frame schedule, screenshots, text-screen dump, 6809 disassembly trace, floppy/SDC/cart/cassette, and RS-232 Pak serial debugging (TXD decoder, RXD driver, pty bridge, ACIA trace) with a minimal DriveWire server and a script to run the real FujiNet daemon against the sim. See verilator/README.md. - The VHDL the build uses (ROMs, RAMs, font) is converted to Verilog in verilator/rtl/; the VHDL CPU is not instantiated (CoCo3_CYC_ACC_6809). - sdram2.sv is simulated with its own controller logic and an SDR chip model. - run_tests.sh: boot, keyboard, disk, WIDTH 80 and HSCREEN tests, judged on the text screen and byte-for-byte against test-ref/ screenshots. rtl/wd1793.sv: spt_addr and buff_wr are declared at module scope instead of inside generate blocks. They are assigned outside those blocks; Quartus accepted it, Verilator rejected spt_addr and silently split buff_wr into a separate net. No change on the FPGA (FM-7 made the same fix). Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
63 lines
1.2 KiB
C++
63 lines
1.2 KiB
C++
#include "sim_audio.h"
|
|
#include <iostream>
|
|
#include <fstream>
|
|
#include <list>
|
|
using namespace std;
|
|
|
|
SimClock clk;
|
|
bool outputToFile;
|
|
ofstream audioFile;
|
|
|
|
SimAudio::SimAudio(int systemClockFrequency, bool saveToFile)
|
|
{
|
|
clk = SimClock(systemClockFrequency / 44100);
|
|
outputToFile = saveToFile;
|
|
}
|
|
|
|
SimAudio::~SimAudio()
|
|
{
|
|
|
|
}
|
|
|
|
void SimAudio::Clock(signed short left, signed short right) {
|
|
clk.Tick();
|
|
if (clk.IsRising()) {
|
|
// Output audio (left channel only for now)
|
|
float l = left / 32768.0f;
|
|
if (outputToFile) {
|
|
audioFile.write((const char*)&l, sizeof(float));
|
|
}
|
|
}
|
|
}
|
|
|
|
void SimAudio::CollectDebug(signed short left, signed short right) {
|
|
float vol_l = left / 32768.0f;
|
|
float vol_r = right / 32768.0f;
|
|
debug_pos++;
|
|
if (debug_pos == debug_max_samples) { debug_pos = 0; }
|
|
debug_wave_l[debug_pos] = vol_l;
|
|
debug_wave_r[debug_pos] = vol_r;
|
|
|
|
}
|
|
|
|
void SimAudio::Initialise() {
|
|
// Reset plot data
|
|
for (int c = 0; c < debug_max_samples; c++) {
|
|
debug_wave_l[c] = 0;
|
|
debug_wave_r[c] = 0;
|
|
debug_positions[c] = (double)c / (double)debug_max_samples;
|
|
}
|
|
if (outputToFile)
|
|
{
|
|
// Setup Audio output stream
|
|
audioFile.open("audio.wav", ios::binary);
|
|
}
|
|
}
|
|
void SimAudio::CleanUp() {
|
|
if (outputToFile)
|
|
{
|
|
audioFile.close();
|
|
}
|
|
}
|
|
|