+ Post New Thread
Results 1 to 5 of 5
  1. #1
    Newbie level 2
    Points: 56, Level: 1

    Join Date
    Nov 2018
    Posts
    5
    Helped
    0 / 0
    Points
    56
    Level
    1

    3-bit adder w 4 bit sum; connect to 2 "7 segment" displays

    Code:
    module Fulladd(
          input a
          input b,
          input cin,
          output s,
          output cout
    );
        
        xor(s, a, b, cin);
        and(t1, a, b);
        and(t2, a, cin);
        and(t3, b, cin);
        or(cout, t1, t2, t3);
        
    endmodule
    
    module add3(a2, a1, a0, b2, b1, b0, s2, s1, s0, cout);
    input a2, a1, a0, b2, b1, b0;
    output cout, s2, s1, s0;
    
    Fulladd stage0 (a0, b0, 0, s0, c1);
    Fulladd stage1 (a1, b1, c1, s1, c2);
    Fulladd stage2 (a2, b2, c2, s2, cout);
    
    endmodule //
    This is what I built for the full adder; when I connect to a board in class I connect the 3 bit inputs to switches on the board. I have Cin = 0; This displays a 4 bit output with the outputs going to LEDs. I need help coding this to get the output to display onto a 1s seven segment display. If the output is over 10 the 10s display will turn on.

    My teacher gave me a hint but would not help much further. He told me the module with have "assign a" and assignment verilog. I am using this in Vivado and a Basys3 board to display this in class.

    Thanks in advance for help!

    •   AltAdvertisment

        
       

  2. #2
    Advanced Member level 4
    Points: 7,862, Level: 21
    Achievements:
    7 years registered Created Blog entry
    dpaul's Avatar
    Join Date
    Jan 2008
    Location
    Germay
    Posts
    1,170
    Helped
    254 / 254
    Points
    7,862
    Level
    21
    Blog Entries
    1

    Re: 3-bit adder w 4 bit sum; connect to 2 "7 segment" displays

    It is your homework right?

    Ask yourself, where and how is the adding taking place?
    What you have posted is just the top module which instantiates other modules.

    Most important, please write a testbench first and verify whether your design is working in simulation. Later go for board level implementation.
    FPGA enthusiast!



    •   AltAdvertisment

        
       

  3. #3
    Super Moderator
    Points: 29,664, Level: 42
    ads-ee's Avatar
    Join Date
    Sep 2013
    Location
    USA
    Posts
    6,843
    Helped
    1628 / 1628
    Points
    29,664
    Level
    42

    Re: 3-bit adder w 4 bit sum; connect to 2 "7 segment" displays

    Quote Originally Posted by dpaul View Post
    It is your homework right?
    What you have posted is just the top module which instantiates other modules.
    Those aren't other modules, they are Verilog language primitives for gates, they are part of the language. Don't know why anyone would teach using them, they seem rather pointless to me, I've never had a reason to use them for 20+ years.

    Note the output of the adder is in binary therefore 1001 = 9 and is the largest single digit number you can represent. Values form 1010 to 1111 require a 10s digit. Search for the double dabble algorithm.



    •   AltAdvertisment

        
       

  4. #4
    Advanced Member level 5
    Points: 15,075, Level: 29

    Join Date
    Nov 2012
    Posts
    2,788
    Helped
    653 / 653
    Points
    15,075
    Level
    29

    Re: 3-bit adder w 4 bit sum; connect to 2 "7 segment" displays

    My teacher gave me a hint but would not help much further.
    Perhaps there is a reason. You need to start with a flow chart: you need to recall the concepts of carry, borrow etc that you have learnt in the basic arithmetic.



  5. #5
    Full Member level 3
    Points: 1,205, Level: 7

    Join Date
    Aug 2016
    Posts
    174
    Helped
    22 / 22
    Points
    1,205
    Level
    7

    Re: 3-bit adder w 4 bit sum; connect to 2 "7 segment" displays

    Quote Originally Posted by jinformations View Post
    Code:
    module Fulladd(
          input a
          input b,
          input cin,
          output s,
          output cout
    );
        
        xor(s, a, b, cin);
        and(t1, a, b);
        and(t2, a, cin);
        and(t3, b, cin);
        or(cout, t1, t2, t3);
        
    endmodule
    
    module add3(a2, a1, a0, b2, b1, b0, s2, s1, s0, cout);
    input a2, a1, a0, b2, b1, b0;
    output cout, s2, s1, s0;
    
    Fulladd stage0 (a0, b0, 0, s0, c1);
    Fulladd stage1 (a1, b1, c1, s1, c2);
    Fulladd stage2 (a2, b2, c2, s2, cout);
    
    endmodule //
    This is what I built for the full adder; when I connect to a board in class I connect the 3 bit inputs to switches on the board. I have Cin = 0; This displays a 4 bit output with the outputs going to LEDs. I need help coding this to get the output to display onto a 1s seven segment display. If the output is over 10 the 10s display will turn on.
    Thanks in advance for help!
    The question to me is vague.

    I think he has more up to two 3-bit inputs where he feeds 0 upto 7 to the FPGA from each input. For the outputs to be 4-bit outputs, I think those are BCD outputs. The board seems to have a BCD-to-seven-segment converter. I think he needshould to implement addition on the 3-bit inputs and then convert the result from straight binary to BCD.

    I don't know the board. I'm just guessing. I don't use verilog either.
    -------------
    --Akanimo.



--[[ ]]--