Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics 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.

Modify this VHDL code as follows

Status
Not open for further replies.

r4am

Newbie level 1
Newbie level 1
Joined
Oct 9, 2013
Messages
1
Helped
0
Reputation
0
Reaction score
0
Trophy points
1
Visit site
Activity points
10
Modify this VHDL code by adding a parameter that sets the number of
flip-flops in the counter.


Code VHDL - [expand]
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
LIBRARY ieee ;
USE ieee.std logic 1164.all ;
USE ieee.std logic unsigned.all ;
ENTITY upcount IS
PORT ( Clock, Resetn, E : IN STD LOGIC ;
Q : OUT STD LOGIC VECTOR (3 DOWNTO 0)) ;
END upcount ;
ARCHITECTURE Behavior OF upcount IS
SIGNAL Count : STD LOGIC VECTOR (3 DOWNTO 0) ;
BEGIN
PROCESS ( Clock, Resetn )
BEGIN
IF Resetn  ’0THEN
Count < ”0000” ;
ELSIF (Clock’EVENT AND Clock  ’1) THEN
IF E  ’1THEN
Count < Count + 1 ;
ELSE
Count < Count ;
END IF ;
END IF ;
END PROCESS ;
Q < Count ;
END Behavior ;

 
Last edited by a moderator:


Code VHDL - [expand]
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
LIBRARY ieee ;
USE ieee.std logic 1164.all ;
USE ieee.std logic unsigned.all ;
ENTITY upcount IS
generic (FFN : integer := 4 );
PORT ( Clock, Resetn, E : IN STD LOGIC ;
Q : OUT STD LOGIC VECTOR (FFN-1 DOWNTO 0)) ;
END upcount ;
ARCHITECTURE Behavior OF upcount IS
SIGNAL Count : STD LOGIC VECTOR (FFN-1 DOWNTO 0) ;
BEGIN
PROCESS ( Clock, Resetn )
BEGIN
IF Resetn  ’0THEN
Count < (others => '0') ;
ELSIF (Clock’EVENT AND Clock  ’1) THEN
IF E  ’1THEN
Count < Count + 1 ;
ELSE
Count < Count ;
END IF ;
END IF ;
END PROCESS ;
Q < Count ;
END Behavior ;



By changing the FFN's value, the FF number can adjust

I think this will works, i haven't compiled it.
 
Last edited by a moderator:

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top