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

Subversion Repositories y80e

[/] [y80e/] [trunk/] [rtl/] [aluout.v] - Blame information for rev 12

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 12 bsa
/*******************************************************************************************/
2
/**                                                                                       **/
3
/** ORIGINAL COPYRIGHT (C) 2011, SYSTEMYDE INTERNATIONAL CORPORATION, ALL RIGHTS RESERVED **/
4
/** COPYRIGHT (C) 2012, SERGEY BELYASHOV                                                  **/
5
/**                                                                                       **/
6
/** alu function unit combiner module                                 Rev 0.0  06/13/2012 **/
7
/**                                                                                       **/
8
/*******************************************************************************************/
9
module aluout (cry_nxt, data_bus, hcar_nxt, one_nxt, par_nxt, sign_nxt, zero_nxt, adder_c,
10
               adder_hc, adder_out, hi_byte, logic_c, logic_hc, logic_out, shft_c, shft_out,
11
               mult_out,
12
               unit_sel, word_op);
13
 
14
  input         adder_c;       /* math carry result                                        */
15
  input         adder_hc;      /* math half-carry result                                   */
16
  input         hi_byte;       /* shift left byte control                                  */
17
  input         logic_c;       /* logic carry result                                       */
18
  input         logic_hc;      /* logic half-carry result                                  */
19
  input         shft_c;        /* shift carry result                                       */
20
  input         word_op;       /* word operation                                           */
21
  input   [1:0] unit_sel;      /* alu function unit select                                 */
22
  input   [7:0] shft_out;      /* shift unit result                                        */
23
  input  [15:0] adder_out;     /* math unit result                                         */
24
  input  [15:0] logic_out;     /* logic unit result                                        */
25
  input  [15:0] mult_out;      /* multiplier unit result                                   */
26
  output        cry_nxt;       /* carry flag next                                          */
27
  output        hcar_nxt;      /* half-carry flag next                                     */
28
  output        one_nxt;       /* one flag next                                            */
29
  output        par_nxt;       /* parity flag next                                         */
30
  output        sign_nxt;      /* sign flag next                                           */
31
  output        zero_nxt;      /* zero flag next                                           */
32
  output [15:0] data_bus;      /* datapath data bus                                        */
33
 
34
  /*****************************************************************************************/
35
  /*                                                                                       */
36
  /* signal declarations                                                                   */
37
  /*                                                                                       */
38
  /*****************************************************************************************/
39
  wire        one_nxt, par_nxt, sign_nxt, zero_nxt;
40
  wire [15:0] data_bus;
41
 
42
  reg         cry_nxt, hcar_nxt;
43
  reg  [15:0] alu_result;
44
 
45
  /*****************************************************************************************/
46
  /*                                                                                       */
47
  /* alu function unit combination                                                         */
48
  /*                                                                                       */
49
  /*****************************************************************************************/
50
  always @ (unit_sel or adder_out or logic_out or shft_out or mult_out) begin
51
    casex (unit_sel)
52
      2'b01:   alu_result = adder_out;
53
      2'b10:   alu_result = {8'h00, shft_out};
54
      2'b11:   alu_result = mult_out;
55
      default: alu_result = logic_out;
56
      endcase
57
    end
58
 
59
  /*****************************************************************************************/
60
  /*                                                                                       */
61
  /* alu flag outputs                                                                      */
62
  /*                                                                                       */
63
  /*****************************************************************************************/
64
  always @ (unit_sel or adder_c or logic_c or shft_c) begin
65
    casex (unit_sel)
66
      2'b01:   cry_nxt = adder_c;
67
      2'b1x:   cry_nxt = shft_c;
68
      default: cry_nxt = logic_c;
69
      endcase
70
    end
71
 
72
  always @ (unit_sel or adder_hc or logic_hc) begin
73
    casex (unit_sel)
74
      2'b01:   hcar_nxt = adder_hc;
75
      2'b1x:   hcar_nxt = 1'b0;
76
      default: hcar_nxt = logic_hc;
77
      endcase
78
    end
79
 
80
  assign one_nxt  = ~|alu_result[7:1] && alu_result[0];
81
  assign par_nxt  = ~^alu_result[7:0];
82
  assign sign_nxt = (word_op) ?   alu_result[15]   :   alu_result[7];
83
  assign zero_nxt = (word_op) ? ~|alu_result[15:0] : ~|alu_result[7:0];
84
 
85
  /*****************************************************************************************/
86
  /*                                                                                       */
87
  /* alu output left shift                                                                 */
88
  /*                                                                                       */
89
  /*****************************************************************************************/
90
  assign data_bus = (hi_byte) ? {alu_result[7:0], alu_result[7:0]} : alu_result[15:0];
91
 
92
  endmodule
93
 
94
 
95
 
96
 
97
 
98
 

powered by: WebSVN 2.1.0

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