I was researching about the topic and it is not a simple matter.
In short, it is used like this.
1. A bit like a vs. the.
2. 은/는 is used to contrast.
3. The focus of 이/가 is on the subject. The focus of 은/는 is on the topic/description.
4. 은/는 can be used with other markers or at the end of a verb conjugation
5. When the sentences are combined, 이/가 must be used in the sentence in the middle.
For more information, you can visit this link, http://wiseinit.com/topic-vs-subject-marker