OpenCores
URL https://opencores.org/ocsvn/yacc/yacc/trunk

Subversion Repositories yacc

[/] [yacc/] [trunk/] [rtl/] [alu.v] - Blame information for rev 4

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 2 tak.sugawa
`include "define.h"
2
//Feb.25.2005 Verilog2001 Style
3
//Jan.20.2005 implict event list
4
//Jun.14.2004 Initial Version
5
//Jul.4.2004 sensibity list bug fix
6
//Jul.5.2004 less area version
7
//Apr.14.2005  Stratix 2 workaround Quartus 4.1/4.2 
8
 
9
module substruct (input [31:0] a,b,
10
                                                                  output [31:0] c);
11
 
12
assign c=a+~b+1;//NG Quartus 4.1/4.2 a-b
13
endmodule
14
 
15
module alu (input [31:0] a,b,
16
                     output reg [31:0] alu_out,
17
                     input [3:0] alu_func);
18
 
19
                                wire [31:0] c;
20
 
21
 
22
parameter   [3:0] alu_nop                 =4'b0000,
23
                  alu_add                 =4'b0001,
24
                  alu_sub                 =4'b0010,
25
                  alu_less_than_unsigned  =4'b0101, //Jul.5.2004
26
                  alu_less_than_signed    =4'b0100, //Jul.5.2004
27
                  alu_OR                  =4'b0011,
28
                  alu_AND                 =4'b0110,
29
                  alu_XOR                 =4'b0111,
30
                  alu_NOR =4'b1000;
31
 
32
        reg [32:0] sum;
33
 
34
        always @* begin //
35
                case (alu_func)
36
                        alu_nop       : alu_out=32'h0000;
37
                        alu_add        : alu_out=a+b;
38
                        alu_sub        : alu_out=c;//Apr.14.2005 NG a-b Quartus 4.1/4.2
39
                        alu_OR         : alu_out=a | b;
40
                        alu_AND        : alu_out=a & b;
41
                        alu_XOR        : alu_out=a ^ b;
42
                        alu_NOR        : alu_out=~(a | b);
43
                        alu_less_than_unsigned : alu_out=a < b;//Jun.29.2004
44
                        alu_less_than_signed: begin
45
                                                 sum={a[31],a}+~{b[31],b}+33'h0_0000_0001;//Apr.14.2005 1'b1;//Important 33'h0_0000_000 :a-b                                                                      $signed(a) > $signed(b);
46
                                                 alu_out={31'h0000_0000,sum[32]};//{31'h0000_0000,sum[32]}; 
47
                                               end
48
                        default : alu_out=32'h0000_0000;
49
 
50
 
51
                endcase
52
        end
53
 
54
                substruct sub(a,b,c);
55
 
56
endmodule
57
 
58
 
59
 
60
 
61
 

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.