From e64c18d0e30c33fe4609c881620fa937da7b8ce3 Mon Sep 17 00:00:00 2001 From: Michael Abed Date: Sun, 2 Dec 2012 12:13:10 -0500 Subject: make git repo --- verilog/alu.v | 67 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 67 insertions(+) create mode 100755 verilog/alu.v (limited to 'verilog/alu.v') diff --git a/verilog/alu.v b/verilog/alu.v new file mode 100755 index 0000000..158d9a6 --- /dev/null +++ b/verilog/alu.v @@ -0,0 +1,67 @@ +`timescale 1ns / 1ps +////////////////////////////////////////////////////////////////////////////////// +// Company: +// Engineer: +// +// Create Date: 19:56:04 10/03/2012 +// Design Name: +// Module Name: alu +// Project Name: +// Target Devices: +// Tool versions: +// Description: +// +// Dependencies: +// +// Revision: +// Revision 0.01 - File Created +// Additional Comments: +// +////////////////////////////////////////////////////////////////////////////////// +module alu( r1, r2, r3, aluop); + +parameter BITS = 32; + +input [BITS-1:0] r2, r3; +input [2:0] aluop; +output [BITS-1:0] r1; + +wire cinw; +wire carries [0:BITS-1]; +wire [BITS-1:0] r1out; +cin_choice cin(cinw, aluop); + +alu_slice1bit alu_slice_init( + .r1(r1out[0]), + .cout(carries[0]), + .r2(r2[0]), + .r3(r3[0]), + .cin(cinw), + .op(aluop) + ); + +generate + genvar i; + for (i = 1; i < BITS; i = i + 1) begin:aluslice + alu_slice1bit alu_slice( + .r1(r1out[i]), + .cout(carries[i]), + .r2(r2[i]), + .r3(r3[i]), + .cin(carries[i-1]), + .op(aluop) + ); + end +endgenerate + +wire sltw; +slt sltg(sltw, r2[BITS-1], r3[BITS-1], r1out[BITS-1], carries[BITS-1]); + + +wire doslt; +wire [BITS-2:0] s; +assign s = 0; +and a(doslt, aluop[2], aluop[1], aluop[0]); +mux_2to1_nbit #(BITS) m(r1, doslt, r1out, {s,sltw}); + +endmodule -- cgit v1.2.3