Example #1
0
/*
 * Configure PORT_1C as data with PORT_1D as the valid signal. Test receiving
 * two different words of data and check they are the correct values.
 */
void port_test_input(chanend c)
{
  port p = port_enable(XS1_PORT_1C);
  port_set_buffered(p);
  port_set_transfer_width(p, 32);

  port p_ready = port_enable(XS1_PORT_1D);
  clock clk = clock_enable(XS1_CLKBLK_2);
  clock_start(clk);

  port_configure_in_strobed_slave(p, p_ready, clk);

  chan_output_word(c, 0); // Send ack

  unsigned int x = port_input(p);
  if (x != 0xfeedbeef) {
    debug_printf("Error %x received instead of 0xfeedbeef\n", x);
  }

  x = port_input(p);
  if (x != 0x12345678) {
    debug_printf("Error %x received instead of 0x12345678\n", x);
  }

  chan_output_word(c, 0); // Send ack

  port_disable(p);
  port_disable(p_ready);
  clock_disable(clk);

  // Get information about the tile/core running the server for debug messages
  unsigned tile_id = get_local_tile_id();
  unsigned core_id = get_logical_core_id();
  debug_printf("%x:%d: input done\n", tile_id, core_id);
}
Example #2
0
/*
 * Configure PORT_1A as data with PORT_1B as the valid signal. Ensure that the
 * receiver is ready using a channel end. Send a word of data, delay for a while
 * and send another word to ensure the valid signals are functioning.
 */
void port_test_output(chanend c)
{
  port p = port_enable(XS1_PORT_1A);
  port_set_buffered(p);
  port_set_transfer_width(p, 32);

  port p_ready = port_enable(XS1_PORT_1B);
  clock clk = clock_enable(XS1_CLKBLK_1);
  clock_start(clk);

  port_configure_out_strobed_master(p, p_ready, clk, 0);

  chan_input_word(c); // Wait for ack

  port_output(p, 0xfeedbeef);

  timer tmr = timer_alloc();
  timer_delay(tmr, 1000);
  timer_free(tmr);

  port_output(p, 0x12345678);

  chan_input_word(c); // Wait for ack

  port_disable(p);
  port_disable(p_ready);
  clock_disable(clk);

  // Get information about the tile/core running the server for debug messages
  unsigned tile_id = get_local_tile_id();
  unsigned core_id = get_logical_core_id();
  debug_printf("%x:%d: output done\n", tile_id, core_id);
}
Example #3
0
/*
 * A server that receives data on a channel end. The first word of data is the
 * return address, the second word is data that it does a bitwise inversion
 * and returns before closing the connection.
 */
void chanend_server(chanend c)
{
  streaming_chanend_t sc = s_chanend_convert(c);
  // Get information about the tile/core running the server for debug messages
  unsigned tile_id = get_local_tile_id();
  unsigned core_id = get_logical_core_id();

  while (1) {
    streaming_chanend_t sender;
    s_chan_in_word(sc, (uint32_t*)&sender);
    uint32_t command;
    s_chan_in_word(sc, &command);
    s_chan_check_ct(sc, XS1_CT_END);

    debug_printf("%x:%d: received %d from %x\n", tile_id, core_id, command, sender);

    // Send a response (simply invert the data)
    s_chanend_set_dest(sc, sender);
    s_chan_out_word(sc, ~command);
    s_chan_out_ct(sc, XS1_CT_END);

    if (command == SHUT_DOWN) {
      debug_printf("%x:%d: shutting down\n", tile_id, core_id);
      break;
    }
  }
}
Example #4
0
void avb_register_talker_streams(chanend talker_ctl,
                                 int num_streams)
{
  int core_id;
  core_id = get_local_tile_id();
  talker_ctl <: core_id;
  talker_ctl <: num_streams;
}
Example #5
0
int avb_register_listener_streams(chanend listener_ctl,
                                   int num_streams)
{
  int core_id;
  int link_id;
  core_id = get_local_tile_id();
  listener_ctl <: core_id;
  listener_ctl <: num_streams;
  listener_ctl :> link_id;
  return link_id;
}
Example #6
0
void get_addresses(chanend c, unsigned *local_server, unsigned *remote_server)
{
  streaming_chanend_t sc = s_chanend_convert(c);
  unsigned tile_id = get_local_tile_id();
  unsigned core_id = get_logical_core_id();

  *local_server = sc;

  // Exchange channel IDs with the other end of a channel
  s_chan_out_word(sc, sc);
  s_chan_out_ct(sc, XS1_CT_END);
  s_chan_in_word(sc, (uint32_t*)remote_server);
  s_chan_check_ct(sc, XS1_CT_END);
  debug_printf("%x:%d: get_addresses: local %x, remote: %x\n",
               tile_id, core_id, *local_server, *remote_server);
}