Skip to content

Commit

Permalink
improved vga controller
Browse files Browse the repository at this point in the history
  • Loading branch information
sylefeb committed Jul 13, 2024
1 parent 69e7552 commit 7eaad3c
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 17 deletions.
21 changes: 21 additions & 0 deletions frameworks/boards/brot/board.json
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,27 @@
{"cmd" : "dfu-suffix", "args" : "-v 1d50 -p 6146 -a build.dfu"},
{"cmd" : "dfu-util", "args" : "-a 0 -D build.dfu"}
]
},
{
"name": "edalize_no_abc9",
"builder" : "edalize",
"description": "Build using Edalize",
"tool": "icestorm",
"tool_options": [
{
"icepack_options": ["-s"],
"yosys_synth_options": ["-dsp","-device u","-top top"],
"nextpnr_options": ["--up5k", "--freq 12", "--package sg48", "-r", "--opt-timing"],
"pnr": "next"
}
],
"bitstream" : "build.bin",
"constraints": [{"name": "brot.pcf", "file_type": "PCF"}],
"program": [
{"cmd" : "cp", "args" : "build.bin build.dfu"},
{"cmd" : "dfu-suffix", "args" : "-v 1d50 -p 6146 -a build.dfu"},
{"cmd" : "dfu-util", "args" : "-a 0 -D build.dfu"}
]
}
]
}
Expand Down
44 changes: 27 additions & 17 deletions projects/common/vga.si
Original file line number Diff line number Diff line change
Expand Up @@ -86,31 +86,41 @@ $$VS_END = V_FRT_PORCH + V_SYNCH
$$VA_START = V_FRT_PORCH + V_SYNCH + V_BCK_PORCH
$$V_END = V_FRT_PORCH + V_SYNCH + V_BCK_PORCH + V_RES

uint12 xcount(0);
uint11 ycount(0);
int13 xcount(0);
int12 ycount(0);

uint12 pix_x <:: (xcount - $HA_START$);
uint11 pix_y <:: (ycount - $VA_START$);
uint1 active_h(0);
uint1 active_v(0);

uint1 active_h <:: (xcount >= $HA_START$ && xcount < $H_END$);
uint1 active_v <:: (ycount >= $VA_START$ && ycount < $VA_START + VGA_VA_END$);
always {

active := active_h && active_v;
active_h = xcount == 0 ? 1
: xcount == $H_END-HA_START$ ? 0
: active_h;
active_v = ycount == 0 ? 1
: ycount == $VGA_VA_END$ ? 0
: active_v;

vga_hs := ~((xcount >= $HS_START$ && xcount < $HS_END$));
vga_vs := ~((ycount >= $VS_START$ && ycount < $VS_END$));
// __display("%d %d h:%b v:%b",xcount,ycount,active_h,active_v);

vblank := (ycount < $VA_START$);
active = active_h && active_v;

always {
vga_x = active_h ? xcount : 0;
vga_y = active_v ? ycount : 0;

vga_hs = xcount == $HS_START-HA_START$ ? 0
: xcount == $HS_END-HA_START-1$ ? 1
: vga_hs;
vga_vs = ycount == $VS_START-VA_START$ ? 0
: ycount == $VS_END-VA_START-1$ ? 1
: vga_vs;

vga_x = active_h ? pix_x : 0;
vga_y = active_v ? pix_y : 0;
vblank = ycount[11,1]; // sign bit

if (xcount == $H_END-1$) {
xcount = 0;
if (ycount == $V_END-1$) {
ycount = 0;
if (xcount == $H_END-HA_START$) {
xcount = __signed($-HA_START+1$);
if (ycount == $V_END-VA_START$) {
ycount = __signed($-VA_START+1$);
} else {
ycount = ycount + 1;
}
Expand Down

0 comments on commit 7eaad3c

Please sign in to comment.