Skip to content

Instantly share code, notes, and snippets.

@szboynono
Created July 4, 2016 23:00
Show Gist options
  • Save szboynono/1978e7ba473bb78b207fbb400e6ba3d6 to your computer and use it in GitHub Desktop.
Save szboynono/1978e7ba473bb78b207fbb400e6ba3d6 to your computer and use it in GitHub Desktop.
module alu4bits;
input [8:0]a,b;
input [3:0]sel;
output [8:0]z;
reg [8:0]z;
always @(sel,a,b)
begin
case(sel)
4'b0000: z = a + b;
4'b0000: z = a - b;
4'b0000: z = b - 1;
4'b0000: z = a * b;
4'b0000: z = a && b;
4'b0000: z = a || b;
4'b0000: z = !a;
4'b0000: z = ~a;
4'b0000: z = a & b;
4'b0000: z = a | b;
4'b0000: z = a ^ b;
4'b0000: z = a << 1;
4'b0000: z = a >> 1;
4'b0000: z = a + 1;
4'b0000: z = a - 1;
4'b0000: z = b;
endcase
end
endmodule
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment