Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Christina Yu
pyriscv
Commits
ba85409e
Commit
ba85409e
authored
Nov 18, 2021
by
Yu Christina Juan
Browse files
fixed 4
parent
13d3a2e7
Changes
3
Hide whitespace changes
Inline
Side-by-side
__pycache__/regfile.cpython-37.pyc
View file @
ba85409e
No preview for this file type
onestage_pt1.py
View file @
ba85409e
...
...
@@ -3,7 +3,7 @@ import itertools
import
sys
from
pydigital.memory
import
readmemh
from
pydigital.register
import
Register
from
pydigital.utils
import
sextend
,
twos_comp
from
pydigital.utils
import
twos_comp
,
twos_comp
from
riscv_isa
import
Instruction
from
riscv_isa
import
decoder
from
riscv_isa.isa
import
regNumToName
...
...
@@ -59,9 +59,9 @@ for t in itertools.count():
rs1Val
=
None
rs2Val
=
None
if
instr
.
rs1
!=
""
:
if
instr
.
rs1
!=
None
:
rs1Val
=
RF
.
read
(
int
(
instr
.
rs1b
,
2
))
if
instr
.
rs2
!=
""
:
if
instr
.
rs2
!=
None
:
rs2Val
=
RF
.
read
(
int
(
instr
.
rs2b
,
2
))
if
instr
.
name
==
"li"
:
...
...
@@ -75,9 +75,9 @@ for t in itertools.count():
rf_wen
=
control
[
instr
.
name
].
rf_wen
wb_sel
=
control
[
instr
.
name
].
wb_sel
op1Mux
=
make_mux
(
lambda
:
rs1Val
,
lambda
:
sextend
(
int
(
instr
.
binVal
[
0
:
20
],
2
),
20
)
<<
12
)
op2Mux
=
make_mux
(
lambda
:
rs2Val
,
lambda
:
sextenssd
(
int
(
instr
.
binVal
[
0
:
7
]
+
instr
.
binVal
[
20
:
25
],
2
),
12
),
\
lambda
:
sextend
(
int
(
instr
.
binVal
[
0
:
12
],
2
),
12
),
pc_val
)
op1Mux
=
make_mux
(
lambda
:
rs1Val
,
lambda
:
twos_comp
(
int
(
instr
.
binVal
[
0
:
20
],
2
),
20
)
<<
12
)
op2Mux
=
make_mux
(
lambda
:
rs2Val
,
lambda
:
twos_comp
(
int
(
instr
.
binVal
[
0
:
7
]
+
instr
.
binVal
[
20
:
25
],
2
),
12
),
\
lambda
:
twos_comp
(
int
(
instr
.
binVal
[
0
:
12
],
2
),
12
),
pc_val
)
op1
=
op1Mux
(
op1_sel
)
op2
=
op2Mux
(
op2_sel
)
...
...
regfile.py
View file @
ba85409e
...
...
@@ -4,6 +4,7 @@ from riscv_isa.isa import regNumToName
class
RegFile
:
def
__init__
(
self
):
self
.
regs
=
[
None
]
*
32
#set all registers as none
self
.
regs
[
0
]
=
0
def
read
(
self
,
rs
):
return
self
.
regs
[
rs
]
#read contents of register
...
...
Write
Preview
Supports
Markdown
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