Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronic Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

Help me write a VHDL code for implementing 4 bits Register

Status
Not open for further replies.

Iuri

Member level 2
Joined
May 14, 2011
Messages
50
Helped
3
Reputation
6
Reaction score
2
Trophy points
1,288
Activity points
1,630
I'm beginner at VHDL and I was trying to implement a 4 bits Register, but I have no idea of how to do it. The code below is what I got at this moment:

Code:
library ieee;
use ieee.std_logic_1164.all;

entity Register4Bits is
	port ( 	D0, D1, D2, D3 :	inout std_logic;
			WR : in std_logic	);    -- W = 0 , R = 1
end Register4Bits;

architecture archRegister4Bits of Register4Bits is
begin
	WriteRead : process ( WR )
	begin
			if WR'event and WR = '1' then
				
			
			elsif WR'event and WR = '0' then
				
				
			end if;
	end process;
end archRegister4Bits;

Please, someone can set me a direction?

thank you very much!
 

TrickyDicky

Advanced Member level 5
Joined
Jun 7, 2010
Messages
7,055
Helped
2,075
Reputation
4,167
Reaction score
2,028
Trophy points
1,393
Activity points
39,018
Re: VHDL 4 bits Register

for a register you need a clock. the code you have written is treating the WR signal as if it is a clock using both edges, which is not supported in FPGAs.

You need to follow the following code template for registers.

Code:
entity reg is
port (
  clk : in std_logic;
  d : in std_logic;
  q : std_logic
);

architecture rtl of reg is
begin

  process(clk)
  begin
    if rising_edge(clk) then
      q <= d;
    end if;
  end process;

end rtl;
 

Iuri

Member level 2
Joined
May 14, 2011
Messages
50
Helped
3
Reputation
6
Reaction score
2
Trophy points
1,288
Activity points
1,630
Re: VHDL 4 bits Register

it works fine! thx man!

this is a little piece of a bigger project... i have to build a ALU of Intel 4004 for a college.
more doubts is comming!
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Top