clear variables;
clear global;
close all;

% Initialise AWE server
awe_init;

% Load AWE Designer design file
GSYS = load_awd('./simple_butterworth.awd');

% Set build control options to avoid errors
global AWE_INFO;
AWE_INFO.buildControl.matchDataType=0;
AWE_INFO.buildControl.matchNumChannels=0;
AWE_INFO.buildControl.validateTopLevelOutputPin=0;

% Build the system so that it is ready for processing and state is reset
GSYS.SYS = build(GSYS.SYS);

% Run processing on floating point data
block_size = 32;
num_blocks = 3;
num_samples = block_size * num_blocks;
x = ones(num_samples , 1);

WIRE_IN = {x};
[~, WIRE_OUT] = process(GSYS.SYS, WIRE_IN, num_blocks);
y = WIRE_OUT{1};

figure(1); hold on; grid on;
plot(x);
plot(y);
legend('Input signal', 'Output signal');