Motherboard Forums


Reply
Thread Tools Display Modes

Converting C-style include file to Verilog?

 
 





















Frank Miles
Guest
Posts: n/a

 
      01-13-2005, 07:14 PM


I have a system that includes both C (for a microprocessor) and Verilog
code. Where these components interact, I would like to have a single
source file from which certain relevant constants are derived. Initially,
at least, I'm looking for a way to simply generate a Verilog file from
a 'C' include file. This would be pretty straightforward except for
the macros in C. (I wrote one but it's kinda limited, doesn't handle
all the C -style math).

Has someone developed a C preprocessor that will do this? I can't seem to
get 'cpp' to emit processed values (e.g. purely numerical if multiple levels
of macros have been used). Normal development environment is Linux...

Thanks for any ideas/insights!

-frank
--
 
Reply With Quote
 
Pablo Bleyer Kocik
Guest
Posts: n/a

 
      01-13-2005, 09:07 PM
Hello Frank.

Some years ago I had a similar problem. I ended up using Python scripts
which generated Verilog and C header files on the fly from the same
template files written in Python.

The nice thing of using a script language is that you can build and
evaluate expressions easily on the fly and that is exactly what I
wanted (some other compiled languages allow you to do the same thing,
for example using reflection in Java, but you end up writing more
code). E.g.

e = "3*4+%(foo)s"
d = {'foo': 5}
n = eval(e % d)
your_function(n) ...

The template scripts were horrible --mixture of numbers, strings,
regexp strings, recursive evaluation of regexps...-- but it did the job
automatically and flawlessly, and therefore was worth the upfront
effort.

Also, Python's re package was very useful because it allows grouped
matches and you can perform simple parsing with them.

Luck with your project.

--
PabloBleyerKocik /"I believed that people would become programmers
pbleyer / and not need companies as much. You can see how
@embedded.cl / laughable that was." -- Steve Wozniak

 
Reply With Quote
 
Kelly Hall
Guest
Posts: n/a

 
      01-14-2005, 04:49 AM
Frank Miles wrote:
> Has someone developed a C preprocessor that will do this? I can't seem to
> get 'cpp' to emit processed values (e.g. purely numerical if multiple levels
> of macros have been used). Normal development environment is Linux...


Just use m4 to generate your C and Verilog header files. m4 is a much
more flexible macro processor than cpp.

Kelly
 
Reply With Quote
 
Jezwold
Guest
Posts: n/a

 
      01-14-2005, 08:13 AM
Ive got a perl script which does this,but it produces vhdl rather than
verilog.Thinking about it making the changes to make it produce verilog
might be just as long winded as writting a new perl script from scratch
but if you want to see it you are welcome.

 
Reply With Quote
 
Frank Miles
Guest
Posts: n/a

 
      01-14-2005, 07:05 PM
In article < .com>,
Jezwold <> wrote:
>Ive got a perl script which does this,but it produces vhdl rather than
>verilog.Thinking about it making the changes to make it produce verilog
>might be just as long winded as writting a new perl script from scratch
>but if you want to see it you are welcome.


Thanks for the offer (and I may be wrong), but it sound like such a port
would probably really difficult ... especially with my limited perl skills.
My current converter, as limited as it is, starts with the C include file.
This is in some ways easiest since some of the "constants" are in the form
of enums. It's written in python. Perhaps I should look at m4...

While I am disappointed that something isn't already available, I guess
that's it. Thanks for your responses!

-frank
--
 
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Re: Help replacing missing a boot.ini file Ben Myers Dell 0 11-10-2008 04:05 PM
Can't copy a file on hard disk DaveJohnson12@nomail. Dell 49 10-27-2007 02:39 PM
Acer Aspire 5000 laptop DVD drive does not burn DVDs correctly - Unspecified Recorder Error Sid B Acer 4 03-16-2007 11:31 PM


All times are GMT. The time now is 04:44 AM.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43