Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- module ALU (
- input [7:0] Rd,
- input [7:0] RrK,
- input [2:0] F,
- output [7:0] Y,
- output Z,
- output C
- );
- reg _Z, _C;
- reg [8:0] _Y;
- parameter _pasaRrk = 3'b000;
- parameter _suma = 3'b001;
- parameter _and = 3'b010;
- parameter _resta = 3'b011;
- parameter _xor = 3'b100;
- parameter _pasaRd = 3'b101;
- parameter _or = 3'b110;
- always @(Rd, RrK, F) begin
- case (F)
- // Dejar pasar
- _pasaRrk: _Y = RrK;
- _suma: _Y = Rd + RrK;
- _and: _Y = Rd & RrK;
- _resta: _Y = Rd - RrK;
- _xor: _Y = Rd ^ Rd;
- _pasaRd: _Y = Rd;
- _or: _Y = Rd | RrK;
- default: _Y = 8'b0;
- endcase
- end
- assign Y = _Y;
- assign Z = ~_Y[7] & ~_Y[6] & ~_Y[5] & ~_Y[4] & ~_Y[3] & ~_Y[2] & ~_Y[1] & ~_Y[0];
- assign C = _Y[8];
- endmodule
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement