Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

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

Status
Not open for further replies.

jinformations

Newbie level 4
Joined
Nov 1, 2018
Messages
5
Helped
0
Reputation
0
Reaction score
0
Trophy points
1
Activity points
63
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!
 

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.
 

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.
 

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.
 

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.
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top