It is expected that building computational models of neural structures taking part in generating cognitive processes and emotions would not only help us understanding the brain but also give us clues to diagnose and develop treatment for neurological disorders and diseases. In this work, a computational model of cognitive task, goal directed behavior is considered. The cortex-basal ganglia-thalamus loop which is known to be effective in goal directed behavior has been modeled. In the model, the stimulus which has been recognized by sensory cortex has been projected to motor cortex giving rise to an action. This relation between stimulus and action has been evaluated by reward and the connection between substructures taking part during this process has been modified by dopamine. This modification is done by spike time dependent plasticity which depends on dopamine level regulated by reward. So, the effect of stimulus on sensory cortex has been carried down to motor cortex by evaluating reward and association between stimuli and action has been built up.