EmbDev.net

Forum: FPGA, VHDL & Verilog RE: I was wondering where I went wrong


Author: Joseph Joe (earthkid123)
Posted on:

Rate this post
0 useful
not useful

module display (clock, AN0, AN1, AN2, AN3, CA, CB, CC, CD, CE, CF, CG, CDP);


//USED FOR SEVEN SEG
input clock;

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

reg [7:0] cathodedata; //cathode data
reg [3:0] anodedata; //anode data
reg [2:0] digit = 1;
reg [6:0] data;
reg setdp;
reg [19:0] counter = 0;

assign CA = cathodedata [7];
assign CB = cathodedata [6];
assign CC = cathodedata [5];
assign CD = cathodedata [4];
assign CE = cathodedata [3];
assign CF = cathodedata [2];
assign CG = cathodedata [1];
assign CDP = cathodedata [0];
assign AN3 = anodedata [3];
assign AN2 = anodedata [2];
assign AN1 = anodedata [1];
assign AN0 = anodedata [0];
//USED FOR SEVEN SEG

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

always@(negedge clock)
begin
    if (digit == 1)
        begin
            if (counter == 200000)
                begin
                    digit = 2;
                end
            else
                begin
                counter = counter + 1;
                data = 4;
                end
        end
    else if (digit == 2)
        begin
            if (counter == 400000)
                begin
                    digit = 3;
                end
            else
                begin
                    counter = counter + 1;
                    data = 3;
                end
        end
    else if (digit == 3)
        begin
            if (counter == 600000)
                begin
                    digit = 4;
                end
            else
                begin
                    counter = counter + 1;
                    data = 2;
                end
        end
    else if (digit == 4)
        begin
            if (counter == 800000)
                begin
                    digit = 1;
                    counter = 0;
                end 
            else
                begin
                    counter = counter + 1;
                    data = 1;
                end
        end 
end


always @ (*)
begin

    case (data)
        6'd0: cathodedata = 8'b00000011; //0
        6'd1: cathodedata = 8'b10011111; //1
        6'd2: cathodedata = 8'b00100101; //2
        6'd3: cathodedata = 8'b00001101; //3
        6'd4: cathodedata = 8'b10011001; //4
        6'd5: cathodedata = 8'b01001001; //5
        6'd6: cathodedata = 8'b01000001; //6
        6'd7: cathodedata = 8'b00011111; //7
        6'd8: cathodedata = 8'b00000001; //8
        6'd9: cathodedata = 8'b00001001; //9
        6'd10: cathodedata = 8'b00010001; //A
        6'd11: cathodedata = 8'b11000001; //B
        6'd12: cathodedata = 8'b01100011; //C
        6'd13: cathodedata = 8'b10000101; //D
        6'd14: cathodedata = 8'b00100001; //E
        6'd15: cathodedata = 8'b01110001; //F
        default: cathodedata = 8'b11111111; //default all off
    endcase

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

    case(digit)
        0: anodedata = 4'b1111; //all OFF
        4: anodedata = 4'b1110; //AN0
        3: anodedata = 4'b1101; //AN1
        2: anodedata = 4'b1011; //AN2
        1: anodedata = 4'b0111; //AN3
        default:
        anodedata = 4'b1111; //all OFF
    endcase

end 
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

: Edited by User
Author: Joseph Joe (earthkid123)
Posted on:

Rate this post
0 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

module seven_seg( intput [3:0]numbers, output reg[6:0] display);

always @(numbers)
  begin  
    case(numbers)
      4'h0: out1=7'b1000000;  //0111111;
      4'h1:  out1=7'b1111001;  //0000110;
      4'h2:  out1=7'b0100100;  //1011011;
      4'h3: out1=7'b0110000;  //1001111;
      4'h4: out1=7'b0011001;  //1100110;
      4'h5: out1=7'b0010010;  //1101101;
      4'h6: out1=7'b0000010;  //1111101;
      4'h7: out1=7'b1111000;  //0000111;
      4'h8: out1=7'b0000000;  //1111111;
      4'h9: out1=7'b0011000;  //1100111;
       default: out1=7'b1111111;//0000000;
    endcase
  end  
endmodule


endmodule
// display numbers*/
/*
module Slowclock(input wire clk, output reg clkslowed
    );
  integer count=0; 
  always @(posedge clk)
    begin 
      if(count<12500)
      begin 
        count=count+1;
      end 
      else 
      begin 
            clkslowed=!clkslowed;
            count=0;
          end
      end
endmodule
//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

Author: Lothar Miller (lkmiller) (Moderator)
Posted on:

Rate this post
0 useful
not useful
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 that out?

You don't have to start a new THREAD for each post. You can simply 
append new experiences with the edit box at the end oo the thread...

: Edited by Moderator
Author: Joseph (Guest)
Posted on:

Rate this post
0 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.

Author: Joseph Abel (Guest)
Posted on:

Rate this post
0 useful
not useful
I feel like im messing my user constraints file I am not sure

Author: Lothar Miller (lkmiller) (Moderator)
Posted on:

Rate this post
0 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...

Author: Joseph (Guest)
Posted on:

Rate this post
0 useful
not useful
I simulated it and I still don't see my problem im not sure what the 
error is why my seven segment display isnt working

Author: Lothar Miller (lkmiller) (Moderator)
Posted on:

Rate this post
0 useful
not useful
Joseph wrote:
> I simulated it
With what result?
Does the behavioral simulation work as expected?

Then something with the implementation on the hardware is wrong. And the 
most significant part to interact with the toolchain is the ucf file. 
There the pin constraints are most important...

Reply

Entering an e-mail address is optional. If you want to receive reply notifications by e-mail, please log in.

Rules — please read before posting

  • Post long source code as attachment, not in the text
  • Posting advertisements is forbidden.

Formatting options

  • [c]C code[/c]
  • [avrasm]AVR assembler code[/avrasm]
  • [vhdl]VHDL code[/vhdl]
  • [code]code in other languages, ASCII drawings[/code]
  • [math]formula (LaTeX syntax)[/math]




Bild automatisch verkleinern, falls nötig
Note: the original post is older than 6 months. Please don't ask any new questions in this thread, but start a new one.