I want to find all the possible ways that 4 variables can be summed to a given number. Suppose I have the variables $$x=x_0+x_1+x_2+x_3$$ I want to fill $x_0,x_1,x_2$ and $x_3$ such that $x_0$ and $x_3$ can be zero or 1 and $x_1$ and $x_2$ can be equal or between 0 to 3. For example if I ask $x=3$ there will be following possibilities: $$1+1+1+0$$ $$1+1+0+1$$ $$1+0+1+1$$ $$0+1+1+1$$ $$1+2+0+0$$ $$1+0+2+0$$ $$0+2+0+1$$ $$0+0+2+1$$ $$0+2+1+0$$ $$0+1+2+0$$ $$0+3+0+0$$ $$0+0+3+0$$ How can I generate these possibilities in Mathematica. Also what if I have more variables for example: $x_0+x_1+x_2+x_3+x_4$ and so on?
Update: In fact this problem is coming from the following generating function: $$1 + 4 x + 8 x^2 + 12 x^3 + 14 x^4 + 12 x^5 + 8 x^6 + 4 x^7 + x^8$$ the coefficients are the possible ways of forming the sum. For instance if we want to make the sum to be equal to 3 then there are 12 possible ways of assigning numbers and so on and so forth. Thus it is important to have that $x_0$ and $x_4$ must be 0 or 1, and $x_2$ and $x_3$ must strictly be between zero and 3. So for instance to make the sum equal to 5 one can not have 0+5+0+0 as it is not allowed.