# Pass large intbv to helper function

**URL:** <https://discourse.myhdl.org/t/pass-large-intbv-to-helper-function/155>\
**Category:** Support\
**Created:** [February 1, 2017, 3:49pm UTC](https://discourse.myhdl.org/t/pass-large-intbv-to-helper-function/155 "2017-02-01T15:49:33Z")\
**Posts on this page:** 1\
**Showing post:** 4

<div class="post-metadata">

**Author:** ![josyb](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.myhdl.org/josyb/32/5_2.png) [@josyb](https://discourse.myhdl.org/u/josyb)\
**Post date:** [February 4, 2017, 1:46pm UTC](https://discourse.myhdl.org/t/pass-large-intbv-to-helper-function/155/4 "2017-02-04T13:46:15Z")

</div>

> [@mario](#):
>
> A cryptographically strong hash algorithm is the requirement.

Does it need to work in hardware? If so, is there a speed/throughput requirement? Or a maximum size of the device?

[quote]  
In fact, the full SHA-256 is already working also using MyHDL types/classes.[/quote]  
I take it that you can simulate your code? Can we see that code?

> [@](#):
>
> In general, is it ok to use self-written Python functions calling other such functions (no recursion) from within HDL blocks?

Yes that is OK. Even recursion should work, although MyHDL may not (yet) allow so.  
I see a few candidates in SHA-256 where I would use a function too: e.g. the **rightrotate** (in Wikipedia’s pseudo-code)

I ran your code through my local MyHDL code-base (which is a heavily evolved branch from the pre-@block tree). And you have a case: the VHDL conversion should make distinction between functions with and without arguments. One without should convert to:

```
function functionName return returntype is
    begin
        ....
        return returnvalue; 
    end function functionName;

```

The other issue, the omission of the function instantiation is also an error in to \_VHDL.py, the code simply expects there is at least one argument.  
Both issues are easy to solve.  
But in defence: the use case for a VHDL function without arguments is very rare … In your particular case you could replace the Sha256\_new() function with a simple constant.

---

_[View the full topic](https://discourse.myhdl.org/t/pass-large-intbv-to-helper-function/155)._
