3

How can I do modeling in reverse by parsing a C program and turning it in to a circuit diagram to be displayed.

Example

alt text

alt text

Except this is psedocode.

Paul
  • 198
  • 1
  • 9
  • 22
  • 1
    While this sounds like a potentially interesting question, what you're asking sounds VERY open-ended. – Matt Ball Aug 25 '10 at 03:30
  • Unless you have a lot of source code at your command, and/or have a lot of hardware specific information, you're not going to be able to do this for many library calls. – Merlyn Morgan-Graham Aug 25 '10 at 03:32
  • 4
    I suspect Googling for "SystemC" will give you some ideas. Like Verilog and VHDL, it was originally targeted primarily as simulation, but there is now a synthesizable subset -- an ability to write code in SystemC (which is really C++ with a class library) and compile it to an actual circuit you can then put into something like a CPLD, FPGA, or possibly an ASIC. – Jerry Coffin Aug 25 '10 at 04:36
  • 1
    "Clonsed as not a real question"? That's unreasonable. As a compiler persion, I think about programs as *circuits* of dataflow and operators. See my answer. – Ira Baxter Aug 25 '10 at 10:15

1 Answers1

0

At a first guess I would say you need to construct a C compiler from scratch (or co-opt one) and inspect the parse tree looking for constructs that you can represent with your list of simple symbols. Once you have done that you need a rendering engine to take the list of detected constructs and lay them out in a pretty picture.

Some random observations:

  1. There are many C concepts that can't be rendered in a simplistic manner (ie pointers)

  2. Making your pic look pretty will be a bitch

  3. Doxygen would be a good place to look for ideas (the do a nice function call structure graph)

  4. Going off on a tangent you might like to look at IEC 61131-3 programming languages for PLCs. These are graphically laid out languages that provide 5 different ways of describing program control and focus heavily on representations of logic

albert
  • 8,285
  • 3
  • 19
  • 32
Peter M
  • 7,309
  • 3
  • 50
  • 91