Rev 197 | Blame | Compare with Previous | Last modification | View Log | RSS feed
/*** Copyright 2006, Ira W. Snyder (devel@irasnyder.com)* License: GNU General Public License v2 (or, at your option, any later* version)*//*** Name: Ira Snyder* Class: CS365 - Computer Architecture* Project #1 - Part 1* Due: 2006-02-06*//*** File: ALU4.v* Purpose: Implementation of a 4-bit ALU.*/module ALU4 (a, b, cin, op, cout, result);input[0:3] a, b;input[0:1] op;input cin;output[0:3] result;output cout;wire bit3_cout, bit2_cout, bit1_cout;/* Link 4 1-bit ALU's together to make a 4-bit ALU.* Connect from LSB to MSB so the ripple-carry works correctly. */ALU1 bit3 (a[3], b[3], cin, op, bit3_cout, result[3]);ALU1 bit2 (a[2], b[2], bit3_cout, op, bit2_cout, result[2]);ALU1 bit1 (a[1], b[1], bit2_cout, op, bit1_cout, result[1]);ALU1 bit0 (a[0], b[0], bit1_cout, op, cout, result[0]);endmodule