Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
cMIPS
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Harbor Registry
Model registry
Operate
Environments
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
Strozzi
cMIPS
Commits
b9757976
Commit
b9757976
authored
9 years ago
by
Strozzi
Browse files
Options
Downloads
Plain Diff
Merge branch 'jedian' into Strozzi
parents
d376d52d
d16c852d
No related branches found
No related tags found
No related merge requests found
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
cMIPS/tests/handlerUART.s
+80
-0
80 additions, 0 deletions
cMIPS/tests/handlerUART.s
cMIPS/tests/handlerUARTjedi2.s
+16
-1
16 additions, 1 deletion
cMIPS/tests/handlerUARTjedi2.s
cMIPS/tests/jedidafu.c
+115
-0
115 additions, 0 deletions
cMIPS/tests/jedidafu.c
with
211 additions
and
1 deletion
cMIPS/tests/handlerUART.s
+
80
−
0
View file @
b9757976
#
UARTinterr
:
#
There
is
space
on
_uart_buff
#
_uart_buff
[
0
]=
UARTstatus
,
[
1
]=
UARTcontrol
,
[
2
]=
data_inp
,
[
3
]=
new
,
#
[
4
]=
$ra
,
[
5
]=
$a0
,
[
6
]=
$a1
,
[
7
]=
$a2
,
[
8
]=
$a3
#
k0
=
_uart_buff
andi
$a1
,
$k1
,
UART_rx_irq
#
Is
this
reception
?
beq
$a1
,
$zero
,
UARTret
#
no
,
maybe
transmission
?
nop
#
handle
reception
lw
$a1
,
4
(
$a0
)
#
Read
data
from
device
nop
#
and
store
it
to
UART
's buffer
sw
$a1
,
2
*
4
(
$k0
)
#
and
return
from
interrupt
addiu
$a1
,
$zero
,
1
sw
$a1
,
3
*
4
(
$k0
)
#
Signal
new
arrival
#
Jedian
:
when
a
new
char
is
on
the
UART
's buffer,
#
i
have
to
enqueue
it
and
update
nrx
.
#
saving
used
registers
on
_uart_buff
sw
$
5
,
9
*
4
(
$k0
)
sw
$
6
,
10
*
4
(
$k0
)
sw
$
7
,
11
*
4
(
$k0
)
#
check
if
queue
is
full
,
maybe
increment
lui
$
5
,
%
hi
(
nrx
)
ori
$
5
,
$
5
,
%
lo
(
nrx
)
lw
$
7
,
0
(
$
5
)
slti
$
6
,
$
7
,
16
beq
$
6
,
$zero
,
overrun
nop
addiu
$
7
,
$
7
,
1
sw
$
7
,
0
(
$
5
)
#
enqueue
lui
$
5
,
%
hi
(
rx_tl
)
#
get
rx
tail
address
ori
$
5
,
$
5
,
%
lo
(
rx_tl
)
lw
$
7
,
0
(
$
5
)
nop
addiu
$
7
,
$
7
,
1
#
increment
in
1
the
tail
of
the
circular
queue
andi
$
7
,
$
7
,
0xf
#
%
16
sw
$
7
,
0
(
$
5
)
###
#
stores
on
queue
on
tail
lui
$
6
,
%
hi
(
rx_q
)
#
get
queue
address
ori
$
6
,
$
6
,
%
lo
(
rx_q
)
addu
$
6
,
$
7
,
$
6
#
calculate
address
to
move
new
char
lw
$
7
,
2
*
4
(
$k0
)
#
get
char
to
be
stored
nop
sb
$
7
,
0
(
$
6
)
#
and
store
it
!
###
#
process
rx_tl
--
update
tail
#
lw
$
7
,
0
(
$
5
)
#
nop
overrun
:
#
do
something
if
queue
is
full
#...
(
doing
absolutely
nothing
besides
stacking
and
unstacking
regs
)
#
loading
back
used
registers
lw
$
5
,
9
*
4
(
$k0
)
lw
$
6
,
10
*
4
(
$k0
)
lw
$
7
,
11
*
4
(
$k0
)
#
Precisa
coisar
o
nrx
(
incrementar
)
#
UARTinterr2
:
#
andi
$a1
,
$k1
,
UART_tx_irq
#
Is
this
transmission
?
#
beq
$a1
,
$zero
,
UARTret
#
no
,
ignore
it
and
return
#
nop
#
handle
transmission
#
...
TODO
#
Lembrar
de
inicializar
os
hd
e
tl
com
0
no
comeco
do
main
#
UARTret
:
This diff is collapsed.
Click to expand it.
cMIPS/tests/handlerUARTjedi2.s
+
16
−
1
View file @
b9757976
...
@@ -22,6 +22,16 @@
...
@@ -22,6 +22,16 @@
sw
$
6
,
10
*
4
(
$k0
)
sw
$
6
,
10
*
4
(
$k0
)
sw
$
7
,
11
*
4
(
$k0
)
sw
$
7
,
11
*
4
(
$k0
)
#
check
if
queue
is
full
,
maybe
increment
lui
$
5
,
%
hi
(
nrx
)
ori
$
5
,
$
5
,
%
lo
(
nrx
)
lw
$
7
,
0
(
$
5
)
slti
$
6
,
$
7
,
16
beq
$
6
,
$zero
,
overrun
nop
addiu
$
7
,
$
7
,
1
sw
$
7
,
0
(
$
5
)
#
enqueue
#
enqueue
lui
$
5
,
%
hi
(
rx_tl
)
#
get
rx
tail
address
lui
$
5
,
%
hi
(
rx_tl
)
#
get
rx
tail
address
ori
$
5
,
$
5
,
%
lo
(
rx_tl
)
ori
$
5
,
$
5
,
%
lo
(
rx_tl
)
...
@@ -45,6 +55,11 @@
...
@@ -45,6 +55,11 @@
#
lw
$
7
,
0
(
$
5
)
#
lw
$
7
,
0
(
$
5
)
#
nop
#
nop
overrun
:
#
do
something
if
queue
is
full
#...
(
doing
absolutely
nothing
besides
stacking
and
unstacking
regs
)
#
loading
back
used
registers
#
loading
back
used
registers
lw
$
5
,
9
*
4
(
$k0
)
lw
$
5
,
9
*
4
(
$k0
)
lw
$
6
,
10
*
4
(
$k0
)
lw
$
6
,
10
*
4
(
$k0
)
...
...
This diff is collapsed.
Click to expand it.
cMIPS/tests/jedidafu.c
0 → 100644
+
115
−
0
View file @
b9757976
#include
"cMIPS.h"
typedef
struct
UARTdriver
{
int
rx_hd
;
// reception queue head index
int
rx_tl
;
// reception queue tail index
char
rx_q
[
16
];
// reception queue
int
tx_hd
;
// transmission queue head index
int
tx_tl
;
// transmission queue tail index
char
tx_q
[
16
];
// transmission queue
int
nrx
;
// number of characters in rx_queue
int
ntx
;
// number of spaces in tx_queue
}
UARTdriver
;
extern
UARTdriver
Ud
;
typedef
struct
control
{
// control register fields (uses only ls byte)
int
ign
:
24
,
// ignore uppermost bits
rts
:
1
,
// Request to Send output (bit 7)
ign2
:
2
,
// bits 6,5 ignored
intTX
:
1
,
// interrupt on TX buffer empty (bit 4)
intRX
:
1
,
// interrupt on RX buffer full (bit 3)
speed
:
3
;
// 4,8,16..256 tx-rx clock data rates (bits 0..2)
}
Tcontrol
;
typedef
struct
status
{
// status register fields (uses only ls byte)
unsigned
int
ign
:
24
,
// ignore uppermost 3 bytes
cts
:
1
,
// Clear To Send input=1 (bit 7)
txEmpty
:
1
,
// TX register is empty (bit 6)
rxFull
:
1
,
// octet available from RX register (bit 5)
int_TX_empt:
1
,
// interrupt pending on TX empty (bit 4)
int_RX_full:
1
,
// interrupt pending on RX full (bit 3)
ign1
:
1
,
// ignored (bit 2)
framing
:
1
,
// framing error (bit 1)
overun
:
1
;
// overun error (bit 0)
}
Tstatus
;
typedef
union
ctlStat
{
// control + status on same address
Tcontrol
ctl
;
// write-only
Tstatus
stat
;
// read-only
}
TctlStat
;
typedef
union
data
{
// data registers on same address
int
tx
;
// write-only
int
rx
;
// read-only
}
Tdata
;
typedef
struct
serial
{
TctlStat
cs
;
Tdata
d
;
}
Tserial
;
char
Getc
()
{
char
c
;
if
(
Ud
.
nrx
>
0
)
{
disableInterr
();
// exclui handler enquanto altera Ud
Ud
.
nrx
-=
1
;
c
=
Ud
.
rx_q
[
Ud
.
rx_hd
];
Ud
.
rx_hd
=
(
Ud
.
rx_hd
+
1
)
&
15
;
// modulo 16
enableInterr
();
}
else
{
c
=
0
;
}
return
c
;
}
int
main
(
void
)
{
// receive a string through the UART serial interface
int
i
,
j
;
volatile
int
state
;
volatile
Tserial
*
uart
;
// tell GCC not to optimize away code
volatile
Tstatus
status
;
Tcontrol
ctrl
;
uart
=
(
void
*
)
IO_UART_ADDR
;
// bottom of UART address range
ctrl
.
ign
=
0
;
ctrl
.
rts
=
0
;
// make RTS=0 to hold RemoteUnit
ctrl
.
ign2
=
0
;
ctrl
.
intTX
=
0
;
ctrl
.
intRX
=
1
;
ctrl
.
speed
=
1
;
// operate at the second highest data rate
uart
->
cs
.
ctl
=
ctrl
;
i
=
-
1
;
ctrl
.
ign
=
0
;
ctrl
.
rts
=
1
;
// make RTS=1 to activate RemoteUnit
ctrl
.
ign2
=
0
;
ctrl
.
intTX
=
0
;
ctrl
.
intRX
=
1
;
ctrl
.
speed
=
1
;
// operate at the second highest data rate
uart
->
cs
.
ctl
=
ctrl
;
do
{
state
=
i
=
i
+
1
;
while
(
Ud
.
rx_tl
==
Ud
.
rx_hd
){
to_stdout
(
'd'
);
state
=
1
-
state
;}
j
=
-
1
;
to_stdout
(
'='
);
do
{
j
=
j
+
1
;
//to_stdout(Ud.rx_q[j]);
to_stdout
(
Getc
());
if
(
Ud
.
rx_q
[
j
]
==
'\n'
)
print
(
Ud
.
nrx
);
//nada ou string completa
}
while
(
j
<
15
);
to_stdout
(
'-'
);
}
while
(
i
<
5
);
return
(
state
+
i
);
}
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