RE: I was wondering where I went wrong

OP #4377830
Rate this post
• ▲ useful
▼ not useful
1
module display (clock, AN0, AN1, AN2, AN3, CA, CB, CC, CD, CE, CF, CG, CDP);
2

3

4
//USED FOR SEVEN SEG
5
input clock;
6

7
output AN0, AN1, AN2, AN3, CA, CB, CC, CD, CE, CF, CG, CDP;
8

9
reg [7:0] cathodedata; //cathode data
10
reg [3:0] anodedata; //anode data
11
reg [2:0] digit = 1;
12
reg [6:0] data;
13
reg setdp;
14
reg [19:0] counter = 0;
15

16
assign CA = cathodedata [7];
17
assign CB = cathodedata [6];
18
assign CC = cathodedata [5];
19
assign CD = cathodedata [4];
20
assign CE = cathodedata [3];
21
assign CF = cathodedata [2];
22
assign CG = cathodedata [1];
23
assign CDP = cathodedata [0];
24
assign AN3 = anodedata [3];
25
assign AN2 = anodedata [2];
26
assign AN1 = anodedata [1];
27
assign AN0 = anodedata [0];
28
//USED FOR SEVEN SEG
29

30
    //Multiplexing
31
    //Board Clock: 50MHz
32
    //p = t*f
33
    //t = 16ms
34
    //p = 16ms * 50*10^6 = 800,000 cycles
35
    //200,000 cycles for each digit
36
    //Refreshed every 16ms (~60Hz)
37

38
always@(negedge clock)
39
begin
40
    if (digit == 1)
41
        begin
42
            if (counter == 200000)
43
                begin
44
                    digit = 2;
45
                end
46
            else
47
                begin
48
                counter = counter + 1;
49
                data = 4;
50
                end
51
        end
52
    else if (digit == 2)
53
        begin
54
            if (counter == 400000)
55
                begin
56
                    digit = 3;
57
                end
58
            else
59
                begin
60
                    counter = counter + 1;
61
                    data = 3;
62
                end
63
        end
64
    else if (digit == 3)
65
        begin
66
            if (counter == 600000)
67
                begin
68
                    digit = 4;
69
                end
70
            else
71
                begin
72
                    counter = counter + 1;
73
                    data = 2;
74
                end
75
        end
76
    else if (digit == 4)
77
        begin
78
            if (counter == 800000)
79
                begin
80
                    digit = 1;
81
                    counter = 0;
82
                end 
83
            else
84
                begin
85
                    counter = counter + 1;
86
                    data = 1;
87
                end
88
        end 
89
end
90

91

92
always @ (*)
93
begin
94

95
    case (data)
96
        6'd0: cathodedata = 8'b00000011; //0
97
        6'd1: cathodedata = 8'b10011111; //1
98
        6'd2: cathodedata = 8'b00100101; //2
99
        6'd3: cathodedata = 8'b00001101; //3
100
        6'd4: cathodedata = 8'b10011001; //4
101
        6'd5: cathodedata = 8'b01001001; //5
102
        6'd6: cathodedata = 8'b01000001; //6
103
        6'd7: cathodedata = 8'b00011111; //7
104
        6'd8: cathodedata = 8'b00000001; //8
105
        6'd9: cathodedata = 8'b00001001; //9
106
        6'd10: cathodedata = 8'b00010001; //A
107
        6'd11: cathodedata = 8'b11000001; //B
108
        6'd12: cathodedata = 8'b01100011; //C
109
        6'd13: cathodedata = 8'b10000101; //D
110
        6'd14: cathodedata = 8'b00100001; //E
111
        6'd15: cathodedata = 8'b01110001; //F
112
        default: cathodedata = 8'b11111111; //default all off
113
    endcase
114

115
    if (setdp == 1) //decimal point
116
        cathodedata = cathodedata & 8'hFE;
117

118
    case(digit)
119
        0: anodedata = 4'b1111; //all OFF
120
        4: anodedata = 4'b1110; //AN0
121
        3: anodedata = 4'b1101; //AN1
122
        2: anodedata = 4'b1011; //AN2
123
        1: anodedata = 4'b0111; //AN3
124
        default:
125
        anodedata = 4'b1111; //all OFF
126
    endcase
127

128
end 
129
endmodule

I am using a Nexys 2 digilent board with Xilinix and I just want to turn 
the seven seg display on as a countdown
OP #4377833
Rate this post
• ▲ useful
▼ not useful
I was wondering in the code what the anode data would be in order to get 
the lights to turn on I am so very confused
1
module seven_seg( intput [3:0]numbers, output reg[6:0] display);
2

3
always @(numbers)
4
  begin  
5
    case(numbers)
6
      4'h0: out1=7'b1000000;  //0111111;
7
      4'h1:  out1=7'b1111001;  //0000110;
8
      4'h2:  out1=7'b0100100;  //1011011;
9
      4'h3: out1=7'b0110000;  //1001111;
10
      4'h4: out1=7'b0011001;  //1100110;
11
      4'h5: out1=7'b0010010;  //1101101;
12
      4'h6: out1=7'b0000010;  //1111101;
13
      4'h7: out1=7'b1111000;  //0000111;
14
      4'h8: out1=7'b0000000;  //1111111;
15
      4'h9: out1=7'b0011000;  //1100111;
16
       default: out1=7'b1111111;//0000000;
17
    endcase
18
  end  
19
endmodule
20

21

22
endmodule
23
// display numbers*/
1
/*
2
module Slowclock(input wire clk, output reg clkslowed
3
    );
4
  integer count=0; 
5
  always @(posedge clk)
6
    begin 
7
      if(count<12500)
8
      begin 
9
        count=count+1;
10
      end 
11
      else 
12
      begin 
13
            clkslowed=!clkslowed;
14
            count=0;
15
          end
16
      end
17
endmodule
18
//slow down clock speed so you can manipulate the seven seg display */
I just dont know why my lights arent going on I have the nexys 2 board I 
need the countdown to work or seven seg display I need for it to 
countdown from 9 to 0
Guest #4378077
Rate this post
• ▲ useful
▼ not useful
Lothar M. wrote:
> Joseph J. wrote:
> I just want to turn the seven seg display on as a countdown
>
> What did happen instead?
> And how did you find out

 Nothing happened it didn't turn on at all the seven segment. I found 
because it didn't work I don't know where I put the actual lights part 
referenced as A0 in the next part.
Moderator (Company: Titel) #4378366
Rate this post
• ▲ useful
▼ not useful
Joseph Abel wrote:
> I feel like im messing my user constraints file I am not sure
What does your simulation look like?
In a behavioral simulation no UCF file is involved. And therefore its 
the best way to start that way.

> I am not sure
What about trying to switch on just some segments on one of the 
digits. That would be a wholy static design without counters and other 
more tricky things.
So: do some small steps and learn by those small steps...

Reply

Note: the original post is older than 6 months. Please don't ask any new questions in this thread, but start a new one.

Formatting
  • [c]C-Code[/c]
  • [vhdl]VHDL-Code[/vhdl]
  • [code]code in other languages, ASCII drawings[/code]
  • [math]formula (LaTeX syntax)[/math]
  • [[Title]] – link to an article
  • Link to another post: right-click its post ID (#8078628), copy the address, paste it into the text

More about formatting

Post long source code as an attachment, not in the text.

Already registered? Log in

Not shown to anyone. We send you a link; your post appears once you confirm it there.

By submitting you create a free account and accept the terms of use.