Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
M
MasterFIP - Gateware
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Wiki
Wiki
image/svg+xml
Discourse
Discourse
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Projects
MasterFIP - Gateware
Commits
1d193d0d
Commit
1d193d0d
authored
Mar 14, 2023
by
kblantos
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
SVA added in TB
parent
85239351
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
170 additions
and
517 deletions
+170
-517
main.sv
testbench/top_mt/main.sv
+156
-515
run.do
testbench/top_mt/run.do
+1
-1
wave.do
testbench/top_mt/wave.do
+13
-1
No files found.
testbench/top_mt/main.sv
View file @
1d193d0d
...
...
@@ -22,13 +22,13 @@ module main;
reg
clk_test
=
0
;
reg
spi_clk
;
reg
rst
;
reg
ertec_rst
=
0
;
logic
spi_cs_n
=
1'b1
;
logic
spi_mosi
=
1'b0
;
logic
spi_miso
=
1'b0
;
logic
[
31
:
0
]
mosi_data
;
logic
[
31
:
0
]
miso_data
;
logic
[
31
:
0
]
test_miso_data
;
logic
[
4
:
0
]
negedge_cnt
=
'h0
;
logic
[
4
:
0
]
posedge_cnt
=
'h0
;
...
...
@@ -37,6 +37,7 @@ module main;
logic
[
31
:
0
]
q_mosi_data
[$]
;
logic
[
31
:
0
]
q_miso_data
[$]
;
logic
[
31
:
0
]
q_mosi_rmq_data
[$]
;
always
#
8
ns
clk_sys
<=
~
clk_sys
;
always
#
100
ns
tmp_spi_clk
<=
~
tmp_spi_clk
;
// 500ns for 1MHz, 100ns for 5MHz, 25ns for 20MHz
...
...
@@ -46,6 +47,7 @@ module main;
initial
begin
repeat
(
20
)
@
(
posedge
clk_sys
)
;
rst_n
=
1
;
ertec_rst
=
1
;
end
IVME64X
VME
(
rst_n
)
;
...
...
@@ -70,6 +72,7 @@ module main;
.
ertec_spi_mosi_i
(
spi_mosi
)
,
.
ertec_spi_cs_n_i
(
spi_cs_n
)
,
.
ertec_spi_miso_o
(
spi_miso
)
,
.
ertec_rst_i
(
ertec_rst
)
,
// VME Interface
.
vme_sysreset_n_i
(
VME_RST_n
)
,
.
vme_as_n_i
(
VME_AS_n
)
,
...
...
@@ -160,36 +163,8 @@ module main;
l
.
pass
()
;
endtask
////////////////////
// Tasks for SPI //
////////////////////
task
sending_mosi
()
;
int
i
;
mosi_data
=
$
urandom_range
(
1000
,
6000
)
;
$
display
(
"MOSI data = %h"
,
mosi_data
)
;
for
(
i
=
32
;
i
>
0
;
i
--
)
begin
@
(
posedge
spi_clk
)
;
spi_mosi
<=
mosi_data
[
i
-
1
]
;
end
endtask
// sending mosi
task
write_to_mt
()
;
$
display
(
"Sending MOSI to the SPI Slave"
)
;
sending_mosi
()
;
endtask
//write_to_mt
task
spi_testing
()
;
$
display
(
"**** SPI Transaction Starts ****"
)
;
spi_cs_n
<=
1'b0
;
$
display
(
"Chip Select de-asserted"
)
;
write_to_mt
()
;
endtask
// spi_testing
always
@
(
posedge
spi_clk
)
begin
test_miso_data
<=
{
test_
miso_data
[
30
:
0
]
,
spi_miso
};
miso_data
<=
{
miso_data
[
30
:
0
]
,
spi_miso
};
end
task
automatic
loadCPUFirmwares
(
MasterfipDriver
drv
)
;
...
...
@@ -213,434 +188,9 @@ module main;
checkCPUCommunication
(
drv
)
;
endtask
// loadCPUFirmwares
task
sending_first_from_ertec
()
;
int
i
;
$
display
(
"**** Starting the 1st frame like ERTEC ****"
)
;
mosi_data
=
'h00020600
;
// Basic Info
for
(
i
=
0
;
i
<
32
;
i
++
)
begin
@
(
posedge
spi_clk
)
;
spi_mosi
=
mosi_data
[
31
-
i
]
;
end
mosi_data
=
'h040000AA
;
for
(
i
=
32
;
i
>
0
;
i
--
)
begin
@
(
posedge
spi_clk
)
;
spi_mosi
=
mosi_data
[
i
-
1
]
;
end
mosi_data
=
'h040000BB
;
for
(
i
=
32
;
i
>
0
;
i
--
)
begin
@
(
posedge
spi_clk
)
;
spi_mosi
=
mosi_data
[
i
-
1
]
;
end
mosi_data
=
'h040000CC
;
for
(
i
=
32
;
i
>
0
;
i
--
)
begin
@
(
posedge
spi_clk
)
;
spi_mosi
=
mosi_data
[
i
-
1
]
;
end
mosi_data
=
'h04000011
;
for
(
i
=
32
;
i
>
0
;
i
--
)
begin
@
(
posedge
spi_clk
)
;
spi_mosi
=
mosi_data
[
i
-
1
]
;
end
mosi_data
=
'h04000022
;
for
(
i
=
32
;
i
>
0
;
i
--
)
begin
@
(
posedge
spi_clk
)
;
spi_mosi
=
mosi_data
[
i
-
1
]
;
end
mosi_data
=
'h04000033
;
for
(
i
=
32
;
i
>
0
;
i
--
)
begin
@
(
posedge
spi_clk
)
;
spi_mosi
=
mosi_data
[
i
-
1
]
;
end
mosi_data
=
'h04000044
;
for
(
i
=
32
;
i
>
0
;
i
--
)
begin
@
(
posedge
spi_clk
)
;
spi_mosi
=
mosi_data
[
i
-
1
]
;
end
mosi_data
=
'h04000055
;
for
(
i
=
32
;
i
>
0
;
i
--
)
begin
@
(
posedge
spi_clk
)
;
spi_mosi
=
mosi_data
[
i
-
1
]
;
end
mosi_data
=
'h04000066
;
for
(
i
=
32
;
i
>
0
;
i
--
)
begin
@
(
posedge
spi_clk
)
;
spi_mosi
=
mosi_data
[
i
-
1
]
;
end
@
(
posedge
spi_clk
)
;
endtask
// sending_first_from_ertec
task
sending_second_from_ertec
()
;
int
i
;
$
display
(
"**** Starting the 2nd frame like ERTEC ****"
)
;
mosi_data
=
'h01020400
;
// Basic Info
for
(
i
=
32
;
i
>
0
;
i
--
)
begin
@
(
posedge
spi_clk
)
;
spi_mosi
=
mosi_data
[
i
-
1
]
;
end
mosi_data
=
'h0A0000AA
;
for
(
i
=
32
;
i
>
0
;
i
--
)
begin
@
(
posedge
spi_clk
)
;
spi_mosi
=
mosi_data
[
i
-
1
]
;
end
mosi_data
=
'h0A0000BB
;
for
(
i
=
32
;
i
>
0
;
i
--
)
begin
@
(
posedge
spi_clk
)
;
spi_mosi
=
mosi_data
[
i
-
1
]
;
end
mosi_data
=
'h0A0000CC
;
for
(
i
=
32
;
i
>
0
;
i
--
)
begin
@
(
posedge
spi_clk
)
;
spi_mosi
=
mosi_data
[
i
-
1
]
;
end
mosi_data
=
'h0A000011
;
for
(
i
=
32
;
i
>
0
;
i
--
)
begin
@
(
posedge
spi_clk
)
;
spi_mosi
=
mosi_data
[
i
-
1
]
;
end
mosi_data
=
'h0A000022
;
for
(
i
=
32
;
i
>
0
;
i
--
)
begin
@
(
posedge
spi_clk
)
;
spi_mosi
=
mosi_data
[
i
-
1
]
;
end
mosi_data
=
'h0A000033
;
for
(
i
=
32
;
i
>
0
;
i
--
)
begin
@
(
posedge
spi_clk
)
;
spi_mosi
=
mosi_data
[
i
-
1
]
;
end
mosi_data
=
'h0A000044
;
for
(
i
=
32
;
i
>
0
;
i
--
)
begin
@
(
posedge
spi_clk
)
;
spi_mosi
=
mosi_data
[
i
-
1
]
;
end
// @(posedge spi_clk);
/* mosi_data = 'h0A000055;
for (i=32;i>0;i--)
begin
@(posedge spi_clk);
spi_mosi = mosi_data[i-1];
end
// @(posedge spi_clk);
mosi_data = 'h0A000066;
for (i=32;i>0;i--)
begin
@(posedge spi_clk);
spi_mosi = mosi_data[i-1];
end
*/
@
(
posedge
spi_clk
)
;
endtask
// sending_second_from_ertec()
task
sending_third_from_ertec
()
;
int
i
;
$
display
(
"**** Starting the 3rd frame like ERTEC ****"
)
;
mosi_data
=
'h00040200
;
// Basic Info
for
(
i
=
32
;
i
>
0
;
i
--
)
begin
@
(
posedge
spi_clk
)
;
spi_mosi
=
mosi_data
[
i
-
1
]
;
end
mosi_data
=
'h0B0000AA
;
for
(
i
=
32
;
i
>
0
;
i
--
)
begin
@
(
posedge
spi_clk
)
;
spi_mosi
=
mosi_data
[
i
-
1
]
;
end
mosi_data
=
'h0B0000BB
;
for
(
i
=
32
;
i
>
0
;
i
--
)
begin
@
(
posedge
spi_clk
)
;
spi_mosi
=
mosi_data
[
i
-
1
]
;
end
mosi_data
=
'h0B0000CC
;
for
(
i
=
32
;
i
>
0
;
i
--
)
begin
@
(
posedge
spi_clk
)
;
spi_mosi
=
mosi_data
[
i
-
1
]
;
end
mosi_data
=
'h0B000011
;
for
(
i
=
32
;
i
>
0
;
i
--
)
begin
@
(
posedge
spi_clk
)
;
spi_mosi
=
mosi_data
[
i
-
1
]
;
end
mosi_data
=
'h0B000022
;
for
(
i
=
32
;
i
>
0
;
i
--
)
begin
@
(
posedge
spi_clk
)
;
spi_mosi
=
mosi_data
[
i
-
1
]
;
end
@
(
posedge
spi_clk
)
;
endtask
task
sending_fourth_from_ertec
()
;
int
i
;
$
display
(
"**** Starting the 4th frame like ERTEC ****"
)
;
mosi_data
=
'h01040600
;
// Basic Info
for
(
i
=
32
;
i
>
0
;
i
--
)
begin
@
(
posedge
spi_clk
)
;
spi_mosi
=
mosi_data
[
i
-
1
]
;
end
mosi_data
=
'h0C0000AA
;
for
(
i
=
32
;
i
>
0
;
i
--
)
begin
@
(
posedge
spi_clk
)
;
spi_mosi
=
mosi_data
[
i
-
1
]
;
end
mosi_data
=
'h0C0000BB
;
for
(
i
=
32
;
i
>
0
;
i
--
)
begin
@
(
posedge
spi_clk
)
;
spi_mosi
=
mosi_data
[
i
-
1
]
;
end
mosi_data
=
'h0C0000CC
;
for
(
i
=
32
;
i
>
0
;
i
--
)
begin
@
(
posedge
spi_clk
)
;
spi_mosi
=
mosi_data
[
i
-
1
]
;
end
mosi_data
=
'h0C000011
;
for
(
i
=
32
;
i
>
0
;
i
--
)
begin
@
(
posedge
spi_clk
)
;
spi_mosi
=
mosi_data
[
i
-
1
]
;
end
mosi_data
=
'h0C000022
;
for
(
i
=
32
;
i
>
0
;
i
--
)
begin
@
(
posedge
spi_clk
)
;
spi_mosi
=
mosi_data
[
i
-
1
]
;
end
mosi_data
=
'h0C000033
;
for
(
i
=
32
;
i
>
0
;
i
--
)
begin
@
(
posedge
spi_clk
)
;
spi_mosi
=
mosi_data
[
i
-
1
]
;
end
mosi_data
=
'h0C000044
;
for
(
i
=
32
;
i
>
0
;
i
--
)
begin
@
(
posedge
spi_clk
)
;
spi_mosi
=
mosi_data
[
i
-
1
]
;
end
mosi_data
=
'h0C000055
;
for
(
i
=
32
;
i
>
0
;
i
--
)
begin
@
(
posedge
spi_clk
)
;
spi_mosi
=
mosi_data
[
i
-
1
]
;
end
mosi_data
=
'h0C000066
;
for
(
i
=
32
;
i
>
0
;
i
--
)
begin
@
(
posedge
spi_clk
)
;
spi_mosi
=
mosi_data
[
i
-
1
]
;
end
@
(
posedge
spi_clk
)
;
endtask
task
sending_fifth_from_ertec
()
;
int
i
;
$
display
(
"**** Starting the 5th frame like ERTEC ****"
)
;
mosi_data
=
'h00060400
;
// Basic Info
for
(
i
=
32
;
i
>
0
;
i
--
)
begin
@
(
posedge
spi_clk
)
;
spi_mosi
=
mosi_data
[
i
-
1
]
;
end
mosi_data
=
'h0D0000AA
;
for
(
i
=
32
;
i
>
0
;
i
--
)
begin
@
(
posedge
spi_clk
)
;
spi_mosi
=
mosi_data
[
i
-
1
]
;
end
mosi_data
=
'h0D0000BB
;
for
(
i
=
32
;
i
>
0
;
i
--
)
begin
@
(
posedge
spi_clk
)
;
spi_mosi
=
mosi_data
[
i
-
1
]
;
end
mosi_data
=
'h0D0000CC
;
for
(
i
=
32
;
i
>
0
;
i
--
)
begin
@
(
posedge
spi_clk
)
;
spi_mosi
=
mosi_data
[
i
-
1
]
;
end
mosi_data
=
'h0D000011
;
for
(
i
=
32
;
i
>
0
;
i
--
)
begin
@
(
posedge
spi_clk
)
;
spi_mosi
=
mosi_data
[
i
-
1
]
;
end
mosi_data
=
'h0D000022
;
for
(
i
=
32
;
i
>
0
;
i
--
)
begin
@
(
posedge
spi_clk
)
;
spi_mosi
=
mosi_data
[
i
-
1
]
;
end
mosi_data
=
'h0D000033
;
for
(
i
=
32
;
i
>
0
;
i
--
)
begin
@
(
posedge
spi_clk
)
;
spi_mosi
=
mosi_data
[
i
-
1
]
;
end
mosi_data
=
'h0D000044
;
for
(
i
=
32
;
i
>
0
;
i
--
)
begin
@
(
posedge
spi_clk
)
;
spi_mosi
=
mosi_data
[
i
-
1
]
;
end
mosi_data
=
'h0D000055
;
for
(
i
=
32
;
i
>
0
;
i
--
)
begin
@
(
posedge
spi_clk
)
;
spi_mosi
=
mosi_data
[
i
-
1
]
;
end
mosi_data
=
'h0D000066
;
for
(
i
=
32
;
i
>
0
;
i
--
)
begin
@
(
posedge
spi_clk
)
;
spi_mosi
=
mosi_data
[
i
-
1
]
;
end
@
(
posedge
spi_clk
)
;
endtask
//sending_fifth_from_ertec()
task
sending_sixth_from_ertec
()
;
int
i
;
$
display
(
"**** Starting the 6th frame like ERTEC ****"
)
;
mosi_data
=
'h01060200
;
// Basic Info
for
(
i
=
32
;
i
>
0
;
i
--
)
begin
@
(
posedge
spi_clk
)
;
spi_mosi
=
mosi_data
[
i
-
1
]
;
end
mosi_data
=
'h0E0000AA
;
for
(
i
=
32
;
i
>
0
;
i
--
)
begin
@
(
posedge
spi_clk
)
;
spi_mosi
=
mosi_data
[
i
-
1
]
;
end
mosi_data
=
'h0E0000BB
;
for
(
i
=
32
;
i
>
0
;
i
--
)
begin
@
(
posedge
spi_clk
)
;
spi_mosi
=
mosi_data
[
i
-
1
]
;
end
mosi_data
=
'h0E0000CC
;
for
(
i
=
32
;
i
>
0
;
i
--
)
begin
@
(
posedge
spi_clk
)
;
spi_mosi
=
mosi_data
[
i
-
1
]
;
end
mosi_data
=
'h0E000011
;
for
(
i
=
32
;
i
>
0
;
i
--
)
begin
@
(
posedge
spi_clk
)
;
spi_mosi
=
mosi_data
[
i
-
1
]
;
end
mosi_data
=
'h0E000022
;
for
(
i
=
32
;
i
>
0
;
i
--
)
begin
@
(
posedge
spi_clk
)
;
spi_mosi
=
mosi_data
[
i
-
1
]
;
end
mosi_data
=
'h0E000033
;
for
(
i
=
32
;
i
>
0
;
i
--
)
begin
@
(
posedge
spi_clk
)
;
spi_mosi
=
mosi_data
[
i
-
1
]
;
end
mosi_data
=
'h0E000044
;
for
(
i
=
32
;
i
>
0
;
i
--
)
begin
@
(
posedge
spi_clk
)
;
spi_mosi
=
mosi_data
[
i
-
1
]
;
end
mosi_data
=
'h0E000055
;
for
(
i
=
32
;
i
>
0
;
i
--
)
begin
@
(
posedge
spi_clk
)
;
spi_mosi
=
mosi_data
[
i
-
1
]
;
end
mosi_data
=
'h0E000066
;
for
(
i
=
32
;
i
>
0
;
i
--
)
begin
@
(
posedge
spi_clk
)
;
spi_mosi
=
mosi_data
[
i
-
1
]
;
end
@
(
posedge
spi_clk
)
;
endtask
CBusAccessor_VME64x
acc
;
// counter that counts the negedge of spi_clk
always
@
(
negedge
spi_clk
)
begin
...
...
@@ -659,6 +209,10 @@ module main;
posedge_cnt
<=
posedge_cnt
+
1
;
end
/*
* Tasks for SPI
*/
logic
[
7
:
0
]
operation
;
logic
[
7
:
0
]
data_len
;
logic
[
7
:
0
]
rmq_id
;
...
...
@@ -668,7 +222,7 @@ module main;
int
i
;
operation
=
'h00
;
rmq_id
=
$
urandom_range
(
0
,
6
)
;
rmq_id
=
$
urandom_range
(
0
,
6
)
;
// 0-> 0,0, 1-> 0,1, 2-> 0,2, 3-> 0,3, 4-> 0,4, 5-> 0,5, 6-> 1,0,
data_len
=
$
urandom_range
(
1
,
16
)
;
basic_info
=
{
operation
,
rmq_id
,
data_len
,
8'h00
};
...
...
@@ -698,11 +252,8 @@ module main;
@
(
posedge
spi_clk
)
;
spi_mosi
=
'h0
;
end
$
display
(
"BASIC INFO
: write
, rmq_id = %d, data_length = %d
\n
"
,
rmq_id
,
data_len
)
;
$
display
(
"BASIC INFO
for WRITE
, rmq_id = %d, data_length = %d
\n
"
,
rmq_id
,
data_len
)
;
q_mosi_data
.
push_back
(
basic_info
)
;
@
(
posedge
DUT
.
cmp_mt_profip_translator
.
s_wr_data_valid
)
;
assert
(
q_mosi_data
[
0
]
==
DUT
.
cmp_mt_profip_translator
.
s_data_reg_o
)
else
$
error
(
"Mismatch in the Basic Info of the frame, expected : %h, received : %h "
,
q_mosi_data
[
0
]
,
DUT
.
cmp_mt_profip_translator
.
s_data_reg_o
)
;
endtask
// write_basic_info
task
write_to_rmq
()
;
...
...
@@ -713,32 +264,140 @@ module main;
// First send the 3 header data
for
(
j
=
3
;
j
>
0
;
j
--
)
begin
mosi_data
=
$
urandom
(
)
;
mosi_data
=
$
urandom
_range
(
1
,
1992
)
;
for
(
i
=
32
;
i
>
0
;
i
--
)
begin
@
(
posedge
spi_clk
)
;
spi_mosi
=
mosi_data
[
i
-
1
]
;
end
$
display
(
"Header %d = %h"
,
j
,
mosi_data
)
;
q_mosi_data
.
push_back
(
mosi_data
)
;
end
// Then send the payload data
for
(
j
=
data_len
;
j
>
0
;
j
--
)
for
(
j
=
data_len
+
1
;
j
>
0
;
j
--
)
begin
mosi_data
=
$
urandom
(
)
;
mosi_data
=
$
urandom
_range
(
1
,
1992
)
;
for
(
i
=
32
;
i
>
0
;
i
--
)
begin
@
(
posedge
spi_clk
)
;
spi_mosi
=
mosi_data
[
i
-
1
]
;
end
$
display
(
"Data %d = %h"
,
j
,
mosi_data
)
;
q_mosi_data
.
push_back
(
mosi_data
)
;
end
@
(
posedge
spi_clk
)
;
spi_mosi
=
'b0
;
endtask
// write_to_rmq
task
read_basic_info
()
;
int
i
;
operation
=
'h01
;
basic_info
=
{
operation
,
rmq_id
,
8'h00
,
8'h00
};
// This generates the basic info
$
display
(
"Basic info for READ : rmq_id = %h"
,
rmq_id
)
;
// First comes the operation
for
(
i
=
8
;
i
>
0
;
i
--
)
begin
@
(
posedge
spi_clk
)
;
spi_mosi
=
operation
[
i
-
1
]
;
end
// Then the RMQ_ID
for
(
i
=
8
;
i
>
0
;
i
--
)
begin
@
(
posedge
spi_clk
)
;
spi_mosi
=
rmq_id
[
i
-
1
]
;
end
// Then the data length of the payload
for
(
i
=
8
;
i
>
0
;
i
--
)
begin
@
(
posedge
spi_clk
)
;
spi_mosi
=
'h0
;
end
// Then the unused byte that concludes the basic info
for
(
i
=
8
;
i
>
0
;
i
--
)
begin
@
(
posedge
spi_clk
)
;
spi_mosi
=
'h0
;
end
q_miso_data
.
push_back
(
basic_info
)
;
endtask
// read_basic_info
int
cnt
=
0
;
logic
[
15
:
0
]
shreg_msb
,
shreg_lsb
;
logic
[
31
:
0
]
shreg
=
32'h0
;
// Collects the data that is written in RMQ
always
@
(
posedge
clk_sys
)
begin
if
(
DUT
.
rmq_src_out
.
valid
&
!
DUT
.
rmq_src_out
.
error
)
begin
shreg_msb
<=
DUT
.
rmq_src_out
.
data
[
15
:
0
]
;
shreg_lsb
<=
shreg_msb
;
shreg
<=
{
shreg_lsb
,
shreg_msb
};
end
end
// -----------------------------------
//! Assertions
//------------------------------------
// -----------------------------------
// -- WRITE SIDE OF RMQ
// -----------------------------------
// Rule write_1 : Ensure that the incoming mosi data is the same as
// the one that is generated by the SPI in mt_profip_translator
always
@
(
posedge
DUT
.
cmp_mt_profip_translator
.
s_wr_data_valid
)
begin
if
(
operation
==
0
)
begin
assert
(
q_mosi_data
[
cnt
]
==
DUT
.
cmp_mt_profip_translator
.
s_data_reg_o
)
else
$
error
(
"Mismatch in MOSI data, position : %d, expected : %h, received : %h "
,
cnt
,
q_mosi_data
[
cnt
]
,
DUT
.
cmp_mt_profip_translator
.
s_data_reg_o
)
;
if
(
cnt
!=
(
4
+
data_len
))
cnt
<=
cnt
+
1
;
else
cnt
<=
0
;
end
end
// Rule write_2: Check that when valid is HIGH in RMQ, after 1 or 2 system clock cycles, the rmq data is the expected one
property
checking_mosi_rmq_data
;
@
(
posedge
clk_sys
)
($
rose
(
DUT
.
rmq_src_out
.
valid
)
&
!
(
DUT
.
rmq_src_out
.
error
))
|->
##[
2
:
3
]
(
shreg
==
DUT
.
cmp_mt_profip_translator
.
s_mosi_data
)
;
endproperty
assert
property
(
checking_mosi_rmq_data
)
else
$
error
(
" MISMATCH in write RMQ data : shreg = %h and mosi_data = %h"
,
shreg
,
DUT
.
cmp_mt_profip_translator
.
s_mosi_data
)
;
// Rule write_3 : Check that the Basic Info data, is the expected one, 32 spi clock cycles after CS is LOW
property
check_basic_info
;
@
(
posedge
spi_clk
)
($
fell
(
spi_cs_n
))
|->
##[
32
:
33
]
(
basic_info
==
DUT
.
cmp_mt_profip_translator
.
s_data_reg_o
)
;
endproperty
assert
property
(
check_basic_info
)
else
$
error
(
"MISMATCH in Basic Info : expected : %h, received : %h"
,
basic_info
,
DUT
.
cmp_mt_profip_translator
.
s_data_reg_o
)
;
// -----------------------------------
// -- READ SIDE OF RMQ
// -----------------------------------
// Rule read_1: check that the data that is sending through MISO with SPI is the expected one
property
check_miso_spi_data
;
@
(
posedge
spi_clk
)
($
rose
(
DUT
.
cmp_mt_profip_translator
.
s_ready
)
|->
##
32
((
DUT
.
cmp_mt_profip_translator
.
s_spi_miso_data
)
==
miso_data
))
;
endproperty
assert
property
(
check_miso_spi_data
)
else
$
error
(
"MISMATCH in SPI MISO : expected = %h, received = %h"
,
DUT
.
cmp_mt_profip_translator
.
s_spi_miso_data
,
miso_data
)
;
// Main testbench
initial
begin
automatic
MockTurtleDriver
drv
;
...
...
@@ -770,55 +429,37 @@ module main;
loadCPUFirmwares
(
fip
)
;
$
display
(
"End of loading firmware"
)
;
spi_cs_n
=
'b0
;
write_to_rmq
()
;
spi_cs_n
=
'b1
;
q_mosi_data
.
delete
()
;
#
1
ms
;
spi_cs_n
=
'b0
;
write_to_rmq
()
;
spi_cs_n
=
'b1
;
q_mosi_data
.
delete
()
;
#
1
ms
;
/*
spi_cs_n = 'b0;
sending_first_from_ertec();
spi_cs_n = 'b1;
#1ms;
spi_cs_n = 'b0;
sending_second_from_ertec();
spi_cs_n = 'b1;
#1ms;
spi_cs_n = 'b0;
sending_third_from_ertec();
spi_cs_n = 'b1;
#1ms;
spi_cs_n = 'b0;
sending_fourth_from_ertec();
spi_cs_n = 'b1;
#1ms;
spi_cs_n = 'b0;
sending_fifth_from_ertec();
spi_cs_n = 'b1;
#1ms;
spi_cs_n = 'b0;
sending_sixth_from_ertec();
spi_cs_n = 'b1;
#1ms;
spi_cs_n = 'b0;
sending_sixth_from_ertec();
spi_cs_n = 'b1;
#1ms;
*/
for
(
int
i
=
0
;
i
<
2
;
i
++
)
begin
$
display
(
"**** Start writing the %d frame ****
\n
"
,
i
+
1
)
;
spi_cs_n
=
'b0
;
write_to_rmq
()
;
spi_cs_n
=
'b1
;
#
1
ms
;
$
display
(
"after the waiting of 1ms"
)
;
q_mosi_data
.
delete
()
;
cnt
<=
0
;
$
display
(
"**** Start reading the %d frame ****
\n
"
,
i
+
1
)
;
spi_cs_n
=
'b0
;
read_basic_info
()
;
@
(
posedge
DUT
.
cmp_mt_profip_translator
.
s_rd_state
==
8
)
;
repeat
(
33
)
@
(
posedge
spi_clk
)
;
// need of 32 spi clocks, add one extra
spi_cs_n
=
'b1
;
#
1
ms
;
q_mosi_data
.
delete
()
;
q_miso_data
.
delete
()
;
cnt
<=
0
;
end
$
finish
;
end
...
...
testbench/top_mt/run.do
View file @
1d193d0d
vsim -voptargs="-O5 +notimingchecks +acc" -classdebug -L unisim -L XilinxCoreLib -t 1ps -nopsl -quiet work.main
vsim -voptargs="-O5 +notimingchecks +acc" -classdebug -
sv_seed random -
L unisim -L XilinxCoreLib -t 1ps -nopsl -quiet work.main
set StdArithNoWarnings 1
set NumericStdNoWarnings 1
...
...
testbench/top_mt/wave.do
View file @
1d193d0d
...
...
@@ -2,7 +2,19 @@ onerror {resume}
quietly WaveActivateNextPane {} 0
# Main Testbench
add wave -noupdate /main/mosi_data
add wave -noupdate -expand -group TESTBENCH /main/mosi_data
add wave -noupdate -expand -group TESTBENCH /main/miso_data
add wave -noupdate -expand -group TESTBENCH /main/test_miso_data
add wave -noupdate -expand -group TESTBENCH /main/negedge_cnt
add wave -noupdate -expand -group TESTBENCH /main/posedge_cnt
add wave -noupdate -expand -group TESTBENCH /main/q_mosi_data
add wave -noupdate -expand -group TESTBENCH /main/q_miso_data
add wave -noupdate -expand -group TESTBENCH /main/operation
add wave -noupdate -expand -group TESTBENCH /main/data_len
add wave -noupdate -expand -group TESTBENCH /main/rmq_id
add wave -noupdate -expand -group TESTBENCH /main/basic_info
add wave -noupdate -expand -group TESTBENCH /main/cnt
# ERTEC
add wave -noupdate -expand -group ERTEC -color Orange /main/DUT/ertec_spi_clk_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