Reputation: 892
We are working on a pipelined processor written in VHDL, and we have some issues with timing, synchronization and registers on the simulator (the code does not need to be synthesizable, because we going to run it only on the simulator).
Imagine we have two processor stages, A and B, with a pipeline register in the middle:
The configuration would be as follows
_______ ___ _______
| | | | | |
---| A |---|R|---| B |---
|_____| |_| |_____|
With this configuration, there is a timing problem:
We would like to have B changing its state and generating an output at t = 1, but we also need the register in the middle to make the pipeline work.
A solution would be to update the R register on falling edge. But then, we are assuming that all processor stages run in half a clock cycle, and the other half is a bit useless.
How is this problem usually solved in pipelines?
Upvotes: 0
Views: 961
Reputation: 892
After talking to quite a few people, I think we found the proper solution to the problem.
The stage B, which has its own state machine, should not have a VHDL process activated on rising edge. It should have the state of the state machine as a signal that is stored on register R.
In more detail, these new signals should be added:
state
: current state of the state machine, output from R, input to Bstate_next
: next state of the state machine, input to R, output from BWhich means that state
is changed for state_next
each rising edge, and B can now work without a process.
Upvotes: 0
Reputation: 763
First of all, just saying from personal experience in this field: never develop your own cpu, unless you are a freaking genius and have another few of your kind to verify your work and port a compiler.
To your problem:
a) A cutset technique is usually used to insert pipeline stages in the design. When implemented properly, you only need to solve control hazards
b) Model your stages not with registers inbetween but with 1-deep transparent FIFOs - you will get automatic stall management for free and it is easier to reason about pipelines
c) Bypass register R. Use data from A to register it in R and in B.
If none above helped, redesign B and/or hire a hardware developer that is used to reason about concurrent hardware.
Upvotes: 1