If I have 9 address bits, how many sets are there in a direct mapped cache?
If I have 10 address bits, how many sets are there in a direct mapped cache?
Is there a general formula for this question?

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
For direct mapped, each address only maps to one location in the cache, thus the number of sets in a direct mapped cache is just the size of the cache.
There would be 0 bits for the tag, and you don’t provide enough information to determine the index or displacement bits.
Assuming you are using word addressing and you meant there are 9 or 10 bits for the index + tag:
9 bits -> 2^9 sets
10 bits -> 2^10 sets