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.

3 Bit Gray Code Counter VHDL Issue

Status
Not open for further replies.

Slen17

Newbie level 2
Joined
Apr 26, 2012
Messages
2
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,306
Hello all, I recently designed a 3 Bit gray code counter, however the simulation did not turn out as intended. Could any of you view my code and inform me as to where I went wrong. Thanks


------------------------------------------------------------------------------------------------------------

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
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
library IEEE;                    
use IEEE.STD_LOGIC_1164.ALL;     
use IEEE.STD_LOGIC_ARITH.ALL;    
use IEEE.STD_LOGIC_UNSIGNED.ALL;
 
entity counter_3bit_gray is 
    port   (Clock         : in   BIT;
            Reset         : in   BIT;
            Count_Out     : out  BIT_VECTOR(2 downto 0));
  end entity;
 
architecture counter_3bit_gray_arch of counter_3bit_gray is
 
component DFF
    port   (Clock           : in   BIT;
            Reset           : in   BIT;
            D               : in   BIT;
            Q, Qn           : out  BIT);
end component;
 
signal Q2_cur, Q1_cur, Q0_cur      : BIT;
signal Q2n_cur, Q1n_cur, Q0n_cur   : BIT;
signal Q2_nxt, Q1_nxt, Q0_nxt      : BIT;
            
 
  begin
 
     Q2 : DFF port map (Clock => Clock, Reset => Reset, D => Q2_nxt, Q => Q2_cur, Qn => Q2n_cur);
     Q1 : DFF port map (Clock => Clock, Reset => Reset, D => Q1_nxt, Q => Q1_cur, Qn => Q1n_cur);
     Q0 : DFF port map (Clock => Clock, Reset => Reset, D => Q0_nxt, Q => Q0_cur, Qn => Q0n_cur); 
     
     Q2_nxt <= (Q2_cur and Q0n_cur) or (Q2_cur and Q1n_cur) or (Q2n_cur and Q1_cur and Q0_cur);  
     Q1_nxt <= (Q2n_cur and Q1n_cur and Q0_cur) or (Q2n_cur and Q1_cur and Q0n_cur) or (Q2_cur and Q1_cur and Q0_cur) or (Q2_cur and Q1n_cur and Q0n_cur);
     Q0_nxt <= Q0n_cur;
 
     Count_Out(2) <= Q2_cur;
     Count_Out(1) <= (Q2n_cur and Q1_cur) or (Q2_cur and Q1n_cur);
     Count_Out(0) <= (Q1_cur and Q0n_cur) or (Q1n_cur and Q0_cur);
 
end architecture;

 
Last edited by a moderator:

specify the problems, we may be able to help
 

I believe I did something wrong in the architecture. The entity matches the testbench, however when I simulate it, it flatlines. I went over the next state logic k-maps as well as those for the output logic, and the SOPs match, so idk whats up. I'm guessing its something that was left out in the architecture(i.e. port map, signal assignment) as this was modeled off a 2bit gray counter, and I may have missed something there when going to 3bit. thanks
 

I believe I did something wrong in the architecture. The entity matches the testbench, however when I simulate it, it flatlines. I went over the next state logic k-maps as well as those for the output logic, and the SOPs match, so idk whats up. I'm guessing its something that was left out in the architecture(i.e. port map, signal assignment) as this was modeled off a 2bit gray counter, and I may have missed something there when going to 3bit. thanks

what does your testbench look like? how did you generate your clock / reset?
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top