一个用于操作顺序门和逆变门的python库。

py-aiger的Python项目详细描述


<图>py-aiger logo <;figcaption>; pyaiger:一个用于操作sequential和 组合电路。 <;/figcaptiton>; <;/数字>;

Build StatuscodecovUpdates

PyPI versionLicense: MITDOI

目录

关于pyaiger

  1. 问:py aiger的发音如何?A:像“派”+“GRRR”。
  2. 问:为什么是Python?你不担心表现吗?!A:不,这个库的目标是易用性和可破解性。
  3. 问:不,我真的很关心表演!A:这个库不适合实现逻辑求解器。对于其他一切,比如在解算器调用之间创建和操作具有数千个门的电路,这个库确实足够快。
  4. 问:这个名字是从哪里来的?a:Aiger是一种流行的电路格式。格式在hardware model checkingsynthesis中使用,并由ABC支持。这个名字是aig(代表And-Inverter-Graph)和奥地利山Eiger的组合。

安装

如果您只需要使用aiger,您可以运行:

$ pip install py-aiger

对于开发人员,请注意此项目使用 poetrypython包/依赖项 管理工具。请熟悉它,然后 运行:

$ poetry install

布尔表达式dsl

虽然功能强大,但在编写组合电路时, 电路dsl可能有些笨拙。对于这个常见的用例,我们有 开发了布尔表达式dsl。所有电路都是这样产生的 只有一个输出。

importaigerx,y,z=aiger.atom('x'),aiger.atom('y'),aiger.atom('z')expr1=x&y# circuit with inputs 'x', 'y' and 1 output computing x AND y.expr2=x|y# logical or.expr3=x^y# logical xor.expr4=x==y# logical ==, xnor.expr5=x.implies(y)expr6=~x# logical negation.expr7=aiger.ite(x,y,z)# if x then y else z.# Atoms can be constants.expr8=x&aiger.atom(True)# Equivilent to just x.expr9=x&aiger.atom(False)# Equivilent to const False.# And you can inspect the AIG if needed.circ=x.aig# And of course, you can get a BoolExpr from a single output aig.expr10=aiger.BoolExpr(circ)

时序电路dsl

importaigerfromaigerimportutils# Parser for ascii AIGER format.aig1=aiger.load(path_to_aig1_file.aag)aig2=aiger.load(path_to_aig2_file.aag)

顺序合成

aig3=aig1>>aig2

平行组合

aig4=aig1|aig2

带锁存器/反馈/延迟的电路

# Connect output y to input x with delay, initialized to True.# (Default initialization is False.)aig5=aig1.feedback(inputs=['x'],outputs=['y'],initials=[True],keep_outputs=True)

重新标记

# Relabel input 'x' to 'z'.aig1['i',{'x':'z'}]# Relabel output 'y' to 'w'.aig1['o',{'y':'w'}]# Relabel latches 'l1' to 'l2'.aig1['l',{'l1':'l2'}]

评估

# Combinatoric evaluation.aig3(inputs={'x':True,'y':False})# Sequential evaluation.sim=aig3.simulate({'x':0,'y':0},{'x':1,'y':2},{'x':3,'y':4})# Simulation Coroutinesim=aig3.simulator()# Coroutinenext(sim)# Initializeprint(sim.send({'x':0,'y':0}))print(sim.send({'x':1,'y':2}))print(sim.send({'x':3,'y':4}))# Unrollaig4=aig3.unroll(steps=10,init=True)

有用电路

# Fix input x to be False.aig4=aiger.source({'x':False})>>aig3# Remove output y. aig4=aig3>>aiger.sink(['y'])# Create duplicate w of output y.aig4=aig3>>aiger.tee({'y':['y','w']})# Make an AND gate.aiger.and_gate(['x','y'],out='name')# Make an OR gate.aiger.or_gate(['x','y'])# Default output name is #or_output.# And outputs.aig1>>aiger.and_gate(aig1.outputs)# Default output name is #and_output.# Or outputs.aig1>>aiger.or_gate(inputs=aig1.outputs,output='my_output')# Flip outputs.aig1>>aiger.bit_flipper(inputs=aig1.outputs)# Flip inputs.aiger.bit_flipper(inputs=aig1.inputs)>>aig1# ITE circuit# ['o1', 'o2'] = ['i1', 'i2'] if 'test' Else ['i3', 'i4'] aiger.common.ite('test',['i1','i2'],['i3','i4'],outputs=['o1','o2'])

额外

eval_order(aig1)# Returns topological ordering of circuit gates.

生态系统

<;图>; py-aiger ecosystem <;figcaption>;Pyager生态系统/堆栈概述。<;/figcaption>; <;/数字>;

稳定

敬请关注!

发展不足

相关项目

  • pyAig:另一个python库 用于与aiger电路一起工作。

引用

@misc{pyAiger,
  author       = {Marcell Vazquez-Chanlatte},
  title        = {mvcisback/py-aiger},
  month        = aug,
  year         = 2018,
  doi          = {10.5281/zenodo.1326224},
  url          = {https://doi.org/10.5281/zenodo.1326224}
}

欢迎加入QQ群-->: 979659372 Python中文网_新手群

推荐PyPI第三方库


热门话题
Docker&SeleniumJava:无法在Docker容器上运行的chrome浏览器中上载图像/文件   在python中运行java命令   Java垃圾收集器异常行为   java java是否根据底层操作系统执行字节码级优化?   java是否可以休眠自定义查询返回映射而不是列表?   java Spring引导RabbitMQ接收器Jackson反序列化到POJO   apache flex在ActionScript3中创建对象相等“HashMap”作为java HashMap   java如何在Eclipse集成中切换JProfiler启动器   缓存JSP页面结果的java最佳实践?   java集成jaxb绑定文件,使用CXF生成基于WSDL的客户端   java为什么在上传操作结束之前,客户端没有检测到HttpServletResponse的PrintWriter内容?   java在接口内创建类和在类内创建接口有什么用   java向文件写入错误Android Studio   java合并多个RealmList并对结果列表排序?   谷歌API视觉java。lang.NoSuchMethodError   java如何使用逗号分别存储每个值,然后将它们存储到单独的数组中?