http://piratemc.com/information/portcullis/
Build the portcullis itself by stacking rows of fences (wood or netherbrick), at least two wide and two high.
Build the wall around it to contain it. Leave enough empty space above the portcullis to allow it to go as high as you want it to go.
Power the portcullis by powering one of the blocks adjacent to it on either side, by attaching a lever or redstone dust. For now, the power has to come from the side.
When the block is powered, the portcullis will start moving upwards, and will keep going until it hits something and can't go any further. It moves slowly, since a portcullis is heavy!
Important: make sure that when it is in the up position, it is still in contact with a powered block (the same one, or a different one).
When the power goes off, the portcullis will drop down (a lot faster than it went up).
Decorate the gate by building walls in front of and behind the portcullis to cover the empty space and to make it appear the portcullis is moving in a groove. Of course you can make it look any way you want!