moonnightingale
Full Member level 6
This is my code
module alu2bit(aluout,result,zero,one,two,three,four,five,six,seven,eight,nine,a,b,select);
output [3:0] aluout,result; // the result
output [3:0] zero,one,two,three,four,five,six,seven,eight,nine;
input [1:0] a,b; // input a and b
input [1:0] select;
reg [3:0] aluout,result;
reg [3:0] zero,one,two,three,four,five,six,seven,eight,nine;
always@(a or b)
begin
case (select)
2'b00:aluout=a+b; // For addition of two bits
2'b01:aluout=a-b; // For addition of two bits
2'b10:aluout=a*b; // For multiplication of two bits
endcase
if (aluout==4'd0) result=zero;
else if (aluout==4'd1) result=one;
else if (aluout==4'd2) result=two;
else if (aluout==4'd3) result=three;
else if (aluout==4'd4) result=four;
else if (aluout==4'd5) result=five;
else if (aluout==4'd6) result=six;
else if (aluout==4'd7) result=seven;
else if (aluout==4'd8) result=eight;
else if (aluout==4'd9) result=nine;
else result=zero;
end
endmodule
I want my LEDs to glow as per my result. how can i tell UCF about my two bit input data a and b
U can also give comments to refine my code
module alu2bit(aluout,result,zero,one,two,three,four,five,six,seven,eight,nine,a,b,select);
output [3:0] aluout,result; // the result
output [3:0] zero,one,two,three,four,five,six,seven,eight,nine;
input [1:0] a,b; // input a and b
input [1:0] select;
reg [3:0] aluout,result;
reg [3:0] zero,one,two,three,four,five,six,seven,eight,nine;
always@(a or b)
begin
case (select)
2'b00:aluout=a+b; // For addition of two bits
2'b01:aluout=a-b; // For addition of two bits
2'b10:aluout=a*b; // For multiplication of two bits
endcase
if (aluout==4'd0) result=zero;
else if (aluout==4'd1) result=one;
else if (aluout==4'd2) result=two;
else if (aluout==4'd3) result=three;
else if (aluout==4'd4) result=four;
else if (aluout==4'd5) result=five;
else if (aluout==4'd6) result=six;
else if (aluout==4'd7) result=seven;
else if (aluout==4'd8) result=eight;
else if (aluout==4'd9) result=nine;
else result=zero;
end
endmodule
I want my LEDs to glow as per my result. how can i tell UCF about my two bit input data a and b
U can also give comments to refine my code