Professional Documents
Culture Documents
/////////////////////////////////////////////////////////////////////////
/////////
// Company: Digilent Inc.
// Engineer: Varun Kondagunturi
//
// Create Date: 17:08:26 06/12/2014
// Design Name:
// Module Name: Abacus_Top_Module
// Project Name:
// Target Devices:
// Tool versions:
//
//
// Description:
//This is the Top-Level Source file for the Abacus Project.
//Slide switches provide two 8-bit binary inputs A and B.
//Slide Switches [15 down to 8] is input A.
//Slide Switches [7 down to 0] is input B.
//Inputs from the Push Buttons ( btnU, btnD, btnR, btnL) will allow the
user to select different arithmetic operations that will be computed on
the inputs A and B.
//btnU: Subtraction/Difference. Result will Scroll
//When A>B, difference is positive.
//When A<B, difference is negative. If the button is not held down but
just pressed once, the result will scroll. To find out if the result is
negative, press and hold onto the push button btnU. This will show the
negative sign.
//btnD: Multiplication/Product. Result will Scroll
//btnR: Quotient(Division Operation). Press and Hold the button to
display result
//btnL: Remainder ( Division Operation). Press and Hold the button to
display result
//Output is displayed on the 7 segment LED display.
//
//
// Dependencies:
//
// Revision:
// Revision 0.01 - File Created
// Additional Comments:
//
/////////////////////////////////////////////////////////////////////////
/////////
module Basys3_Abacus_Top(
//CLK Input
input clk,
// LED Outputs
output [15:0] led,
);
//adder signals
wire [7:0] sum;
wire [7:0] diff;
wire cout;
// Difference Signals
wire [7:0] zero_diff;
wire [7:0] twoC_diff;
B = twoC_diff[7:0];
x[15:12] = 'hA;
x[11:8] = scroll_dataout[11:8]; //hundreds;
x[7:4] = scroll_dataout[7:4];// tens;
x[3:0] = scroll_dataout[3:0];//ones;
end
begin
B = diff[7:0];
x[15:12] = scroll_dataout[15:12];//'hC;
x[11:8] = scroll_dataout[11:8]; //hundreds;
x[7:4] = scroll_dataout[7:4];// tens;
x[3:0] = scroll_dataout[3:0];//ones;
end
B = Product[15:0];
x[15:12] = scroll_dataout[15:12];//'hC
x[11:8] = scroll_dataout[11:8]; //hundreds;
x[7:4] = scroll_dataout[7:4];// tens;
x[3:0] = scroll_dataout[3:0];//ones;
end
B1 = QU[7:0]; // bcdout1
x[15:12] = scroll_dataout_QU[15:12];//'hC;
x[11:8] = scroll_dataout_QU[11:8]; //hundreds;
x[7:4] = scroll_dataout_QU[7:4];// tens;
x[3:0] = scroll_dataout_QU[3:0];//ones;
end
B2 = REM[7:0]; // bcdout2
x[15:12] = scroll_dataout_REM[15:12];//'hC;
x[11:8] = scroll_dataout_REM[11:8]; //hundreds;
x[7:4] = scroll_dataout_REM[7:4];// tens;
x[3:0] = scroll_dataout_REM[3:0];//ones;
end
else
begin
B = {cout, sum[7:0]};
x[15:12] = scroll_dataout[15:12];//'hC;
x[11:8] = scroll_dataout[11:8]; //hundreds;
x[7:4] = scroll_dataout[7:4];// tens;
x[3:0] = scroll_dataout[3:0];//ones;
end
end
// Binary to BCD conversion module1 for Adder/Sub/Multi Result
bin_to_decimal u1 (
.B(B),
.bcdout(bcdout)
);
.B1(B1), // QU in binary
.bcdout1(bcdout1)// QU in BCD
);
// Scrolls Display
seg_scroll u4(
.clk(clk),
.clr(clr_seg),
.scroll_datain(bcdout),
.scroll_dataout(scroll_dataout)
);
.clk(clk),
.clr(clr_seg_DIV),
.scroll_datain_QU(bcdout1),
.scroll_dataout_QU(scroll_dataout_QU)
);
.clk(clk),
.clr(clr_seg_DIV),
.scroll_datain_REM(bcdout2),
.scroll_dataout_REM(scroll_dataout_REM)
);
seg7decimal u7 (
.x(x),
.clk(clk),
.clr(btnC),
.a_to_g(seg),
.an(an),
.dp(dp)
);
// Arithmetic Operations
// Adder/Subtractor Module
adder u8 (
.clk(clk),
.a(sw[15:8]),
.b(sw[7:0]),
.sum(sum),
.diff(diff),
.cout(cout),
.cin(btnU)
);
// Product/Multiplication
.clk(clk),
//.clr(btn[1]),
.A0_3(sw[11:8]),
.B0_3(sw[3:0]),
.pp0(PP0)
);
.clk(clk),
//.clr(btn[1]),
.A4_7(sw[15:12]),
.B0_3(sw[3:0]),
.pp1(PP1)
);
.clk(clk),
//.clr(btn[1]),
.A0_3(sw[11:8]),
.B4_7(sw[7:4]),
.pp2(PP2)
);
);
// Divider Module
divider u13(
.clk(clk),
.div(sw[15:8]),
.dvr(sw[7:0]),
.quotient(QU),
.remainder(REM)
);
endmodule