module Sub1bits (SW, LEDR, LEDG);
input [17:0] SW; // toggle switches
output [17:0] LEDR; // red LEDS
output [7:0] LEDG; // green LEDs
//set original program input , output
wire X, Y, Bin;
wire Dif, Bout;
//mapping to hardware
assign LEDR = SW;
//assign SW to input
assign X=SW[2];
assign Y=SW[1];
assign Bin=SW[0];
// X - Y -Bin = Bout , Dif
//Assign difference and borrow
assign Dif = (((~X)&(~Y)&Bin)|((~X)&(Y)&(~Bin))|(X&(~Y)&(~Bin))|(X & Y & Bin));
assign Bout = (((~X)&Y)|((~X)&Bin)|(Y & Bin));
assign LEDG[0]=Dif;
assign LEDG[1]=Bout;
endmodule
/*original program
//-------------------------------------
//Filename : fadd1_df.v
//-------------------------------------
module fadd1_df(X, Y, Bin, Dif, Bout);
input X, Y, Bin;
output Dif, Bout;
//Assign difference and borrow
assign Dif = (((~X)&(~Y)&Bin)|((~X)&(Y)&(~Bin))|(X&(~Y)&(~Bin))|(X & Y & Bin));
assign Bout = (((~X)&Y)|((~X)&Bin)|(Y & Bin));
endmodule
*/
沒有留言:
張貼留言