Courage
Newbie level 3
Hey guys, this is my first and hopefully not my last post. I'm a noob in verilog and also seems that i'm pretty much stupid :-( because i need a simple 8 bit ALU code and i need it tomorrow is there anyone that can help me?
You can start from this code:
module alu(clk, a, b, opcode, outp);
input clk;
input [7:0] a, b;
input [2:0] opcode;
output [7:0] outp;
reg [7:0] outp;
always @(posedge clk)
begin
case (opcode)
3'h0 : outp <= a + b;
3'h1 : outp <= a - b;
3'h2 : outp <= a & b;
3'h3 : outp <= a | b;
3'h4 : outp <= ~a;
endcase
end
endmodule
but i need to add a carry and a function in case of 0 (zero) to it, which i don't know how.
and if anyone can point me in the direction of a diagram for it, I'd be forever in your debt.
Thank you in advance to anyone that can help.
You can start from this code:
module alu(clk, a, b, opcode, outp);
input clk;
input [7:0] a, b;
input [2:0] opcode;
output [7:0] outp;
reg [7:0] outp;
always @(posedge clk)
begin
case (opcode)
3'h0 : outp <= a + b;
3'h1 : outp <= a - b;
3'h2 : outp <= a & b;
3'h3 : outp <= a | b;
3'h4 : outp <= ~a;
endcase
end
endmodule
but i need to add a carry and a function in case of 0 (zero) to it, which i don't know how.
and if anyone can point me in the direction of a diagram for it, I'd be forever in your debt.
Thank you in advance to anyone that can help.