Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
8bitAdder_FPGA
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
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
Péter Márk
8bitAdder_FPGA
Commits
62e4b41e
Commit
62e4b41e
authored
1 year ago
by
Péter Márk
Browse files
Options
Downloads
Patches
Plain Diff
C kódja a 8 bit addernek
parent
fe793963
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
eightbit.c
+46
-0
46 additions, 0 deletions
eightbit.c
with
46 additions
and
0 deletions
eightbit.c
0 → 100644
+
46
−
0
View file @
62e4b41e
#define LED_MATRIX_0_BASE (0x80000000)//100000000 00000000 00000000 0000000
#define SWITCHES_0_BASE (0x80000004) //100000000 00000000 00000000 0000100
#define BTN_0_BASE (0x80000008) //100000000 00000000 00000000 0001000 mutat 1 bite-ra és az ott lévő adatot éselem össze
#define PAUSE (0x10)
int
main
()
{
volatile
unsigned
*
LED
=
(
unsigned
*
)
LED_MATRIX_0_BASE
;
volatile
unsigned
*
switches
=
(
unsigned
*
)
SWITCHES_0_BASE
;
volatile
unsigned
*
buttons
=
(
unsigned
*
)
BTN_0_BASE
;
unsigned
sw_state
;
unsigned
stored_value1
=
0
;
// Az első tárolt érték
unsigned
stored_value2
=
0
;
// A második tárolt érték
for
(;;)
{
sw_state
=
*
switches
;
// Gombok kezelése
volatile
unsigned
store_btn1
=
*
buttons
&
0x01
;
volatile
unsigned
store_btn2
=
*
buttons
&
0x02
;
volatile
unsigned
calc_btn
=
*
buttons
&
0x04
;
// Értékek tárolása
if
(
store_btn1
)
{
stored_value1
=
sw_state
;
}
else
if
(
store_btn2
)
{
stored_value2
=
sw_state
;
}
// Összeadás gomb kezelése
if
(
calc_btn
)
{
volatile
unsigned
sum
=
stored_value1
+
stored_value2
;
while
(
*
buttons
&
0x04
)
{
*
LED
=
sum
;
}
}
else
{
*
LED
=
sw_state
;
}
// Várakozás
for
(
int
n
=
PAUSE
;
n
>
0
;
n
--
)
;
}
}
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