Re: [myhdl-list] intbv.wrap()
Brought to you by:
jandecaluwe
From: Tom D. <td...@di...> - 2011-04-18 17:09:05
|
Why not make it part of the intbv object? It seems like when you create the intbv you should know if you want bounds checking or wrapping. So you would do this: x = intbv(0,min=-8,max=7,wrap=True) x[:] = x + 5 The default would be wrap=False. On 04/18/2011 10:10 AM, Christopher Felton wrote: > I have been working on a intbv.wrap() function. Below are a couple > comments and questions. > > **Modeling** > The intbv has the convenient bound checking. This bound checking is > enforces the min-max which can be arbitrary. The max and min properties > can be set regardless of the inherent min and max of the binary word. > > Here I refer to a binary word as a collection of bits. > > Example, and intbv can be declared as x = intbv(0, max=6, min=-5). This > is perfectly legal and can be useful. This type of usage states that I > would like to have a binary word and I expect its values to always be in > this range min-max. Declaring an intbv of this type doesn't add any > additional logic to a design it only enforces the desired behavior > during simulation. > > An intbv wrap function doesn't make sense in the previous example. > Because it is not the inherent behavior of the binary word being > modeled. Wraps of this type can be implemented but they require > additional logic and this additional logic should be stated in a design. > > To use the wrap function, the inherent wrapping of a binary word, the > min and max must match the min-max of the binary word. An assertion is > added to enforce this rule, any objections? > > **Conversion** > For the conversion I will need some assistance. I assume the wrap > function will be handled similar to the concat and intbv.signed > functions. I believe the a condition needs to be added to the > *visit_Call* function the _analyze.py module. Jan D. could you give me > some pointers if this is correct? For conversion, the proposed method > would be to ignore the wrap functions and just include whatever is > passed to wrap (if that makes sense?). Example x.next = x.wrap(x+1) > would result in x<= x + 1; > > **Questions** > In the visit_Call function, what is the node.obj? > > Do you think the handler for the wrap function should also determine if > node.signed should be set True? > > > Note: Above I indicated the wrap is a inherent property of a binary > word. A binary word is just a container so this isn't exactly correct. > In this context I am extending it to any operation that results in a > limited number of bits. Example is an adder whose results are always N > bits regardless of the inputs. > > Chris Felton > > On 4/12/2011 6:52 AM, Christopher Felton wrote: >> I created a small write-up here, >> http://www.myhdl.org/doku.php/user:cfelton:projects:wrap, for a proposed >> intbv.wrap() function. >> >> I wrote this quick and probably needs a second look. I will look at the >> implementation details later. >> >> Any comments welcome. >> >> Thanks >> Chris Felton >> >> > > ------------------------------------------------------------------------------ > Benefiting from Server Virtualization: Beyond Initial Workload > Consolidation -- Increasing the use of server virtualization is a top > priority.Virtualization can reduce costs, simplify management, and improve > application availability and disaster protection. Learn more about boosting > the value of server virtualization. http://p.sf.net/sfu/vmware-sfdev2dev > _______________________________________________ > myhdl-list mailing list > myh...@li... > https://lists.sourceforge.net/lists/listinfo/myhdl-list |