BCD to 7-segment decoder?? what correct result

Discussion in 'Programmer's Corner' started by noor22, May 18, 2013.

  1. noor22

    Thread Starter New Member

    Oct 11, 2012
    19
    0
    hi everyone :)

    i made same project on this thread but with differnce code my code like this :p
    http://forum.allaboutcircuits.com/showthread.php?t=30141

    Code ( (Unknown Language)):
    1.  
    2. module Seven_Seg_Display_V2001 (
    3. output  [0: 6] Display,
    4. input [3: 0] BCD
    5. );
    6. // abc_defg
    7. parameter BLANK = 7'b000_0000;
    8. parameter ZERO = 7'b111_1110; // h7e
    9. parameter ONE = 7'b011_0000; // h30
    10. parameter TWO = 7'b110_1101; // h6d
    11. parameter THREE = 7'b111_1001; // h79
    12. parameter FOUR = 7'b011_0011; // h33
    13. parameter FIVE = 7'b101_1011; // h5b
    14. parameter SIX = 7'b101_1111; // h5f
    15. parameter SEVEN = 7'b111_0000; // h70
    16. parameter EIGHT = 7'b111_1111; // h7f
    17. parameter NINE = 7'b111_1011; // h7b
    18. /*always @ (BCD)
    19. case (BCD)
    20. 0: Display = ZERO;
    21. 1: Display = ONE;
    22. 2: Display = TWO;
    23. 3: Display = THREE;
    24. 4: Display = FOUR;
    25. 5: Display = FIVE;
    26. 6: Display = SIX;
    27. 7: Display = SEVEN;
    28. 8: Display = EIGHT;
    29. 9: Display = NINE;
    30. default: Display = BLANK;
    31. endcase*/
    32. endmodule
    33. module t_Seven_Seg_Display_V2001 ();
    34. wire [6: 0] Display;
    35. reg [3: 0] BCD;
    36. parameter BLANK = 7'b000_0000;
    37. parameter ZERO = 7'b111_1110; // h7e
    38. parameter ONE = 7'b011_0000; // h30
    39. parameter TWO = 7'b110_1101; // h6d
    40. parameter THREE = 7'b111_1001; // h79
    41. parameter FOUR = 7'b011_0011; // h33
    42. parameter FIVE = 7'b101_1011; // h5b
    43. parameter SIX = 7'b001_1111; // h1f
    44. parameter SEVEN = 7'b111_0000; // h70
    45. parameter EIGHT = 7'b111_1111; // h7f
    46. parameter NINE = 7'b111_1011; // h7b
    47. initial #120 $finish;
    48. initial fork
    49. #10 BCD = 0;
    50. #20 BCD = 1;
    51. #30 BCD = 2;
    52. #40 BCD = 3;
    53. #50 BCD = 4;
    54. #60 BCD = 5;
    55. #70 BCD = 6;
    56. #80 BCD = 7;
    57. #90 BCD = 8;
    58. #100 BCD = 9;
    59. join
    60. Seven_Seg_Display_V2001 M0 (Display, BCD);
    61.  
    62. initial begin
    63. $monitor("  BLANK=%b, ZERO=%b,ONE=%b,TWO=%b, THREE=%b,FOUR=%b,FIVE=%b, SIX=%b,SEVEN=%b, EIGHT=%b,NINE=%b",BLANK,ZERO,ONE,TWO,THREE,FOUR,FIVE,SIX,SEVEN,EIGHT,NINE);
    64. end
    65. endmodule
    66.  

    Here is the result of the simulation
    [​IMG][/url][/IMG]
    http://im33.gulfup.com/LbmSF.png

    i want to check it is correct or not :confused::(
    can u tell me if it not correct answer what is the right answer?
    i hope to get any reply before 24 hour bec. it must be sumitted twm.:mad:

    thankx
    w8 w8 w8
     
  2. WBahn

    Moderator

    Mar 31, 2012
    17,743
    4,795
    Since this is homework, it really should be in the Homework Help section.

    Also, you need to show what work YOU have done to solve YOUR homework problem. We won't just do it for you.

    What is preventing you from being able to determine whether your code is producing the correct results?
     
  3. noor22

    Thread Starter New Member

    Oct 11, 2012
    19
    0
    thank u for reply,:)
    bec. this is first time to use verilog
    i do not study it before but my teacher requirement to do it by using verilog:confused:
     
  4. WBahn

    Moderator

    Mar 31, 2012
    17,743
    4,795
    Let's take a step back. What result is your code supposed to produce?
     
  5. noor22

    Thread Starter New Member

    Oct 11, 2012
    19
    0
    it convert bcd to 7 segment
    4 binry input 7 decoder output than it show on 7 segment like decimal number
    0,1,2,3,4,5,6,7,8,9

    +-a-+
    f b
    |-g-|
    e c
    +-d-+
     
  6. WBahn

    Moderator

    Mar 31, 2012
    17,743
    4,795
    And how is this supposed to be shown in the simulation results you posted?
     
  7. noor22

    Thread Starter New Member

    Oct 11, 2012
    19
    0
    this is my question :):)
     
  8. WBahn

    Moderator

    Mar 31, 2012
    17,743
    4,795
    Well, how are WE supposed to know how YOUR simulation is supposed to show something?

    If we came to you and said that we were putting together a simulation to test whether a BCD-to-7SEG encoder was working properly, what signals would YOU tell US should be in the simulation?
     
  9. noor22

    Thread Starter New Member

    Oct 11, 2012
    19
    0
    it show decimal nu. from 0 to 9
    each signal one line
    --0
    ----1
    -------2
    ---------3
    -------------4
    ----------------5
    ---------------------6
    so on
    ^^
     
  10. WBahn

    Moderator

    Mar 31, 2012
    17,743
    4,795
    Do you have ten different signals?

    You have a 4-bit input (the BCD value) and a 7-bit output (the signals to the 7SEG display).

    Let's call the bits of the input V[3:0] wher V[3] is the msb and V[0] is the lsb.

    Let's call the bits of the output Y[6:0] where Y[6] is the 'g' segment and Y[0] is the 'a' segment.

    For the decoder you are trying to implement, is the output HI or LO for a segment that is supposed to be lit?

    Can you prepare a truth table for what your input/output relationships should be?

    DEC V[3] V[2] V[1] V[0] g f e d c b a
    0
    1
    2
    3
    4
    5
    6
    7
    8
    9
     
  11. noor22

    Thread Starter New Member

    Oct 11, 2012
    19
    0
  12. WBahn

    Moderator

    Mar 31, 2012
    17,743
    4,795
    Okay, so set up your simulation so that it shows these signals.
     
  13. noor22

    Thread Starter New Member

    Oct 11, 2012
    19
    0
    ok how?:confused::confused::confused:
     
  14. noor22

    Thread Starter New Member

    Oct 11, 2012
    19
    0
    it must change this part of my code ?



    $monitor(" BLANK=%b, ZERO=%b,ONE=%b,TWO=%b, THREE=%b,FOUR=%b,FIVE=%b, SIX=%b,SEVEN=%b, EIGHT=%b,NINE=%b",BLANK,ZERO,ONE,TWO,THREE,FOUR,FIVE,SIX,SEVEN,EIGHT,NINE
     
  15. noor22

    Thread Starter New Member

    Oct 11, 2012
    19
    0
  16. WBahn

    Moderator

    Mar 31, 2012
    17,743
    4,795
    How can we possibly tell you how to set up your simulation when we don't even know what simulator you are using? There are dozens of simulators out there. If you tell us exactly which simulation environment you are using, then MAYBE someone here might be familiar with it. But you best bet is to go through the tutorials that usually come with the simulator for Getting Started. They usually aren't very thorough, but should cover the basics that you need for this.
     
Loading...