Пример #1
0
from bdp import block, cap, path, text, fig, prev, p, poffx

part = block(text_margin=p(0.5, 0.5),
             alignment="nw",
             dotted=True,
             group='tight',
             group_margin=[p(1, 3), p(1, 2)])

comp = block(size=p(4, 4), nodesep=(6, 2))
ps_comp = block(size=p(6, 6), nodesep=(2, 3))
bus_cap = cap(length=0.4, width=0.6, inset=0, type='Stealth')
bus = path(style=(None, bus_cap),
           line_width=0.3,
           double=True,
           border_width=0.06)
bus_text = text(font="\\scriptsize", margin=p(0, 0.5))

functor = part("Tuple fmap")
functor['split'] = comp("split", size=(4, 4))
functor['f1'] = comp(r"$\times 2$",
                     size=(4, 3)).right(functor['split']).aligny(
                         functor['split'].w(1),
                         prev().s(0))
functor['f2'] = comp(r"$\times 2$", size=(4, 3)).below(functor['f1'])

functor['concat'] = comp("ccat", size=(4, 4)).right(functor['f1']).aligny(
    functor['split'].p)

prod2split = bus(functor['split'].w(0.5) - p(4, 0), functor['split'].w(0.5))
fig << prod2split
fig << bus_text("(u16, u16)").align(prod2split.pos(0.5), prev().s(0.5, 0.2))
Пример #2
0
from bdp import block, p, group, cap, path, text, fig, prev, render_fig

bus_cap = cap(length=0.4, width=0.6, inset=0, type='Stealth')
bus = path(color="black!40",
           style=('', bus_cap),
           shorten=p(0.2, 0.2),
           line_width=0.3,
           border_width=0.06,
           double=True)
bus_text = text(font="\\footnotesize", margin=p(0.4, 0.2))

gear = block(size=p(4, 2), nodesep=p(2, 2))

echo_sim = block("mono_echo_sim",
                 text_margin=p(0.5, 0.5),
                 alignment="nw",
                 dotted=True,
                 group='tight',
                 group_margin=[p(2, 3), p(2, 1)],
                 text_font="\\Large")

echo_sim['drv'] = gear('drv')
echo_sim['echo'] = gear('echo').right(echo_sim['drv'])
echo_sim['collect'] = gear('collect').right(echo_sim['echo'])

fig << bus(echo_sim['drv'].e(0.5), echo_sim['echo'].w(0.5))
fig << bus(echo_sim['echo'].e(0.5), echo_sim['collect'].w(0.5))

fig << echo_sim

# render_fig(fig)
Пример #3
0
from bdp import block, p, group, cap, path, text, fig, prev, render_fig, poffx

bus_cap = cap(length=0.4, width=0.6, inset=0, type='Stealth')
bus = path(
    color="black!40",
    style=('', bus_cap),
    shorten=p(0.2, 0.2),
    line_width=0.3,
    border_width=0.06,
    double=True)
bus_text = text(font="\\footnotesize", margin=p(0.5, 0.35))

gear = block(size=p(6, 4), nodesep=p(2, 2))

fig['drv'] = gear('drv', size=p(6, 2))
fig['riscv'] = gear('riscv').right(fig['drv'], 3)
fig['register_file'] = gear('register_file').below(fig['riscv'])

fig << bus(fig['drv'].e(1), fig['riscv'].w(1))
fig << bus_text("instruction").align(fig[-1].pos(0), prev().s())
fig << bus(
    fig['riscv'].e(1), poffx(7), fig['register_file'].e(3), routedef='|-')
fig << bus_text("reg_file_rd_req").align(fig[-1].pos(0), prev().s())

fig << bus(
    fig['riscv'].e(3), poffx(5), fig['register_file'].e(1), routedef='|-')
fig << bus_text("reg_file_wr_req").align(fig[-1].pos(0), prev().s())

fig << bus(
    fig['register_file'].w(0.5), poffx(-3), fig['riscv'].w(3), routedef='|-')
fig << bus_text("reg_rd_data").align(fig[-1].pos(1.0), prev().s(1.1))
Пример #4
0
from bdp import block, p, group, cap, path, text, poffx, poffy, prectx, fig, render_fig, cur, prev

mul_block = block("x", size=p(2, 2), shape='circle')
add_block = block("+", size=p(2, 2), shape='circle')
bus_cap = cap(length=0.4, width=0.6, inset=0, type='Stealth')
bus = path(color="black!40",
           style=('', bus_cap),
           shorten=p(0.2, 0.2),
           line_width=0.3,
           border_width=0.06,
           double=True)
bus_text = text(font="\\footnotesize", margin=p(0.4, 0.4))

echo = block("echo",
             text_margin=p(0.5, 0.5),
             alignment="nw",
             dotted=True,
             group='tight',
             group_margin=[p(1, 3), p(2, 1)],
             text_font="\\Large")


def make_external(pos, direction='o', pin_extrude=1.5, **kwds):
    if direction == 'o':
        style = ('', bus_cap)
    else:
        style = (bus_cap, '')
    return bus(pos,
               poffx(echo.w() - pos - p(pin_extrude, 0)),
               style=style,
               **kwds)