# How to provide custom functions in v1model.p4

**URL:** <https://forum.p4.org/t/how-to-provide-custom-functions-in-v1model-p4/167>\
**Category:** Uncategorized\
**Created:** [November 20, 2021, 11:24am UTC](https://forum.p4.org/t/how-to-provide-custom-functions-in-v1model-p4/167 "2021-11-20T11:24:34Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Heiben](https://avatars.discourse-cdn.com/v4/letter/h/848f3c/32.png) [@Heiben](https://forum.p4.org/u/Heiben)\
**Post date:** [November 20, 2021, 11:24am UTC](https://forum.p4.org/t/how-to-provide-custom-functions-in-v1model-p4/167/1 "2021-11-20T11:24:34Z")

</div>

I want to design custom functions in v1model.p4 just like the hash provided in the p4 file. But I don’t really know how to add this function in source code. Is there any way to add my own code?

---

<div class="post-metadata">

**Author:** ![ederollora](https://sea1.discourse-cdn.com/flex019/user_avatar/forum.p4.org/ederollora/32/21_2.png) [@ederollora](https://forum.p4.org/u/ederollora)\
**Post date:** [November 20, 2021, 8:44pm UTC](https://forum.p4.org/t/how-to-provide-custom-functions-in-v1model-p4/167/2 "2021-11-20T20:44:30Z")

</div>

Hi,

My short answer was going to be: declare it in v1model.p4 (your own _extern_, since that is what you are looking for) and implement it in bmv2. But I found a more complete one.

If the steps have not changed, a better answer is provided [here](https://github.com/p4lang/behavioral-model/issues/697) by Antonin Bas. That thread has a long discussion, so you can actually check the p4-macsec case they mention after his response. Which tried to achieve a similar thing to yours in terms of an extern implementation.

Cheers,

---

<div class="post-metadata">

**Author:** ![Heiben](https://avatars.discourse-cdn.com/v4/letter/h/848f3c/32.png) [@Heiben](https://forum.p4.org/u/Heiben)\
**Post date:** [November 22, 2021, 7:12am UTC](https://forum.p4.org/t/how-to-provide-custom-functions-in-v1model-p4/167/3 "2021-11-22T07:12:54Z")

</div>

Thank you very much, it is very helpful to me!
