You'll need to revisit some physics.
Namely the ideal Gas Law..... PV = nRT
Understand this & you can write a function similar to FI_Air_Mass(.....) below.
This function takes pressure (P) & volume(V) & intake air temp (T) and solves for n (number of moles) using the ideal gas law and then converts the moles to micrograms.
--this is cut/paste from my code where I'm calculating PW
-- FI.ICAM (instantaneous cylinder air mass in ugrams)
-- FI.ICAV (instantaneous cylinder air volume in cc's )
(this is how much air is currently filling the cylinder each stroke - note its rarely the swept volume of cylinder)
(as the engine (normally aspirated at least) never is that efficient & this varies with rpm)
(if the current VE was 100% then ICAV would be = to engine displacement/# of cylinders.)
(if a turbo under lots of boots, the ICAV would be LARGER than displacement/#cyl as we're stuffing extra air)
-- FI.ICPW (instantaneous cylinder pulse width)
-- Engine.IAT (intake air temp)
-- Engine.MAP (manifold pressure)
// correct the volume reading for air temperature
// returns ugrams of air/cylinder/intake stroke
FI.ICAM = FI_Air_Mass(Engine.MAP, Engine.IAT, FI.ICAV);
// calculate the static pulse width (1 cylinder, no Vsag or Opening time), ug->us
FI.ICPW = pulse_width_for_given_air_mass(FI.ICAM);
-- now you would adjust for different enrichments, target AFR, dead time of injectors, ect.
Note: I think many programmers actually use PV=nRT to pre-calculate what the FCPW (full cylinder pulse width) would be at what's called STP. (Standard Temperature and Pressure, 100kPa & 25C) & then shrink from that based on run time readings. This is to save the math overhead done during realtime operation. I just do the math as I have plenty of processing cycles.
I'm not sure what Fred does, but MS I *think* does this as I see people talking about "base pulse" or something similar and that sounds like a pre-calculated pulse to me.
As to your question of how many of those grams reach the cylinders.....All of them! If a gram of air goes in the intake, it makes it to the cylinder. MAF reads all cylinders so you have to divide by 4,6,8,ect. If you have an air leak in your intake, then EXTRA air sneaks in that your MAF or your MAP table is unaware of and you get a lean condition as your ecu had no idea some was leaking.
Lenny