Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
CAOS_HW
HDL_IP
SafeSU
Commits
43e40ec5
Commit
43e40ec5
authored
Aug 25, 2020
by
Guillem
Browse files
extend MCCU TB, fix comment spelling
parent
e2e710ed
Changes
5
Hide whitespace changes
Inline
Side-by-side
submodules/MCCU/hdl/MCCU.sv
View file @
43e40ec5
...
...
@@ -206,7 +206,7 @@
Add quotas of all active signals. The ones that are not
enabled are 0. The quotas in ccc_suma_int[i] are added at every
cycle independently of the enable signal, but ccc_suma_int will
only be substracted to the quota i
d
MCCU is enabled
only be substracted to the quota i
f
MCCU is enabled
----------*/
for
(
i
=
0
;
i
<
N_CORES
;
i
=
i
+
1
)
begin
:
AddEventsWeights
tmp_ccc_suma_int
=
0
;
...
...
submodules/MCCU/tb/questa_sim/colors.vh
0 → 100644
View file @
43e40ec5
`define START_GREEN_PRINT $write("%c[1;32m",27);
`define START_RED_PRINT $write("%c[1;31m",27);
`define END_COLOR_PRINT $write("%c[0m",27);
submodules/MCCU/tb/questa_sim/runtest.sh
View file @
43e40ec5
$1
#
$1
if
[
-z
"
$1
"
]
then
...
...
@@ -12,5 +12,5 @@ else
vmap work
$PWD
/MCCU
vlog +acc
=
rn +incdir+../../hdl/ ../../hdl/
*
.sv tb_MCCU.sv
vmake MCCU/
>
Makefile
vsim work.tb_MCCU
$1
-do
"
run 40000
"
vsim work.tb_MCCU
$1
-do
"
do save_wave.do
"
fi
submodules/MCCU/tb/questa_sim/save_wave.do
0 → 100644
View file @
43e40ec5
set WildcardFilter ""
log -r /*
run -all
quit
submodules/MCCU/tb/questa_sim/tb_MCCU.sv
View file @
43e40ec5
...
...
@@ -18,7 +18,7 @@
// intended behaviour. Designed to be used with QuestaSim.
`timescale
1
ns
/
1
ns
`default_nettype
none
`include
"colors.vh"
//***Headers***
//***Test bench***
module
tb_MCCU
();
...
...
@@ -27,9 +27,9 @@ module tb_MCCU();
parameter
CLK_HALF_PERIOD
=
CLK_PERIOD
/
2
;
//***DUT parameters***
parameter
TB_DATA_WIDTH
=
32
;
parameter
TB_WEIGHTS_WIDTH
=
7
;
parameter
TB_N_CORES
=
1
;
parameter
TB_CORE_EVENTS
=
1
;
parameter
TB_WEIGHTS_WIDTH
=
8
;
parameter
TB_N_CORES
=
4
;
parameter
TB_CORE_EVENTS
=
2
;
//***Signals***
reg
tb_clk_i
;
reg
tb_rstn_i
;
...
...
@@ -41,6 +41,9 @@ module tb_MCCU();
reg
tb_update_quota_i
[
0
:
TB_N_CORES
-
1
];
wire
[
TB_DATA_WIDTH
-
1
:
0
]
tb_quota_o
[
0
:
TB_N_CORES
-
1
];
wire
tb_interruption_quota_o
[
TB_N_CORES
-
1
:
0
];
//store name of test for easier debug of waveform
reg
[
64
*
8
:
0
]
tb_test_name
;
reg
tb_fail
=
0
;
//***Module***
MCCU
#(
.
DATA_WIDTH
(
TB_DATA_WIDTH
),
...
...
@@ -100,6 +103,92 @@ task automatic init_sim;
$
dumpvars
(
0
,
dut_MCCU
);
end
endtask
//***task automatic test_0weigths_1ev***
//Set weigths,quotas and events. Then check for interrupt
task
automatic
test_weigths_ev_quota
(
input
int
weights_i
,
input
events_i
,
input
int
quota_i
,
input
intr_o
);
;
begin
int
tmp
=
0
;
disable_MCCU
;
//rise all events
if
(
events_i
)
begin
rise_event
(
0
,
0
);
rise_event
(
1
,
0
);
rise_event
(
2
,
0
);
rise_event
(
3
,
0
);
rise_event
(
0
,
1
);
rise_event
(
1
,
1
);
rise_event
(
2
,
1
);
rise_event
(
3
,
1
);
end
else
begin
release_event
(
0
,
0
);
release_event
(
1
,
0
);
release_event
(
2
,
0
);
release_event
(
3
,
0
);
release_event
(
0
,
1
);
release_event
(
1
,
1
);
release_event
(
2
,
1
);
release_event
(
3
,
1
);
end
//Core_id, Singal ID, weight
set_weight
(
0
,
0
,
weights_i
);
set_weight
(
1
,
0
,
weights_i
);
set_weight
(
2
,
0
,
weights_i
);
set_weight
(
3
,
0
,
weights_i
);
set_weight
(
0
,
1
,
weights_i
);
set_weight
(
1
,
1
,
weights_i
);
set_weight
(
2
,
1
,
weights_i
);
set_weight
(
3
,
1
,
weights_i
);
//Set quota for each core
set_quota
(
quota_i
,
0
);
set_quota
(
quota_i
,
1
);
set_quota
(
quota_i
,
2
);
set_quota
(
quota_i
,
3
);
enable_MCCU
();
#
CLK_PERIOD
;
#
CLK_PERIOD
;
#
CLK_PERIOD
;
get_interrupt
(
0
,
tmp
);
$
display
(
"interrupt value is %d"
,
tmp
);
if
(
tmp
!=
intr_o
)
begin
tb_fail
=
1
;
$
error
(
"FAIL test_sim. Expected interrupt %d"
,
intr_o
);
`START_RED_PRINT
$
display
(
"FAIL"
);
$
display
(
"%s"
,
tb_test_name
);
`END_COLOR_PRINT
end
get_interrupt
(
1
,
tmp
);
$
display
(
"interrupt value is %d"
,
tmp
);
if
(
tmp
!=
intr_o
)
begin
tb_fail
=
1
;
$
error
(
"FAIL test_sim. Expected interrupt %d"
,
intr_o
);
`START_RED_PRINT
$
display
(
"FAIL"
);
$
display
(
"%s"
,
tb_test_name
);
`END_COLOR_PRINT
end
get_interrupt
(
2
,
tmp
);
$
display
(
"interrupt value is %d"
,
tmp
);
if
(
tmp
!=
intr_o
)
begin
tb_fail
=
1
;
$
error
(
"FAIL test_sim. Expected interrupt %d"
,
intr_o
);
`START_RED_PRINT
$
display
(
"FAIL"
);
$
display
(
"%s"
,
tb_test_name
);
`END_COLOR_PRINT
end
get_interrupt
(
3
,
tmp
);
$
display
(
"interrupt value is %d"
,
tmp
);
if
(
tmp
!=
intr_o
)
begin
tb_fail
=
1
;
$
error
(
"FAIL test_sim. Expected interrupt %d"
,
intr_o
);
`START_RED_PRINT
$
display
(
"FAIL"
);
$
display
(
"%s"
,
tb_test_name
);
`END_COLOR_PRINT
end
end
endtask
//***task automatic test_sim***
task
automatic
test_sim
;
...
...
@@ -109,21 +198,32 @@ task automatic init_sim;
int
unsigned
c1_s1
=
0
;
int
unsigned
q_val
=
150
;
$
display
(
"*** test_sim."
);
tb_test_name
=
"test_sim"
;
//***Handcrafted test***
enable_MCCU
;
set_quota
(
q_val
,
c1_id
);
#
CLK_PERIOD
;
get_remaining_quota
(
c1_id
,
temp
);
if
(
temp
!=
q_val
)
if
(
temp
!=
q_val
)
begin
tb_fail
=
1
;
$
error
(
"FAIL test_sim.
\n
Expected remaining_quota %d,\
obtained %d"
,
q_val
,
temp
);
`START_RED_PRINT
$
display
(
"FAIL"
);
`END_COLOR_PRINT
end
set_quota
(
200
,
c1_id
);
#
CLK_PERIOD
;
disable_MCCU
;
get_remaining_quota
(
c1_id
,
temp
);
if
(
temp
!=
200
)
if
(
temp
!=
200
)
begin
tb_fail
=
1
;
$
error
(
"FAIL test_sim.
\n
Expected remaining_quota %d,\
obtained %d"
,
200
,
temp
);
`START_RED_PRINT
$
display
(
"FAIL"
);
`END_COLOR_PRINT
end
#
CLK_PERIOD
;
set_weight
(
c1_id
,
c1_s1
,
10
);
#
CLK_PERIOD
;
...
...
@@ -131,44 +231,74 @@ task automatic init_sim;
rise_event
(
c1_id
,
c1_s1
);
#
CLK_PERIOD
;
get_remaining_quota
(
c1_id
,
temp
);
if
(
temp
!=
200
)
if
(
temp
!=
200
)
begin
tb_fail
=
1
;
$
error
(
"FAIL test_sim.
\n
Expected remaining_quota %d,\
obtained %d"
,
200
,
temp
);
`START_RED_PRINT
$
display
(
"FAIL"
);
`END_COLOR_PRINT
end
//quota shall decrease to 190
enable_MCCU
;
rise_event
(
c1_id
,
c1_s1
);
#
CLK_PERIOD
;
get_remaining_quota
(
c1_id
,
temp
);
if
(
temp
!=
190
)
if
(
temp
!=
190
)
begin
tb_fail
=
1
;
$
error
(
"FAIL test_sim.
\n
Expected remaining_quota %d,\
obtained %d"
,
190
,
temp
);
`START_RED_PRINT
$
display
(
"FAIL"
);
`END_COLOR_PRINT
end
//quota shall decrease to 180
release_event
(
c1_id
,
c1_s1
);
#
CLK_PERIOD
;
get_remaining_quota
(
c1_id
,
temp
);
if
(
temp
!=
180
)
if
(
temp
!=
180
)
begin
tb_fail
=
1
;
$
error
(
"FAIL test_sim.
\n
Expected remaining_quota %d,\
obtained %d"
,
180
,
temp
);
`START_RED_PRINT
$
display
(
"FAIL"
);
`END_COLOR_PRINT
end
#
CLK_PERIOD
;
reset_dut
;
#
CLK_PERIOD
;
//quota sall be 0
get_remaining_quota
(
c1_id
,
temp
);
if
(
temp
!=
0
)
if
(
temp
!=
0
)
begin
tb_fail
=
1
;
$
error
(
"FAIL test_sim.
\n
Expected remaining_quota %d,\
obtained %d"
,
0
,
temp
);
`START_RED_PRINT
$
display
(
"FAIL"
);
`END_COLOR_PRINT
end
#
CLK_PERIOD
;
//interrupt shall be risen quota shall remain 0
rise_event
(
c1_id
,
c1_s1
);
#
CLK_PERIOD
;
get_remaining_quota
(
c1_id
,
temp
);
if
(
temp
!=
0
)
if
(
temp
!=
0
)
begin
tb_fail
=
1
;
$
error
(
"FAIL test_sim.
\n
Expected remaining_quota %d,\
obtained %d"
,
0
,
temp
);
`START_RED_PRINT
$
display
(
"FAIL"
);
`END_COLOR_PRINT
end
get_interrupt
(
c1_id
,
temp
);
$
display
(
"interrupt value is %d"
,
temp
);
if
(
temp
!=
1
)
if
(
temp
!=
1
)
begin
tb_fail
=
1
;
$
error
(
"FAIL test_sim. Expected interruption high"
);
`START_RED_PRINT
$
display
(
"FAIL"
);
`END_COLOR_PRINT
end
$
display
(
"Done"
);
end
endtask
...
...
@@ -189,8 +319,11 @@ task automatic init_sim;
if
((
quota_i
>
((
2
**
32
)
-
1
)))
// $display("***WARNING: quota_i > TB_DATA_WIDTH^2. quota_i=%d",quota_i);
if
((
core_i
>
TB_N_CORES
))
begin
tb_fail
=
1
;
$
error
(
"core_i > N_CORES. core_i=%d"
,
core_i
);
`START_RED_PRINT
$
display
(
"FAIL"
);
`END_COLOR_PRINT
end
endtask
//***task get_remaining_quota
...
...
@@ -200,8 +333,11 @@ task automatic init_sim;
value_o
=
tb_quota_o
[
core_i
];
$
display
(
"get quota of core: %d remaining quota: %d"
,
core_i
,
value_o
);
if
((
core_i
>
TB_N_CORES
))
begin
tb_fail
=
1
;
$
error
(
"core_i > N_CORES. core_i=%d"
,
core_i
);
`START_RED_PRINT
$
display
(
"FAIL"
);
`END_COLOR_PRINT
end
endtask
//***task enable_MCCU
...
...
@@ -215,33 +351,41 @@ task automatic init_sim;
tb_enable_i
=
1'b0
;
endtask
//***task rise_event
task
automatic
rise_event
;
input
core_i
;
input
signal_i
;
task
automatic
rise_event
(
input
int
core_i
,
signal_i
);
tb_events_i
[
core_i
][
signal_i
]
=
1'b1
;
$
display
(
"rise
core
: %d of core: %d"
,
core_i
,
signal
_i
);
$
display
(
"rise
event
: %d of core: %d"
,
signal_i
,
core
_i
);
if
((
signal_i
>
TB_CORE_EVENTS
))
begin
tb_fail
=
1
;
$
error
(
"signal_i > TB_CORE_EVENTS. signal_i=%d"
,
signal_i
);
`START_RED_PRINT
$
display
(
"FAIL"
);
`END_COLOR_PRINT
end
if
((
core_i
>
TB_N_CORES
))
begin
tb_fail
=
1
;
$
error
(
"core_i > N_CORES. core_i=%d"
,
core_i
);
`START_RED_PRINT
$
display
(
"FAIL"
);
`END_COLOR_PRINT
end
endtask
//***task release_event
task
automatic
release_event
;
input
core_i
;
input
signal_i
;
task
automatic
release_event
(
input
int
core_i
,
signal_i
);
tb_events_i
[
core_i
][
signal_i
]
=
1'b0
;
$
display
(
"release
core
: %d of core: %d"
,
core_i
,
signal
_i
);
$
display
(
"release
event
: %d of core: %d"
,
signal_i
,
core
_i
);
if
((
signal_i
>
TB_CORE_EVENTS
))
begin
tb_fail
=
1
;
$
error
(
"signal_i > TB_CORE_EVENTS. signal_i=%d"
,
signal_i
);
`START_RED_PRINT
$
display
(
"FAIL"
);
`END_COLOR_PRINT
end
if
((
core_i
>
TB_N_CORES
))
begin
tb_fail
=
1
;
$
error
(
"core_i > N_CORES. core_i=%d"
,
core_i
);
`START_RED_PRINT
$
display
(
"FAIL"
);
`END_COLOR_PRINT
end
endtask
//***task set_weight
...
...
@@ -254,12 +398,18 @@ task automatic init_sim;
if
((
weight_i
>
2
**
TB_WEIGHTS_WIDTH
))
$
display
(
"***WARNING: weight_i > TB_WEIGHTS_WIDTH^2. weight_i=%d"
,
weight_i
);
if
((
signal_i
>
TB_CORE_EVENTS
))
begin
tb_fail
=
1
;
$
error
(
"signal_i > TB_CORE_EVENTS. signal_i=%d"
,
signal_i
);
`START_RED_PRINT
$
display
(
"FAIL"
);
`END_COLOR_PRINT
end
if
((
core_i
>
TB_N_CORES
))
begin
tb_fail
=
1
;
$
error
(
"core_i > N_CORES. core_i=%d"
,
core_i
);
`START_RED_PRINT
$
display
(
"FAIL"
);
`END_COLOR_PRINT
end
endtask
...
...
@@ -270,8 +420,11 @@ task automatic init_sim;
value_o
=
tb_interruption_quota_o
[
core_i
];
$
display
(
"get quota of core: %d remaining quota: %d"
,
core_i
,
value_o
);
if
((
core_i
>
TB_N_CORES
))
begin
tb_fail
=
1
;
$
error
(
"core_i > N_CORES. core_i=%d"
,
core_i
);
`START_RED_PRINT
$
display
(
"FAIL"
);
`END_COLOR_PRINT
end
endtask
...
...
@@ -281,6 +434,26 @@ task automatic init_sim;
init_dump
();
reset_dut
();
test_sim
();
tb_test_name
={
"t_weigths_ev_quota(0,1,255,0);"
}
;
test_weigths_ev_quota
(.
weights_i
(
0
),.
events_i
(
1
),.
quota_i
(
255
),.
intr_o
(
0
));
tb_test_name
={
"t_weigths_ev_quota(10,1,255,0);"
}
;
test_weigths_ev_quota
(
10
,
1
,
255
,
0
);
tb_test_name
={
"t_weigths_ev_quota(255,1,255,1);"
}
;
test_weigths_ev_quota
(
255
,
1
,
255
,
1
);
tb_test_name
={
"t_weigths_ev_quota(255,0,255,0);"
}
;
test_weigths_ev_quota
(
255
,
0
,
255
,
0
);
tb_test_name
={
"t_weigths_ev_quota(2,1,3,1);"
}
;
test_weigths_ev_quota
(
2
,
1
,
3
,
1
);
tb_test_name
={
"t_weigths_ev_quota(0,1,0,0);"
}
;
test_weigths_ev_quota
(
0
,
1
,
0
,
0
);
tb_test_name
={
"t_weigths_ev_quota(10,0,0,0);"
}
;
test_weigths_ev_quota
(
10
,
0
,
0
,
0
);
$
finish
;
end
/*
//name ,rstn_i ,enable_i ,events_i ,quota_i ,events_weights_i
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment