Skip to content

Commit

Permalink
Support for monochrome video and external config pins
Browse files Browse the repository at this point in the history
  • Loading branch information
harbaum committed Oct 4, 2023
1 parent dd1ca5a commit 6e3d81d
Show file tree
Hide file tree
Showing 16 changed files with 245 additions and 194 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@ impl/gwsynthesis/
impl/temp/
impl/pnr/
*.gprj.user
*.vcd
7 changes: 5 additions & 2 deletions sim/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,11 +56,14 @@ the testbench. It can be viewed by ```make video```.
[Video_tb](video_tb) is a test for the video generation. It displays
a static image and runs it through the ```scandoubler.v``` and
```video_analyzer.v```. This demo will also write an image file
for visial inspection.
for visual inspection.

The demo can also be run on real hardware. In that case the image
has to be copied to flash memory first:

```
$ openFPGALoader --external-flash -o 1048576 vmem32k.bin
$ openFPGALoader --external-flash -o 2097152 vmem32k.bin
```

If you want to test a monochrome video use ```mono32k.bin``` for
a monochrome test image.
3 changes: 3 additions & 0 deletions sim/video_tb/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,9 @@ video.png: video.rgb
elif [ $$(du -b $< | cut -f 1) = 941824 ]; then\
echo "scandoubled ST PAL";\
ffmpeg -vcodec rawvideo -f rawvideo -pix_fmt rgb444 -s 832x566 -i video.rgb -f image2 -vcodec png video.png;\
elif [ $$(du -b $< | cut -f 1) = 512000 ]; then\
echo "Monochrome ST";\
ffmpeg -vcodec rawvideo -f rawvideo -pix_fmt rgb444 -s 640x400 -i video.rgb -f image2 -vcodec png video.png;\
else \
echo "Unknown format";\
fi;
Expand Down
Binary file added sim/video_tb/mono32k.bin
Binary file not shown.
34 changes: 21 additions & 13 deletions sim/video_tb/sdram.gtkw
Original file line number Diff line number Diff line change
@@ -1,24 +1,24 @@
[*]
[*] GTKWave Analyzer v3.3.114 (w)1999-2023 BSI
[*] Sat Sep 30 17:48:54 2023
[*] Mon Oct 2 07:01:46 2023
[*]
[dumpfile] "gstmcu.vcd"
[dumpfile_mtime] "Sat Sep 30 17:48:28 2023"
[dumpfile_size] 724313343
[savefile] "sdram.gtkw"
[timestart] 3724000
[size] 1280 947
[dumpfile] "/home/tharbaum/tmp/private_stuff/mistlite/atarist/sim/video_tb/gstmcu.vcd"
[dumpfile_mtime] "Mon Oct 2 06:57:21 2023"
[dumpfile_size] 844299337
[savefile] "/home/tharbaum/tmp/private_stuff/mistlite/atarist/sim/video_tb/sdram.gtkw"
[timestart] 3637570
[size] 1920 1122
[pos] 0 0
*-19.000002 4399026 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1
*-11.400000 3653600 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1
[treeopen] TOP.
[treeopen] TOP.ste_tb.
[treeopen] TOP.ste_tb.gstshifter.
[treeopen] TOP.ste_tb.gstshifter.shifter_video.
[treeopen] TOP.ste_tb.sdram.
[sst_width] 209
[sst_width] 279
[signals_width] 236
[sst_expanded] 1
[sst_vpaned_height] 515
[sst_vpaned_height] 629
@28
TOP.porb
TOP.resb
Expand All @@ -34,8 +34,16 @@ TOP.HSYNC_N
@22
TOP.B[5:0]
TOP.R[5:0]
TOP.B[5:0]
TOP.ste_tb.G[5:0]
@24
TOP.ste_tb.video_analyzer.hcnt[12:0]
@25
TOP.ste_tb.video_analyzer.vcnt[9:0]
@22
TOP.ste_tb.gstshifter.R[3:0]
@28
TOP.ste_tb.gstshifter.shifter_video.notlow
TOP.ste_tb.gstshifter.shmode[1:0]
[color] 2
TOP.ste_tb.sdram.cs
@24
Expand All @@ -56,8 +64,8 @@ TOP.ste_tb.video_analyzer.vs
TOP.ste_tb.video_analyzer.hcntL[12:0]
TOP.ste_tb.video_analyzer.vcntL[9:0]
@28
TOP.ste_tb.video_analyzer.pal
@29
TOP.ste_tb.video_analyzer.changed
TOP.ste_tb.video_analyzer.mode[1:0]
TOP.ste_tb.gstshifter.DE
[pattern_trace] 1
[pattern_trace] 0
25 changes: 22 additions & 3 deletions sim/video_tb/ste_tb.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
#include "verilated.h"
#include "verilated_vcd_c.h"

#define MONO
// #define NTSC // undef for PAL

static Vste_tb *tb;
Expand All @@ -18,10 +19,14 @@ static unsigned char rom[8*1024*1024]; // 8 MB spi flash
void initrom() {
for(int i=0;i<sizeof(ram);i++) ram[i] = i;

// load ram into into space at 1 MB
// load ram into into space at 2 MB
#ifdef MONO
FILE *file=fopen("mono32k.bin", "rb");
#else
FILE *file=fopen("vmem32k.bin", "rb");
if(!file) { perror("opening vmem32k.bin"); exit(-1); }
fread(rom+0x100000, 32, 1000, file);
#endif
if(!file) { perror("opening mono/vmem32k.bin"); exit(-1); }
fread(rom+0x200000, 32, 1000, file);
fclose(file);
}

Expand Down Expand Up @@ -133,6 +138,12 @@ void dump() {
pix = 0;
}

#ifdef MONO
#define COLS 640
#define ROWS 400
#define COL1ST 149
#define ROW1ST 38
#else
#ifdef NTSC
#define COLS 848
#define ROWS 484
Expand All @@ -143,6 +154,7 @@ void dump() {
#define ROWS 566
#define COL1ST 82
#define ROW1ST 58
#endif
#endif

vsync = tb->VSYNC_N;
Expand Down Expand Up @@ -174,11 +186,18 @@ int main(int argc, char **argv) {
tb->trace(trace, 99);
trace->open("gstmcu.vcd");

#ifdef MONO
tb->mono_detect = 0; // 1 - color, 0 - mono
#else
tb->mono_detect = 1;

#ifdef NTSC
tb->ntsc = 1;
#else
tb->ntsc = 0;
#endif
#endif

tb->resb = 0;
tb->porb = 0; // 0=cold, 1=warm boot
tick(1);
Expand Down
Loading

0 comments on commit 6e3d81d

Please sign in to comment.