Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
targets: prepare atlys_edid_debug for debugging EDID signals with Lit…
…eScope
- Loading branch information
1 parent
d040a09
commit 168e844
Showing
4 changed files
with
95 additions
and
8 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,47 @@ | ||
from targets.atlys_hdmi2usb import * | ||
|
||
from misoclib.com.uart.phy import UARTPHY | ||
from misoclib.com import uart | ||
from misoclib.tools.wishbone import WishboneStreamingBridge | ||
|
||
class UARTVirtualPhy: | ||
def __init__(self): | ||
self.sink = Sink([("data", 8)]) | ||
self.source = Source([("data", 8)]) | ||
|
||
|
||
class EDIDDebugSoC(VideomixerSoC): | ||
def __init__(self, platform, with_uart=False, **kwargs): | ||
VideomixerSoC.__init__(self, platform, with_uart=with_uart, **kwargs) | ||
|
||
uart_sel = platform.request("user_dip", 0) | ||
self.comb += platform.request("user_led", 0).eq(uart_sel) | ||
|
||
self.submodules.uart_phy = UARTPHY(platform.request("serial"), self.clk_freq, 115200) | ||
uart_phys = { | ||
"cpu": UARTVirtualPhy(), | ||
"bridge": UARTVirtualPhy() | ||
} | ||
self.comb += [ | ||
If(uart_sel, | ||
Record.connect(self.uart_phy.source, uart_phys["bridge"].source), | ||
Record.connect(uart_phys["bridge"].sink, self.uart_phy.sink), | ||
uart_phys["cpu"].source.ack.eq(1) # avoid stalling cpu | ||
).Else( | ||
Record.connect(self.uart_phy.source, uart_phys["cpu"].source), | ||
Record.connect(uart_phys["cpu"].sink, self.uart_phy.sink), | ||
uart_phys["bridge"].source.ack.eq(1) # avoid stalling bridge | ||
) | ||
] | ||
|
||
# UART cpu | ||
self.submodules.uart = uart.UART(uart_phys["cpu"]) | ||
|
||
# UART bridge | ||
self.submodules.bridge = WishboneStreamingBridge(uart_phys["bridge"], self.clk_freq) | ||
self.add_wb_master(self.bridge.wishbone) | ||
|
||
# XXX add LiteScope on EDID lines | ||
|
||
|
||
default_subtarget = EDIDDebugSoC |
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,31 @@ | ||
#!/usr/bin/env python3 | ||
import argparse | ||
import importlib | ||
|
||
|
||
def _get_args(): | ||
parser = argparse.ArgumentParser() | ||
parser.add_argument("-b", "--bridge", default="uart", help="Bridge to use") | ||
parser.add_argument("--port", default="3", help="UART port") | ||
parser.add_argument("--baudrate", default=115200, help="UART baudrate") | ||
parser.add_argument("--busword", default=8, help="CSR busword") | ||
|
||
parser.add_argument("test", nargs="+", help="specify a test") | ||
|
||
return parser.parse_args() | ||
|
||
if __name__ == "__main__": | ||
args = _get_args() | ||
if args.bridge == "uart": | ||
from misoclib.com.uart.software.wishbone import UARTWishboneBridgeDriver | ||
port = args.port if not args.port.isdigit() else int(args.port) | ||
wb = UARTWishboneBridgeDriver(port, args.baudrate, "../csr.csv", int(args.busword), debug=False) | ||
else: | ||
ValueError("Invalid bridge {}".format(args.bridge)) | ||
|
||
def _import(name): | ||
return importlib.import_module(name) | ||
|
||
for test in args.test: | ||
t = _import(test) | ||
t.main(wb) |
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,9 @@ | ||
def main(wb): | ||
wb.open() | ||
regs = wb.regs | ||
# # # | ||
print("sysid : 0x{:04x}".format(regs.identifier_sysid.read())) | ||
print("revision : 0x{:04x}".format(regs.identifier_revision.read())) | ||
print("frequency : {}MHz".format(int(regs.identifier_frequency.read()/1000000))) | ||
# # # | ||
wb.close() |