Subversion Repositories programming

Rev

Rev 197 | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
207 ira 1
/**
2
 * Copyright 2006, Ira W. Snyder (devel@irasnyder.com)
3
 * License: GNU General Public License v2 (or, at your option, any later
4
 * version)
5
 */
6
 
7
/**
8
 * Name: Ira Snyder
9
 * Class: CS365 - Computer Architecture
10
 * Project #1 - Part 1
11
 * Due: 2006-02-06
12
 */
13
 
14
/**
15
 * File: ALU4.v
16
 * Purpose: Implementation of a 4-bit ALU.
17
 */
18
 
195 ira 19
module ALU4 (a, b, cin, op, cout, result);
20
    input[0:3] a, b;
21
    input[0:1] op;
22
    input cin;
23
 
24
    output[0:3] result;
25
    output cout;
26
 
27
    wire bit3_cout, bit2_cout, bit1_cout;
28
 
196 ira 29
    /* Link 4 1-bit ALU's together to make a 4-bit ALU.
30
     * Connect from LSB to MSB so the ripple-carry works correctly. */
195 ira 31
    ALU1 bit3 (a[3], b[3], cin, op, bit3_cout, result[3]);
32
    ALU1 bit2 (a[2], b[2], bit3_cout, op, bit2_cout, result[2]);
33
    ALU1 bit1 (a[1], b[1], bit2_cout, op, bit1_cout, result[1]);
34
    ALU1 bit0 (a[0], b[0], bit1_cout, op, cout, result[0]);
35
endmodule
36