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: 40abd66d6921
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: 1e1f7ce30e46
Choose a head ref
  • 8 commits
  • 9 files changed
  • 1 contributor

Commits on Apr 13, 2015

  1. Copy the full SHA
    cb473dd View commit details
  2. liteusb: pep8 (E302)

    enjoy-digital committed Apr 13, 2015
    Copy the full SHA
    4974fd6 View commit details
  3. liteusb: pep8 (E201)

    enjoy-digital committed Apr 13, 2015
    Copy the full SHA
    ce0e818 View commit details
  4. liteusb: pep8 (E231)

    enjoy-digital committed Apr 13, 2015
    Copy the full SHA
    9e3d3e7 View commit details
  5. liteusb: pep8 (E222)

    enjoy-digital committed Apr 13, 2015
    Copy the full SHA
    39df1ff View commit details
  6. liteusb: pep8 (E225)

    enjoy-digital committed Apr 13, 2015
    Copy the full SHA
    5343537 View commit details
  7. liteusb: pep8 (E265)

    enjoy-digital committed Apr 13, 2015
    Copy the full SHA
    f10e873 View commit details
  8. Copy the full SHA
    1e1f7ce View commit details
80 changes: 41 additions & 39 deletions misoclib/com/liteusb/common.py
Original file line number Diff line number Diff line change
@@ -1,58 +1,60 @@
import random

from migen.fhdl.std import *
from migen.genlib.fsm import *
from migen.actorlib.fifo import *
from migen.flow.actor import EndpointDescription

user_layout = EndpointDescription(
[ ("dst", 8),
("length", 4*8),
("error", 1),
("d", 8)
],
packetized=True
[("dst", 8),
("length", 4*8),
("error", 1),
("d", 8)
],
packetized=True
)

phy_layout = [
("d", 8)
]
phy_layout = [("d", 8)]


class LiteUSBPipe:
def __init__(self, layout):
self.sink = Sink(layout)
self.source = Source(layout)
def __init__(self, layout):
self.sink = Sink(layout)
self.source = Source(layout)


class LiteUSBTimeout(Module):
def __init__(self, clk_freq, length):
cnt_max = int(clk_freq*length)
width = bits_for(cnt_max)

self.clear = Signal()
self.done = Signal()

cnt = Signal(width)
self.sync += \
If(self.clear,
cnt.eq(0)
).Elif(~self.done,
cnt.eq(cnt+1)
)
self.comb += self.done.eq(cnt == cnt_max)
def __init__(self, clk_freq, length):
cnt_max = int(clk_freq*length)
width = bits_for(cnt_max)

self.clear = Signal()
self.done = Signal()

cnt = Signal(width)
self.sync += \
If(self.clear,
cnt.eq(0)
).Elif(~self.done,
cnt.eq(cnt+1)
)
self.comb += self.done.eq(cnt == cnt_max)


#
# TB
#
import random

def randn(max_n):
return random.randint(0, max_n-1)
return random.randint(0, max_n-1)


class RandRun:
def __init__(self, level=0):
self.run = True
self.level = level

def do_simulation(self, selfp):
self.run = True
n = randn(100)
if n < self.level:
self.run = False
def __init__(self, level=0):
self.run = True
self.level = level

def do_simulation(self, selfp):
self.run = True
n = randn(100)
if n < self.level:
self.run = False
31 changes: 16 additions & 15 deletions misoclib/com/liteusb/core/com.py
Original file line number Diff line number Diff line change
@@ -6,21 +6,22 @@
from misoclib.com.liteusb.core.packetizer import LiteUSBPacketizer
from misoclib.com.liteusb.core.depacketizer import LiteUSBDepacketizer


class LiteUSBCom(Module):
def __init__(self, phy, *ports):
# crossbar
self.submodules.crossbar = LiteUSBCrossbar(list(ports))
def __init__(self, phy, *ports):
# crossbar
self.submodules.crossbar = LiteUSBCrossbar(list(ports))

# packetizer / depacketizer
self.submodules.packetizer = LiteUSBPacketizer()
self.submodules.depacketizer = LiteUSBDepacketizer()
self.comb += [
self.crossbar.slave.source.connect(self.packetizer.sink),
self.depacketizer.source.connect(self.crossbar.slave.sink)
]
# packetizer / depacketizer
self.submodules.packetizer = LiteUSBPacketizer()
self.submodules.depacketizer = LiteUSBDepacketizer()
self.comb += [
self.crossbar.slave.source.connect(self.packetizer.sink),
self.depacketizer.source.connect(self.crossbar.slave.sink)
]

# phy
self.comb += [
self.packetizer.source.connect(phy.sink),
phy.source.connect(self.depacketizer.sink)
]
# phy
self.comb += [
self.packetizer.source.connect(phy.sink),
phy.source.connect(self.depacketizer.sink)
]
Loading