Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
dvisampler: character synchronization
- Loading branch information
Sebastien Bourdeauducq
committed
Mar 21, 2013
1 parent
7c4ca4f
commit 515cdb2
Showing
4 changed files
with
78 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
from migen.fhdl.structure import * | ||
from migen.fhdl.module import Module | ||
from migen.genlib.cdc import MultiReg | ||
from migen.genlib.misc import optree | ||
from migen.bank.description import * | ||
|
||
_control_tokens = [0b1101010100, 0b0010101011, 0b0101010100, 0b1010101011] | ||
|
||
class CharSync(Module, AutoReg): | ||
def __init__(self, required_controls=8): | ||
self.raw_data = Signal(10) | ||
self.char_synced = Signal() | ||
self.data = Signal(10) | ||
|
||
self._r_char_synced = RegisterField(1, READ_ONLY, WRITE_ONLY) | ||
|
||
### | ||
|
||
raw_data1 = Signal(10) | ||
self.sync.pix += raw_data1.eq(self.raw_data) | ||
raw = Signal(20) | ||
self.comb += raw.eq(Cat(raw_data1, self.raw_data)) | ||
|
||
found_control = Signal() | ||
control_position = Signal(max=10) | ||
for i in range(10): | ||
self.sync.pix += If(optree("|", [raw[i:i+10] == t for t in _control_tokens]), | ||
found_control.eq(1), | ||
control_position.eq(i) | ||
) | ||
|
||
control_counter = Signal(max=required_controls) | ||
previous_control_position = Signal(max=10) | ||
word_sel = Signal(max=10) | ||
self.sync.pix += [ | ||
If(found_control & (control_position == previous_control_position), | ||
If(control_counter == (required_controls - 1), | ||
control_counter.eq(0), | ||
self.char_synced.eq(1), | ||
word_sel.eq(control_position) | ||
).Else( | ||
control_counter.eq(control_counter + 1) | ||
) | ||
).Else( | ||
control_counter.eq(0) | ||
), | ||
previous_control_position.eq(control_position) | ||
] | ||
self.specials += MultiReg(self.char_synced, self._r_char_synced.field.w) | ||
|
||
self.sync.pix += self.data.eq(raw >> word_sel) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters