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

Subversion Repositories 8051

[/] [8051/] [tags/] [rel_12/] [rtl/] [verilog/] [oc8051_alu_src_sel.v] - Blame information for rev 141

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 81 simont
//////////////////////////////////////////////////////////////////////
2
////                                                              ////
3
////  8051 alu source select module                               ////
4
////                                                              ////
5
////  This file is part of the 8051 cores project                 ////
6
////  http://www.opencores.org/cores/8051/                        ////
7
////                                                              ////
8
////  Description                                                 ////
9
////   Multiplexer wiht whitch we select data on alu sources      ////
10
////                                                              ////
11
////  To Do:                                                      ////
12
////   nothing                                                    ////
13
////                                                              ////
14
////  Author(s):                                                  ////
15
////      - Simon Teran, simont@opencores.org                     ////
16
////                                                              ////
17
//////////////////////////////////////////////////////////////////////
18
////                                                              ////
19
//// Copyright (C) 2000 Authors and OPENCORES.ORG                 ////
20
////                                                              ////
21
//// This source file may be used and distributed without         ////
22
//// restriction provided that this copyright statement is not    ////
23
//// removed from the file and that any derivative work contains  ////
24
//// the original copyright notice and the associated disclaimer. ////
25
////                                                              ////
26
//// This source file is free software; you can redistribute it   ////
27
//// and/or modify it under the terms of the GNU Lesser General   ////
28
//// Public License as published by the Free Software Foundation; ////
29
//// either version 2.1 of the License, or (at your option) any   ////
30
//// later version.                                               ////
31
////                                                              ////
32
//// This source is distributed in the hope that it will be       ////
33
//// useful, but WITHOUT ANY WARRANTY; without even the implied   ////
34
//// warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR      ////
35
//// PURPOSE.  See the GNU Lesser General Public License for more ////
36
//// details.                                                     ////
37
////                                                              ////
38
//// You should have received a copy of the GNU Lesser General    ////
39
//// Public License along with this source; if not, download it   ////
40
//// from http://www.opencores.org/lgpl.shtml                     ////
41
////                                                              ////
42
//////////////////////////////////////////////////////////////////////
43
//
44
// CVS Revision History
45
//
46
// $Log: not supported by cvs2svn $
47 141 simont
// Revision 1.1  2003/01/13 14:13:12  simont
48
// initial import
49 81 simont
//
50
//
51 141 simont
//
52 81 simont
 
53
// synopsys translate_off
54
`include "oc8051_timescale.v"
55
// synopsys translate_on
56
 
57
`include "oc8051_defines.v"
58
 
59
 
60
module oc8051_alu_src_sel (clk, rst, rd, sel1, sel2, sel3,
61
                     acc, ram, pc, dptr,
62
 
63
                     op1, op2, op3,
64
 
65
                     src1, src2, src3);
66
 
67
 
68
input clk, rst, rd, sel3;
69 141 simont
input [1:0] sel2;
70
input [2:0] sel1;
71 81 simont
input [7:0] acc, ram;
72
input [15:0] dptr;
73
input [15:0] pc;
74
 
75
 
76
input [7:0] op1, op2, op3;
77
 
78
output [7:0] src1, src2, src3;
79
 
80
reg [7:0] src1, src2, src3;
81
 
82
reg [7:0] op1_r, op2_r, op3_r;
83
reg [15:0] pc_r;
84
 
85
///////
86
//
87
// src1
88
//
89
///////
90
always @(sel1 or op1_r or op2_r or op3_r or pc_r or acc or ram)
91
begin
92
  case (sel1)
93
    `OC8051_AS1_RAM: src1 = ram;
94
    `OC8051_AS1_ACC: src1 = acc;
95
    `OC8051_AS1_OP1: src1 = op1_r;
96
    `OC8051_AS1_OP2: src1 = op2_r;
97
    `OC8051_AS1_OP3: src1 = op3_r;
98
    `OC8051_AS1_PCH: src1 = pc_r[15:8];
99
    `OC8051_AS1_PCL: src1 = pc_r[7:0];
100
    default: src1 = 8'h00;
101
  endcase
102
end
103
 
104
///////
105
//
106
// src2
107
//
108
///////
109 141 simont
always @(sel2 or op2_r or acc or ram or op1_r or pc)
110 81 simont
begin
111
  case (sel2)
112
    `OC8051_AS2_ACC: src2= acc;
113
    `OC8051_AS2_ZERO: src2= 8'h00;
114
    `OC8051_AS2_RAM: src2= ram;
115
    `OC8051_AS2_OP2: src2= op2_r;
116
    default: src2= 8'h00;
117
  endcase
118
end
119
 
120
///////
121
//
122
// src3
123
//
124
///////
125
 
126
always @(sel3 or pc[15:8] or dptr[15:8] or op1_r)
127
begin
128
  case (sel3)
129
    `OC8051_AS3_DP:   src3= dptr[15:8];
130
    `OC8051_AS3_PC:   src3= pc[15:8];
131
    default: src3= 16'h0;
132
  endcase
133
end
134
 
135
 
136
always @(posedge clk or posedge rst)
137
  if (rst) begin
138
    op1_r <= #1 8'h00;
139
    op2_r <= #1 8'h00;
140
    op3_r <= #1 8'h00;
141
  end else begin
142
    op1_r <= #1 op1;
143
    op2_r <= #1 op2;
144
    op3_r <= #1 op3;
145
  end
146
 
147
always @(posedge clk or posedge rst)
148
  if (rst) begin
149
    pc_r <= #1 16'h0;
150
  end else if (rd) begin
151
    pc_r <= #1 pc;
152
  end
153
endmodule

powered by: WebSVN 2.1.0

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