Chapter 6
Vectorized Code Generation
6-26
ni.com
INIT := TRUE;
X := ptr_of(ss_1_states(0)’address);
XD := ptr_of(ss_1_states(1)’address);
X.sensor_delay := (others => 0.0);
XD.sensor_delay := (others => 0.0);
for cnt in RT_INTEGER range 0..10 loop
R_P(cnt) := RP(cnt);
end loop;
SUBSYS_PREINIT(1) := FALSE;
return;
end if;
------ Output Update. ------
-- ---------------------------- Time Delay --
-- {VecEx..12} --
if INIT then
k_1 := 0;
for i_1 in RT_INTEGER range 1..5 loop
X.sensor_delay(k_1) := R_P(i_1);
k_1 := k_1 + 1;
end loop;
end if;
k_1 := 1;
for i_1 in RT_INTEGER range 1..5 loop
Y.delayed_pulse(-1+i_1) := X.sensor_delay(-1+k_1);
k_1 := k_1 + 1;
end loop;
-- ---------------------------- Gain Block --
-- {VecEx..2} --
for i_1 in RT_INTEGER range 1..5 loop
Throttle(-1+i_1) := R_P(5+i_1)*U.sensor_5(-1+i_1);
end loop;
------ State Update. ------
-- ---------------------------- Time Delay --
-- {VecEx..12} --
k_1 := 0;
for i_1 in RT_INTEGER range 1..5 loop
XD.sensor_delay(k_1) := Throttle(-1+i_1);
k_1 := k_1 + 1;
end loop;