I'm pretty new to designing hardware with VHDL, and I think I'm making a noob mistake. I'm making a CPU and my registerfile is rising_edge triggered. I had a problem though. I'll try putting some pseudo code to clear it up
on rising_edge {r0in <= 20; }
CLOCK CYCLE
on rising_edge {r1in <= r0out; }
CLOCK CYCLE
My problem is that r1in would be getting the old value of r0 instead of the appropriate 20. I then proceeded to change my code to use falling_edge instead of rising_edge for only the registerfile. A simplified version is below:
process(WriteEnable, DataIn, Clock)
begin
if falling_edge(Clock) then --note the falling_edge instead of rising_edge
if(WriteEnable = '1') then
registers <= DataIn;
end if;
end if;
end process;
DataOut <= registers;
So now my registers are falling_edge triggered instead of rising_edge. All of the test cases I have pass with this configuration and it synthesizes without warnings... but is this correct?
I'm asking this question because I've long been told to only use both edges in a design if you really know what you're doing. I've been programming in VHDL for a few weeks, so I want to make sure that this is an appropriate case to ues both edges