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

Subversion Repositories hive

[/] [hive/] [trunk/] [v01.10/] [core.v] - Blame information for rev 3

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 3 ericw
/*
2
--------------------------------------------------------------------------------
3
 
4
Module : core.v
5
 
6
--------------------------------------------------------------------------------
7
 
8
Function:
9
- Processor core with 8 stage pipeline, 8 threads, and 4 stacks per thread.
10
 
11
Instantiates:
12
- control_ring.v
13
- data_ring.v
14
- reg_set.v
15
- reg_set_shim.v
16
- dp_ram_infer.v
17
 
18
 
19
--------------------
20
- Revision History -
21
--------------------
22
 
23
v01.10 - 2013-07-06
24
- Shuffled opcode encoding again:
25
  - Unused jmp_iz never houses rd_i ops.
26
  - Unused jmp_i never houses wr_i ops.
27
  - jmp_i always immediate field reduced to 5 bits for consistency,
28
    which leaves an unused 32 code gap.
29
- Edited boot code tests to work with this new encoding.
30
 
31
v01.09 (cont) - 2013-06-25
32
- Passes boot code verification for:
33
  - All I/O ops.
34
 
35
v01.09 - 2013-06-24
36
- First public release.
37
- Shuffled opcode encoding again:
38
  - Unused never jmp_i fits read/write perfectly.
39
  - Unused always jmp_i zero comparison allows for 1 bit immediate field
40
    expansion of jmp_i(gle/z).
41
- Removed all skip instructions (redundant w/ jmp_i).
42
- All the above allows add_i immediate field expansion to 6 bits.
43
- Opcode encoding is now more straightforward with fewer immediate field sizes.
44
- Worked on pc_ring.v and pointer_ring.v, now use simple loops rather than
45
  generate, the logic produced better tracks the module paramters.
46
- Removed "skp" control bit from pc_ring.v, op_decode.v, control_ring.v.
47
- Removed intr_ack_o from core I/O.
48
- Renamed "register_set*" => "reg_set*".
49
- (Considering adding a leading zero count opcode, it doesn't take many LEs.)
50
- Seeing a write to thread 7 stack 0 memory at startup, don't think it
51
  means anything due to clearing.
52
- Passes boot code verification for:
53
  - Interrupts.
54
  - Stack ops, depth, error reporting (all threads).
55
  - All branch / conditional ops.
56
  - All logical / arithmetic / shift ops.
57
 
58
v01.08 - 2013-06-14
59
- Added parameter options for stack pointer error protections & brought them
60
  to the top level.
61
- The unsigned restoring division subroutine works!
62
 
63
v01.07 - 2013-06-11
64
- Changed opcodes to make swapping of (A?B) operands cover all logical needs:
65
  - op_skp_ul => op_skp_l
66
  - op_skp_ge => op_skp_uge
67
  - op_jmp_iul => op_jmp_il
68
  - op_jmp_ige => op_jmp_iuge
69
- Changed verification boot code tests to reflect above (passes).
70
 
71
v01.06 - 2013-06-10
72
- Fixed latency of test fields in op_decode.v (were only registered 1x, s/b 2x).
73
- Fixed subtle immediate address offset sign issue in pc_ring.v.
74
- Fixed subtle immediate data sign issue in stacks_mux.v.
75
- Minor style edits to visually align port names @ vector_sr.v instances.
76
- The log2 subroutine works!
77
 
78
v01.05 - 2013-06-07
79
- Put the skip instructions back (for convenience & clarity).
80
- Changes to op_decode.v, separate immediate data and address decodes,
81
  misc. edits to improve speed.
82
- Renamed "op_codes.h" => "op_encode.h".
83
- Lots of minor edits at the higher levels.
84
- Added "copyright.txt" to directory.
85
 
86
v01.04 - 2013-06-06
87
- Added op_jmp_i (A?B) instructions.
88
- Removed all skip instructions (redundant).
89
 
90
v01.03 - 2013-06-04
91
- Changed op_jmp_i to be conditional (A?0).
92
- Renamed "addr_regs.h" => "register_set_addr.h".
93
- New boot code does log2.
94
 
95
v01.02 (cont) - 2013-05-23
96
- Old boot code file renamed: "boot_code.h" => "boot_code_00.h".
97
- New boot code file tests all op_codes and gives final report.
98
 
99
v01.02 - 2013-05-22
100
- Memory writes now work, the fix was to swap pc/op_code ROM side A with
101
   data RW side B of main memory "dp_ram_infer.v".  It seems side A is
102
   incorrectly used as the master mode for both ports.
103
- Renamed "alu_input_mux.v" => "stacks_mux.v".
104
- Removed enable from "register_set.v" and "register_set_shim.v".
105
- Monkeyed with "register_set_shim.v" a bit.
106
- Removed async resets from "dp_ram_infer.v" and "dq_ram_infer.v".
107
- Passes boot code tests 0, 1, 2, 3, 4.
108
 
109
v01.01 - 2013-05-22
110
- Added clear and interrupt BASE and SPAN parameters.
111
- Because BASE is a simple MSB concatenation, for it to be effective
112
   make BASE >= 2^(THRD_W+SPAN).  BASE LSBs below this point are ignored.
113
- Individual clear and interrupt address interspacing = 2^SPAN.
114
- Example:
115
   CLR_BASE ='h0 positions thread 0 clear @ 0.
116
   CLR_SPAN =2 positions thread 1 clear @ 4, thread 2 @ 8, etc.
117
   INTR_BASE='h20 positions thread 0 interrupt @ 'd32.
118
   INTR_SPAN=2 positions thread 1 interrupt @ 'd36, thread 2 @ 'd40, etc.
119
- Moved most core top port parameters to localparam.
120
- Modified boot code tests accordingly.
121
- Passes boot code tests 0, 1, 2.
122
- Memory writes still don't work!
123
 
124
v01.00 - 2013-05-21 - born
125
- EP3C5E144C8: ~180MHz, ~1785 LEs (34% of logic).
126
- Fixed immediate value bug (was only registered 1x in op_decode.v, s/b 2x).
127
- Passes boot code tests 0, 1, 2.
128
- Memory writes don't work!
129
 
130
--------------------------------------------------------------------------------
131
*/
132
 
133
module core
134
        #(
135
        parameter       integer                                                 DATA_W                  = 32,           // data width
136
        parameter       integer                                                 THREADS                 = 8,            // threads
137
        parameter       [DATA_W/4-1:0]                                   VER_MAJ                 = 'h01, // core version
138
        parameter       [DATA_W/4-1:0]                                   VER_MIN                 = 'h10  // core version
139
        )
140
        (
141
        // clocks & resets
142
        input                   wire                                                            clk_i,                                          // clock
143
        input                   wire                                                            rst_i,                                          // async. reset, active high
144
        //
145
        input                   wire    [THREADS-1:0]                    intr_req_i,                                     // event request, active high
146
        //
147
        input                   wire    [DATA_W-1:0]                     io_i,                                                   // gpio
148
        output          wire    [DATA_W-1:0]                     io_o
149
        );
150
 
151
 
152
        /*
153
        ----------------------
154
        -- internal signals --
155
        ----------------------
156
        */
157
        `include "functions.h"  // for clog2()
158
        //
159
        localparam      integer                                                 ADDR_W                  = 16;           // address width
160
        localparam      integer                                                 PNTR_W                  = 5;            // stack pointer width
161
        localparam      integer                                                 MEM_ADDR_W              = 13;           // main memory width
162
        localparam      [ADDR_W-1:0]                                     CLR_BASE                        = 'h0;  // clear address base (concat)
163
        localparam      integer                                                 CLR_SPAN                        = 2;            // clear address span (2^n)
164
        localparam      [ADDR_W-1:0]                                     INTR_BASE               = 'h20; // interrupt address base (concat)
165
        localparam      integer                                                 INTR_SPAN               = 2;            // interrupt address span (2^n)
166
        localparam      integer                                                 THRD_W                  = clog2( THREADS );
167
        localparam      integer                                                 STACKS                  = 4;            // number of stacks
168
        localparam      integer                                                 STK_W                           = clog2( STACKS );
169
        localparam      integer                                                 IM_DATA_W               = 8;            // immediate data width
170
        localparam      integer                                                 IM_ADDR_W               = 5;            // immediate address width
171
        localparam      integer                                                 LG_W                            = 2;
172
        localparam      integer                                                 OP_CODE_W               = DATA_W/2;
173
        localparam      integer                                                 REG_ADDR_W              = 4;
174
        localparam      integer                                                 IM_RW_W                 = 4;
175
        localparam      integer                                                 POP_PROT                        = 1;            // 1=error protection, 0=none
176
        localparam      integer                                                 PUSH_PROT               = 1;            // 1=error protection, 0=none
177
        //
178
        wire                                    [THREADS-1:0]                    clr_req;
179
        wire                                    [THREADS-1:0]                    intr_en;
180
        wire                                    [OP_CODE_W-1:0]          op_code;
181
        wire                                                                                            op_code_er;
182
        wire                                    [STK_W-1:0]                              a_sel, b_sel;
183
        wire                                                                                            imda, sgn, ext;
184
        wire                                    [LG_W-1:0]                               lg;
185
        wire                                                                                            add, sub, mul, shl, cpy, dm, rtn, rd, wr;
186
        wire                                                                                            stk_clr;
187
        wire                                    [STACKS-1:0]                     pop, push, pop_er, push_er;
188
        wire                                    [DATA_W-1:0]                     a, b;
189
        wire                                    [IM_DATA_W-1:0]          im_data;
190
        wire                                    [IM_ADDR_W-1:0]          im_addr;
191
        wire                                                                                            nez, ne, ltz, lt;
192
        wire                                    [THRD_W-1:0]                     thrd_0, thrd_2, thrd_3, thrd_6;
193
        wire                                    [ADDR_W-1:0]                     pc_1, pc_3, pc_4;
194
        wire                                    [DATA_W/2-1:0]                   dm_rd_data;
195
        wire                                    [DATA_W/2-1:0]                   rd_data, wr_data;
196
        wire                                    [ADDR_W-1:0]                     addr;
197
        wire                                                                                            regs_wr, regs_rd, dm_wr;
198
 
199
 
200
        /*
201
        ================
202
        == code start ==
203
        ================
204
        */
205
 
206
 
207
        // the control ring
208
        control_ring
209
        #(
210
        .DATA_W                         ( DATA_W ),
211
        .ADDR_W                         ( ADDR_W ),
212
        .THREADS                                ( THREADS ),
213
        .THRD_W                         ( THRD_W ),
214
        .STACKS                         ( STACKS ),
215
        .STK_W                          ( STK_W ),
216
        .IM_DATA_W                      ( IM_DATA_W ),
217
        .IM_ADDR_W                      ( IM_ADDR_W ),
218
        .OP_CODE_W                      ( OP_CODE_W ),
219
        .LG_W                                   ( LG_W ),
220
        .CLR_BASE                       ( CLR_BASE ),
221
        .CLR_SPAN                       ( CLR_SPAN ),
222
        .INTR_BASE                      ( INTR_BASE ),
223
        .INTR_SPAN                      ( INTR_SPAN )
224
        )
225
        control_ring
226
        (
227
        .clk_i                          ( clk_i ),
228
        .rst_i                          ( rst_i ),
229
        .clr_req_i                      ( clr_req ),
230
        .clr_ack_o                      (  ),  // unused
231
        .intr_en_i                      ( intr_en ),
232
        .intr_req_i                     ( intr_req_i ),
233
        .intr_ack_o                     (  ),  // unused
234
        .op_code_i                      ( op_code ),
235
        .op_code_er_o           ( op_code_er ),
236
        .b_lo_i                         ( b[DATA_W/2-1:0] ),
237
        .im_data_o                      ( im_data ),
238
        .a_sel_o                                ( a_sel ),
239
        .b_sel_o                                ( b_sel ),
240
        .imda_o                         ( imda ),
241
        .sgn_o                          ( sgn ),
242
        .ext_o                          ( ext ),
243
        .lg_o                                   ( lg ),
244
        .add_o                          ( add ),
245
        .sub_o                          ( sub ),
246
        .mul_o                          ( mul ),
247
        .shl_o                          ( shl ),
248
        .cpy_o                          ( cpy ),
249
        .dm_o                                   ( dm ),
250
        .rtn_o                          ( rtn ),
251
        .rd_o                                   ( rd ),
252
        .wr_o                                   ( wr ),
253
        .stk_clr_o                      ( stk_clr ),
254
        .pop_o                          ( pop ),
255
        .push_o                         ( push ),
256
        .nez_i                          ( nez ),
257
        .ne_i                                   ( ne ),
258
        .ltz_i                          ( ltz ),
259
        .lt_i                                   ( lt ),
260
        .thrd_0_o                       ( thrd_0 ),
261
        .thrd_2_o                       ( thrd_2 ),
262
        .thrd_3_o                       ( thrd_3 ),
263
        .thrd_6_o                       ( thrd_6 ),
264
        .im_addr_o                      ( im_addr ),
265
        .pc_1_o                         ( pc_1 ),
266
        .pc_3_o                         ( pc_3 ),
267
        .pc_4_o                         ( pc_4 )
268
        );
269
 
270
 
271
        // the data ring
272
        data_ring
273
        #(
274
        .DATA_W                         ( DATA_W ),
275
        .ADDR_W                         ( ADDR_W ),
276
        .THREADS                                ( THREADS ),
277
        .THRD_W                         ( THRD_W ),
278
        .STACKS                         ( STACKS ),
279
        .STK_W                          ( STK_W ),
280
        .PNTR_W                         ( PNTR_W ),
281
        .IM_DATA_W                      ( IM_DATA_W ),
282
        .LG_W                                   ( LG_W ),
283
        .POP_PROT                       ( POP_PROT ),
284
        .PUSH_PROT                      ( PUSH_PROT )
285
        )
286
        data_ring
287
        (
288
        .clk_i                          ( clk_i ),
289
        .rst_i                          ( rst_i ),
290
        .a_sel_i                                ( a_sel ),
291
        .b_sel_i                                ( b_sel ),
292
        .imda_i                         ( imda ),
293
        .sgn_i                          ( sgn ),
294
        .ext_i                          ( ext ),
295
        .lg_i                                   ( lg ),
296
        .add_i                          ( add ),
297
        .sub_i                          ( sub ),
298
        .mul_i                          ( mul ),
299
        .shl_i                          ( shl ),
300
        .cpy_i                          ( cpy ),
301
        .dm_i                                   ( dm ),
302
        .rtn_i                          ( rtn ),
303
        .stk_clr_i                      ( stk_clr ),
304
        .pop_i                          ( pop ),
305
        .push_i                         ( push ),
306
        .thrd_6_i                       ( thrd_6 ),
307
        .im_data_i                      ( im_data ),
308
        .dm_data_i                      ( rd_data ),
309
        .pc_3_i                         ( pc_3 ),
310
        .a_o                                    ( a ),
311
        .b_o                                    ( b ),
312
        .nez_o                          ( nez ),
313
        .ne_o                                   ( ne ),
314
        .ltz_o                          ( ltz ),
315
        .lt_o                                   ( lt ),
316
        .pop_er_o                       ( pop_er ),
317
        .push_er_o                      ( push_er )
318
        );
319
 
320
 
321
        // shim for memory and register set access
322
        reg_set_shim
323
        #(
324
        .REGS_IN                                ( 1 ),
325
        .REGS_OUT                       ( 1 ),
326
        .DATA_W                         ( DATA_W ),
327
        .ADDR_W                         ( ADDR_W ),
328
        .REG_ADDR_W                     ( REG_ADDR_W ),
329
        .IM_ADDR_W                      ( IM_RW_W )
330
        )
331
        reg_set_shim
332
        (
333
        .clk_i                          ( clk_i ),
334
        .rst_i                          ( rst_i ),
335
        .a_i                                    ( a ),
336
        .ext_i                          ( ext ),
337
        .wr_data_o                      ( wr_data ),
338
        .b_lo_i                         ( b[DATA_W/2-1:0] ),
339
        .im_addr_i                      ( im_addr[IM_RW_W-1:0] ),
340
        .pc_1_i                         ( pc_1 ),
341
        .addr_o                         ( addr ),
342
        .wr_i                                   ( wr ),
343
        .rd_i                                   ( rd ),
344
        .regs_wr_o                      ( regs_wr ),
345
        .regs_rd_o                      ( regs_rd ),
346
        .dm_wr_o                                ( dm_wr )
347
        );
348
 
349
 
350
        // internal register set
351
        reg_set
352
        #(
353
        .REGS_IN                                ( 1 ),
354
        .REGS_OUT                       ( 1 ),
355
        .DATA_W                         ( DATA_W/2 ),
356
        .ADDR_W                         ( REG_ADDR_W ),
357
        .THREADS                                ( THREADS ),
358
        .THRD_W                         ( THRD_W ),
359
        .STACKS                         ( STACKS ),
360
        .STK_W                          ( STK_W ),
361
        .VER_MAJ                                ( VER_MAJ ),
362
        .VER_MIN                                ( VER_MIN )
363
        )
364
        reg_set
365
        (
366
        .clk_i                          ( clk_i ),
367
        .rst_i                          ( rst_i ),
368
        .addr_i                         ( addr[REG_ADDR_W-1:0] ),
369
        .wr_i                                   ( regs_wr ),
370
        .rd_i                                   ( regs_rd ),
371
        .data_i                         ( wr_data ),
372
        .data_o                         ( rd_data ),
373
        .dm_data_i                      ( dm_rd_data ),
374
        .clr_req_o                      ( clr_req ),
375
        .intr_en_o                      ( intr_en ),
376
        .thrd_0_i                       ( thrd_0 ),
377
        .op_code_er_i           ( op_code_er ),
378
        .thrd_2_i                       ( thrd_2 ),
379
        .pop_er_i                       ( pop_er ),
380
        .thrd_3_i                       ( thrd_3 ),
381
        .push_er_i                      ( push_er ),
382
        .io_lo_i                                ( io_i[DATA_W/2-1:0] ),
383
        .io_hi_i                                ( io_i[DATA_W-1:DATA_W/2] ),
384
        .io_lo_o                                ( io_o[DATA_W/2-1:0] ),
385
        .io_hi_o                                ( io_o[DATA_W-1:DATA_W/2] )
386
        );
387
 
388
 
389
        // instruction and data memory
390
        dp_ram_infer
391
        #(
392
        .REG_A_OUT                      ( 1 ),
393
        .REG_B_OUT                      ( 1 ),
394
        .DATA_W                         ( OP_CODE_W ),
395
        .ADDR_W                         ( MEM_ADDR_W ),
396
        .RD_MODE                        ( "WR_DATA" )  // functional don't care
397
        )
398
        main_mem
399
        (
400
        .a_clk_i                                ( clk_i ),
401
        .a_addr_i                       ( addr ),
402
        .a_wr_i                         ( dm_wr ),
403
        .a_data_i                       ( wr_data ),
404
        .a_data_o                       ( dm_rd_data ),
405
        .b_clk_i                                ( clk_i ),
406
        .b_addr_i                       ( pc_4 ),
407
        .b_wr_i                         ( 1'b0 ),  // unused
408
        .b_data_i                       (  ),  // unused
409
        .b_data_o                       ( op_code )
410
        );
411
 
412
 
413
endmodule

powered by: WebSVN 2.1.0

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