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
b59a8e3b
Commit
b59a8e3b
authored
8 months ago
by
Solveig Langbakk
Browse files
Options
Downloads
Patches
Plain Diff
fikset ting
parent
e7b9be7f
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
controller.vhd
+52
-65
52 additions, 65 deletions
controller.vhd
with
52 additions
and
65 deletions
controller.vhd
+
52
−
65
View file @
b59a8e3b
...
...
@@ -12,7 +12,7 @@ entity Controller is
Data_bus
:
inout
std_logic_vector
(
7
downto
0
);
parity_sel
:
in
std_logic_vector
(
1
downto
0
);
adresse
:
out
std_logic_vector
(
2
downto
0
);
Rd_sig
,
Wr_sig
:
in
out
std_logic
Rd_sig
,
Wr_sig
:
out
std_logic
);
end
Controller
;
...
...
@@ -20,88 +20,75 @@ end Controller;
architecture
RTL
of
Controller
is
--Arkitekturen begynner
type
reader_status
is
(
reading
,
idle
);
signal
status
:
reader_status
:
=
idle
;
signal
internal_baud
:
std_logic_vector
(
2
downto
0
);
-- Internal signal for baud
signal
internal_parity
:
std_logic_vector
(
1
downto
0
);
-- Internt signal for parity
signal
internal_z
:
std_logic_vector
(
2
downto
0
);
--Arkitekturen begynner
begin
-- Rd_sig <= '1' when status = reading else '0';
-- prosessen begynner
p_clk
:
process
(
clk
,
rst_n
,
msg_key
,
b
aud_rate_sel
,
parity_sel
)
p_clk
:
process
(
clk
,
rst_n
,
msg_key
,
B
aud_rate_sel
,
parity_sel
,
Data_bus
)
begin
Wr_sig
<=
'0'
;
Rd_sig
<=
'0'
;
LED_msg
<=
'0'
;
-- Hvis det ikke er konfigurasjonstid, da gjør vi slik:
if
rising_edge
(
clk
)
then
-- Reset er starten av oppdraget. Her sendes config-informasjon.
if
rst_n
=
'0'
then
case
Baud_rate_sel
is
when
"000"
=>
Data_bus
(
2
downto
0
)
<=
"000"
;
when
"001"
=>
Data_bus
(
2
downto
0
)
<=
"001"
;
when
"010"
=>
Data_bus
(
2
downto
0
)
<=
"010"
;
when
"011"
=>
Data_bus
(
2
downto
0
)
<=
"011"
;
when
"100"
=>
Data_bus
(
2
downto
0
)
<=
"100"
;
when
others
=>
Data_bus
(
2
downto
0
)
<=
"111"
;
when
"000"
=>
internal_baud
(
2
downto
0
)
<=
"000"
;
when
"001"
=>
internal_baud
(
2
downto
0
)
<=
"001"
;
when
"010"
=>
internal_baud
(
2
downto
0
)
<=
"010"
;
when
"011"
=>
internal_baud
(
2
downto
0
)
<=
"011"
;
when
"100"
=>
internal_baud
(
2
downto
0
)
<=
"100"
;
when
others
=>
internal_baud
(
2
downto
0
)
<=
"111"
;
end
case
;
case
parity_sel
is
when
"00"
=>
Data_bus
(
4
downto
3
)
<=
"00"
;
when
"01"
=>
Data_bus
(
4
downto
3
)
<=
"01"
;
when
"10"
=>
Data_bus
(
4
downto
3
)
<=
"10"
;
when
"11"
=>
Data_bus
(
4
downto
3
)
<=
"11"
;
when
others
=>
Data_bus
(
4
downto
3
)
<=
"00"
;
-- Velger dette til default
when
"00"
=>
internal_parity
(
1
downto
0
)
<=
"00"
;
when
"01"
=>
internal_parity
(
1
downto
0
)
<=
"01"
;
when
"10"
=>
internal_parity
(
1
downto
0
)
<=
"10"
;
when
"11"
=>
internal_parity
(
1
downto
0
)
<=
"11"
;
when
others
=>
internal_parity
(
1
downto
0
)
<=
"00"
;
-- Default
end
case
;
internal_z
(
2
downto
0
)
<=
"000"
;
Data_bus
(
7
downto
5
)
<=
"ZZZ"
;
--Sender config info til TX config adresse.
adresse
<=
"000"
;
Rd_sig
<=
'0'
;
Data_bus
(
7
downto
0
)
<=
internal_z
&
internal_parity
&
internal_baud
;
Wr_sig
<=
'1'
;
--Sender config info til RX config adresse.
adresse
<=
"100"
;
-- Write settes til null. Ingenting skal sendes fra CTRL altså.
Wr_sig
<=
'0'
;
else
if
rst_n
=
'1'
then
adresse
<=
"000"
;
elsif
rising_edge
(
clk
)
then
--status <= idle;
--Wr_sig <= '0';
-- Hvis meldingsknappen trykkes, da sender vi en pre-definert bokstav til TX for videresending.
Bokstaven er A.
-- Hvis meldingsknappen trykkes, da sender vi en pre-definert bokstav til TX for videresending.
if
msg_key
=
'1'
then
adresse
<=
"001"
;
Data_bus
<=
"01000001"
;
Data_bus
<=
"01000101"
;
Wr_sig
<=
'1'
;
Wr_sig
<=
'0'
;
adresse
<=
"001"
;
end
if
;
--Hvis RX har mottatt noe data, så skal vi sende videre. Vi skal også skru på led-paeren.
if
adresse
=
"101"
then
Rd_sig
<=
'1'
;
if
adresse
=
"101"
and
msg_key
=
'0'
then
status
<=
reading
;
LED_msg
<=
'1'
;
LED_msg
<=
'0'
;
adresse
<=
"001"
;
Wr_sig
<=
'1'
;
Rd_sig
<=
'0'
;
Wr_sig
<=
'0'
;
--status <= idle;
else
Data_bus
<=
"ZZZZZZZZ"
;
adresse
<=
"ZZZ"
;
Wr_sig
<=
'0'
;
Rd_sig
<=
'0'
;
--status <= idle;
end
if
;
end
if
;
end
if
;
--end if;
end
if
;
end
process
p_clk
;
...
...
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