Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
C
Conv TTL RS485 - 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
Conv TTL RS485 - Gateware
Commits
8301a504
Commit
8301a504
authored
Feb 20, 2018
by
Evangelia Gousiou
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
added glitch filter test
parent
1351d6b2
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
119 additions
and
72 deletions
+119
-72
testbench.vhd
sim/testbench.vhd
+95
-32
testbench_pkg.vhd
sim/testbench_pkg.vhd
+24
-40
No files found.
sim/testbench.vhd
View file @
8301a504
This diff is collapsed.
Click to expand it.
sim/testbench_pkg.vhd
View file @
8301a504
...
...
@@ -276,17 +276,18 @@ end component conv_ttl_rs485;
constant
send_val
:
in
std_logic_vector
(
31
downto
0
);
err
:
out
natural
);
procedure
read_i2c
(
signal
i2c_m_in
:
out
t_i2c_master_in
;
signal
i2c_m_out
:
in
t_i2c_master_out
;
constant
slv_addr
:
in
std_logic_vector
(
6
downto
0
);
constant
reg_addr
:
in
std_logic_vector
(
31
downto
0
);
constant
reg_name
:
string
(
1
to
8
);
signal
rcvd_val
:
out
std_logic_vector
(
31
downto
0
);
constant
exp_val
:
in
std_logic_vector
(
31
downto
0
);
err
:
out
natural
);
procedure
read_i2c_err
(
signal
i2c_m_in
:
out
t_i2c_master_in
;
signal
i2c_m_out
:
in
t_i2c_master_out
);
procedure
read_i2c
(
signal
i2c_m_in
:
out
t_i2c_master_in
;
signal
i2c_m_out
:
in
t_i2c_master_out
;
constant
slv_addr
:
in
std_logic_vector
(
6
downto
0
);
constant
reg_addr
:
in
std_logic_vector
(
31
downto
0
);
constant
reg_name
:
string
(
1
to
8
);
signal
rcvd_val
:
out
std_logic_vector
(
31
downto
0
);
constant
exp_val
:
in
std_logic_vector
(
31
downto
0
);
constant
eval_result
:
in
boolean
;
err
:
out
natural
);
-- procedure read_i2c_err (signal i2c_m_in : out t_i2c_master_in;
-- signal i2c_m_out : in t_i2c_master_out);
end
testbench_pkg
;
package
body
testbench_pkg
is
...
...
@@ -355,7 +356,7 @@ package body testbench_pkg is
end
if
;
numb_cnt
:
=
numb_cnt
+
1
;
end
loop
;
wait
for
ns_off
;
wait
for
500
ns
;
-- wait for all pulses to propagate to the output
end
procedure
generate_pulse
;
...
...
@@ -390,6 +391,7 @@ package body testbench_pkg is
constant
reg_name
:
string
(
1
to
8
);
signal
rcvd_val
:
out
std_logic_vector
(
31
downto
0
);
constant
exp_val
:
in
std_logic_vector
(
31
downto
0
);
constant
eval_result
:
in
boolean
;
err
:
out
natural
)
is
variable
err_cnt
:
natural
:
=
0
;
begin
...
...
@@ -413,13 +415,16 @@ package body testbench_pkg is
" is 0x"
,
i2c_m_out
.
i2c_master_rcvd_val
);
wait
until
i2c_m_out
.
i2c_master_finish
=
'0'
;
print_now
(
"read_i2c: completed"
);
if
i2c_m_out
.
i2c_master_rcvd_val
=
exp_val
then
print_now_s_s
(
"[OK] Correct reading from reg "
,
reg_name
,
"; expected value matches read value"
);
else
print_now_s_std_s_std
(
"[ERR]: Read value from "
&
reg_name
&
": "
,
i2c_m_out
.
i2c_master_rcvd_val
,
"; expected value: "
,
exp_val
);
err_cnt
:
=
err_cnt
+
1
;
end
if
;
if
eval_result
=
TRUE
then
if
i2c_m_out
.
i2c_master_rcvd_val
=
exp_val
then
print_now_s_s
(
"[OK] Correct reading from reg "
,
reg_name
,
"; expected value matches read value"
);
else
print_now_s_std_s_std
(
"[ERR]: Read value from "
&
reg_name
&
": "
,
i2c_m_out
.
i2c_master_rcvd_val
,
"; expected value: "
,
exp_val
);
err_cnt
:
=
err_cnt
+
1
;
end
if
;
end
if
;
err
:
=
err_cnt
;
print_now
(
"---------------"
);
end
procedure
read_i2c
;
...
...
@@ -459,27 +464,6 @@ package body testbench_pkg is
----------------------------------------------------------------------------------------------------
procedure
read_i2c_err
(
signal
i2c_m_in
:
out
t_i2c_master_in
;
signal
i2c_m_out
:
in
t_i2c_master_out
)
is
variable
err_cnt
:
natural
:
=
0
;
begin
print_now
(
"---------------"
);
print_now
(
"read_i2c_err: start"
);
i2c_m_in
.
i2c_master_start
<=
'0'
;
i2c_m_in
.
i2c_master_rdwr
<=
'0'
;
--mst_fsm_op
i2c_m_in
.
i2c_master_slv_addr
<=
"1011111"
;
i2c_m_in
.
i2c_master_reg_addr
<=
(
others
=>
'0'
);
i2c_m_in
.
i2c_master_send_val
<=
(
others
=>
'1'
);
wait
for
1
us
;
i2c_m_in
.
i2c_master_slv_addr
<=
"1011111"
;
i2c_m_in
.
i2c_master_reg_addr
<=
x"F1F1F1F1"
;
i2c_m_in
.
i2c_master_start
<=
'1'
;
i2c_m_in
.
i2c_master_rdwr
<=
'1'
;
--read
wait
for
C_CLK_20_PER
;
i2c_m_in
.
i2c_master_start
<=
'0'
;
wait
until
i2c_m_out
.
i2c_master_ready
=
'1'
;
print_now
(
"---------------"
);
end
procedure
read_i2c_err
;
end
;
...
...
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