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

Subversion Repositories hive

[/] [hive/] [trunk/] [v01.10/] [boot_code/] [boot_code_v_interrupts.h] - Blame information for rev 10

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

Line No. Rev Author Line
1 3 ericw
/*
2
--------------------------------------------------------------------------------
3
 
4
Module : boot_code.h
5
 
6
--------------------------------------------------------------------------------
7
 
8
Function:
9
- Boot code for a processor core.
10
 
11
Instantiates:
12
- Nothing.
13
 
14
Notes:
15
- For testing (@ core.v):
16
  CLR_BASE              = 'h0;
17
  CLR_SPAN              = 2;  // gives 4 instructions
18
  INTR_BASE             = 'h20;  // 'd32
19
  INTR_SPAN             = 2;  // gives 4 instructions
20
 
21
 
22
--------------------------------------------------------------------------------
23
*/
24
 
25
        /*
26
        -------------------------
27
        -- external parameters --
28
        -------------------------
29
        */
30
        `include "op_encode.h"
31
        `include "reg_set_addr.h"
32
 
33
        /*
34
        ------------------------------------------------------------
35
        -- defines that make programming code more human readable --
36
        ------------------------------------------------------------
37
        */
38
        `define s0                              2'd0
39
        `define s1                              2'd1
40
        `define s2                              2'd2
41
        `define s3                              2'd3
42
        `define _                               1'b0
43
        `define P                               1'b1
44
        //
45
        `define op_rd_i         op_rd_i[9:4]
46
        `define op_rd_ix                op_rd_ix[9:4]
47
        //
48
        `define op_jmp_iez      op_jmp_iez[9:5]
49
        `define op_jmp_ilz      op_jmp_ilz[9:5]
50
        `define op_jmp_ilez     op_jmp_ilez[9:5]
51
        `define op_jmp_igz      op_jmp_igz[9:5]
52
        `define op_jmp_igez     op_jmp_igez[9:5]
53
        `define op_jmp_iglz     op_jmp_iglz[9:5]
54
        `define op_jmp_i                op_jmp_i[9:5]
55
        //
56
        `define op_wr_i         op_wr_i[9:4]
57
        `define op_wr_ix                op_wr_ix[9:4]
58
        //
59
        `define op_jmp_ie               op_jmp_ie[9:5]
60
        `define op_jmp_il               op_jmp_il[9:5]
61
        `define op_jmp_ile      op_jmp_ile[9:5]
62
        `define op_jmp_iug      op_jmp_iug[9:5]
63
        `define op_jmp_iuge     op_jmp_iuge[9:5]
64
        `define op_jmp_igl      op_jmp_igl[9:5]
65
        //
66
        `define op_byt_i                op_byt_i[9:8]
67
        //
68
        `define op_shl_i                op_shl_i[9:6]
69
        `define op_shl_iu               op_shl_iu[9:6]
70
        `define op_add_i                op_add_i[9:6]
71
 
72
        /*
73
        ----------------------------------------
74
        -- initialize: fill with default data --
75
        ----------------------------------------
76
        */
77
        integer i;
78
 
79
        initial begin
80
 
81
/*      // fill with nop (some compilers need this)
82
        for ( i = 0; i < CAPACITY; i = i+1 ) begin
83
                ram[i] = { op_nop, `_, `_, `s0, `s0 };
84
        end
85
*/
86
 
87
        /*
88
        ---------------
89
        -- boot code --
90
        ---------------
91
        */
92
 
93
 
94
        // Thread 0 : enable interrupts
95
        // All threads : output thread ID @ interrupt
96
 
97
        ///////////////
98
        // clr space //
99
        ///////////////
100
 
101
        // thread 0 : enable interrupts & loop forever
102
        i='h0;   ram[i] = {  op_lit_u,              `_, `_, `s0, `s3 };  // lit => s3
103
        i=i+1;   ram[i] = 16'h100                                     ;  // addr
104
        i=i+1;   ram[i] = {  op_gsb,                `P, `_, `s3, `s3 };  // gsb, pop s3 (addr)
105
        i=i+1;   ram[i] = { `op_jmp_i,       -5'h1, `_, `_, `s0, `s0 };  // loop forever
106
        // all others : loop forever
107
        i='h4;   ram[i] = { `op_jmp_i,       -5'h1, `_, `_, `s0, `s0 };  // loop forever
108
        i=i+4;   ram[i] = { `op_jmp_i,       -5'h1, `_, `_, `s0, `s0 };  // loop forever
109
        i=i+4;   ram[i] = { `op_jmp_i,       -5'h1, `_, `_, `s0, `s0 };  // loop forever
110
        i=i+4;   ram[i] = { `op_jmp_i,       -5'h1, `_, `_, `s0, `s0 };  // loop forever
111
        i=i+4;   ram[i] = { `op_jmp_i,       -5'h1, `_, `_, `s0, `s0 };  // loop forever
112
        i=i+4;   ram[i] = { `op_jmp_i,       -5'h1, `_, `_, `s0, `s0 };  // loop forever
113
        i=i+4;   ram[i] = { `op_jmp_i,       -5'h1, `_, `_, `s0, `s0 };  // loop forever
114
 
115
        ////////////////
116
        // intr space //
117
        ////////////////
118
 
119
        // all threads : read and output thread ID
120
        i='h20;  ram[i] = {  op_lit_u,              `_, `_, `s0, `s3 };  // lit => s3
121
        i=i+1;   ram[i] = 16'h110                                     ;  // addr
122
        i=i+1;   ram[i] = {  op_gsb,                `P, `_, `s3, `s3 };  // gsb, pop s3 (addr)
123
        i=i+1;   ram[i] = {  op_gto,                `P, `_, `s3, `s0 };  // return, pop s3
124
        //
125
        i=i+1;   ram[i] = {  op_lit_u,              `_, `_, `s0, `s3 };  // lit => s3
126
        i=i+1;   ram[i] = 16'h110                                     ;  // addr
127
        i=i+1;   ram[i] = {  op_gsb,                `P, `_, `s3, `s3 };  // gsb, pop s3 (addr)
128
        i=i+1;   ram[i] = {  op_gto,                `P, `_, `s3, `s0 };  // return, pop s3
129
        //
130
        i=i+1;   ram[i] = {  op_lit_u,              `_, `_, `s0, `s3 };  // lit => s3
131
        i=i+1;   ram[i] = 16'h110                                     ;  // addr
132
        i=i+1;   ram[i] = {  op_gsb,                `P, `_, `s3, `s3 };  // gsb, pop s3 (addr)
133
        i=i+1;   ram[i] = {  op_gto,                `P, `_, `s3, `s0 };  // return, pop s3
134
        //
135
        i=i+1;   ram[i] = {  op_lit_u,              `_, `_, `s0, `s3 };  // lit => s3
136
        i=i+1;   ram[i] = 16'h110                                     ;  // addr
137
        i=i+1;   ram[i] = {  op_gsb,                `P, `_, `s3, `s3 };  // gsb, pop s3 (addr)
138
        i=i+1;   ram[i] = {  op_gto,                `P, `_, `s3, `s0 };  // return, pop s3
139
        //
140
        i=i+1;   ram[i] = {  op_lit_u,              `_, `_, `s0, `s3 };  // lit => s3
141
        i=i+1;   ram[i] = 16'h110                                     ;  // addr
142
        i=i+1;   ram[i] = {  op_gsb,                `P, `_, `s3, `s3 };  // gsb, pop s3 (addr)
143
        i=i+1;   ram[i] = {  op_gto,                `P, `_, `s3, `s0 };  // return, pop s3
144
        //
145
        i=i+1;   ram[i] = {  op_lit_u,              `_, `_, `s0, `s3 };  // lit => s3
146
        i=i+1;   ram[i] = 16'h110                                     ;  // addr
147
        i=i+1;   ram[i] = {  op_gsb,                `P, `_, `s3, `s3 };  // gsb, pop s3 (addr)
148
        i=i+1;   ram[i] = {  op_gto,                `P, `_, `s3, `s0 };  // return, pop s3
149
        //
150
        i=i+1;   ram[i] = {  op_lit_u,              `_, `_, `s0, `s3 };  // lit => s3
151
        i=i+1;   ram[i] = 16'h110                                     ;  // addr
152
        i=i+1;   ram[i] = {  op_gsb,                `P, `_, `s3, `s3 };  // gsb, pop s3 (addr)
153
        i=i+1;   ram[i] = {  op_gto,                `P, `_, `s3, `s0 };  // return, pop s3
154
        //
155
        i=i+1;   ram[i] = {  op_lit_u,              `_, `_, `s0, `s3 };  // lit => s3
156
        i=i+1;   ram[i] = 16'h110                                     ;  // addr
157
        i=i+1;   ram[i] = {  op_gsb,                `P, `_, `s3, `s3 };  // gsb, pop s3 (addr)
158
        i=i+1;   ram[i] = {  op_gto,                `P, `_, `s3, `s0 };  // return, pop s3
159
 
160
        ///////////////////////
161
        // code & data space //
162
        ///////////////////////
163
 
164
 
165
 
166
        /////////////////
167
        // subroutines //
168
        /////////////////
169
 
170
 
171
        // sub : enable all ints, return to (s3)
172
        i='h100; ram[i] = {  op_lit_u,              `_, `_, `s0, `s1 };  // lit => s1
173
        i=i+1;   ram[i] = REG_BASE_ADDR                               ;  // reg base addr
174
        i=i+1;   ram[i] = { `op_byt_i,       -8'd1, `_, `_, `s0, `s0 };  // -1=>s0
175
        i=i+1;   ram[i] = { `op_wr_i, INTR_EN_ADDR, `P, `P, `s1, `s0 };  // write s0 => (s1+offset), pop both
176
        i=i+1;   ram[i] = {  op_gto,                `P, `_, `s3, `s0 };  // return, pop s3
177
 
178
        // sub : read thread ID, write to GPIO, pop, return to (s3)
179
        i='h110; ram[i] = {  op_lit_u,              `_, `_, `s0, `s1 };  // lit => s1
180
        i=i+1;   ram[i] = REG_BASE_ADDR                               ;  // reg base addr
181
        i=i+1;   ram[i] = { `op_rd_i, THRD_ID_ADDR, `_, `_, `s1, `s0 };  // read (s1+offset) => s0, pop s1
182
        i=i+1;   ram[i] = { `op_wr_i,   IO_LO_ADDR, `P, `P, `s1, `s0 };  // write s0 => (s1+offset), pop both
183
        i=i+1;   ram[i] = {  op_gto,                `P, `_, `s3, `s0 };  // return, pop s3
184
 
185
 
186
        end

powered by: WebSVN 2.1.0

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