For Programmers: Free Programming Magazines  


Home > Archive > Compilers > May 2005 > lex/yacc and verilog









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author lex/yacc and verilog
80085

2005-05-13, 6:59 pm

Hi all,

I'm new to this forum and need some help with lex/yacc.

I'm writing a parser that takes a verilog module specification I've developed as an input.

My question might seem relatively simple to this group since my job function is not software development. My main problem is that I can't figure out where to place a sensible boundary between lex and yacc.

The verilog signal specification we've developed can take the form of:

[code]
variable = 0 to 10;
SIGNAL storage_{variable}_ack[12:0]
SIGNAL storage_req
SIGNAL storage_buffer[12:0]
[\code]

How do I write a lexer that takes into account all of these formats, and more importantly, how do I then store the bit range values and the variable references and associate them with the signal?

For now I've written complex grammar rules in yacc to account for each unique combination:

[code]
STRING '[' INT ':' INT ']'
STRING '{' STRING '}' STRING '[' INT ':' INT ']'
[\code]
etc etc etc...

It's easy to observe that the grammar rules quickly become unmanageable at some point and that the tool will not scale easily as multiple variables can be referenced...

It seems obvious to me that this bit-range/variable parsing needs to be done initially in the lexer, and then the entire signal structure passed to yacc... I'm just not sure how to do this in lex. This would be a cakewalk in something like PERL, but lex cannot grab "pieces" of a regular expression match... or at least I'm not aware of it.

Can someone help?

Signed,
hardware architect in dire need of good software experience
Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com