From DD-WRT Wiki
Asterisk is a complete PBX in software. It provides all of the features you would expect from a PBX and more. Asterisk does voice over IP in many protocols, it needs no additional hardware for Voice-over-IP, and can interoperate with almost all standards-based telephony equipment using relatively inexpensive hardware.
Originally this page was started to describe a method of manually installing Asterisk, actually elaborating this workflow step-by-step.
While the page got finished, the method was completely outdated, since meanwhile community members created much better ways to have Asterisk running well under dd-wrt, along with many other tools, in a completely automated manner.
Thus, I decided to remove the clumsy description I made, and to point you in the right direction:
Optware is a package that is needed anyway. Following the steps above will let you install Optware and Asterisk very easily. There are many other useful packages that automatically get installed too, but each package can be enabled or disabled individually, so no waste of CPU cycles or memory occurs if certain services are not needd. I recommend using at least a 512MB Flash disk for storage, formatted as ext3, as described.
There's a simple GUI for Asterisk too, have a look here on how to install it.