Structural 8 Bit Shift Register Example(Architecture - Generate with If Scheme)
ARCHITECTURE structural OF shift_reg8_str IS
FOR ALL : mux2 USE ENTITY
SIGNAL mux_out : level_vector(7 DOWNTO 0);
SIGNAL dff_out : level_vector(7 DOWNTO 0);
-- COMPONENT INSTANTIATION (GENERATE W/ IF)
G1:FOR i IN 0 TO 7 GENERATE
MUX1 : mux2 GENERIC MAP(tprop => tprop/2)
DFF1 : dff GENERIC MAP(tprop => tprop/2,
PORT MAP(d => mux_out(i),
MUX1 : mux2 GENERIC MAP(tprop => tprop/2)
PORT MAP(a => dff_out(i-1),
DFF1 : dff GENERIC MAP(tprop => tprop/2,
PORT MAP(d => mux_out(i),
Notes:
This is the architecture which uses a complex generate statement. There is an IF statement within the generate statement to handle the fact that the mux that is connected to the 0th bit is connected to scan_in instead of the output of the DFF in the previous bit position. Here again, the colors highlight the three parts of the structural description.
Note that the concurrent signal assignment statements to connect the dff_out signal to the Q outputs are inside the generate statements.