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

Subversion Repositories hive

[/] [hive/] [trunk/] [v04.05/] [hive_core.v] - Blame information for rev 11

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

Line No. Rev Author Line
1 4 ericw
/*
2
--------------------------------------------------------------------------------
3
 
4
Module : hive_core.v
5
 
6
--------------------------------------------------------------------------------
7
 
8
Function:
9
- General purpose barrel processor FPGA core with:
10
  - 8 threads & 8 stage pipeline
11
  - 8 simple stacks per thread
12
  - 32 bit data
13
  - 16 bit opcode
14
  - 16 bit address
15
 
16
Instantiates (at this level):
17
- control_ring.v
18
- data_ring.v
19
- reg_set.v
20
- reg_mem_shim.v
21
- dp_ram_infer.v
22
 
23
--------------------
24
- Revision History -
25
--------------------
26
 
27
v04.05 - 2014-01-02
28
- Note main version jump.
29
- Branched design back into main line.
30
- OP_CODE_W is now MEM_DATA_W.
31
 
32
v01.04 - 2014-01-01
33
- Moved register set and main memory data port one pipeline stage later.
34
- op_pow is back and is now sign neutral.
35
- Op renaming: psh_iu => psu_i.
36
- `_0, `_1, etc. is now `s* in all boot code.
37
- Added header blocking statements to some *.h files (didn't work for all).
38
- Use of real rather than integer types in UART calculations for clarity.
39
- EP3C5E144C: 2662 LEs, 198MHz (w/o DSE, synthesis optimized for speed).
40
- Passes all boot code verification & functional tests.
41
 
42
v01.03 - 2013-12-23
43
- Short 4 bit (+7/-8) immediate (A?B) jumps have replaced all following jumps.
44
- Removed unconditional immediate jump (use op_jmp_ie).
45
- Immediate (A?0) jumps, data, and add IM value reduced to 6 bits.
46
- Removed op_pow_i, op_shl_iu is op_psh_iu: combo pow2 and right shift,
47
  op_shl_u is strictly unsigned shift.
48
- UART added to register set.
49
- Op renaming:
50
    dat_f* => lit_*
51
    shl_iu => psh_iu
52
- Small changes to register set base component parameters & I/O.
53
- Opcode encode/decode now over full opcode width.
54
- EP3C5E144C: 2650 LEs, 189MHz (w/o DSE).
55
- Passes all boot code verification & functional tests.
56
 
57
v01.02 - 2013-12-06
58
- Following jumps (jmp_f) have replaced all skips.
59
- Added op_pow & op_pow_i opcodes.
60
- A odd testing removed (lack of opcode space).
61
- op_pop now covers all stacks at once via {pb, sb, pa, sa} binary field.
62
- op_reg_r now signed, added read and write high register ops (_wh is ~free).
63
- Added op_lit_u to accomodate 16 bit addresses & such.
64
- Op renaming:
65
    lit => dat_f
66
    byt => dat_i
67
    *_sx => *_xs
68
    *_ux => *_xu
69
- Moved PC interrupt & jmp_f address loads to stage 4 of PC pipe.
70
- op_dat_fh now uses A as source of low data rather than B,
71
  which is more consistent and allows unrelated pop.
72
- Register set addresses now defined as 8 bits wide.
73
- EP3C5E144C: ~2500 LEs, 185MHz (w/o DSE).
74
- Passes all boot code verification tests.
75
- Passes boot code functional tests: divide, sqrt, log2, exp2.
76
 
77
v01.01 - 2013-11-19
78
- Born.  Based on Hive v3.10.  Has 8 stacks per thread.
79
- Skips are back for A odd and (A?B) testing.
80
- Removed op_cls as it seems too dangerous.  May put back in register set.
81
- Lots of op renaming:
82
    dat_f => lit
83
    dat_i => byt
84
    or_br => bro, etc.
85
    or => orr
86
    pc => pgc (to make all op bases 3 letters)
87
- Reg access now unsigned low with no immediate offset.
88
- Added register to flag decode output, moved all PC changes to stage 3.
89
- EP3C5E144C: ~2400 LEs, 178MHz (w/o DSE).
90
- BROKEN: reg_mem_shim.v has bad decoding for dmem addr.
91
 
92
--------------------------------------------------------------------------------
93
*/
94
 
95
module hive_core
96
        #(
97
        parameter       integer                                                 CLK_HZ                  = 160000000,    // master clk_i rate (Hz)
98
        parameter       integer                                                 DATA_W                  = 32,           // data width
99
        parameter       integer                                                 THREADS                 = 8,            // threads (don't change!)
100
        parameter       [DATA_W/4-1:0]                                   VER_MAJ                 = 'h04, // core version
101
        parameter       [DATA_W/4-1:0]                                   VER_MIN                 = 'h05  // core version
102
        )
103
        (
104
        // clocks & resets
105
        input                   wire                                                            clk_i,                                          // clock
106
        input                   wire                                                            rst_i,                                          // async. reset, active high
107
        //
108
        input                   wire    [THREADS-1:0]                    intr_req_i,                                     // event request, active high
109
        //
110
        input                   wire    [DATA_W-1:0]                     io_i,                                                   // gpio
111
        output          wire    [DATA_W-1:0]                     io_o,
112
        //
113
        input                   wire                                                            uart_rx_i,                                      // serial data
114
        output          wire                                                            uart_tx_o                                       // serial data
115
        );
116
 
117
 
118
        /*
119
        ----------------------
120
        -- internal signals --
121
        ----------------------
122
        */
123
        `include "functions.h"  // for clog2()
124
        //
125
        localparam      integer                                                 ADDR_W                  = DATA_W/2;     // address width
126
        localparam      integer                                                 PNTR_W                  = 5;            // stack pointer width
127
        localparam      integer                                                 MEM_ADDR_W              = 13;           // main memory address width
128
        localparam      integer                                                 MEM_DATA_W              = DATA_W/2;             // main memory data width
129
        localparam      [ADDR_W-1:0]                                     CLR_BASE                        = 'h0;  // clear address base (concat)
130
        localparam      integer                                                 CLR_SPAN                        = 2;            // clear address span (2^n)
131
        localparam      [ADDR_W-1:0]                                     INTR_BASE               = 'h20; // interrupt address base (concat)
132
        localparam      integer                                                 INTR_SPAN               = 2;            // interrupt address span (2^n)
133
        localparam      integer                                                 THRD_W                  = clog2( THREADS );
134
        localparam      integer                                                 STACKS                  = 8;            // number of stacks
135
        localparam      integer                                                 STK_W                           = clog2( STACKS );
136
        localparam      integer                                                 IM_W                            = 6;            // immediate width
137
        localparam      integer                                                 LG_SEL_W                        = 4;
138
        localparam      integer                                                 REG_ADDR_W              = 4;
139
        localparam      integer                                                 DM_OFFS_W               = 4;
140
        localparam      integer                                                 PROT_POP                        = 1;            // 1=error protection, 0=none
141
        localparam      integer                                                 PROT_PUSH               = 1;            // 1=error protection, 0=none
142
        localparam      integer                                                 UART_DATA_W             = 8;            // uart data width (bits)
143
        localparam      integer                                                 UART_BAUD_RATE  = 115200;       // uart baud rate (Hz)
144
        //
145
        wire                                    [THREADS-1:0]                    clr_req;
146
        wire                                    [THREADS-1:0]                    intr_en;
147
        wire                                    [MEM_DATA_W-1:0]         op_code;
148
        wire                                                                                            op_code_er;
149
        wire                                    [STK_W-1:0]                              data_sel_a, data_sel_b, addr_sel_b;
150
        wire                                                                                            imda;
151
        wire                                                                                            imad;
152
        wire                                                                                            sgn, ext, hgh;
153
        wire                                                                                            lg;
154
        wire                                    [LG_SEL_W-1:0]                   lg_sel;
155
        wire                                                                                            add, sub, mul, shl, pow, rtn;
156
        wire                                                                                            stk_clr;
157
        wire                                    [STACKS-1:0]                     pop, push, pop_er_2, push_er_3;
158
        wire                                    [DATA_W-1:0]                     a_data;
159
        wire                                    [ADDR_W-1:0]                     b_addr;
160
        wire                                    [IM_W-1:0]                               im;
161
        wire                                                                                            flg_od_2, flg_nz_2, flg_lz_2, flg_ne_2, flg_lt_2;
162
        wire                                    [THRD_W-1:0]                     thrd_0, thrd_2, thrd_3, thrd_6;
163
        wire                                    [ADDR_W-1:0]                     pc_1, pc_3, pc_4;
164
        wire                                    [MEM_DATA_W-1:0]         dm_rd_data_4, rg_rd_data_4;
165
        wire                                    [MEM_DATA_W-1:0]         wr_data_2;
166
        wire                                    [ADDR_W-1:0]                     dm_addr_2, rg_addr_2;
167
        wire                                                                                            dm_rd, dm_wr, rg_rd, rg_wr;
168
        wire                                                                                            dm_wr_2, rg_rd_2, rg_wr_2;
169
        wire                                                                                            lit;
170
 
171
 
172
        /*
173
        ================
174
        == code start ==
175
        ================
176
        */
177
 
178
 
179
        // the control ring
180
        control_ring
181
        #(
182
        .DATA_W                         ( DATA_W ),
183
        .ADDR_W                         ( ADDR_W ),
184
        .THREADS                                ( THREADS ),
185
        .THRD_W                         ( THRD_W ),
186
        .STACKS                         ( STACKS ),
187
        .STK_W                          ( STK_W ),
188
        .IM_W                                   ( IM_W ),
189
        .MEM_DATA_W                     ( MEM_DATA_W ),
190
        .LG_SEL_W                       ( LG_SEL_W ),
191
        .CLR_BASE                       ( CLR_BASE ),
192
        .CLR_SPAN                       ( CLR_SPAN ),
193
        .INTR_BASE                      ( INTR_BASE ),
194
        .INTR_SPAN                      ( INTR_SPAN )
195
        )
196
        control_ring
197
        (
198
        .clk_i                          ( clk_i ),
199
        .rst_i                          ( rst_i ),
200
        .clr_req_i                      ( clr_req ),
201
        .clr_ack_o                      (  ),  // unused
202
        .intr_en_i                      ( intr_en ),
203
        .intr_req_i                     ( intr_req_i ),
204
        .intr_ack_o                     (  ),  // unused
205
        .op_code_i                      ( op_code ),
206
        .op_code_er_o           ( op_code_er ),
207
        .b_addr_i                       ( b_addr ),
208
        .im_o                                   ( im ),
209
        .data_sel_a_o           ( data_sel_a ),
210
        .data_sel_b_o           ( data_sel_b ),
211
        .addr_sel_b_o           ( addr_sel_b ),
212
        .imda_o                         ( imda ),
213
        .imad_o                         ( imad ),
214
        .sgn_o                          ( sgn ),
215
        .hgh_o                          ( hgh ),
216
        .ext_o                          ( ext ),
217
        .lg_sel_o                       ( lg_sel ),
218
        .add_o                          ( add ),
219
        .sub_o                          ( sub ),
220
        .mul_o                          ( mul ),
221
        .shl_o                          ( shl ),
222
        .pow_o                          ( pow ),
223
        .rtn_o                          ( rtn ),
224
        .lit_o                          ( lit ),
225
        .dm_rd_o                                ( dm_rd ),
226
        .dm_wr_o                                ( dm_wr ),
227
        .rg_rd_o                                ( rg_rd ),
228
        .rg_wr_o                                ( rg_wr ),
229
        .stk_clr_o                      ( stk_clr ),
230
        .pop_o                          ( pop ),
231
        .push_o                         ( push ),
232
        .flg_nz_2_i                     ( flg_nz_2 ),
233
        .flg_lz_2_i                     ( flg_lz_2 ),
234
        .flg_ne_2_i                     ( flg_ne_2 ),
235
        .flg_lt_2_i                     ( flg_lt_2 ),
236
        .thrd_0_o                       ( thrd_0 ),
237
        .thrd_2_o                       ( thrd_2 ),
238
        .thrd_3_o                       ( thrd_3 ),
239
        .thrd_6_o                       ( thrd_6 ),
240
        .pc_1_o                         ( pc_1 ),
241
        .pc_3_o                         ( pc_3 ),
242
        .pc_4_o                         ( pc_4 )
243
        );
244
 
245
 
246
        // the data ring
247
        data_ring
248
        #(
249
        .DATA_W                         ( DATA_W ),
250
        .ADDR_W                         ( ADDR_W ),
251
        .THREADS                                ( THREADS ),
252
        .THRD_W                         ( THRD_W ),
253
        .STACKS                         ( STACKS ),
254
        .STK_W                          ( STK_W ),
255
        .PNTR_W                         ( PNTR_W ),
256
        .IM_W                                   ( IM_W ),
257
        .LG_SEL_W                       ( LG_SEL_W ),
258
        .PROT_POP                       ( PROT_POP ),
259
        .PROT_PUSH                      ( PROT_PUSH )
260
        )
261
        data_ring
262
        (
263
        .clk_i                          ( clk_i ),
264
        .rst_i                          ( rst_i ),
265
        .data_sel_a_i           ( data_sel_a ),
266
        .data_sel_b_i           ( data_sel_b ),
267
        .addr_sel_b_i           ( addr_sel_b ),
268
        .imda_i                         ( imda ),
269
        .imad_i                         ( imad ),
270
        .sgn_i                          ( sgn ),
271
        .ext_i                          ( ext ),
272
        .hgh_i                          ( hgh ),
273
        .lg_sel_i                       ( lg_sel ),
274
        .add_i                          ( add ),
275
        .sub_i                          ( sub ),
276
        .mul_i                          ( mul ),
277
        .shl_i                          ( shl ),
278
        .pow_i                          ( pow ),
279
        .rtn_i                          ( rtn ),
280
        .dm_rd_i                                ( dm_rd ),
281
        .rg_rd_i                                ( rg_rd ),
282
        .stk_clr_i                      ( stk_clr ),
283
        .pop_i                          ( pop ),
284
        .push_i                         ( push ),
285
        .thrd_6_i                       ( thrd_6 ),
286
        .im_i                                   ( im ),
287
        .dm_rd_data_4_i ( dm_rd_data_4 ),
288
        .rg_rd_data_4_i ( rg_rd_data_4 ),
289
        .pc_3_i                         ( pc_3 ),
290
        .a_data_o                       ( a_data ),
291
        .b_addr_o                       ( b_addr ),
292
        .flg_nz_2_o                     ( flg_nz_2 ),
293
        .flg_lz_2_o                     ( flg_lz_2 ),
294
        .flg_ne_2_o                     ( flg_ne_2 ),
295
        .flg_lt_2_o                     ( flg_lt_2 ),
296
        .pop_er_2_o                     ( pop_er_2 ),
297
        .push_er_3_o            ( push_er_3 )
298
        );
299
 
300
 
301
        // shim for memory and register set access
302
        reg_mem_shim
303
        #(
304
        .DATA_W                         ( DATA_W ),
305
        .ADDR_W                         ( ADDR_W ),
306
        .IM_W                                   ( DM_OFFS_W )
307
        )
308
        reg_mem_shim
309
        (
310
        .clk_i                          ( clk_i ),
311
        .rst_i                          ( rst_i ),
312
        .hgh_i                          ( hgh ),
313
        .lit_i                          ( lit ),
314
        .dm_wr_i                                ( dm_wr ),
315
        .rg_rd_i                                ( rg_rd ),
316
        .rg_wr_i                                ( rg_wr ),
317
        .dm_wr_o                                ( dm_wr_2 ),
318
        .rg_rd_o                                ( rg_rd_2 ),
319
        .rg_wr_o                                ( rg_wr_2 ),
320
        .a_data_i                       ( a_data ),
321
        .wr_data_o                      ( wr_data_2 ),
322
        .b_addr_i                       ( b_addr ),
323
        .im_i                                   ( im[DM_OFFS_W-1:0] ),
324
        .pc_1_i                         ( pc_1 ),
325
        .rg_addr_o                      ( rg_addr_2 ),
326
        .dm_addr_o                      ( dm_addr_2 )
327
        );
328
 
329
 
330
        // internal register set
331
        reg_set
332
        #(
333
        .REGS_IN                                ( 1 ),
334
        .REGS_OUT                       ( 1 ),
335
        .DATA_W                         ( DATA_W/2 ),
336
        .ADDR_W                         ( REG_ADDR_W ),
337
        .THREADS                                ( THREADS ),
338
        .THRD_W                         ( THRD_W ),
339
        .STACKS                         ( STACKS ),
340
        .STK_W                          ( STK_W ),
341
        .VER_MAJ                                ( VER_MAJ ),
342
        .VER_MIN                                ( VER_MIN ),
343
        .UART_DATA_W            ( UART_DATA_W ),
344
        .CLK_HZ                         ( CLK_HZ ),
345
        .UART_BAUD_RATE ( UART_BAUD_RATE )
346
        )
347
        reg_set
348
        (
349
        .clk_i                          ( clk_i ),
350
        .rst_i                          ( rst_i ),
351
        .addr_i                         ( rg_addr_2[REG_ADDR_W-1:0] ),
352
        .wr_i                                   ( rg_wr_2 ),
353
        .rd_i                                   ( rg_rd_2 ),
354
        .data_i                         ( wr_data_2 ),
355
        .data_o                         ( rg_rd_data_4 ),
356
        .clr_req_o                      ( clr_req ),
357
        .intr_en_o                      ( intr_en ),
358
        .thrd_0_i                       ( thrd_0 ),
359
        .op_code_er_i           ( op_code_er ),
360
        .thrd_2_i                       ( thrd_2 ),
361
        .pop_er_2_i                     ( pop_er_2 ),
362
        .thrd_3_i                       ( thrd_3 ),
363
        .push_er_3_i            ( push_er_3 ),
364
        .io_lo_i                                ( io_i[DATA_W/2-1:0] ),
365
        .io_hi_i                                ( io_i[DATA_W-1:DATA_W/2] ),
366
        .io_lo_o                                ( io_o[DATA_W/2-1:0] ),
367
        .io_hi_o                                ( io_o[DATA_W-1:DATA_W/2] ),
368
        .uart_rx_i                      ( uart_rx_i ),
369
        .uart_tx_o                      ( uart_tx_o )
370
        );
371
 
372
 
373
        // instruction and data memory
374
        dp_ram_infer
375
        #(
376
        .REG_A_OUT                      ( 1 ),
377
        .REG_B_OUT                      ( 1 ),
378
        .DATA_W                         ( MEM_DATA_W ),
379
        .ADDR_W                         ( MEM_ADDR_W ),
380
        .MODE                           ( "RAW" )  // functional don't care
381
        )
382
        main_mem
383
        (
384
        .a_clk_i                                ( clk_i ),
385
        .a_addr_i                       ( dm_addr_2 ),
386
        .a_wr_i                         ( dm_wr_2 ),
387
        .a_data_i                       ( wr_data_2 ),
388
        .a_data_o                       ( dm_rd_data_4 ),
389
        .b_clk_i                                ( clk_i ),
390
        .b_addr_i                       ( pc_4 ),
391
        .b_wr_i                         ( 1'b0 ),  // unused
392
        .b_data_i                       (  ),  // unused
393
        .b_data_o                       ( op_code )
394
        );
395
 
396
 
397
endmodule

powered by: WebSVN 2.1.0

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