Bug 68

Summary: nmigen general utils needed
Product: Libre-SOC's first SoC Reporter: Luke Kenneth Casson Leighton <lkcl>
Component: Source CodeAssignee: Luke Kenneth Casson Leighton <lkcl>
Status: PAYMENTPENDING FIXED    
Severity: enhancement CC: libre-soc-bugs
Priority: ---    
Version: unspecified   
Hardware: PC   
OS: Linux   
NLnet milestone: NLnet.2019.02.012 total budget (EUR) for completion of task and all subtasks: 500
budget (EUR) for this task, excluding subtasks' budget: 500 parent task for budget allocation: 62
child tasks for budget allocation: The table of payments (in EUR) for this task; TOML format:
lkcl={amount=500, paid=2019-11-19}
Bug Depends on:    
Bug Blocks: 62    
Attachments: provides Record.__iter__

Description Luke Kenneth Casson Leighton 2019-04-19 10:25:16 BST
* eq
* flatten
* shape
* like
* cat
* functions/classes for walking data structures (__iter__/__next__ and yield)

https://git.libre-riscv.org/?p=ieee754fpu.git;a=blob;f=src/add/singlepipe.py;h=fe052be72a3e70fde85e56058cf708ea9e7cd341;hb=25a0ec563bd7837b43a1d04036b2a5945c97023b#l291

properly evaluate if eq and flatten are needed as globals, or if they are better
placed into a class.

benefits of eq and flatten being globals is that they can accept lists
(or tuples, or anything supporting python Sequence pattern, including
generators and iterators).

like needed for creating similar object to one that already exists.
Comment 1 Luke Kenneth Casson Leighton 2019-04-19 18:16:30 BST
occurred to me that eq is equivalent to the pattern of the python operator
module.

as such this would tend to suggest a name for a module where it could
live: nmutil.operator.

from nmutil.operator import eq

this would form the pattern for additional "global" functions present
in Value (such as shape, implies and part).


flatten is... different, in that it is already in nmigen.tools, which
in turn assumes that the nmigen object is iterable (isinstance(x, Iterable)
and that in turn implies it should have an __iter__ (etc. etc.).

except, the version in nmigen.tools fails because Record doesn't have
an __iter__.

patch for Record created (attached)
Comment 2 Luke Kenneth Casson Leighton 2019-04-19 18:17:15 BST
Created attachment 8 [details]
provides Record.__iter__
Comment 3 Luke Kenneth Casson Leighton 2019-04-27 15:58:21 BST
(In reply to Luke Kenneth Casson Leighton from comment #1)

> as such this would tend to suggest a name for a module where it could
> live: nmutil.operator.
> 
> from nmutil.operator import eq

 moved eq, shape and cat to nmoperator.py temporarily.
 also the two visitor classes.