1 |
2 |
bsa |
/*******************************************************************************************/
|
2 |
|
|
/** **/
|
3 |
6 |
bsa |
/** ORIGINAL COPYRIGHT (C) 2011, SYSTEMYDE INTERNATIONAL CORPORATION, ALL RIGHTS RESERVED **/
|
4 |
|
|
/** COPYRIGHT (C) 2012, SERGEY BELYASHOV **/
|
5 |
2 |
bsa |
/** **/
|
6 |
6 |
bsa |
/** alu a input multiplexer module Rev 0.0 06/13/2012 **/
|
7 |
2 |
bsa |
/** **/
|
8 |
|
|
/*******************************************************************************************/
|
9 |
|
|
module aluamux (adda_in, alua_in, alua_reg, aa_reg_out, bit_mask, daa_out, hl_reg_out,
|
10 |
6 |
bsa |
ii_reg, int_addr, ix_reg, iy_reg, pc_reg, rr_reg, rst_addr, tmp_reg);
|
11 |
2 |
bsa |
|
12 |
|
|
input [7:0] aa_reg_out; /* a register output */
|
13 |
|
|
input [7:0] bit_mask; /* bit mask for bit operations */
|
14 |
|
|
input [7:0] daa_out; /* daa constant */
|
15 |
|
|
input [7:0] ii_reg; /* i register output */
|
16 |
|
|
input [7:0] rr_reg; /* r register output */
|
17 |
|
|
input [7:0] rst_addr; /* restart address */
|
18 |
|
|
input [15:0] hl_reg_out; /* hl register output */
|
19 |
|
|
input [15:0] int_addr; /* interrupt address */
|
20 |
|
|
input [15:0] ix_reg; /* ix register output */
|
21 |
|
|
input [15:0] iy_reg; /* iy register output */
|
22 |
|
|
input [15:0] pc_reg; /* pc register output */
|
23 |
6 |
bsa |
input [15:0] tmp_reg; /* tmp register output */
|
24 |
2 |
bsa |
input [`ALUA_IDX:0] alua_reg; /* pipelined alu input a mux control */
|
25 |
|
|
output [15:0] adda_in; /* address alu a input bus */
|
26 |
|
|
output [15:0] alua_in; /* alu a input bus */
|
27 |
|
|
|
28 |
|
|
/*****************************************************************************************/
|
29 |
|
|
/* */
|
30 |
|
|
/* signal declarations */
|
31 |
|
|
/* */
|
32 |
|
|
/*****************************************************************************************/
|
33 |
|
|
reg [15:0] alua_in;
|
34 |
|
|
reg [15:0] alua_in_0, alua_in_1, alua_in_2, alua_in_3, alua_in_4, alua_in_5;
|
35 |
|
|
reg [15:0] alua_in_6, alua_in_7, alua_in_8, alua_in_9, alua_in_10, alua_in_11;
|
36 |
6 |
bsa |
reg [15:0] alua_in_12, alua_in_13, alua_in_14;
|
37 |
2 |
bsa |
|
38 |
|
|
wire [15:0] adda_in;
|
39 |
|
|
wire [15:0] adda_in_0, adda_in_1, adda_in_2, adda_in_4, adda_in_5, adda_in_12;
|
40 |
6 |
bsa |
wire [15:0] adda_in_14;
|
41 |
2 |
bsa |
|
42 |
|
|
/*****************************************************************************************/
|
43 |
|
|
/* */
|
44 |
|
|
/* alu input a select */
|
45 |
|
|
/* */
|
46 |
|
|
/*****************************************************************************************/
|
47 |
|
|
always @ (alua_reg or aa_reg_out or bit_mask or daa_out or ii_reg or int_addr or
|
48 |
|
|
hl_reg_out or ix_reg or iy_reg or pc_reg or rr_reg or rst_addr) begin
|
49 |
|
|
alua_in_0 = 16'h0;
|
50 |
|
|
alua_in_1 = 16'h0;
|
51 |
|
|
alua_in_2 = 16'h0;
|
52 |
|
|
alua_in_3 = 16'h0;
|
53 |
|
|
alua_in_4 = 16'h0;
|
54 |
|
|
alua_in_5 = 16'h0;
|
55 |
|
|
alua_in_6 = 16'h0;
|
56 |
|
|
alua_in_7 = 16'h0;
|
57 |
|
|
alua_in_8 = 16'h0;
|
58 |
|
|
alua_in_9 = 16'h0;
|
59 |
|
|
alua_in_10 = 16'h0;
|
60 |
|
|
alua_in_11 = 16'h0;
|
61 |
|
|
alua_in_12 = 16'h0;
|
62 |
|
|
alua_in_13 = 16'h0;
|
63 |
6 |
bsa |
alua_in_14 = 16'h0;
|
64 |
2 |
bsa |
if (alua_reg[`AA_ONE]) alua_in_0 = 16'h0001;
|
65 |
|
|
if (alua_reg[`AA_M1]) alua_in_1 = 16'hffff;
|
66 |
|
|
if (alua_reg[`AA_M2]) alua_in_2 = 16'hfffe;
|
67 |
|
|
if (alua_reg[`AA_HL]) alua_in_3 = hl_reg_out;
|
68 |
|
|
if (alua_reg[`AA_IX]) alua_in_4 = ix_reg;
|
69 |
|
|
if (alua_reg[`AA_IY]) alua_in_5 = iy_reg;
|
70 |
|
|
if (alua_reg[`AA_PC]) alua_in_6 = pc_reg;
|
71 |
|
|
if (alua_reg[`AA_AA]) alua_in_7 = {8'h00, aa_reg_out};
|
72 |
|
|
if (alua_reg[`AA_BIT]) alua_in_8 = {8'h00, bit_mask};
|
73 |
|
|
if (alua_reg[`AA_DAA]) alua_in_9 = {8'h00, daa_out};
|
74 |
|
|
if (alua_reg[`AA_II]) alua_in_10 = {8'h00, ii_reg};
|
75 |
|
|
if (alua_reg[`AA_RR]) alua_in_11 = {8'h00, rr_reg};
|
76 |
|
|
if (alua_reg[`AA_INT]) alua_in_12 = int_addr;
|
77 |
6 |
bsa |
if (alua_reg[`AA_TMP]) alua_in_13 = tmp_reg;
|
78 |
|
|
if (alua_reg[`AA_RST]) alua_in_14 = {8'h00, rst_addr};
|
79 |
2 |
bsa |
end
|
80 |
|
|
|
81 |
|
|
always @ (alua_in_0 or alua_in_1 or alua_in_2 or alua_in_3 or alua_in_4 or
|
82 |
|
|
alua_in_5 or alua_in_6 or alua_in_7 or alua_in_8 or alua_in_9 or
|
83 |
6 |
bsa |
alua_in_10 or alua_in_11 or alua_in_12 or alua_in_13 or alua_in_14) begin
|
84 |
2 |
bsa |
alua_in = alua_in_0 | alua_in_1 | alua_in_2 | alua_in_3 | alua_in_4 |
|
85 |
|
|
alua_in_5 | alua_in_6 | alua_in_7 | alua_in_8 | alua_in_9 |
|
86 |
6 |
bsa |
alua_in_10 | alua_in_11 | alua_in_12 | alua_in_13 | alua_in_14;
|
87 |
2 |
bsa |
end
|
88 |
|
|
|
89 |
|
|
/*****************************************************************************************/
|
90 |
|
|
/* */
|
91 |
|
|
/* address alu input a select */
|
92 |
|
|
/* */
|
93 |
|
|
/*****************************************************************************************/
|
94 |
|
|
assign adda_in_0 = (alua_reg[`AA_ONE]) ? 16'h0001 : 16'h0000;
|
95 |
|
|
assign adda_in_1 = (alua_reg[`AA_M1]) ? 16'hffff : 16'h0000;
|
96 |
|
|
assign adda_in_2 = (alua_reg[`AA_M2]) ? 16'hfffe : 16'h0000;
|
97 |
|
|
assign adda_in_4 = (alua_reg[`AA_IX]) ? ix_reg : 16'h0000;
|
98 |
|
|
assign adda_in_5 = (alua_reg[`AA_IY]) ? iy_reg : 16'h0000;
|
99 |
|
|
assign adda_in_12 = (alua_reg[`AA_INT]) ? int_addr : 16'h0000;
|
100 |
6 |
bsa |
assign adda_in_14 = (alua_reg[`AA_RST]) ? {8'h00, rst_addr} : 16'h0000;
|
101 |
2 |
bsa |
|
102 |
|
|
assign adda_in = adda_in_0 | adda_in_1 | adda_in_2 | adda_in_4 | adda_in_5 |
|
103 |
6 |
bsa |
adda_in_12 | adda_in_14;
|
104 |
2 |
bsa |
|
105 |
|
|
endmodule
|
106 |
|
|
|
107 |
|
|
|
108 |
|
|
|
109 |
|
|
|
110 |
|
|
|
111 |
|
|
|
112 |
|
|
|