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
a4a7ec2c
Commit
a4a7ec2c
authored
Feb 08, 2018
by
Evangelia Gousiou
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
test bench added check for comparison of front and rear output; fixed rs485_fs input
parent
03a4b568
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
131 additions
and
62 deletions
+131
-62
testbench.vhd
sim/testbench.vhd
+99
-52
testbench_pkg.vhd
sim/testbench_pkg.vhd
+32
-10
No files found.
sim/testbench.vhd
View file @
a4a7ec2c
...
...
@@ -68,8 +68,8 @@ architecture behav of testbench is
signal
gf_en_n_in
:
std_logic
;
signal
ttl_n_in
,
ttl_out
:
std_logic_vector
(
C_NR_CHANS
-1
downto
0
)
:
=
(
others
=>
'
0
'
);
signal
rs485_n_in
,
rs485_
n_out
:
std_logic_vector
(
C_NR_CHANS
-1
downto
0
)
:
=
(
others
=>
'0
'
);
signal
ttl_n_in
,
ttl_out
:
std_logic_vector
(
C_NR_CHANS
-1
downto
0
)
:
=
(
others
=>
'
1
'
);
signal
rs485_n_in
,
rs485_
fs_n_in
,
rs485_out
:
std_logic_vector
(
C_NR_CHANS
-1
downto
0
)
:
=
(
others
=>
'1
'
);
signal
sscl_out
:
std_logic
;
signal
sscl_en_out
:
std_logic
;
...
...
@@ -86,15 +86,7 @@ architecture behav of testbench is
signal
pcbrev
:
std_logic_vector
(
5
downto
0
);
signal
rtmm_in
:
std_logic_vector
(
2
downto
0
);
signal
rtmp_in
:
std_logic_vector
(
2
downto
0
);
signal
line_front_in
:
std_logic_vector
(
C_NR_CHANS
-1
downto
0
);
signal
line_inv_in
:
std_logic_vector
(
C_NR_INV_CHANS
-1
downto
0
);
signal
line_rear_in
:
std_logic_vector
(
C_NR_CHANS
-1
downto
0
);
signal
line_front_fs_in
:
std_logic_vector
(
C_NR_CHANS
-1
downto
0
);
signal
line_inv_fs_in
:
std_logic_vector
(
C_NR_INV_CHANS
-1
downto
0
);
signal
line_rear_fs_in
:
std_logic_vector
(
C_NR_CHANS
-1
downto
0
);
signal
i2c_master_rcvd_val
,
i2c_master_rcvd_val1
,
i2c_master_rcvd_val2
,
i2c_master_rcvd_val3
,
i2c_master_rcvd_val4
:
std_logic_vector
(
31
downto
0
);
signal
i2c_master_rcvd_val
:
std_logic_vector
(
31
downto
0
);
signal
i2c_m_in
:
t_i2c_master_in
;
signal
i2c_m_out
:
t_i2c_master_out
;
...
...
@@ -106,6 +98,7 @@ architecture behav of testbench is
-- signal nb_pulses_to_send_slv : std_logic_vector(31 downto 0);
signal
reg_id
:
integer
:
=
0
;
signal
adr
:
std_logic_vector
(
31
downto
0
);
signal
fp_rp_same
,
fp_rp_oppos
:
unsigned
(
C_NR_CHANS
-1
downto
0
);
procedure
read_i2c
(
signal
i2c_m_in
:
out
t_i2c_master_in
;
...
...
@@ -209,14 +202,14 @@ begin
inv_oen_o
=>
open
,
rs485_oen_o
=>
open
,
-- Front panel channels
ttl_n_i
=>
ttl_n_in
,
--: in std_logic_vector(5 downto 0);
ttl_o
=>
ttl_out
,
--: out std_logic_vector(5 downto 0);
inv_n_i
=>
(
others
=>
'0'
),
--inv_n_in, --: in std_logic_vector(3 downto 0);
inv_o
=>
open
,
--inv_n_out, --: out std_logic_vector(3 downto 0);
ttl_n_i
=>
ttl_n_in
,
ttl_o
=>
ttl_out
,
inv_n_i
=>
(
others
=>
'0'
),
inv_o
=>
open
,
-- Rear panel channels
rs485_n_i
=>
rs485_n_in
,
--: in std_logic_vector(5 downto 0);
rs485_fs_n_i
=>
(
others
=>
'0'
),
--: in std_logic_vector(5 downto 0); --failsafe?
rs485_o
=>
rs485_
n_out
,
--: out std_logic_vector(5 downto 0);
rs485_n_i
=>
rs485_n_in
,
rs485_fs_n_i
=>
rs485_fs_n_in
,
rs485_o
=>
rs485_
out
,
-- Rear input and output termination lines
iterm_en_o
=>
open
,
oterm_en_o
=>
open
,
...
...
@@ -264,7 +257,8 @@ begin
led_gf_syspw_o
=>
open
,
led_ttl_i2c_o
=>
open
);
sscl
(
0
)
<=
sscl_out
when
(
sscl_en_out
=
'1'
)
else
'1'
;
ssda
(
0
)
<=
ssda_out
when
(
ssda_en_out
=
'1'
)
else
'1'
;
...
...
@@ -349,6 +343,30 @@ begin
scl_o
=>
scl
,
sda_o
=>
sda
);
--============================================================================
-- Check if ttl_out matches rs485_out
--============================================================================
compare_front_rear_pulses
:
process
(
clk_20
)
begin
if
rising_edge
(
clk_20
)
then
if
vme_sysreset_n
=
'0'
then
fp_rp_same
<=
(
others
=>
'0'
);
fp_rp_oppos
<=
(
others
=>
'0'
);
else
for
i
in
0
to
C_NR_CHANS
-1
loop
if
ttl_out
(
i
)
=
rs485_out
(
i
)
then
fp_rp_same
(
i
)
<=
'1'
;
end
if
;
if
ttl_out
(
i
)
=
not
rs485_out
(
i
)
then
fp_rp_oppos
(
i
)
<=
'1'
;
end
if
;
end
loop
;
end
if
;
end
if
;
end
process
;
--============================================================================
-- processes to provide stimulus and checks
...
...
@@ -357,16 +375,24 @@ begin
--i2c access
p_stim_i2c
:
process
variable
i
:
integer
:
=
0
;
variable
nb_pulses_to_send
:
integer
:
=
15
0
;
variable
nb_pulses_to_send
:
integer
:
=
15
;
variable
nb_pulses_to_send_slv
:
std_logic_vector
(
31
downto
0
);
variable
glitch_filter_en
:
std_logic
:
=
'0'
;
variable
ttl_out_bar_en
:
std_logic
:
=
'0'
;
begin
print
(
"***************************************************"
);
print
(
" Start of Tests"
);
print
(
"***************************************************"
);
print
(
"************************************************************"
);
print
(
" Start of Tests"
);
print
(
"************************************************************"
);
---------------------------------------------------------------------------
-- Board settings
print
(
" ---> Configure board settings"
);
settings_config
(
glitch_filter_en
,
ttl_out_bar_en
,
sw_gp_n_in
,
sw_other_in
,
pcbrev
,
rtmm_in
);
---------------------------------------------------------------------------
-- VME reset
print
(
" ---> VME reset"
);
print_now
(
"Sending VME reset"
);
wait
until
vme_sysreset_n
=
'1'
;
print_now
(
"VME reset completed"
);
...
...
@@ -375,56 +401,78 @@ begin
---------------------------------------------------------------------------
-- I2C reading of the board ID register
read_i2c
(
i2c_m_in
,
i2c_m_out
,
"1011110"
,
c_REG_MAP
(
0
)
.
reg_addr
,
c_REG_MAP
(
0
)
.
reg_name
,
i2c_master_rcvd_val
,
C_BOARD_ID
);
print
(
" ---> I2C reading of the Board ID register"
);
--read_i2c (i2c_m_in, i2c_m_out, "1011110", c_REG_MAP(0).reg_addr, c_REG_MAP(0).reg_name, i2c_master_rcvd_val, C_BOARD_ID);
---------------------------------------------------------------------------
---------------------------------------------------------------------------
-- I2C writing of a big value to Front Panel Counter 1
print
(
" ---> I2C writing of a big value to the Front Panel Channel 1 Counter register"
);
write_i2c
(
i2c_m_in
,
i2c_m_out
,
"1011110"
,
c_REG_MAP
(
4
)
.
reg_addr
,
c_REG_MAP
(
4
)
.
reg_name
,
x"FFFFFFF0"
);
---------------------------------------------------------------------------
---------------------------------------------------------------------------
-- Sending pulses to Front Panel Channel 1
-- Sending pulses to Front Panel Channel 1
print
(
" ---> Sending pulses"
);
nb_pulses_to_send_slv
:
=
std_logic_vector
(
to_unsigned
(
nb_pulses_to_send
,
nb_pulses_to_send_slv
'length
));
print_now_s_i
(
"Sending TTL pulses to Front Panel Channel 1: "
,
nb_pulses_to_send
);
print_now_s_i
(
"Sending TTL pulses to Front Panel Channel 1: "
,
nb_pulses_to_send
);
rs485_fs_n_in
<=
(
others
=>
'0'
);
generate_pulse
(
ttl_n_in
(
0
),
nb_pulses_to_send
,
200
ns
,
200
ns
);
---------------------------------------------------------------------------
---------------------------------------------------------------------------
-- Check if TTL out and RS485 out are the same
print
(
" ---> Check that Rear output is the same as Front output"
);
if
fp_rp_same
(
0
)
=
'0'
then
print_now
(
"[OK] Rear Channel 1 matches Front Channel 1"
);
else
print_now
(
"[ERR] Rear Channel 1 does not match Front Channel 1"
);
end
if
;
---------------------------------------------------------------------------
---------------------------------------------------------------------------
-- Reading from the I2C Front Panel regs; read only first 2 Channels to speed up testbench
while
not
(
i
=
3
)
loop
if
i
=
0
then
-- Front Panel Channel 1 register should roll over and read
read_i2c
(
i2c_m_in
,
i2c_m_out
,
"1011110"
,
c_REG_MAP
(
i
+
4
)
.
reg_addr
,
c_REG_MAP
(
i
+
4
)
.
reg_name
,
i2c_master_rcvd_val
,
x"00000087"
);
else
-- Front Panel Channel 2 register should have not counted any pulses
read_i2c
(
i2c_m_in
,
i2c_m_out
,
"1011110"
,
c_REG_MAP
(
i
+
4
)
.
reg_addr
,
c_REG_MAP
(
i
+
4
)
.
reg_name
,
i2c_master_rcvd_val
,
(
others
=>
'0'
));
end
if
;
i
:
=
i
+
1
;
end
loop
;
---------------------------------------------------------------------------
-- Reading from the I2C Rear Panel regs; read only first Channel to speed up testbench
i
:
=
0
;
while
not
(
i
=
2
)
loop
if
i
=
0
then
-- Check Rear Panel Channel 1 counter has not counted any pulses
read_i2c
(
i2c_m_in
,
i2c_m_out
,
"1011110"
,
c_REG_MAP
(
i
+
10
)
.
reg_addr
,
c_REG_MAP
(
i
+
10
)
.
reg_name
,
i2c_master_rcvd_val
,
(
others
=>
'0'
));
else
-- Check Rear Panel Channel 1 counter has not counted any pulses
read_i2c
(
i2c_m_in
,
i2c_m_out
,
"1011110"
,
c_REG_MAP
(
i
+
10
)
.
reg_addr
,
c_REG_MAP
(
i
+
10
)
.
reg_name
,
i2c_master_rcvd_val
,
(
others
=>
'0'
));
end
if
;
i
:
=
i
+
1
;
end
loop
;
-- print(" ---> I2C reading of the front pulse counters");
-- while not(i = 3) loop
-- if i = 0 then
-- -- Front Panel Channel 1 register should roll over and read
-- read_i2c (i2c_m_in, i2c_m_out, "1011110", c_REG_MAP(i+4).reg_addr, c_REG_MAP(i+4).reg_name , i2c_master_rcvd_val, x"00000087");
-- else
-- -- Front Panel Channel 2 register should have not counted any pulses
-- read_i2c (i2c_m_in, i2c_m_out, "1011110", c_REG_MAP(i+4).reg_addr, c_REG_MAP(i+4).reg_name, i2c_master_rcvd_val, (others =>'0'));
-- end if;
-- i := i + 1;
-- end loop;
-- ---------------------------------------------------------------------------
-- -- Reading from the I2C Rear Panel regs; read only first Channel to speed up testbench
-- print(" ---> I2C reading of the rear pulse counters");
-- i := 0;
-- while not(i = 2) loop
-- if i = 0 then
-- -- Check Rear Panel Channel 1 counter has not counted any pulses
-- read_i2c (i2c_m_in, i2c_m_out, "1011110", c_REG_MAP(i+10).reg_addr, c_REG_MAP(i+10).reg_name , i2c_master_rcvd_val, (others =>'0'));
-- else
-- -- Check Rear Panel Channel 1 counter has not counted any pulses
-- read_i2c (i2c_m_in, i2c_m_out, "1011110", c_REG_MAP(i+10).reg_addr, c_REG_MAP(i+10).reg_name, i2c_master_rcvd_val, (others =>'0'));
-- end if;
-- i := i + 1;
-- end loop;
---------------------------------------------------------------------------
wait
for
1000
ns
;
---------------------------------------------------------------------------
-- Sending 150 pulses to Rear Panel Channel 2
-- Sending pulses to Rear Panel Channel 2
print
(
" ---> Sending pulses"
);
nb_pulses_to_send
:
=
5
;
print_now_s_i
(
"Sending pulses to Rear Panel Channel 1: "
,
nb_pulses_to_send
);
print_now_s_i
(
"Sending pulses to Rear Panel Channel 1: "
,
nb_pulses_to_send
);
rs485_fs_n_in
<=
rs485_n_in
;
generate_pulse
(
rs485_n_in
(
1
),
nb_pulses_to_send
,
200
ns
,
200
ns
);
---------------------------------------------------------------------------
-- Reading from the I2C Front Panel regs; read one reg to speed up testbench
print
(
" ---> I2C reading of the rear pulse counters"
);
i
:
=
6
;
while
not
(
i
=
8
)
loop
if
i
=
0
then
...
...
@@ -442,7 +490,6 @@ begin
end
process
p_stim_i2c
;
end
architecture
behav
;
--==============================================================================
-- architecture end
...
...
sim/testbench_pkg.vhd
View file @
a4a7ec2c
...
...
@@ -245,22 +245,44 @@ end component conv_ttl_rs485;
ns_on
:
in
time
;
ns_off
:
in
time
);
procedure
settings_config
(
constant
glitch_filter_en
:
in
std_logic
;
constant
ttl_out_bar_en
:
in
std_logic
;
signal
sw_gp_n
:
out
std_logic_vector
(
7
downto
0
);
signal
sw_other
:
out
std_logic_vector
(
31
downto
0
);
signal
pcbrev
:
out
std_logic_vector
(
5
downto
0
);
signal
rtmm
:
out
std_logic_vector
(
2
downto
0
));
end
testbench_pkg
;
package
body
testbench_pkg
is
--==================================================================================================
-- Procedures
--==================================================================================================
procedure
settings_config
(
signal
sw_gp_n_in
:
out
std_logic_vector
(
7
downto
0
);
signal
sw_other_in
:
out
std_logic_vector
(
31
downto
0
);
signal
pcbrev
:
out
std_logic_vector
(
5
downto
0
);
signal
rtmm_in
:
out
std_logic_vector
(
2
downto
0
))
is
procedure
settings_config
(
constant
glitch_filter_en
:
in
std_logic
;
constant
ttl_out_bar_en
:
in
std_logic
;
signal
sw_gp_n
:
out
std_logic_vector
(
7
downto
0
);
signal
sw_other
:
out
std_logic_vector
(
31
downto
0
);
signal
pcbrev
:
out
std_logic_vector
(
5
downto
0
);
signal
rtmm
:
out
std_logic_vector
(
2
downto
0
))
is
begin
sw_gp_n_in
(
0
)
<=
'1'
;
-- disable glitch filter ?
sw_gp_n_in
(
1
)
<=
'1'
;
--
sw_gp_n_in
(
7
downto
2
)
<=
(
others
=>
'0'
);
sw_other_in
<=
(
others
=>
'0'
);
pcbrev
<=
"111100"
;
rtmm_in
<=
(
others
=>
'0'
);
sw_gp_n
(
7
)
<=
glitch_filter_en
;
if
glitch_filter_en
=
'1'
then
print_now
(
"Glitch filter enabled"
);
else
print_now
(
"Glitch filter disabled"
);
end
if
;
sw_gp_n
(
0
)
<=
ttl_out_bar_en
;
if
ttl_out_bar_en
=
'1'
then
print_now
(
"TTL output BAR enabled"
);
else
print_now
(
"TTL output BAR disabled"
);
end
if
;
sw_gp_n
(
6
downto
1
)
<=
(
others
=>
'0'
);
-- not used
sw_other
<=
(
others
=>
'0'
);
-- not used
pcbrev
<=
"111100"
;
-- not used
rtmm
<=
(
others
=>
'0'
);
-- not used
end
procedure
;
----------------------------------------------------------------------------------------------------
...
...
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