From 312256a18d31916cb8f1f28f119cf11c5719fca4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Robert=20J=C3=B6rdens?= Date: Fri, 7 Sep 2018 15:30:04 +0200 Subject: [PATCH] grabber: fix frame size off-by-1 --- artiq/firmware/libboard_artiq/grabber.rs | 6 +++++- artiq/gateware/grabber/core.py | 12 +++++++----- 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/artiq/firmware/libboard_artiq/grabber.rs b/artiq/firmware/libboard_artiq/grabber.rs index 2973dc2e9..ba5e2a4db 100644 --- a/artiq/firmware/libboard_artiq/grabber.rs +++ b/artiq/firmware/libboard_artiq/grabber.rs @@ -134,8 +134,12 @@ pub fn tick() { if clock_pattern_ok(g) { let last_xy = get_last_pixels(g); if last_xy != unsafe { INFO[g].frame_size } { + // x capture is on ~LVAL which is after + // the last increment on DVAL + // y capture is on ~FVAL which coincides with the + // last increment on ~LVAL info!("grabber{} frame size: {}x{}", - g, last_xy.0 + 1, last_xy.1 + 1); + g, last_xy.0, last_xy.1 + 1); unsafe { INFO[g].frame_size = last_xy } } State::Watch diff --git a/artiq/gateware/grabber/core.py b/artiq/gateware/grabber/core.py index 60c40ce2d..4baaf98c3 100644 --- a/artiq/gateware/grabber/core.py +++ b/artiq/gateware/grabber/core.py @@ -89,14 +89,16 @@ class Parser(Module, AutoCSR): pix.x.eq(pix.x + 1), ), If(~lval, - If(last_lval, last_x.eq(pix.x)), - pix.x.eq(0), - If(last_fval & last_lval, + If(last_lval, + last_x.eq(pix.x), pix.y.eq(pix.y + 1) - ) + ), + pix.x.eq(0) ), If(~fval, - If(last_fval, last_y.eq(pix.y)), + If(last_fval, + last_y.eq(pix.y) + ), pix.y.eq(0) ) ]