[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [f-cpu] C/VHDL interface



Wow, that was fast :)

On Tue, Aug 14, 2001 at 03:08:23AM +0200, Yann Guidon wrote:
[...]
> > The problem is that I a) can't tell which tarball is which and b)
> > which you are referring to -- e.g. is the one you mentioned the one I
> > downloaded yesterday, or is it a new one?  A date or version would
> > help a lot.
> 
> if the file size has increased, it is certainly a new version ;-)

I can't see the file size without downloading it :(

> but i'll try to be more verbose now.
> and maybe separate the stuffs in different dirs.
> 
> > > >         - simple expressions must not use operators other than `*'
> > > >           (multiplication), `/' (division), `+' (sum) and `-' (subtraction
> > > >           or negation), and the parentheses '(' and ')'
> > > however boolean operations like "|" is useful when defining masks etc.
> > Hmm... the syntax and operator precedence is different in C and VHDL.
> > that won't work unless the expression is fully parenthesized (and I
> > really mean *fully*).
> 
> that's the burden of the coder and i never trust precedence ;-)
> so it should work for me.
> 
> and now, the script....

Scripts.  Plural.  See attachment :)

It's quick-and-dirty (no syntax checking!) but it works.  If you want
something more sophisticated -- I'll write a YACC parser tomorrow ;)

CU,
-- 
 Michael "Tired" Riepe <Michael.Riepe@stud.uni-hannover.de>
 "All I wanna do is have a little fun before I die"
#! /bin/bash -
# X-to-C converter
# usage: xtoc infile > outfile
infile=${1?'usage: xtoc infile > outfile'}
echo "/* This file was automatically generated by xtoc. DO NOT EDIT! */
#define and	&
#define or 	|
#define xor	^
#define not	~
#line 1 \"$infile\""
bsnl() { while IFS= read line; do echo "$line"; done; }
bsnl < "$infile" | sed 's,[ 	]\+, ,g
s,# *\(.*\) *,/* \1 */,
s,^ *\([A-Z][0-9A-Z_]*\) *= *\([^ ].*\) *$,#define \1	(\2),'
#! /bin/bash -
# X-to-VHDL converter
# usage: xtovhdl infile > outfile
infile=${1?'usage: xtovhdl infile > outfile'}
pkgname=${infile//[!0-9A-Z_a-z]//}
echo "-- This file was automatically generated by xtovhdl. DO NOT EDIT!
package $pkgname is"
bsnl() { while IFS= read line; do echo "$line"; done; }
bsnl < "$infile" | sed 's,[ 	]\+, ,g
s,# *\(.*\) *,-- \1,
s,^ *\([A-Z][0-9A-Z_]*\) *= *\('\'.\''\) *$,	constant \1 : character := \2;,
s,^ *\([A-Z][0-9A-Z_]*\) *= *\(\".*\"\) *$,	constant \1 : string := \2;,
s,^ *\([A-Z][0-9A-Z_]*\) *= *\(.*\) *,	constant \1 : integer := \2;,'
echo "end $pkgname;"