BASIC: file dates and data files
DATE "YYYY-MM-DD[ HH:MM[:SS]]" sets a clock kept from the millisecond counter, DATE prints it and DATE$ returns it. Directory entries now record each file's creation date (format BFS2; a BFS1 directory is widened when read), and DIR shows it. send-bas.py and get-bas.py set the date from the PC when they connect (--no-date to skip). Data files: OPEN "NAME" FOR INPUT|OUTPUT|APPEND AS #n (n = 1-3), PRINT #n, INPUT #n, LINE INPUT [#n,], EOF(n), CLOSE [#n]. SAVE and LOAD now use the same channel code. A written file replaces the old one only at CLOSE; APPEND shares the old file's full blocks and copies the last part block. New errors FILE ALREADY OPEN, FILE NOT OPEN, INPUT PAST END; PROGRAM TOO BIG TO SAVE becomes FILE TOO BIG. The program area shrinks from 23000 to 22100 bytes to keep the stack at about 3 KB beside the file buffers. Code now ends at 7EBFh. The simulation sets the date, checks it in DIR and round-trips a data file, waiting for expected rows instead of fixed delays. Tested on the board: dates, write/append/read, EOF, the BFS1 conversion. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
29a15bf7c7
commit
767377f38d
9 files changed
+11631
-11174
No files matched your search
+25
-3
@@ -147,6 +147,24 @@ module tb_terminal;
|
||||
end
|
||||
endtask
|
||||
|
||||
// wait (up to 100 ms) for a row to read want, then check it
|
||||
task wait_row(input integer rr, input [8*40-1:0] want);
|
||||
integer cc, n;
|
||||
reg [8*40-1:0] got;
|
||||
realtime t0;
|
||||
begin
|
||||
t0 = $realtime;
|
||||
n = 0;
|
||||
for (cc = 0; cc < 40; cc = cc + 1) if (want[cc*8 +: 8] != 0) n = cc + 1;
|
||||
got = 0;
|
||||
while (got != want && $realtime - t0 < 100_000_000) begin
|
||||
#100_000;
|
||||
for (cc = 0; cc < n; cc = cc + 1) got[(n - 1 - cc) * 8 +: 8] = cellraw(rr, cc);
|
||||
end
|
||||
expect_row(rr, want);
|
||||
end
|
||||
endtask
|
||||
|
||||
// capture one frame
|
||||
reg [11:0] fb [0:640*480-1];
|
||||
reg cap = 0, smp = 0;
|
||||
@@ -286,12 +304,12 @@ module tb_terminal;
|
||||
capture_frame("frame_3.ppm");
|
||||
|
||||
// ---- files in the flash, and the bitstream protection
|
||||
uart_str({"CLS:NEW\01510 PRINT \"SAVED\";6*7\015SAVE \"TEST1\"\015NEW\015",
|
||||
uart_str({"CLS:DATE \"2026-11-28 09:30\":NEW\01510 PRINT \"SAVED\";6*7\015SAVE \"TEST1\"\015NEW\015",
|
||||
"LOAD \"TEST1\"\015RUN\015DIR\015"});
|
||||
#20_000_000;
|
||||
expect_row(13, "SAVED 42");
|
||||
expect_row(17, "TEST1 21");
|
||||
expect_row(18, "1 FILE, 1780K FREE");
|
||||
wait_row(17, "TEST1 21 2026-11-28 09:30");
|
||||
wait_row(18, "1 FILE, 1780K FREE");
|
||||
uart_str("OUT 64,1:OUT 65,6:OUT 64,0:OUT 64,1:OUT 65,32:OUT 65,0:OUT 65,0:OUT 65,0:OUT 64,0\015");
|
||||
#3_000_000;
|
||||
if (flash.programs > 0 && flash.erases > 0 && flash.violations == 0)
|
||||
@@ -303,6 +321,10 @@ module tb_terminal;
|
||||
errors = errors + 1;
|
||||
end
|
||||
|
||||
// ---- a data file: write it, read it back
|
||||
uart_str({"CLS:OPEN \"D\" FOR OUTPUT AS 1:PRINT #1,\"XY\";\",\";7:CLOSE\015",
|
||||
"OPEN \"D\" FOR INPUT AS 1:INPUT #1,A$,B:PRINT A$;B*6;EOF(1):CLOSE\015"});
|
||||
wait_row(3, "XY 42 -1");
|
||||
dump_screen;
|
||||
if (errors == 0) $display("ALL TESTS PASSED");
|
||||
else $display("%0d TESTS FAILED", errors);
|
||||
|
||||
Reference in new issue
Block a user