Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: m-labs/misoc
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: 581cf5bcb898
Choose a base ref
...
head repository: m-labs/misoc
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 45797f9132b9
Choose a head ref
  • 4 commits
  • 4 files changed
  • 1 contributor

Commits on May 16, 2013

  1. Add GPIO buttons and LEDs

    Sebastien Bourdeauducq committed May 16, 2013
    Copy the full SHA
    71cc2db View commit details
  2. software/videomixer: better pot calibration

    Sebastien Bourdeauducq committed May 16, 2013
    Copy the full SHA
    ac64701 View commit details
  3. software/videomixer: support additive blending (enable with SW1, stat…

    …us on LED)
    Sebastien Bourdeauducq committed May 16, 2013
    Copy the full SHA
    a39bf8c View commit details
  4. framebuffer: saturate instead of overflow

    Sebastien Bourdeauducq committed May 16, 2013
    Copy the full SHA
    45797f9 View commit details
Showing with 73 additions and 13 deletions.
  1. +7 −3 milkymist/framebuffer/__init__.py
  2. +20 −0 milkymist/gpio/__init__.py
  3. +40 −9 software/videomixer/main.c
  4. +6 −1 top.py
10 changes: 7 additions & 3 deletions milkymist/framebuffer/__init__.py
Original file line number Diff line number Diff line change
@@ -75,10 +75,14 @@ def __init__(self, nimages, latency):
for component in ["r", "g", "b"]:
incomps = [getattr(pix, component) for pix in inpixs]
outcomp = getattr(outpix, component)
outcomp_full = Signal(18)
outcomp_full = Signal(19)
self.comb += [
outcomp_full.eq(sum(incomp*factor for incomp, factor in zip(incomps, factors))),
outcomp.eq(outcomp_full[8:])
If(outcomp_full[18],
outcomp.eq(2**10 - 1) # saturate on overflow
).Else(
outcomp.eq(outcomp_full[8:18])
)
]

pipe_stmts = []
@@ -90,7 +94,7 @@ def __init__(self, nimages, latency):
self.comb += self.source.payload.eq(outval)

class MixFramebuffer(Module, AutoCSR):
def __init__(self, pads, *asmiports, blender_latency=4):
def __init__(self, pads, *asmiports, blender_latency=5):
pack_factor = asmiports[0].hub.dw//(2*bpp)
packed_pixels = structuring.pack_layout(pixel_layout, pack_factor)

20 changes: 20 additions & 0 deletions milkymist/gpio/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
from migen.fhdl.structure import *
from migen.fhdl.module import Module
from migen.genlib.cdc import MultiReg
from migen.bank.description import *

class GPIOIn(Module, AutoCSR):
def __init__(self, signal):
self._r_in = CSRStatus(len(signal))
self.specials += MultiReg(signal, self._r_in.status)

class GPIOOut(Module, AutoCSR):
def __init__(self, signal):
self._r_out = CSRStorage(len(signal))
self.comb += signal.eq(self._r_out.storage)

class Blinker(Module):
def __init__(self, signal, divbits=26):
counter = Signal(divbits)
self.comb += signal.eq(counter[divbits-1])
self.sync += counter.eq(counter + 1)
49 changes: 40 additions & 9 deletions software/videomixer/main.c
Original file line number Diff line number Diff line change
@@ -13,8 +13,8 @@

static int scale_pot(int raw, int range)
{
int pot_min = 54000;
int pot_max = 105400;
int pot_min = 64000;
int pot_max = 103000;
int scaled;

scaled = range*(raw - pot_min)/(pot_max - pot_min);
@@ -25,20 +25,51 @@ static int scale_pot(int raw, int range)
return scaled;
}

static void pots_service(void)
static void regular_blend(int p0, int p1)
{
static int last_event;
int blackout;
int crossfade;

blackout = scale_pot(p0, 256);
crossfade = scale_pot(p1, 255);

fb_blender_f0_write(crossfade*blackout >> 8);
fb_blender_f1_write((255-crossfade)*blackout >> 8);
}

static void additive_blend(int p0, int p1)
{
fb_blender_f0_write(scale_pot(p0, 255));
fb_blender_f1_write(scale_pot(p1, 255));
}

static void pots_service(void)
{
static int last_event;
static int additive_blend_enabled;
static int old_btn;
int btn;
int p0, p1;

if(elapsed(&last_event, identifier_frequency_read()/32)) {
btn = buttons_in_read() & 0x1;
if(btn && !old_btn) {
additive_blend_enabled = !additive_blend_enabled;
if(additive_blend_enabled)
leds_out_write(leds_out_read() | 0x1);
else
leds_out_write(leds_out_read() & ~0x1);
}
old_btn = btn;

pots_start_busy_write(1);
while(pots_start_busy_read());
blackout = scale_pot(pots_res0_read(), 256);
crossfade = scale_pot(pots_res1_read(), 255);

fb_blender_f0_write(crossfade*blackout >> 8);
fb_blender_f1_write((255-crossfade)*blackout >> 8);
p0 = pots_res0_read();
p1 = pots_res1_read();
if(!additive_blend_enabled)
regular_blend(p0, p1);
else
additive_blend(p0, p1);
}
}

7 changes: 6 additions & 1 deletion top.py
Original file line number Diff line number Diff line change
@@ -8,7 +8,8 @@
from migen.bank import csrgen

from milkymist import m1crg, lm32, norflash, uart, s6ddrphy, dfii, asmicon, \
identifier, timer, minimac3, framebuffer, asmiprobe, dvisampler, counteradc
identifier, timer, minimac3, framebuffer, asmiprobe, dvisampler, \
counteradc, gpio
from cif import get_macros

version = get_macros("common/version.h")["VERSION"][1:-1]
@@ -78,6 +79,8 @@ class SoC(Module):
"dvisampler1": 10,
"dvisampler1_edid_mem": 11,
"pots": 12,
"buttons": 13,
"leds": 14
}

interrupt_map = {
@@ -152,6 +155,8 @@ def __init__(self, platform):
pots_pads = platform.request("dvi_pots")
self.submodules.pots = counteradc.CounterADC(pots_pads.charge,
[pots_pads.blackout, pots_pads.crossfade])
self.submodules.buttons = gpio.GPIOIn(Cat(platform.request("user_btn", 0), platform.request("user_btn", 2)))
self.submodules.leds = gpio.GPIOOut(Cat(*[platform.request("user_led", i) for i in range(2)]))

self.submodules.csrbankarray = csrgen.BankArray(self,
lambda name, memory: self.csr_map[name if memory is None else name + "_" + memory.name_override])