Question

I'm designing a Single Cycle CPU. I have designed both the data path and controller for this CPU. Now I have encountered a problem. For the Instruction Memory and Data Memory, there should be a way out for inputs and outputs out of the CPU, since it is needed to write data to IM and read data from DM, and viceversa.

But the way I have designed my data path, these two memories are part of the data path. since for writing to a memory, you need to provide an address and a data, and in the data path there are already wires connected to these memories, I don't know how I should connect two wires to a single input/output place.

for example, for writing to the IM, I provide the inputs "IM_address" and "IM_data_in". but in the data path, the wires connected to the address input of this memory are outputs of other components, so I cannot assign the IM_address wire to this place because it should both be an input and an output at the same time.

now I know that there is something called an "inout" , but I'm not familiar with the usage of it, and I am also not sure that this might apply to my situation.

if anybody could give me a help on this, I would very much appreciate it!

thanks in advance

Was it helpful?

Solution

Only one component can read or write to any memory location at a time. If two components ever need to access the same memory, you either need to duplicate the memory and give each person their own copy, or create an arbitration scheme to prevent both components from reading/writing at the same time.

It sounds to me like you need to be using a multiplexer and selecting who is able to write to the instruction memory at any given time. I would think though that you should only be writing to the instruction memory at initialization, to program your CPU. Why would other components need to access the instruction memory?

A Multiplexer, or mux for short, is able to select one of a number of inputs to a single output. The signal that does the selection needs to be set by you.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top