Adding code to a behaviour

At present the double behaviour will not do anything because we haven't added any code. We must now add C code to each block so that the integer_source block outputs an integer when the simulation starts and the double block doubles and outputs any integer that it receives.

To add code to a block, right click on the block and choose New view.... Now click Whitebox C and answer yes to the question about updating the interface of the cell. A text window will appear with 2 functions already defined. These functions must always be present and will run at the following times:

  1. poin_entry_Init() - This function will be called once when the simulation is first started.
  2. poin_entry_Run() - This function will be called each time a message arrives at any of the block's input ports.

The code for each block is shown below. This demonstrates how to send and receive messages through ports.

Double block code
Code for the double block


integer_source block code
Code for the integer_source block

Once you have written the code, save it by clicking the save button on the toolbar and compile it by clicking tools/generate object code. Also update the behaviour by going to the behaviour view and clicking tools/generate netlist.

Next...