Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
P
picsimlab
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Analytics
Analytics
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Commits
Open sidebar
xpstem
picsimlab
Commits
e848690d
Commit
e848690d
authored
Apr 06, 2024
by
lcgamboa
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
chg: Gpsim interface optimization to improve simulation performance
parent
1e9b2e6d
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
24 additions
and
31 deletions
+24
-31
src/boards/bridge_gpsim.cc
src/boards/bridge_gpsim.cc
+24
-31
No files found.
src/boards/bridge_gpsim.cc
View file @
e848690d
#include "bridge_gpsim.h"
#include "bridge_gpsim.h"
// GpSim includes
// #include <gpsim/cod.h>
// #include <gpsim/interface.h>
// #include <gpsim/gpsim_classes.h>
#include <gpsim/pic-processor.h>
#include <gpsim/pic-processor.h>
// #include <gpsim/uart.h>
// #include <gpsim/pir.h>
// #include <gpsim/eeprom.h>
// #include <gpsim/packages.h>
// #include <gpsim/stimuli.h>
#include <gpsim/sim_context.h>
#include <gpsim/sim_context.h>
#include "../lib/util.h"
#include "../lib/util.h"
...
@@ -19,15 +10,21 @@ void simulation_cleanup(void);
...
@@ -19,15 +10,21 @@ void simulation_cleanup(void);
static
pic_processor
*
gpic
=
NULL
;
static
pic_processor
*
gpic
=
NULL
;
static
IOPIN
*
iopins
[
100
];
int
bridge_gpsim_init
(
const
char
*
processor
,
const
char
*
fileName
,
float
freq
)
{
int
bridge_gpsim_init
(
const
char
*
processor
,
const
char
*
fileName
,
float
freq
)
{
// initialize_gpsim_core ();
// initialization_is_complete ();
Processor
*
tempProc
=
0l
;
Processor
*
tempProc
=
0l
;
CSimulationContext
::
GetContext
()
->
LoadProgram
(
fileName
,
processor
,
&
tempProc
,
NULL
);
CSimulationContext
::
GetContext
()
->
LoadProgram
(
fileName
,
processor
,
&
tempProc
,
NULL
);
gpic
=
dynamic_cast
<
pic_processor
*>
(
tempProc
);
gpic
=
dynamic_cast
<
pic_processor
*>
(
tempProc
);
bridge_gpsim_set_frequency
(
freq
);
bridge_gpsim_set_frequency
(
freq
);
if
(
gpic
)
{
for
(
int
pin
=
1
;
pin
<=
bridge_gpsim_get_pin_count
();
pin
++
)
{
iopins
[
pin
]
=
gpic
->
get_pin
(
pin
);
}
}
return
(
gpic
!=
NULL
)
-
1
;
return
(
gpic
!=
NULL
)
-
1
;
}
}
...
@@ -58,23 +55,21 @@ const char* bridge_gpsim_get_pin_name(int pin) {
...
@@ -58,23 +55,21 @@ const char* bridge_gpsim_get_pin_name(int pin) {
}
}
unsigned
char
bridge_gpsim_get_pin_value
(
int
pin
)
{
unsigned
char
bridge_gpsim_get_pin_value
(
int
pin
)
{
return
gpic
->
get_pin_state
(
pin
);
if
(
iopins
[
pin
])
{
return
iopins
[
pin
]
->
getDrivingState
();
}
return
0
;
}
}
unsigned
char
bridge_gpsim_get_pin_dir
(
int
pin
)
{
unsigned
char
bridge_gpsim_get_pin_dir
(
int
pin
)
{
IOPIN
*
iopin
=
gpic
->
get_pin
(
pin
);
if
(
iopins
[
pin
])
{
return
(
iopins
[
pin
]
->
get_direction
()
==
IOPIN
::
DIR_INPUT
);
if
(
iopin
)
{
return
(
iopin
->
get_direction
()
==
IOPIN
::
DIR_INPUT
);
}
}
return
0
;
return
0
;
}
}
void
bridge_gpsim_set_pin_value
(
int
pin
,
unsigned
char
value
)
{
void
bridge_gpsim_set_pin_value
(
int
pin
,
unsigned
char
value
)
{
IOPIN
*
iopin
=
gpic
->
get_pin
(
pin
);
char
cPinState
=
iopins
[
pin
]
->
getForcedDrivenState
();
char
cPinState
=
iopin
->
getForcedDrivenState
();
switch
(
cPinState
)
{
switch
(
cPinState
)
{
case
'0'
:
case
'0'
:
...
@@ -82,30 +77,28 @@ void bridge_gpsim_set_pin_value(int pin, unsigned char value) {
...
@@ -82,30 +77,28 @@ void bridge_gpsim_set_pin_value(int pin, unsigned char value) {
case
'X'
:
case
'X'
:
case
'1'
:
case
'1'
:
if
(
value
)
{
if
(
value
)
{
iopin
->
forceDrivenState
(
'1'
);
iopin
s
[
pin
]
->
forceDrivenState
(
'1'
);
iopin
->
putState
(
true
);
iopin
s
[
pin
]
->
putState
(
true
);
}
else
{
}
else
{
iopin
->
forceDrivenState
(
'0'
);
iopin
s
[
pin
]
->
forceDrivenState
(
'0'
);
iopin
->
putState
(
false
);
iopin
s
[
pin
]
->
putState
(
false
);
}
}
break
;
break
;
case
'W'
:
case
'W'
:
if
(
!
value
)
if
(
!
value
)
iopin
->
forceDrivenState
(
'w'
);
iopin
s
[
pin
]
->
forceDrivenState
(
'w'
);
break
;
break
;
case
'w'
:
case
'w'
:
if
(
value
)
if
(
value
)
iopin
->
forceDrivenState
(
'W'
);
iopin
s
[
pin
]
->
forceDrivenState
(
'W'
);
break
;
break
;
}
}
}
}
void
bridge_gpsim_set_apin_value
(
int
pin
,
float
value
)
{
void
bridge_gpsim_set_apin_value
(
int
pin
,
float
value
)
{
IOPIN
*
iopin
=
gpic
->
get_pin
(
pin
);
iopins
[
pin
]
->
set_is_analog
(
true
);
iopins
[
pin
]
->
set_Cth
(
5e-12
);
iopin
->
set_is_analog
(
true
);
iopins
[
pin
]
->
set_nodeVoltage
(
value
);
iopin
->
set_Cth
(
5e-12
);
iopin
->
set_nodeVoltage
(
value
);
}
}
void
bridge_gpsim_step
(
void
)
{
void
bridge_gpsim_step
(
void
)
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment