EXP4
EXP4
Design, Implement, simulate and synthesize the following circuits : A. 16 bit up and down counter B. 8 bit shift register with parallel loading, parallel output, serial in-out capacity C. 1101 Sequence Detector (overlapped) D. 0101 Sequence detector (non overlapped).
for 16 bit there is 16 flip flops are required and the input of J and K is short so it is nothing but a T flip flop so, implementation is done with this circuit reference.
VHDL Codes :
T Flip flop :
4 bit Counter :
Note :
if we write Q as STD_LOGIC_VECTOR (3 downto 0) then code check correctly and also synthesize but it uses only one T FF (in RTL) so, it's output is undefined and the code not work properly.
16 bit Counter :
To implement the 16 bit counter we use the port map of 4 (4 bit UP/DOWN Counter) so, only code complexity get reduced.
library IEEE; use IEEE.STD_LOGIC_1164.ALL; entity counter_16bit_up_down is port ( T : in STD_LOGIC; clk : in STD_LOGIC; Reset : in STD_LOGIC; up_down: in STD_LOGIC; Q : buffer STD_LOGIC_VECTOR(15 downto 0); NQ : buffer STD_LOGIC_VECTOR(15 downto 0) ); end counter_16bit_up_down; architecture Behavioral of counter_16bit_up_down is component counter_4bit_up_down is Port ( T_in : in STD_LOGIC; Clock : in STD_LOGIC; Clear : in STD_LOGIC; up : in STD_LOGIC; Q0 : buffer STD_LOGIC; NQ0 : buffer STD_LOGIC; Q1 : buffer STD_LOGIC; NQ1 : buffer STD_LOGIC; Q2 : buffer STD_LOGIC; NQ2 : buffer STD_LOGIC; Q3 : buffer STD_LOGIC; NQ3 : buffer STD_LOGIC ); end component; signal toggle1,toggle2,toggle3 : STD_LOGIC; begin Counter1 : counter_4bit_up_down port map('1',clk,reset,up_down,Q(0),NQ(0),Q(1),NQ(1),Q(2),NQ(2),Q(3),NQ(3)); toggle1 <= ((up_down)and(Q(3))and(Q(2))and(Q(1))and(Q(0)))or((not(up_down))and (NQ(3))and(NQ(2))and(NQ(1))and(NQ(0))); Counter2 : counter_4bit_up_down port map(toggle1,clk,reset,up_down,Q(4),NQ(4),Q(5),NQ(5),Q(6),NQ(6),Q(7),NQ(7)) ;
toggle2 <= ((up_down)and toggle1 and (Q(4))and(Q(5))and(Q(6))and(Q(7)) and (Q(7))and(Q(6))and(Q(5))and(Q(4)))or((not(up_down))and toggle1 and (NQ(4))and(NQ(5))and(NQ(6))and(NQ(7))); Counter3 : counter_4bit_up_down port map(toggle2,clk,reset,up_down,Q(8),NQ(8),Q(9),NQ(9),Q(10),NQ(10),Q(11),NQ( 11)); toggle3 <= ((up_down) and toggle2 and (Q(11))and(Q(10))and(Q(9))and(Q(8)))or((not(up_down)) and toggle2 and(NQ(11))and(NQ(10))and(NQ(9))and(NQ(8))); Counter4 : counter_4bit_up_down port map(toggle3,clk,reset,up_down,Q(12),NQ(12),Q(13),NQ(13),Q(14),NQ(14),Q(15) ,NQ(15)); end Behavioral;
SIMULATION :
It's RTL is perfectly create a counter from device CLB. Also, Simulate perfectly.
B. 8 bit shift register with parallel loading, parallel output, serial in-out capacity :
VHDL Code :
RTL :
Simulation :
RTL :
Simulation
RTL
Simulation :