HDLRuby 2.11.10 → 2.11.12
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +55 -18
- data/ext/hruby_sim/hruby_rcsim_build.c +110 -83
- data/ext/hruby_sim/hruby_sim.h +3 -0
- data/ext/hruby_sim/hruby_sim_calc.c +14 -6
- data/ext/hruby_sim/hruby_sim_core.c +20 -7
- data/ext/hruby_sim/hruby_sim_list.c +1 -1
- data/ext/hruby_sim/hruby_sim_stack_calc.c +3 -2
- data/ext/hruby_sim/hruby_sim_tree_calc.c +8 -1
- data/ext/hruby_sim/hruby_sim_vcd.c +24 -7
- data/ext/hruby_sim/hruby_sim_vizualize.c +9 -1
- data/lib/HDLRuby/hdr_samples/constant_in_function.rb +3 -1
- data/lib/HDLRuby/hdr_samples/counter_dff_bench.rb +3 -1
- data/lib/HDLRuby/hdr_samples/huge_rom.rb +1 -1
- data/lib/HDLRuby/hdr_samples/mei8.rb +11 -11
- data/lib/HDLRuby/hdr_samples/mei8_bench.rb +11 -11
- data/lib/HDLRuby/hdr_samples/neg_arith_bench.rb +4 -4
- data/lib/HDLRuby/hdr_samples/rom_nest.rb +1 -1
- data/lib/HDLRuby/hdr_samples/ruby_fir_hw.rb +4 -4
- data/lib/HDLRuby/hdr_samples/struct.rb +44 -10
- data/lib/HDLRuby/hdr_samples/with_bram.rb +45 -0
- data/lib/HDLRuby/hdr_samples/with_casts.rb +3 -3
- data/lib/HDLRuby/hdr_samples/with_concat.rb +6 -6
- data/lib/HDLRuby/hdr_samples/with_connector_memory.rb +2 -2
- data/lib/HDLRuby/hdr_samples/with_def.rb +10 -3
- data/lib/HDLRuby/hdr_samples/with_define_operator.rb +44 -0
- data/lib/HDLRuby/hdr_samples/with_fixpoint.rb +12 -12
- data/lib/HDLRuby/hdr_samples/with_init.rb +3 -3
- data/lib/HDLRuby/hdr_samples/with_leftright.rb +21 -0
- data/lib/HDLRuby/hdr_samples/with_reduce.rb +13 -13
- data/lib/HDLRuby/hdr_samples/with_ref_array.rb +6 -6
- data/lib/HDLRuby/hdr_samples/with_subsums.rb +3 -3
- data/lib/HDLRuby/hdr_samples/with_terminate.rb +3 -3
- data/lib/HDLRuby/hdr_samples/with_to_a.rb +10 -10
- data/lib/HDLRuby/hdr_samples/with_values.rb +3 -3
- data/lib/HDLRuby/hdrcc.rb +14 -1
- data/lib/HDLRuby/hruby_bstr.rb +10 -5
- data/lib/HDLRuby/hruby_high.rb +114 -27
- data/lib/HDLRuby/hruby_low.rb +187 -16
- data/lib/HDLRuby/hruby_low2c.rb +71 -11
- data/lib/HDLRuby/hruby_low2vhd.rb +2 -1
- data/lib/HDLRuby/hruby_low_fix_types.rb +1 -0
- data/lib/HDLRuby/hruby_low_mutable.rb +30 -1
- data/lib/HDLRuby/hruby_low_resolve.rb +15 -2
- data/lib/HDLRuby/hruby_low_without_concat.rb +28 -8
- data/lib/HDLRuby/hruby_low_without_parinseq.rb +14 -4
- data/lib/HDLRuby/hruby_low_without_select.rb +2 -2
- data/lib/HDLRuby/hruby_low_without_subsignals.rb +279 -0
- data/lib/HDLRuby/hruby_rcsim.rb +99 -87
- data/lib/HDLRuby/hruby_rsim.rb +132 -7
- data/lib/HDLRuby/hruby_rsim_vcd.rb +99 -27
- data/lib/HDLRuby/hruby_values.rb +35 -31
- data/lib/HDLRuby/std/bram.rb +22 -0
- data/lib/HDLRuby/std/fixpoint.rb +2 -2
- data/lib/HDLRuby/std/fsm.rb +20 -3
- data/lib/HDLRuby/std/function_generator.rb +2 -2
- data/lib/HDLRuby/version.rb +1 -1
- metadata +7 -3
- data/lib/HDLRuby/hdr_samples/sumprod.rb +0 -29
|
@@ -19,7 +19,7 @@ Elem get_element(void* data) {
|
|
|
19
19
|
/* Is the pool empty? */
|
|
20
20
|
if (empty_list(&pool_elements)) {
|
|
21
21
|
/* Yes, allocates a new element. */
|
|
22
|
-
elem = malloc(sizeof(ElemS));
|
|
22
|
+
elem = (Elem)malloc(sizeof(ElemS));
|
|
23
23
|
elem->data = data;
|
|
24
24
|
elem->next = NULL;
|
|
25
25
|
} else {
|
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
**/
|
|
15
15
|
|
|
16
16
|
/* The stack variables. */
|
|
17
|
-
#define STACK_SIZE
|
|
17
|
+
#define STACK_SIZE 0x100000
|
|
18
18
|
static Value stack[STACK_SIZE];
|
|
19
19
|
static int head = STACK_SIZE;
|
|
20
20
|
|
|
@@ -86,7 +86,8 @@ Value unary(Value (*oper)(Value,Value)) {
|
|
|
86
86
|
// dst = oper(pop(),dst);
|
|
87
87
|
// push(dst);
|
|
88
88
|
// return dst;
|
|
89
|
-
|
|
89
|
+
Value v = pop();
|
|
90
|
+
return oper(v,peek());
|
|
90
91
|
}
|
|
91
92
|
|
|
92
93
|
/** Binary calculation.
|
|
@@ -181,7 +181,7 @@ Value calc_expression(Expression expr, Value res) {
|
|
|
181
181
|
* @param behavior the behavior in execution. */
|
|
182
182
|
void execute_statement(Statement stmnt, int mode, Behavior behavior) {
|
|
183
183
|
/* Depending on the kind of statement. */
|
|
184
|
-
// printf("Executing statement=%p with kind=%d\n",stmnt,stmnt->kind);fflush(stdout);
|
|
184
|
+
// printf("Executing statement=%p with kind=%d in mode=%d\n",stmnt,stmnt->kind,mode);fflush(stdout);
|
|
185
185
|
switch(stmnt->kind) {
|
|
186
186
|
case TRANSMIT:
|
|
187
187
|
{
|
|
@@ -236,6 +236,7 @@ void execute_statement(Statement stmnt, int mode, Behavior behavior) {
|
|
|
236
236
|
lastV = calc_expression(refr->last,lastV);
|
|
237
237
|
long long last = value2integer(lastV);
|
|
238
238
|
free_value();
|
|
239
|
+
// printf("firstV=%lld lastV=%lld right=%lld mode=%d\n",firstV->data_int,lastV->data_int,right->data_int,mode);
|
|
239
240
|
/* Generate the reference inside the left value. */
|
|
240
241
|
RefRangeS ref =
|
|
241
242
|
make_ref_rangeS((SignalI)(refr->ref),refr->type,
|
|
@@ -399,9 +400,15 @@ void execute_statement(Statement stmnt, int mode, Behavior behavior) {
|
|
|
399
400
|
}
|
|
400
401
|
break;
|
|
401
402
|
}
|
|
403
|
+
case TIME_TERMINATE:
|
|
404
|
+
{
|
|
405
|
+
terminate();
|
|
406
|
+
break;
|
|
407
|
+
}
|
|
402
408
|
case BLOCK:
|
|
403
409
|
{
|
|
404
410
|
Block block = (Block)stmnt;
|
|
411
|
+
// printf("Block mode=%d\n",block->mode);
|
|
405
412
|
/* Execute each statement of the block. */
|
|
406
413
|
for(int i=0; i<block->num_stmnts; ++i)
|
|
407
414
|
execute_statement(block->stmnts[i],block->mode,behavior);
|
|
@@ -155,12 +155,28 @@ static void vcd_print_value(Value value) {
|
|
|
155
155
|
/** Prints a signal declaration.
|
|
156
156
|
* @param signal the signal to declare */
|
|
157
157
|
static void vcd_print_var(SignalI signal) {
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
158
|
+
if (signal->num_signals > 0) {
|
|
159
|
+
int i;
|
|
160
|
+
/* The signal is hierarchical, declare its sub signals. */
|
|
161
|
+
/* Declares the hierachical name. */
|
|
162
|
+
vcd_print("$scope module ");
|
|
163
|
+
vcd_print_name((Object)signal);
|
|
164
|
+
vcd_print(" $end\n");
|
|
165
|
+
/* Declare the inners of the systems. */
|
|
166
|
+
for(i=0; i<signal->num_signals; ++i) {
|
|
167
|
+
vcd_print_var(signal->signals[i]);
|
|
168
|
+
}
|
|
169
|
+
/* Close the hierarchy. */
|
|
170
|
+
vcd_print("$upscope $end\n");
|
|
171
|
+
} else {
|
|
172
|
+
/* The signal is flat, can declarate it directly. */
|
|
173
|
+
vcd_print("$var wire %d ",type_width(signal->type));
|
|
174
|
+
// vcd_print_full_name((Object)signal);
|
|
175
|
+
vcd_print_signal_id(signal);
|
|
176
|
+
vcd_print(" ");
|
|
177
|
+
vcd_print_name((Object)signal);
|
|
178
|
+
vcd_print(" $end\n");
|
|
179
|
+
}
|
|
164
180
|
}
|
|
165
181
|
|
|
166
182
|
|
|
@@ -180,7 +196,8 @@ static void vcd_print_signal_fvalue(SignalI signal) {
|
|
|
180
196
|
/** Prints a signal with its current value if any
|
|
181
197
|
* @param signal the signal to show */
|
|
182
198
|
static void vcd_print_signal_cvalue(SignalI signal) {
|
|
183
|
-
if (signal->c_value) {
|
|
199
|
+
if ((signal->num_signals == 0) && signal->c_value) {
|
|
200
|
+
/* The signal is not hierachical and has a current value. */
|
|
184
201
|
vcd_print_value(signal->c_value);
|
|
185
202
|
// vcd_print(" ");
|
|
186
203
|
// vcd_print_full_name((Object)signal);
|
|
@@ -63,8 +63,15 @@ void default_print_name(Object object) {
|
|
|
63
63
|
}
|
|
64
64
|
/* Depending on the kind of object. */
|
|
65
65
|
switch(object->kind) {
|
|
66
|
-
case SYSTEMT:
|
|
67
66
|
case SIGNALI:
|
|
67
|
+
/* Print the name if name. */
|
|
68
|
+
/* Trick: SystemT, SignalI, Scope and SystemI have the
|
|
69
|
+
* field name at the same place. */
|
|
70
|
+
if (((SignalI)object)->name != NULL) {
|
|
71
|
+
printf("%s",((SignalI)object)->name);
|
|
72
|
+
}
|
|
73
|
+
break;
|
|
74
|
+
case SYSTEMT:
|
|
68
75
|
case SCOPE:
|
|
69
76
|
case SYSTEMI:
|
|
70
77
|
/* Print the name if name. */
|
|
@@ -73,6 +80,7 @@ void default_print_name(Object object) {
|
|
|
73
80
|
if (((SystemI)object)->name != NULL) {
|
|
74
81
|
printf("%s",((SystemI)object)->name);
|
|
75
82
|
}
|
|
83
|
+
break;
|
|
76
84
|
default: /* Nothing to do */
|
|
77
85
|
break;
|
|
78
86
|
}
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
|
|
4
4
|
function :func do |addr|
|
|
5
|
-
bit[4][-4].constant tbl: [
|
|
5
|
+
bit[4][-4].constant tbl: [ _b1000, _b1001, _b1010, _b1011 ]
|
|
6
6
|
|
|
7
7
|
tbl[addr]
|
|
8
8
|
end
|
|
@@ -10,9 +10,11 @@ end
|
|
|
10
10
|
|
|
11
11
|
system :with_func do
|
|
12
12
|
[4].inner :addr, :val
|
|
13
|
+
# bit[4][-4].constant tbl: [ _b1000, _b1001, _b1010, _b1011 ]
|
|
13
14
|
|
|
14
15
|
val <= func(addr)
|
|
15
16
|
# val <= 1
|
|
17
|
+
# val <= tbl[addr]
|
|
16
18
|
|
|
17
19
|
timed do
|
|
18
20
|
addr <= 0
|
|
@@ -117,7 +117,7 @@ system :mei8 do |prog_file = "./prog.obj"|
|
|
|
117
117
|
# Format 1
|
|
118
118
|
entry("01oooyyy") { wf <= 1
|
|
119
119
|
# Destination is also y in case of inc/dec
|
|
120
|
-
hif (ir[6..4] ==
|
|
120
|
+
hif (ir[6..4] == _b101) { dst <= y }
|
|
121
121
|
alu.(o,a,src1) } # binary alu
|
|
122
122
|
# Format 1 extended.
|
|
123
123
|
entry("10000yyy") { wr <= 0; wf <= 1
|
|
@@ -128,17 +128,17 @@ system :mei8 do |prog_file = "./prog.obj"|
|
|
|
128
128
|
entry("10011yyy") { branch <= 1 # jr y, must inc y
|
|
129
129
|
alu.(2,src1) } # since pc-1 is used
|
|
130
130
|
# Format 2
|
|
131
|
-
entry("1010iiii") { alu.(7,[
|
|
131
|
+
entry("1010iiii") { alu.(7,[_b0000,i]) } # movl i
|
|
132
132
|
entry("1011iiii") { alu.(7,[i,a[3..0]]) } # movh i
|
|
133
133
|
# Format 4
|
|
134
134
|
entry("11110110") { branch <= 1 # trap
|
|
135
135
|
alu.(7,0xFC) }
|
|
136
|
-
entry("11110ooo") { wf <= 1; alu.([
|
|
136
|
+
entry("11110ooo") { wf <= 1; alu.([_b1,o],a) } # unary alu
|
|
137
137
|
entry("111110os") { st <= s; ld <= ~s # ++--ld / ++--st
|
|
138
|
-
alu.([
|
|
138
|
+
alu.([_b001,o],g); dst <= 6 }
|
|
139
139
|
entry("1111110i") { branch <= i
|
|
140
140
|
st <= ~i; ld <= i
|
|
141
|
-
alu.([
|
|
141
|
+
alu.([_b001,~i],h)
|
|
142
142
|
dst <= 7; io_out <= pc } # push / pop pc
|
|
143
143
|
# Format 3
|
|
144
144
|
entry("11cccsii") { branch <= cc; wr <= 0
|
|
@@ -180,7 +180,7 @@ system :mei8 do |prog_file = "./prog.obj"|
|
|
|
180
180
|
[a,b,c,d,e,f,g,h,zf,cf,sf,vf,nbr,npc,s].each { |r| r <= 0 }
|
|
181
181
|
end
|
|
182
182
|
# Ensures a is 0 and enable interrupts when starting.
|
|
183
|
-
helsif(init) { a<= 0; s <=
|
|
183
|
+
helsif(init) { a<= 0; s <= _b00000011; }
|
|
184
184
|
helsif(iq_calc) do
|
|
185
185
|
s[7] <= 1
|
|
186
186
|
hif(iq1) { s[1] <= 0 }
|
|
@@ -195,14 +195,14 @@ system :mei8 do |prog_file = "./prog.obj"|
|
|
|
195
195
|
zf <= alu.zf; cf <= alu.cf; sf <= alu.sf; vf <= alu.vf
|
|
196
196
|
end
|
|
197
197
|
# Specific cases
|
|
198
|
-
hif(ir ==
|
|
199
|
-
hif(ir ==
|
|
198
|
+
hif(ir == _b11110111) { s <= a; a <= s } # xs
|
|
199
|
+
hif(ir == _b11110110) { s[7] <= 1 } # trap
|
|
200
200
|
hif(branch) { npc <= alu.z; nbr <= 1 } # Branch
|
|
201
201
|
end
|
|
202
202
|
# Write memory read result to a register if any.
|
|
203
203
|
helsif (io_r_done) do
|
|
204
204
|
hif(branch) { npc <= data; nbr <= 1 } # pop case
|
|
205
|
-
helsif(ir[7..3] ==
|
|
205
|
+
helsif(ir[7..3] == _b10001) do # ld case
|
|
206
206
|
[a,b,c,d,e,f,g,h].hcase(dst) {|r| r <= data }
|
|
207
207
|
end
|
|
208
208
|
helse { a <= data } # ld++-- case
|
|
@@ -231,8 +231,8 @@ system :mei8 do |prog_file = "./prog.obj"|
|
|
|
231
231
|
goto(iq_chk,:iq_s) # Interrupt / No interrupt
|
|
232
232
|
goto(branch,:br) # Branch instruction
|
|
233
233
|
goto((ld|st) & ~io_done,:ld_st) # ld/st instruction
|
|
234
|
-
goto(ir ==
|
|
235
|
-
goto(ir ==
|
|
234
|
+
goto(ir == _b11111110,:ht) # Halt instruction
|
|
235
|
+
goto(ir == _b11111111,:re) } # Reset instruction
|
|
236
236
|
# Branch state.
|
|
237
237
|
state(:br) { goto(iq_chk,:iq_s,:fe) } # Interrupt / No interrupt
|
|
238
238
|
sync(:br) { hif(nbr) { pc <= npc-1 } } # Next pc is the branch target
|
|
@@ -119,7 +119,7 @@ system :mei8 do |prog_file = "./prog.obj"|
|
|
|
119
119
|
# Format 1
|
|
120
120
|
entry("01oooyyy") { wf <= 1
|
|
121
121
|
# Destination is also y in case of inc/dec
|
|
122
|
-
hif (ir[6..4] ==
|
|
122
|
+
hif (ir[6..4] == _b101) { dst <= y }
|
|
123
123
|
alu.(o,a,src1) } # binary alu
|
|
124
124
|
# Format 1 extended.
|
|
125
125
|
entry("10000yyy") { wr <= 0; wf <= 1
|
|
@@ -130,17 +130,17 @@ system :mei8 do |prog_file = "./prog.obj"|
|
|
|
130
130
|
entry("10011yyy") { branch <= 1 # jr y, must inc y
|
|
131
131
|
alu.(2,src1) } # since pc-1 is used
|
|
132
132
|
# Format 2
|
|
133
|
-
entry("1010iiii") { alu.(7,[
|
|
133
|
+
entry("1010iiii") { alu.(7,[_b0000,i]) } # movl i
|
|
134
134
|
entry("1011iiii") { alu.(7,[i,a[3..0]]) } # movh i
|
|
135
135
|
# Format 4
|
|
136
136
|
entry("11110110") { branch <= 1 # trap
|
|
137
137
|
alu.(7,0xFC) }
|
|
138
|
-
entry("11110ooo") { wf <= 1; alu.([
|
|
138
|
+
entry("11110ooo") { wf <= 1; alu.([_b1,o],a) } # unary alu
|
|
139
139
|
entry("111110os") { st <= s; ld <= ~s # ++--ld / ++--st
|
|
140
|
-
alu.([
|
|
140
|
+
alu.([_b001,o],g); dst <= 6 }
|
|
141
141
|
entry("1111110i") { branch <= i
|
|
142
142
|
st <= ~i; ld <= i
|
|
143
|
-
alu.([
|
|
143
|
+
alu.([_b001,~i],h)
|
|
144
144
|
dst <= 7; io_out <= pc } # push / pop pc
|
|
145
145
|
# Format 3
|
|
146
146
|
entry("11cccsii") { branch <= cc; wr <= 0
|
|
@@ -182,7 +182,7 @@ system :mei8 do |prog_file = "./prog.obj"|
|
|
|
182
182
|
[a,b,c,d,e,f,g,h,zf,cf,sf,vf,nbr,npc,s].each { |r| r <= 0 }
|
|
183
183
|
end
|
|
184
184
|
# Ensures a is 0 and enable interrupts when starting.
|
|
185
|
-
helsif(init) { a<= 0; s <=
|
|
185
|
+
helsif(init) { a<= 0; s <= _b00000011; }
|
|
186
186
|
helsif(iq_calc) do
|
|
187
187
|
s[7] <= 1
|
|
188
188
|
hif(iq1) { s[1] <= 0 }
|
|
@@ -197,14 +197,14 @@ system :mei8 do |prog_file = "./prog.obj"|
|
|
|
197
197
|
zf <= alu.zf; cf <= alu.cf; sf <= alu.sf; vf <= alu.vf
|
|
198
198
|
end
|
|
199
199
|
# Specific cases
|
|
200
|
-
hif(ir ==
|
|
201
|
-
hif(ir ==
|
|
200
|
+
hif(ir == _b11110111) { s <= a; a <= s } # xs
|
|
201
|
+
hif(ir == _b11110110) { s[7] <= 1 } # trap
|
|
202
202
|
hif(branch) { npc <= alu.z; nbr <= 1 } # Branch
|
|
203
203
|
end
|
|
204
204
|
# Write memory read result to a register if any.
|
|
205
205
|
helsif (io_r_done) do
|
|
206
206
|
hif(branch) { npc <= data; nbr <= 1 } # pop case
|
|
207
|
-
helsif(ir[7..3] ==
|
|
207
|
+
helsif(ir[7..3] == _b10001) do # ld case
|
|
208
208
|
[a,b,c,d,e,f,g,h].hcase(dst) {|r| r <= data }
|
|
209
209
|
end
|
|
210
210
|
helse { a <= data } # ld++-- case
|
|
@@ -233,8 +233,8 @@ system :mei8 do |prog_file = "./prog.obj"|
|
|
|
233
233
|
goto(iq_chk,:iq_s) # Interrupt / No interrupt
|
|
234
234
|
goto(branch,:br) # Branch instruction
|
|
235
235
|
goto((ld|st) & ~io_done,:ld_st) # ld/st instruction
|
|
236
|
-
goto(ir ==
|
|
237
|
-
goto(ir ==
|
|
236
|
+
goto(ir == _b11111110,:ht) # Halt instruction
|
|
237
|
+
goto(ir == _b11111111,:re) } # Reset instruction
|
|
238
238
|
# Branch state.
|
|
239
239
|
state(:br) { goto(iq_chk,:iq_s,:fe) } # Interrupt / No interrupt
|
|
240
240
|
sync(:br) { hif(nbr) { pc <= npc-1 } } # Next pc is the branch target
|
|
@@ -42,15 +42,15 @@ system :neg_arith_bench do
|
|
|
42
42
|
z <= x * y
|
|
43
43
|
cmp <= (x < y)
|
|
44
44
|
!10.ns
|
|
45
|
-
x <=
|
|
46
|
-
y <=
|
|
45
|
+
x <= _b000000011010
|
|
46
|
+
y <= _b000011111010
|
|
47
47
|
z <= 0
|
|
48
48
|
!10.ns
|
|
49
49
|
z <= x * y
|
|
50
50
|
cmp <= (x < y)
|
|
51
51
|
!10.ns
|
|
52
|
-
x <=
|
|
53
|
-
y <=
|
|
52
|
+
x <= _b000000011010
|
|
53
|
+
y <= _b111111111010
|
|
54
54
|
z <= 0
|
|
55
55
|
!10.ns
|
|
56
56
|
z <= x * y
|
|
@@ -50,13 +50,13 @@ system :work do
|
|
|
50
50
|
|
|
51
51
|
# The input memory.
|
|
52
52
|
mem_rom([8],8,clk,rst,
|
|
53
|
-
[
|
|
54
|
-
|
|
53
|
+
[_b00000001,_b00000010,_b00000011,_b00000100,
|
|
54
|
+
_b00000101,_b00000110,_b00000111,_b00001000]).(:iMem)
|
|
55
55
|
# The output memory.
|
|
56
56
|
mem_dual([8],8,clk,rst).(:oMem)
|
|
57
57
|
# The coefficients.
|
|
58
|
-
coefs = [
|
|
59
|
-
|
|
58
|
+
coefs = [_b11001100,_b00110011,_b10101010,_b01010101,
|
|
59
|
+
_b11110000,_b00001111,_b11100011,_b00011100]
|
|
60
60
|
|
|
61
61
|
# The filter
|
|
62
62
|
fir([8],iMem.branch(:rinc),oMem.branch(:winc),coefs).(:my_fir).(clk,rst,req,ack)
|
|
@@ -1,14 +1,48 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
output :q
|
|
4
|
-
|
|
5
|
-
par(clk.posedge) { q <= d & ~rst }
|
|
1
|
+
typedef(:some_struct) do
|
|
2
|
+
{ sub2: bit, sub3: bit[2] }
|
|
6
3
|
end
|
|
7
4
|
|
|
8
5
|
system :my_system do
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
6
|
+
inner :x
|
|
7
|
+
[3].inner :y
|
|
8
|
+
inner :z
|
|
9
|
+
{ sub0: bit, sub1: bit[2]}.inner :sigA
|
|
10
|
+
some_struct.inner :sigB, :sigC
|
|
11
|
+
|
|
12
|
+
sigC <= sigA
|
|
13
|
+
|
|
14
|
+
par(sigA) { z <= ~z }
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
timed do
|
|
18
|
+
z <= 0
|
|
19
|
+
x <= 1
|
|
20
|
+
y <= _b000
|
|
21
|
+
!10.ns
|
|
22
|
+
sigA.sub0 <= 0
|
|
23
|
+
sigA.sub1 <= x
|
|
24
|
+
sigB.sub2 <= 0
|
|
25
|
+
sigB.sub3 <= x
|
|
26
|
+
!10.ns
|
|
27
|
+
sigA.sub0 <= x
|
|
28
|
+
sigA.sub1 <= ~sigB.sub3
|
|
29
|
+
sigB.sub2 <= x
|
|
30
|
+
sigB.sub3 <= ~sigA.sub1
|
|
31
|
+
!10.ns
|
|
32
|
+
sigA <= _b111
|
|
33
|
+
sigB <= _b111
|
|
34
|
+
!10.ns
|
|
35
|
+
sigA <= _b100
|
|
36
|
+
!10.ns
|
|
37
|
+
y <= sigA
|
|
38
|
+
sigB <= sigA
|
|
39
|
+
!10.ns
|
|
40
|
+
sigA <= _b011
|
|
41
|
+
!10.ns
|
|
42
|
+
sigB <= sigA
|
|
43
|
+
!10.ns
|
|
44
|
+
sigB <= sigA + 1
|
|
45
|
+
!10.ns
|
|
46
|
+
end
|
|
47
|
+
|
|
14
48
|
end
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
require 'std/bram.rb'
|
|
2
|
+
|
|
3
|
+
include HDLRuby::High::Std
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
# A system testing the memory.
|
|
7
|
+
system :bram_test do
|
|
8
|
+
|
|
9
|
+
widthA = 16
|
|
10
|
+
widthD = 8
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
input :clk,:rwb
|
|
14
|
+
[widthA].inner :addr
|
|
15
|
+
[widthD].inner :din,:dout
|
|
16
|
+
|
|
17
|
+
bram(widthA,widthD).(:bramI).(clk,rwb,addr,din,dout)
|
|
18
|
+
|
|
19
|
+
timed do
|
|
20
|
+
clk <= 0
|
|
21
|
+
rwb <= 1
|
|
22
|
+
addr <= 0
|
|
23
|
+
din <= 0
|
|
24
|
+
!10.ns
|
|
25
|
+
clk <= 1
|
|
26
|
+
!10.ns
|
|
27
|
+
rwb <= 1
|
|
28
|
+
repeat(16) do
|
|
29
|
+
clk <= 0
|
|
30
|
+
!10.ns
|
|
31
|
+
clk <= 1
|
|
32
|
+
addr <= addr + 1
|
|
33
|
+
din <= din + 1
|
|
34
|
+
!10.ns
|
|
35
|
+
end
|
|
36
|
+
rwb <= 0
|
|
37
|
+
repeat(16) do
|
|
38
|
+
clk <= 0
|
|
39
|
+
!10.ns
|
|
40
|
+
clk <= 1
|
|
41
|
+
addr <= addr-1
|
|
42
|
+
!10.ns
|
|
43
|
+
end
|
|
44
|
+
end
|
|
45
|
+
end
|
|
@@ -10,16 +10,16 @@ system :with_concat do
|
|
|
10
10
|
val3 <= [val2,val0]
|
|
11
11
|
|
|
12
12
|
timed do
|
|
13
|
-
val0 <=
|
|
14
|
-
val1 <=
|
|
13
|
+
val0 <= _b1111
|
|
14
|
+
val1 <= _b0000
|
|
15
15
|
count <= 0
|
|
16
16
|
!10.ns
|
|
17
|
-
val0 <=
|
|
18
|
-
val1 <=
|
|
17
|
+
val0 <= _b1001
|
|
18
|
+
val1 <= _b0110
|
|
19
19
|
count <= 1
|
|
20
20
|
!10.ns
|
|
21
|
-
val0 <=
|
|
22
|
-
val1 <=
|
|
21
|
+
val0 <= _b1010
|
|
22
|
+
val1 <= _b0101
|
|
23
23
|
count <= 2
|
|
24
24
|
!10.ns
|
|
25
25
|
end
|
|
@@ -12,8 +12,8 @@ system :channel_connector do
|
|
|
12
12
|
address_width = 4 # lutのアドレスのビット幅
|
|
13
13
|
typ = signed[integer_width + decimal_width] # データ型
|
|
14
14
|
|
|
15
|
-
inputs_x =
|
|
16
|
-
inputs_h =
|
|
15
|
+
inputs_x = _b00010011
|
|
16
|
+
inputs_h = _b10100001
|
|
17
17
|
columns = [2, 2, 1]
|
|
18
18
|
|
|
19
19
|
inner :clk, # clock
|
|
@@ -9,11 +9,18 @@ end
|
|
|
9
9
|
system :def_bench do
|
|
10
10
|
|
|
11
11
|
[2].inner :addr
|
|
12
|
-
[8].inner :val0, :val1
|
|
12
|
+
[8].inner :val0, :val1, :val2, :val3
|
|
13
13
|
|
|
14
14
|
par do
|
|
15
|
-
val0 <= lut84([
|
|
16
|
-
val1 <= lut84([
|
|
15
|
+
val0 <= lut84([_b8d0,_b8d1,_b8d4,_b8d9],addr)
|
|
16
|
+
val1 <= lut84([_b8d0,_b8d1,_b8d4,_b8d9],3-addr)
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
bit[8][-4].inner otbl: [_b8d0,_b8d1,_b8d4,_b8d9]
|
|
20
|
+
|
|
21
|
+
par do
|
|
22
|
+
val2 <= otbl[addr]
|
|
23
|
+
val3 <= otbl[3-addr]
|
|
17
24
|
end
|
|
18
25
|
|
|
19
26
|
timed do
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
# A sample for testing define operator.
|
|
2
|
+
|
|
3
|
+
typedef :sat100 do |width|
|
|
4
|
+
signed[width]
|
|
5
|
+
end
|
|
6
|
+
|
|
7
|
+
sat100.define_operator(:+) do |width, x,y|
|
|
8
|
+
tmp = x.as(bit[width]) + y.as(bit[width])
|
|
9
|
+
mux(tmp > 100,tmp,100)
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
typedef :sat do |width, max|
|
|
13
|
+
signed[width]
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
sat.define_operator(:+) do |width,max, x,y|
|
|
17
|
+
tmp = x.as(bit[width]) + y.as(bit[width])
|
|
18
|
+
mux(tmp > max, tmp, max)
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
system :bench_sat do
|
|
23
|
+
sat100(8).inner :x,:y,:z
|
|
24
|
+
sat(8,55).inner :u,:v,:w
|
|
25
|
+
|
|
26
|
+
timed do
|
|
27
|
+
x <= 40
|
|
28
|
+
y <= 32
|
|
29
|
+
z <= x+y
|
|
30
|
+
!10.ns
|
|
31
|
+
u <= 20
|
|
32
|
+
v <= 24
|
|
33
|
+
w <= u+v
|
|
34
|
+
!10.ns
|
|
35
|
+
x <= 70
|
|
36
|
+
y <= 32
|
|
37
|
+
z <= x+y
|
|
38
|
+
!10.ns
|
|
39
|
+
u <= 50
|
|
40
|
+
v <= 24
|
|
41
|
+
w <= u+v
|
|
42
|
+
!10.ns
|
|
43
|
+
end
|
|
44
|
+
end
|
|
@@ -14,9 +14,9 @@ system :fix_test do
|
|
|
14
14
|
|
|
15
15
|
# Performs calculation between then
|
|
16
16
|
timed do
|
|
17
|
-
# x <=
|
|
17
|
+
# x <= _b00110011 # 3.1875
|
|
18
18
|
x <= 3.1875.to_fix(4)
|
|
19
|
-
y <=
|
|
19
|
+
y <= _b01000000 # 4
|
|
20
20
|
!10.ns
|
|
21
21
|
z <= x + y
|
|
22
22
|
!10.ns
|
|
@@ -24,8 +24,8 @@ system :fix_test do
|
|
|
24
24
|
!10.ns
|
|
25
25
|
z <= z / x
|
|
26
26
|
!10.ns
|
|
27
|
-
a <=
|
|
28
|
-
b <=
|
|
27
|
+
a <= _b00010000
|
|
28
|
+
b <= _b00001111
|
|
29
29
|
!10.ns
|
|
30
30
|
c <= a * b
|
|
31
31
|
d <= 0
|
|
@@ -49,15 +49,15 @@ system :fix_test do
|
|
|
49
49
|
!10.ns
|
|
50
50
|
c <= a * b
|
|
51
51
|
!10.ns
|
|
52
|
-
# a <=
|
|
53
|
-
# b <=
|
|
54
|
-
a <=
|
|
55
|
-
b <=
|
|
52
|
+
# a <= _b00010000
|
|
53
|
+
# b <= _b00010101
|
|
54
|
+
a <= _sb0000111x
|
|
55
|
+
b <= _sb1110011x
|
|
56
56
|
!10.ns
|
|
57
|
-
# a <= a &
|
|
58
|
-
# b <= b |
|
|
59
|
-
a <= a |
|
|
60
|
-
b <= b |
|
|
57
|
+
# a <= a & _b11111110
|
|
58
|
+
# b <= b | _b00000001
|
|
59
|
+
a <= a | _b00000001
|
|
60
|
+
b <= b | _b00000001
|
|
61
61
|
!10.ns
|
|
62
62
|
c <= a * b
|
|
63
63
|
!10.ns
|
|
@@ -2,9 +2,9 @@
|
|
|
2
2
|
# A benchmark for testing the initialization of signals.
|
|
3
3
|
system :with_init do
|
|
4
4
|
[8].constant cst0: 127
|
|
5
|
-
constant cst1:
|
|
6
|
-
[8].inner sig0:
|
|
7
|
-
inner sig1:
|
|
5
|
+
constant cst1: _b1
|
|
6
|
+
[8].inner sig0: _b10000000
|
|
7
|
+
inner sig1: _b1
|
|
8
8
|
[8].inner :sig2
|
|
9
9
|
|
|
10
10
|
timed do
|