Doubt related to usage of module inverse

i am unable to understnad the line
y=((p%w)*modInv(d,w))%w, why do we need modInv of d here?