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

Subversion Repositories zet86

[/] [zet86/] [trunk/] [cores/] [zet/] [rtl/] [util/] [primitives.v] - Blame information for rev 55

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 17 zeus
/*
2
 *  Copyright (c) 2008  Zeus Gomez Marmolejo <zeus@opencores.org>
3
 *
4
 *  This file is part of the Zet processor. This processor is free
5
 *  hardware; you can redistribute it and/or modify it under the terms of
6
 *  the GNU General Public License as published by the Free Software
7
 *  Foundation; either version 3, or (at your option) any later version.
8
 *
9 18 zeus
 *  Zet is distrubuted in the hope that it will be useful, but WITHOUT
10
 *  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
11
 *  or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
12
 *  License for more details.
13 17 zeus
 *
14
 *  You should have received a copy of the GNU General Public License
15 18 zeus
 *  along with Zet; see the file COPYING. If not, see
16 17 zeus
 *  <http://www.gnu.org/licenses/>.
17
 */
18
 
19 2 zeus
//
20
// Multiplexor 8:1 de 16 bits d'amplada
21
//
22
module mux8_16(sel, in0, in1, in2, in3, in4, in5, in6, in7, out);
23
  input  [2:0]  sel;
24
  input  [15:0] in0, in1, in2, in3, in4, in5, in6, in7;
25
  output [15:0] out;
26
 
27
  reg    [15:0] out;
28
 
29
  always @(sel or in0 or in1 or in2 or in3 or in4 or in5 or in6 or in7)
30
    case(sel)
31
     3'd0:  out = in0;
32
     3'd1:  out = in1;
33
     3'd2:  out = in2;
34
     3'd3:  out = in3;
35
     3'd4:  out = in4;
36
     3'd5:  out = in5;
37
     3'd6:  out = in6;
38
     3'd7:  out = in7;
39
    endcase
40
endmodule
41
 
42
 
43
//
44
// Multiplexor 8:1 de 8 bits d'amplada
45
//
46
/*
47
module mux8_8(sel, in0, in1, in2, in3, in4, in5, in6, in7, out);
48
  input  [2:0]  sel;
49
  input  [7:0] in0, in1, in2, in3, in4, in5, in6, in7;
50
  output [7:0] out;
51
 
52
  reg    [7:0] out;
53
 
54
  always @(sel or in0 or in1 or in2 or in3 or in4 or in5 or in6 or in7)
55
    case(sel)
56
     3'd0:  out = in0;
57
     3'd1:  out = in1;
58
     3'd2:  out = in2;
59
     3'd3:  out = in3;
60
     3'd4:  out = in4;
61
     3'd5:  out = in5;
62
     3'd6:  out = in6;
63
     3'd7:  out = in7;
64
    endcase
65
endmodule
66
*/
67
//
68 15 zeus
// Multiplexor 8:1 d'1 bit d'amplada
69
//
70
module mux8_1(sel, in0, in1, in2, in3, in4, in5, in6, in7, out);
71
  input  [2:0]  sel;
72
  input  in0, in1, in2, in3, in4, in5, in6, in7;
73
  output out;
74
 
75
  reg    out;
76
 
77
  always @(sel or in0 or in1 or in2 or in3 or in4 or in5 or in6 or in7)
78
    case(sel)
79
     3'd0:  out = in0;
80
     3'd1:  out = in1;
81
     3'd2:  out = in2;
82
     3'd3:  out = in3;
83
     3'd4:  out = in4;
84
     3'd5:  out = in5;
85
     3'd6:  out = in6;
86
     3'd7:  out = in7;
87
    endcase
88
endmodule
89
 
90
//
91 31 zeus
// Multiplexor 4:1 de 16 bits d'amplada
92 15 zeus
//
93 31 zeus
module mux4_16(sel, in0, in1, in2, in3, out);
94 15 zeus
  input  [1:0]  sel;
95 31 zeus
  input  [15:0] in0, in1, in2, in3;
96
  output [15:0] out;
97 15 zeus
 
98 31 zeus
  reg    [15:0] out;
99 15 zeus
 
100
  always @(sel or in0 or in1 or in2 or in3)
101
    case(sel)
102
     2'd0:  out = in0;
103
     2'd1:  out = in1;
104
     2'd2:  out = in2;
105
     2'd3:  out = in3;
106
    endcase
107
endmodule
108
 
109 35 zeus
/*
110 15 zeus
//
111 31 zeus
// Multiplexor 4:1 de 1 bits d'amplada
112 15 zeus
//
113 31 zeus
module mux4_1(sel, in0, in1, in2, in3, out);
114 15 zeus
  input  [1:0]  sel;
115 31 zeus
  input  in0, in1, in2, in3;
116
  output out;
117 15 zeus
 
118 31 zeus
  reg    out;
119 15 zeus
 
120
  always @(sel or in0 or in1 or in2 or in3)
121
    case(sel)
122
     2'd0:  out = in0;
123
     2'd1:  out = in1;
124
     2'd2:  out = in2;
125
     2'd3:  out = in3;
126
    endcase
127
endmodule
128
 
129
//
130
// Multiplexor 2:1 de 8 bits d'amplada
131
//
132
module mux2_8(sel, in0, in1, out);
133
  input        sel;
134
  input  [7:0] in0, in1;
135
  output [7:0] out;
136
 
137
  reg    [7:0] out;
138
 
139
  always @(sel or in0 or in1)
140
    case(sel)
141
     1'd0:  out = in0;
142
     1'd1:  out = in1;
143
    endcase
144
endmodule
145
 
146
//
147 31 zeus
// Multiplexor 4:1 de 32 bits d'amplada
148 15 zeus
//
149 31 zeus
 
150
module mux4_32(sel, in0, in1, in2, in3, out);
151 15 zeus
  input  [1:0]  sel;
152 31 zeus
  input  [31:0] in0, in1, in2, in3;
153
  output [31:0] out;
154 15 zeus
 
155 31 zeus
  reg    [31:0] out;
156 15 zeus
 
157
  always @(sel or in0 or in1 or in2 or in3)
158
    case(sel)
159
     2'd0:  out = in0;
160
     2'd1:  out = in1;
161
     2'd2:  out = in2;
162
     2'd3:  out = in3;
163
    endcase
164 25 zeus
endmodule
165
 
166 31 zeus
//
167
// Multiplexor 8:1 de 17 bits d'amplada
168
//
169
module mux8_17(sel, in0, in1, in2, in3, in4, in5, in6, in7, out);
170
  input  [2:0]  sel;
171
  input  [16:0] in0, in1, in2, in3, in4, in5, in6, in7;
172
  output [16:0] out;
173
 
174
  reg    [16:0] out;
175
 
176
  always @(sel or in0 or in1 or in2 or in3 or in4 or in5 or in6 or in7)
177
    case(sel)
178
     3'd0:  out = in0;
179
     3'd1:  out = in1;
180
     3'd2:  out = in2;
181
     3'd3:  out = in3;
182
     3'd4:  out = in4;
183
     3'd5:  out = in5;
184
     3'd6:  out = in6;
185
     3'd7:  out = in7;
186
    endcase
187
endmodule
188
*/
189
 
190 27 zeus
/*
191 25 zeus
//
192
// 1 bit cell divider by 10
193
//
194
module div10b1 (
195
    input  [3:0] c,
196
    input        a,
197
    output       q,
198
    output [3:0] r
199
  );
200
 
201
  // Continuous assignments
202
  assign r = { c[3]&c[0] | c[2]&~c[1]&~c[0],
203
               ~c[2]&c[1] | c[1]&c[0] | c[3]&~c[0],
204
               c[3]&~c[0] | c[2]&c[1]&~c[0] | ~c[3]&~c[2]&~c[0],
205
               a };
206
  assign q = c[3] | c[2]&c[1] | c[2]&c[0];
207
endmodule
208
 
209
//
210
// 8 bit divider by 10
211
//
212
module div10b8 (
213
    input  [7:0] a,
214
    output [4:0] q,
215
    output [3:0] r
216
  );
217
 
218
  // Net declarations
219
  wire [3:0] c10, c21, c32, c43;
220
 
221
  // Module instantiations
222
  div10b1 bit4 (
223
    .c ({1'b0, a[7:5]}),
224
    .a (a[4]),
225
    .q (q[4]),
226
    .r (c43)
227
  );
228
 
229
  div10b1 bit3 (
230
    .c (c43),
231
    .a (a[3]),
232
    .q (q[3]),
233
    .r (c32)
234
  );
235
 
236
  div10b1 bit2 (
237
    .c (c32),
238
    .a (a[2]),
239
    .q (q[2]),
240
    .r (c21)
241
  );
242
 
243
  div10b1 bit1 (
244
    .c (c21),
245
    .a (a[1]),
246
    .q (q[1]),
247
    .r (c10)
248
  );
249
 
250
  div10b1 bit0 (
251
    .c (c10),
252
    .a (a[0]),
253
    .q (q[0]),
254
    .r (r)
255
  );
256 27 zeus
*/
257 25 zeus
 
258 27 zeus
module fulladd16 (
259
    input  [15:0] x,
260
    input  [15:0] y,
261
    input         ci,
262
    output        co,
263
    output [15:0] z,
264
    input         s
265
  );
266
 
267
  // Continuous assignments
268
  assign {co,z} = {1'b0, x} + {s, y} + ci;
269 25 zeus
endmodule

powered by: WebSVN 2.1.0

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