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
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Solveig Langbakk
progkrets
Commits
c258e3fd
Commit
c258e3fd
authored
6 months ago
by
Nils
Browse files
Options
Downloads
Patches
Plain Diff
Kontrolerer databuzz til å bli z ellers
parent
01e1eaa6
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
Tx.vhd
+9
-3
9 additions, 3 deletions
Tx.vhd
Tx_tb.vhd
+31
-6
31 additions, 6 deletions
Tx_tb.vhd
with
40 additions
and
9 deletions
Tx.vhd
+
9
−
3
View file @
c258e3fd
...
@@ -87,7 +87,7 @@ architecture Behavioral of Tx is
...
@@ -87,7 +87,7 @@ architecture Behavioral of Tx is
begin
begin
p_bit_send
:
TxD
<=
bit_to_send
;
p_bit_send
:
TxD
<=
bit_to_send
;
process
(
clk
,
rst_n
)
is
p_seq
:
process
(
clk
,
rst_n
)
is
begin
begin
if
rst_n
=
'0'
then
if
rst_n
=
'0'
then
--resetter systemet
--resetter systemet
...
@@ -99,7 +99,9 @@ begin
...
@@ -99,7 +99,9 @@ begin
tx_state
<=
tx_state_type
'left
;
tx_state
<=
tx_state_type
'left
;
bit_count
<=
0
;
bit_count
<=
0
;
data_reg
<=
(
others
=>
'0'
);
data_reg
<=
(
others
=>
'0'
);
ready_to_send
<=
'0'
;
elsif
rising_edge
(
clk
)
then
elsif
rising_edge
(
clk
)
then
Data_bus
<=
(
others
=>
'Z'
);
case
adresse
is
case
adresse
is
when
"000"
=>
-- Konfigurasjonsinnstillinger
when
"000"
=>
-- Konfigurasjonsinnstillinger
if
Wr_sig
=
'1'
then
if
Wr_sig
=
'1'
then
...
@@ -118,8 +120,12 @@ begin
...
@@ -118,8 +120,12 @@ begin
if
tx_state
=
IDLE
then
if
tx_state
=
IDLE
then
Data_bus
<=
(
others
=>
'0'
);
Data_bus
<=
(
others
=>
'0'
);
else
else
-- Sett LSB til 1 når ikke IDLE
Data_bus
<=
(
others
=>
'0'
);
Data_bus
<=
(
others
=>
'0'
);
Data_bus
(
0
)
<=
'1'
;
-- Sett LSB til 1 når ikke IDLE
Data_bus
(
0
)
<=
'1'
;
--(0 => '1', others => '0');
--Data_bus <= (others => '0');
--evt std_logic_vector(unsigned(others => '0') + 1);
end
if
;
end
if
;
else
null
;
else
null
;
end
if
;
end
if
;
...
@@ -177,7 +183,7 @@ begin
...
@@ -177,7 +183,7 @@ begin
end
process
;
end
process
;
-- baud_rate Generator Process
-- baud_rate Generator Process
process
(
clk
,
rst_n
)
p_baud_gen
:
process
(
clk
,
rst_n
)
begin
begin
if
rst_n
=
'0'
then
if
rst_n
=
'0'
then
baud_count
<=
0
;
baud_count
<=
0
;
...
...
This diff is collapsed.
Click to expand it.
Tx_tb.vhd
+
31
−
6
View file @
c258e3fd
...
@@ -17,8 +17,8 @@ architecture SimulationModel of Tx_tb is
...
@@ -17,8 +17,8 @@ architecture SimulationModel of Tx_tb is
Port
(
Port
(
clk
:
in
std_logic
;
clk
:
in
std_logic
;
rst_n
:
in
std_logic
;
rst_n
:
in
std_logic
;
Rd_sig
:
in
std_logic
;
Rd_sig
:
in
std_logic
;
Wr_sig
:
in
std_logic
;
Wr_sig
:
in
std_logic
;
adresse
:
in
std_logic_vector
(
2
downto
0
);
adresse
:
in
std_logic_vector
(
2
downto
0
);
Data_bus
:
inout
std_logic_vector
(
7
downto
0
);
Data_bus
:
inout
std_logic_vector
(
7
downto
0
);
TxD
:
out
std_logic
TxD
:
out
std_logic
...
@@ -90,26 +90,44 @@ begin
...
@@ -90,26 +90,44 @@ begin
Data_bus
<=
"00000001"
;
-- Sett baud rate til 57600 (001) og ingen paritet (00)
Data_bus
<=
"00000001"
;
-- Sett baud rate til 57600 (001) og ingen paritet (00)
wait
for
CLK_PERIOD
;
wait
for
CLK_PERIOD
;
Wr_sig
<=
'0'
;
Wr_sig
<=
'0'
;
Data_bus
<=
(
others
=>
'Z'
);
adresse
<=
(
others
=>
'Z'
);
wait
for
CLK_PERIOD
;
wait
for
CLK_PERIOD
;
end
config
;
end
config
;
-- Test Case 1: Konfigurasjon av baud rate og paritet
procedure
config2
is
begin
Wr_sig
<=
'1'
;
adresse
<=
"000"
;
-- Konfigurer baud rate og paritet
Data_bus
<=
"00011000"
;
-- Sett baud rate til 57600 (000) og ingen paritet (11)
wait
for
CLK_PERIOD
;
Wr_sig
<=
'0'
;
Data_bus
<=
(
others
=>
'Z'
);
adresse
<=
(
others
=>
'Z'
);
wait
for
CLK_PERIOD
;
end
config2
;
procedure
send
is
procedure
send
is
begin
begin
Wr_sig
<=
'1'
;
Wr_sig
<=
'1'
;
adresse
<=
"001"
;
-- Sender data til Tx
adresse
<=
"001"
;
-- Sender data til Tx
Data_bus
<=
"10101010"
;
-- data
Data_bus
<=
"10101010"
;
-- data
wait
for
CLK_PERIOD
;
wait
for
2
*
CLK_PERIOD
;
Wr_sig
<=
'0'
;
Wr_sig
<=
'0'
;
wait
for
20
*
CLK_PERIOD
;
adresse
<=
(
others
=>
'Z'
);
wait
for
0
.
18
ms
;
Data_bus
<=
(
others
=>
'Z'
);
wait
for
CLK_PERIOD
;
wait
for
0
.
05
ms
;
end
send
;
end
send
;
procedure
test_busy
is
procedure
test_busy
is
begin
begin
Rd_sig
<=
'1'
;
Rd_sig
<=
'1'
;
adresse
<=
"010"
;
--
K
on
figur
er
B
er om status
adresse
<=
"010"
;
--
C
on
troll
er
b
er om status
wait
for
2
*
CLK_PERIOD
;
wait
for
2
*
CLK_PERIOD
;
Rd_sig
<=
'0'
;
Rd_sig
<=
'0'
;
adresse
<=
(
others
=>
'Z'
);
wait
for
CLK_PERIOD
;
wait
for
CLK_PERIOD
;
wait
for
0
.
1
ms
;
wait
for
0
.
1
ms
;
end
test_busy
;
end
test_busy
;
...
@@ -117,9 +135,16 @@ begin
...
@@ -117,9 +135,16 @@ begin
begin
begin
tb_init
;
tb_init
;
wait
for
0
.
01
ms
;
config
;
config
;
wait
for
0
.
01
ms
;
send
;
send
;
test_busy
;
test_busy
;
wait
for
0
.
05
ms
;
test_busy
;
config2
;
send
;
wait
for
0
.
1
ms
;
wait
for
100
ns
;
wait
for
100
ns
;
assert
false
report
"Testbench finished"
severity
failure
;
assert
false
report
"Testbench finished"
severity
failure
;
...
...
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