From 0d02304dcf35303e83262527c391ec208405a77d Mon Sep 17 00:00:00 2001 From: Peder Bergebakken Sundt Date: Sat, 15 Aug 2020 15:48:53 +0200 Subject: [PATCH] Hook up the VGA controller in top, draw a circle --- fpga/icebreaker_vga.dg | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/fpga/icebreaker_vga.dg b/fpga/icebreaker_vga.dg index 870a550..ffe723a 100644 --- a/fpga/icebreaker_vga.dg +++ b/fpga/icebreaker_vga.dg @@ -5,6 +5,8 @@ import "/nmigen_dg/*" import "/subprocess" import "/sys" import "common/pipeline" +import "common/to_signed" +import "modules/vga/DviController12" import "resources/pmod" @@ -40,6 +42,9 @@ run_icepll = current target -> Top = subclass Elaboratable where elaborate = platform ~> m where with m = Module! => + # Configure DVI controller + dvi = Submodule$ DviController12 x:800 y:480 fps:60 + # setup clock default_clk = platform.request platform.default_clk dir:"-" @@ -50,7 +55,7 @@ Top = subclass Elaboratable where pll_config = run_icepll default_freq - 40e6 + dvi.pix_freq print dvi.timings print pll_config @@ -86,9 +91,20 @@ Top = subclass Elaboratable where Comb$ platform.request "led_g" :== ~state + # Feed a pciture to the DVI controller + Sync$ dvi.r :== 0x0 + Sync$ dvi.g :== 0x0 + Sync$ dvi.b :== 0x0 + cx = to_signed dvi.pixel_x - (800//2) + cy = to_signed dvi.pixel_y - (480//2) + When (cx*cx + cy*cy < 150**2) $ -> + Sync$ dvi.r :== 0xF + Sync$ dvi.g :== 0xF + Sync$ dvi.b :== 0xF + if __name__ == "__main__" => plat = ICEBreakerPlatform! plat.add_resources$ pmod.dvi_12bit 0 plat.add_resources$ plat.break_off_pmod - plat.build Top! do_program: ("--flash" in sys.argv) + plat.build Top! do_program: ("--flash" in sys.argv) synth_opts: "-dsp"