[Cryptech Tech] Keeping magic numbers in sync between Verilog and C
Rob Austein
sra at hactrn.net
Wed Sep 30 22:03:47 UTC 2015
At Wed, 30 Sep 2015 23:02:25 +0300, Pavel Shatov wrote:
>
> I see, that right now every core has a wrapper, and this wrapper
> contains an array of localparams. Many of these localparams are repeated
> in different cores, since we decided, that similar cores should have
> similar address space layout. I think, an elegant solution will be to
> move all magic localparams into a separate .v file. This file will
> contain only localparams, and every core will then `include this .v file
> and get access to magic constants.
That would be fine. I was trying to avoid forcing that model on the
Verilog programmers, but it's certainly simpler overall.
> Converting .v file with localparams into .h file with #defines in
> another question. I faced the same problem several times in previous
> projects, but I still don't have any good enough solution. The first
> annoying thing is that numbers in Verilog are like 16'hABCD and like
> 0xABCD in C. I personally have a crazy PHP script, that can do the
> trick, but I won't share it. In Russia we have a law, that prohibits
> distribution of explicit adult content, you know.
If we're willing to put up with this being a #include / `include file,
the obvious answer is a minor variation on this: write the constants
as input to a script in some convenient format, have that script emit
both .h and .v output.
In this case I'd probably just write a Python class that understands
Verilog integer constant syntax, it's not that complicated.
More information about the Tech
mailing list