Take a look at Mentor's Catapult C. It translates untimed C models
into synthesizable VHDL or verilog. You must specify the clock period.
It assumes loop iterations take one clock, but individual instructions
do not. You can tell it to unroll loops to perform their statements in
parallel, or partially or fully pipeline the model, with varying clock
cycles per pipe state (i.e. the pipeline need not accept new data every
clock). The nice thing about it is that it takes care of the control
logic to turn the untimed (i.e. one-clock) description into a useable
hardware design that could target a variety of space-performance
trade-offs.
They have a very good interface synthesis approach. They can access
the inputs and outputs in parallel, streaming in order, or pick them
out of an external (to their model, not necessarily to the FPGA) single
or dual port ram. Internal arrays can also be stored in registers or
single or dual port rams. They also assume the whole hardware model
operates with one clock input and one reset input (asynchronous or
synchronous, per your choice).
The bottom line is that you wouldn't use it to design a whole chip,
but you would use it to design a hardware implementation of a software
algorithm. Then the chip designer, using verilog or vhdl, would
develop the rest of the chip around it.
They also provide the hooks for testing the hardware description from
original c code used to test the c model (at the transaction level),
using system-c concurrently with the vhdl or verilog model in modelsim.
In addition, they provide cycle-accurate vhdl and verilog models of the
hardware design. I chastised them on the fact that if they worked on
their synthesizable vhdl, they could use the same code for synthesis
and cycle based simulation (using variables and a single clocked
processes, etc.).
I took a 3 day training class with it a couple of weeks ago, and I, a
die-hard vhdl designer, was impressed!
Andy
Martin said:
If the synthesis software is really this capable, there is no need for
hardware engineers. Everyone can do hardware design after taking C
programming 101 and we all will become unemployed
Well, eventually, it's going to happen. We'll be abstracted far
enough away from the hardware to still be productive.
Let me give an example. Assume that we want to design a sorting
circuit that sorts a register of 1000 8-bit word with minimal
hardware.
OK, but I notice you've said minimal hardware there - my point was
"gets the job done"... maybe I have an enormous FPGA.
For simplicity, let us use the bubble sort algorithm:
n=100
for (i=0; i<n-1; i++) {
for (j=0; j<n-1-i; j++)
if (a[j+1] < a[j]) { /* compare the two neighbors */
tmp = a[j]; /* swap a[j] and a[j+1] */
a[j] = a[j+1];
a[j+1] = tmp;
}
}
The hardware designer's approach is to develop a control FSM to mimic
the algorithm. It can be done with one 8-bit comparator in
0.5*1000*1000 clock cycles.
Yes. Maybe in 1 process, and maybe in 2, or maybe three
If we ignore the underlying hardware structure and just translate C
constructs to corresponding VHDL constructs directly (the C
programmer's approach), we can still derive correct VHDL code:
process(clock)
variable a: std_logic_vector(999 downto 0) of
std_logic_vector(7 dwonto 0);
variable tmp: std_logic_vector(7 dwonto 0);
begin
if (clock'event and clock='1') then
-- register
q <= d;
a := q;
-- combinational sorting circuit based on
-- one-to-one mapping of C constructs
for i in 0 to N-2 loop
for j in 0 to N-2-i loop
if (a(j+1) <a(j)) then
tmp := a(j);
a(j) := a(j+1);
a(j+1) := tmp;
end if;
end loop;
end loop;
-- result to register input
d <= a;
end process;
I wasn't suggesting directly mapping C-code to VHDL like this, just that
the "describe everything to the synthesizer" approach can be a bit
heavy-handed and time consuming.
The resulting circuit can complete sorting in one clock cycle but
requires 0.5*1000*1000 8-bit comparators. We need a extremely large
target device to accommodate the synthesized circuit. It will be very
demanding for synthesis software to convert this code into a circuit
with only one comparator. I think my job is still safe, for now
I don't suggest that the synth *can* make those sort of
transformations. It doesn't have the constraints currently to know.
As an aside, I think that FpgaC will do it with one comparator and a
memory, (maybe fpga_toys will chip in here).
In the future, we *will* be moving away from low-level stuff like this
(personally, I don't think *C* is high enough level, but that's another
debate
Cheers,
Martin