Making a shift register in VHDL

Status
Not open for further replies.

voho

Full Member level 2
Joined
Feb 24, 2004
Messages
121
Helped
2
Reputation
4
Reaction score
1
Trophy points
1,298
Location
Nador City
Activity points
852
Hi all,

I would like to do in VHDL à shift register with:

serial and parallele input and serial and parallele output.

Thank's in advance regards
 

Re: shift register

maybe...

Code:
-- 4-bit loadable serial-in and serial-out shift register
--     CLK: in STD_LOGIC;
--     DIN: in STD_LOGIC;
--     LOAD: in STD_LOGIC;
--     LOAD_DATA: in STD_LOGIC_VECTOR(3 downto 0);
--     DOUT: out STD_LOGIC; 
 
--**Insert the following between the 'architecture' and
---'begin' keywords**
signal REG: STD_LOGIC_VECTOR(3 downto 0);
 
--**Insert the following after the 'begin' keyword**
process (CLK)
begin
   if CLK'event and CLK='1' then
   if (LOAD='1') then
     REG <= LOAD_DATA;
   else
        REG <= REG(2 downto 0) & DIN;
   end if;
   end if;
 DOUT <= REG(3);
end process;





Code:
-- 4-bit serial-in and parallel-out shift register
--     CLK: in STD_LOGIC;
--     DIN: in STD_LOGIC;
--     DOUT: out STD_LOGIC_VECTOR(3 downto 0);
 
--**Insert the following between the 'architecture' and
---'begin' keywords**
signal REG: STD_LOGIC_VECTOR(3 downto 0);
 
--**Insert the following after the 'begin' keyword**
process (CLK)
begin
   if CLK'event and CLK='1' then  
      REG <= REG(2 downto 0) & DIN;
   end if;
 DOUT <= REG;
end process;



Code:
-- 4-bit serial-in and serial-out shift register
--     CLK: in STD_LOGIC;
--     DIN: in STD_LOGIC;
--     DOUT: out STD_LOGIC;
 
--**Insert the following between the 'architecture' and
---'begin' keywords**
signal REG: STD_LOGIC_VECTOR(3 downto 0);
 
--**Insert the following after the 'begin' keyword**
process (CLK)
begin
   if CLK'event and CLK='1' then  
      REG <= REG(2 downto 0) & DIN;
   end if;
 DOUT <= REG(3);
end process;
 

Status
Not open for further replies.

Similar threads

Cookies are required to use this site. You must accept them to continue using the site. Learn more…