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: 4259699d7819
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: ad01dc8a7445
Choose a head ref
  • 4 commits
  • 4 files changed
  • 1 contributor

Commits on May 5, 2013

  1. dvisampler/decoding: hold C when DE=1

    Sebastien Bourdeauducq committed May 5, 2013
    Copy the full SHA
    71e3bba View commit details
  2. dvisampler: add sync polarity detection module (thanks Lars for sugge…

    …stions)
    Sebastien Bourdeauducq committed May 5, 2013
    Copy the full SHA
    e3e1dcd View commit details
  3. dvisampler/resdetection: use DE instead of hsync

    Sebastien Bourdeauducq committed May 5, 2013
    Copy the full SHA
    ea20b74 View commit details
  4. software/videomixer: use new resdetection regs

    Sebastien Bourdeauducq committed May 5, 2013
    Copy the full SHA
    ad01dc8 View commit details
Showing with 77 additions and 55 deletions.
  1. +1 −4 milkymist/dvisampler/decoding.py
  2. +24 −46 milkymist/dvisampler/resdetection.py
  3. +49 −0 milkymist/dvisampler/syncpol.py
  4. +3 −5 software/videomixer/main.c
5 changes: 1 addition & 4 deletions milkymist/dvisampler/decoding.py
Original file line number Diff line number Diff line change
@@ -13,10 +13,7 @@ def __init__(self):

###

self.sync.pix += [
self.output.de.eq(1),
self.output.c.eq(0)
]
self.sync.pix += self.output.de.eq(1)
for i, t in enumerate(control_tokens):
self.sync.pix += If(self.input == t,
self.output.de.eq(0),
70 changes: 24 additions & 46 deletions milkymist/dvisampler/resdetection.py
Original file line number Diff line number Diff line change
@@ -4,68 +4,46 @@
from migen.bank.description import *

class ResolutionDetection(Module, AutoCSR):
def __init__(self, nbits=10):
self.hsync = Signal()
def __init__(self, nbits=11):
self.vsync = Signal()
self.de = Signal()

self._hres = CSRStatus(nbits)
self._vres = CSRStatus(nbits)
self._de_cycles = CSRStatus(2*nbits)

###

# HRES/VRES
hsync_r = Signal()
vsync_r = Signal()
p_hsync = Signal()
p_vsync = Signal()
self.sync.pix += [
hsync_r.eq(self.hsync),
vsync_r.eq(self.vsync),
]
self.comb += [
p_hsync.eq(self.hsync & ~hsync_r),
p_vsync.eq(self.vsync & ~vsync_r)
]
# Detect DE transitions
de_r = Signal()
pn_de = Signal()
self.sync.pix += de_r.eq(self.de)
self.comb += pn_de.eq(~self.de & de_r)

# HRES
hcounter = Signal(nbits)
vcounter = Signal(nbits)
self.sync.pix += [
If(p_hsync,
hcounter.eq(0)
).Elif(self.de,
self.sync.pix += If(self.de,
hcounter.eq(hcounter + 1)
),
If(p_vsync,
vcounter.eq(0)
).Elif(p_hsync,
vcounter.eq(vcounter + 1)
).Else(
hcounter.eq(0)
)
]

hcounter_st = Signal(nbits)
vcounter_st = Signal(nbits)
self.sync.pix += [
If(p_hsync & (hcounter != 0), hcounter_st.eq(hcounter)),
If(p_vsync & (vcounter != 0), vcounter_st.eq(vcounter))
]
self.sync.pix += If(pn_de, hcounter_st.eq(hcounter))
self.specials += MultiReg(hcounter_st, self._hres.status)
self.specials += MultiReg(vcounter_st, self._vres.status)

# DE
de_r = Signal()
pn_de = Signal()
self.sync.pix += de_r.eq(self.de)
self.comb += pn_de.eq(~self.de & de_r)
# VRES
vsync_r = Signal()
p_vsync = Signal()
self.sync.pix += vsync_r.eq(self.vsync),
self.comb += p_vsync.eq(self.vsync & ~vsync_r)

decounter = Signal(2*nbits)
self.sync.pix += If(self.de,
decounter.eq(decounter + 1)
).Else(
decounter.eq(0)
vcounter = Signal(nbits)
self.sync.pix += If(p_vsync,
vcounter.eq(0)
).Elif(pn_de,
vcounter.eq(vcounter + 1)
)

decounter_st = Signal(2*nbits)
self.sync.pix += If(pn_de, decounter_st.eq(decounter))
self.specials += MultiReg(decounter_st, self._de_cycles.status)
vcounter_st = Signal(nbits)
self.sync.pix += If(p_vsync, vcounter_st.eq(vcounter))
self.specials += MultiReg(vcounter_st, self._vres.status)
49 changes: 49 additions & 0 deletions milkymist/dvisampler/syncpol.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
from migen.fhdl.structure import *
from migen.fhdl.module import Module
from migen.genlib.record import Record

from milkymist.dvisampler.common import channel_layout

class SyncPolarity(Module):
def __init__(self):
self.valid_i = Signal()
self.data_in0 = Record(channel_layout)
self.data_in1 = Record(channel_layout)
self.data_in2 = Record(channel_layout)

self.valid_o = Signal()
self.de = Signal()
self.hsync = Signal()
self.vsync = Signal()
self.r = Signal(8)
self.g = Signal(8)
self.b = Signal(8)

###

de = self.data_in0.de
de_r = Signal()
c = self.data_in0.c
c_polarity = Signal(2)
c_out = Signal(2)

self.comb += [
self.de.eq(de_r),
self.hsync.eq(c_out[0]),
self.vsync.eq(c_out[1])
]

self.sync.pix += [
self.valid_o.eq(self.valid_i),
self.r.eq(self.data_in2.d),
self.g.eq(self.data_in1.d),
self.b.eq(self.data_in0.d),

de_r.eq(de),
If(de_r & ~de,
c_polarity.eq(c),
c_out.eq(0)
).Else(
c_out.eq(c ^ c_polarity)
)
]
8 changes: 3 additions & 5 deletions software/videomixer/main.c
Original file line number Diff line number Diff line change
@@ -10,7 +10,7 @@ static int d0, d1, d2;

static void print_status(void)
{
printf("Ph: %4d %4d %4d // %d%d%d [%d %d %d] // %d // %dx%d // %d\n", d0, d1, d2,
printf("Ph: %4d %4d %4d // %d%d%d [%d %d %d] // %d // %dx%d\n", d0, d1, d2,
dvisampler0_data0_charsync_char_synced_read(),
dvisampler0_data1_charsync_char_synced_read(),
dvisampler0_data2_charsync_char_synced_read(),
@@ -19,8 +19,7 @@ static void print_status(void)
dvisampler0_data2_charsync_ctl_pos_read(),
dvisampler0_chansync_channels_synced_read(),
dvisampler0_resdetection_hres_read(),
dvisampler0_resdetection_vres_read(),
dvisampler0_resdetection_de_cycles_read());
dvisampler0_resdetection_vres_read());
}

static void calibrate_delays(void)
@@ -100,7 +99,6 @@ static int init_phase(void)

static void vmix(void)
{
int i;
unsigned int counter;

while(1) {
@@ -118,7 +116,7 @@ static void vmix(void)
counter++;
if(counter == 2000000) {
print_status();
//adjust_phase();
adjust_phase();
counter = 0;
}
}