I have a runtime exception using a variable as second parameter of partout function. May be a minor bug. Here is my code:
Code: Select all
#include <platform.h>
#include <xs1.h>
#include <xclib.h>
out buffered port:8 Clk = XS1_PORT_1M; // a buffered 1 bit port
clock ClkBlk1 = XS1_CLKBLK_1; // the clock for the buffered port
int main()
{
unsigned int NumClk;
// configure port and clock block
configure_clock_ref(ClkBlk1, 64);
configure_out_port(Clk, ClkBlk1, 0);
start_clock(ClkBlk1);
for(NumClk = 10; NumClk >= 4; NumClk -= 4)
Clk <: 0x55; // load 4 clocks
// load remaining clock
#if 1
if(NumClk)
partout(Clk, 2*NumClk, 0x55); // that's strange!! can't use a variable as second parameter
#else
if(1 == NumClk) // need to do in this way
partout(Clk, 2, 0x55);
else if(2 == NumClk)
partout(Clk, 4, 0x55);
else if(3 == NumClk)
partout(Clk, 6, 0x55);
# endif
sync(Clk); // wait clocks flushed
return 0;
}