Forum Discussion

Altera_Forum's avatar
Altera_Forum
Icon for Honored Contributor rankHonored Contributor
16 years ago

Should C2H work on pin I/O?

Hi-

I'm working on my first experiments with using the C2H compiler. For starters, I have a SW function that performs a bit-banged SPI output function (CS, CLK, and DATA). It works implemented as a SW function. I've attached the C source file. The problem I'm having is that when I attempt to build it as a HW accelerated function I'm met with the following error:

"# 2009.11.17 12.44.13 (*) Running Generator Program for accelerator_SkeletonStandalone_spiWrite

identified subroutine named spiWrite

making hdl for subroutine named spiWrite

ERROR:

C2H:33: C2H ERROR: spiWrite::symbol underscorebuiltin_stwio_function_dereference0 not known to parent (c_bare_block=HASH(0x31b09c4))

at file: , line: 33

Accelerator module generation failed."

It appears the tool is unable to translate the _builtin_stwio function which is buried in the macro of IOWR_ALTERA_AVALON_PIO_DATA() which I use to toggle my output pins.

I'm fearing the worst here. Is it true then that pin I/O within a function selected to accelerate is not possible and then disqualifies the function from HW acceleration? If not, how do I overcome the problem I described?

Thanks, John Speth

3 Replies

  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    C2H designed only for math acceleration. There is other tool like Impulse CoDeveloper it can generate external hardware control signals.. like turning on/off LED connected to NIOS processor.

  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    C2H compiles ANSI C code. By the looks of the error you attempted to accelerate a driver that contains the IOWR macro. That macro isn't part of ANSI C so C2H doesn't know what to do with it. C2H accesses peripherals though pointers and doesn't have a need for IOWR/IORD macros since it doesn't contain a cache.

    If you wrote bit banging code using pointers this will work.... but do you really need this much speed? In software when you bit bang a PIO signal transitions are slow and everything works fine. Using C2H you could cause signal transitions to occur every clock cycle which may be too fast for whatever is hooked up over I2C. If you add additional code to slow the transitions down then it begs the question "why not just use software for this?"
  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    I agree that doing SPI in HDL will result in execution that will be too fast. It was simply an exercise with the hope of becoming enlightened.

    John Speth