Tom Kelliher, CS 240
Apr. 20, 2012
Read 7-6, 7-9.
VHDL for sequential circuits.
Shift registers.
Examples: register file, MDR, MAR.
Example: program counter.
Use a mux approach:
Gating the clock will save the muxes, but clock gating is usually a bad idea -- clock skew problems.
clockToFF = load and clock
clockToFF = !load or clock
Note: The handling of the load signal could be used to implement a synchronous reset.
-- VHDL for 32 bit parallel load register with asynchronous low -- reset. library ieee; use ieee.std_logic_1164.all; entity parallel_register is port ( clock, load, reset_n : in std_logic; d : in std_logic_vector (31 downto 0); q : out std_logic_vector (31 downto 0)); end parallel_register; architecture dataflow of parallel_register is signal state : std_logic_vector (31 downto 0); begin -- dataflow q <= state; -- Output process. state_reg : process (clock, reset_n) begin -- process state if (reset_n = '0') then -- asynchronous reset (active low) state <= X"00000000"; elsif (clock'event and clock = '1') then -- rising clock edge if (load = '1') then state <= d; else state <= state; end if; end if; end process state_reg; end dataflow;