Feedback Loop – Issues with Program Counter Input to Output

cpudigital-logichomebrew-cpu

I'm designing a very simple CPU to be built on a custom PCB. I designed the CPU in LogicCircuit, and it seems to work. But I'm wondering it a specific part of the CPU will also work in real life.

I implemented the JMP instruction as follows (cycle counter increases on falling edge):

  • Cycle 1: PC Output Enable onto address bus is active, PC Output Enable into the ALU is active, PC Write Enable is active (to latch the increased PC from the ALU). On rising edge, latch the instruction from ROM and latch the increased PC from the ALU into the PC register at the same time.
  • Cycle 2: PC Output Enable onto address bus is active, PC Write Enable is active. On rising edge, latch the new PC value from ROM)

My question is now, is it problematic that in Cycle 1 im latching the new PC value and the instruction at the same time. My thinking is that the instruction from ROM will be latched first before the increased PC value is latched. In the simulation this seems to work, but im not sure if im getting into any race condition in real life.

Best Answer

So you're saying that the new PC value is the second word of the instruction in the ROM. As long as the PC is a truly edge-triggered register, there will be no problem. It will capture the output of the ROM, and its output, along with the output of the ROM, cannot possibly change soon enough to violate the hold time requirement at the input of the PC register.

This is generally true of synchronous logic -- you can connect the output of one register directly to the input of another register on the same clock, and no data setup/hold time errors will occur.