Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
P
progkrets
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Solveig Langbakk
progkrets
Commits
d16a0377
Commit
d16a0377
authored
8 months ago
by
Nils
Browse files
Options
Downloads
Patches
Plain Diff
La til Tx testbenk
parent
2ecf4019
No related branches found
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
Tx_tb.vhd
+116
-0
116 additions, 0 deletions
Tx_tb.vhd
with
116 additions
and
0 deletions
Tx_tb.vhd
0 → 100644
+
116
−
0
View file @
d16a0377
-- Testbench of Tx
library
IEEE
;
use
IEEE
.
STD_LOGIC_1164
.
ALL
;
use
IEEE
.
NUMERIC_STD
.
ALL
;
-- Entity of testbench (empty)
entity
Tx_tb
is
end
Tx_tb
;
architecture
SimulationModel
of
Tx_tb
is
-- Constant declaration
constant
CLK_PERIOD
:
time
:
=
20
ns
;
-- 50 MHz klokke
-- Component declarasion
component
Tx
Port
(
clk
:
in
std_logic
;
rst_n
:
in
std_logic
;
Rd_sig
:
in
std_logic
;
Wr_sig
:
in
std_logic
;
adresse
:
in
std_logic_vector
(
2
downto
0
);
Data_bus
:
inout
std_logic_vector
(
7
downto
0
);
TxD
:
out
std_logic
);
end
component
;
-- Signal declaration
signal
clk
:
std_logic
:
=
'0'
;
signal
rst_n
:
std_logic
:
=
'1'
;
signal
adresse
:
std_logic_vector
(
2
downto
0
);
signal
Data_bus
:
std_logic_vector
(
7
downto
0
);
signal
TxD
:
std_logic
;
signal
Rd_sig
:
std_logic
;
signal
Wr_sig
:
std_logic
;
begin
-- Component instantiations UART TX-modul (DUT)
DUT
:
component
Tx
Port
Map
(
clk
=>
clk
,
rst_n
=>
rst_n
,
adresse
=>
adresse
,
Data_bus
=>
Data_bus
,
TxD
=>
TxD
,
Rd_sig
=>
Rd_sig
,
Wr_sig
=>
Wr_sig
);
-- Generation of clock
p_clk
:
process
is
begin
clk
<=
'0'
;
wait
for
CLK_PERIOD
/
2
;
clk
<=
'1'
;
wait
for
CLK_PERIOD
/
2
;
end
process
;
--Generation of resetN
p_rst_n
:
process
is
begin
rst_n
<=
'0'
;
wait
for
2
.
2
*
CLK_PERIOD
;
rst_n
<=
'1'
;
wait
;
end
process
;
-- Test procedure
p_test_procedure
:
process
-- Initialisation of testbench
procedure
tb_init
is
begin
adresse
<=
(
others
=>
'Z'
);
Data_bus
<=
(
others
=>
'Z'
);
Wr_sig
<=
'0'
;
Rd_sig
<=
'0'
;
wait
until
rst_n
=
'1'
;
wait
for
100
ns
;
wait
until
rising_edge
(
clk
);
wait
for
1
ns
;
end
tb_init
;
-- Test Case 1: Konfigurasjon av baud rate og paritet
procedure
config
is
begin
Wr_sig
<=
'1'
;
adresse
<=
"000"
;
-- Konfigurer baud rate og paritet
Data_bus
<=
"00011001"
;
-- Sett baud rate til 57600 (001) og ulik paritet (11)
wait
for
CLK_PERIOD
;
Wr_sig
<=
'0'
;
wait
for
CLK_PERIOD
;
end
config
;
procedure
send
is
begin
Wr_sig
<=
'1'
;
adresse
<=
"001"
;
-- Sender data til Tx
Data_bus
<=
"11111111"
;
-- data
wait
for
CLK_PERIOD
;
Wr_sig
<=
'0'
;
wait
for
20
*
CLK_PERIOD
;
wait
for
0
.
25
ms
;
end
send
;
begin
tb_init
;
config
;
send
;
wait
for
100
ns
;
assert
false
report
"Testbench finished"
severity
failure
;
end
process
;
end
architecture
SimulationModel
;
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment