1. InnocentOfTheWorld

    Thread Starter Member

    Apr 15, 2010
    47
    1
    Hello i am new on fpga and verilog.in this code i have taken input from keypad and want to make a calculator and display on lcd.help me in code please how to make alu of calculator and modification in this code regarding input and how to display on 8 bit lcd please help.
    Code ( (Unknown Language)):
    1. `timescale 1ns / 1ps
    2. //////////////////////////////////////////////////////////////////////////////////
    3. // Company:
    4. // Engineer:
    5. //
    6. // Create Date:    14:53:29 10/15/2011
    7. // Design Name:
    8. // Module Name:    kepad
    9. // Project Name:
    10. // Target Devices:
    11. // Tool versions:
    12. // Description:
    13. //
    14. // Dependencies:
    15. //
    16. // Revision:
    17. // Revision 0.01 - File Created
    18. // Additional Comments:
    19. //
    20. //////////////////////////////////////////////////////////////////////////////////
    21. module kepad(
    22.     input [3:0] in1,
    23.     output reg [3:0] out1,
    24.      output reg [3:0] sevenseg,
    25.     input clk
    26.     );
    27.      reg [3:0] num1=0;
    28.      reg [3:0] num2=0;
    29.      reg [3:0] opr=0;
    30.      reg [1:0] count=0;
    31. //in1 = in1;   
    32. //out1=out1    
    33. //  sevenseg=0;
    34. always@(posedge clk)
    35. begin
    36. out1=1;
    37. if(in1==8)
    38. sevenseg=7;
    39. if(in1==4)
    40. sevenseg=4;
    41. if(in1==2)
    42. sevenseg=1;
    43. if(in1==1)
    44.  sevenseg=10;   //10=reset
    45. out1=2;
    46. if(in1==8)
    47. sevenseg=8;
    48. if(in1==4)
    49. sevenseg=5;
    50. if(in1==2)
    51. sevenseg=2;
    52. if(in1==1)
    53.  sevenseg=0;
    54. out1=4;
    55. if(in1==8)
    56. sevenseg=9;
    57. if(in1==4)
    58. sevenseg=6;
    59. if(in1==2)
    60. sevenseg=3;             //missed '11'
    61. if(in1==1)
    62.  sevenseg=12;   //12='='
    63. out1=8;
    64. if(in1==8)
    65.  sevenseg=13;   //13=/
    66. if(in1==4)
    67.  sevenseg=14;   //14=*
    68. if(in1==2)
    69.   sevenseg=15;  //15=-
    70. if(in1==1)
    71.  sevenseg=16;   //16=+
    72. end
    73. always@(sevenseg)
    74. begin
    75. count=count+1;
    76. end
    77. always@ (sevenseg or count)
    78. case(count)
    79. 2'd0: opr=12;
    80. 2'd1: num1=sevenseg;
    81. 2'd2: opr=sevenseg;
    82. 2'd3: num2=sevenseg;
    83. default: opr=0;
    84. endcase
    85. //if(count==3)
    86. //
    87. endmodule
    88.  
     
  2. RRITESH KAKKAR

    Senior Member

    Jun 29, 2010
    2,831
    89
    Hi ICOW,

    can you please tell me about the kit or that programmer you are using for programming...
     
  3. InnocentOfTheWorld

    Thread Starter Member

    Apr 15, 2010
    47
    1
    i am using spartan 3
    x3cs400
     
    RRITESH KAKKAR likes this.
Loading...