Bug 68 - nmigen general utils needed
Summary: nmigen general utils needed
Status: PAYMENTPENDING FIXED
Alias: None
Product: Libre-SOC's first SoC
Classification: Unclassified
Component: Source Code (show other bugs)
Version: unspecified
Hardware: PC Linux
: --- enhancement
Assignee: Luke Kenneth Casson Leighton
URL:
Depends on:
Blocks: 62
  Show dependency treegraph
 
Reported: 2019-04-19 10:25 BST by Luke Kenneth Casson Leighton
Modified: 2020-12-04 22:29 GMT (History)
1 user (show)

See Also:
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}


Attachments
provides Record.__iter__ (675 bytes, patch)
2019-04-19 18:17 BST, Luke Kenneth Casson Leighton
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
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.