Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
L
lab-2
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
Container 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
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Yann Roberge
lab-2
Commits
8dbb2d4a
Commit
8dbb2d4a
authored
3 years ago
by
Yann Roberge
Browse files
Options
Downloads
Patches
Plain Diff
Début de l'étage EXECUTE
parent
024c57a5
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
sources/riscv_decode.vhd
+11
-2
11 additions, 2 deletions
sources/riscv_decode.vhd
sources/riscv_execute.vhd
+82
-0
82 additions, 0 deletions
sources/riscv_execute.vhd
sources/riscv_pkg.vhd
+6
-2
6 additions, 2 deletions
sources/riscv_pkg.vhd
with
99 additions
and
4 deletions
sources/riscv_decode.vhd
+
11
−
2
View file @
8dbb2d4a
...
@@ -262,7 +262,6 @@ begin
...
@@ -262,7 +262,6 @@ begin
end
case
;
end
case
;
end
process
decode_jump_decode
;
end
process
decode_jump_decode
;
--------------------------------------
--signal shamt : std_logic_vector(SHAMT_WIDTH-1 downto 0);
--signal shamt : std_logic_vector(SHAMT_WIDTH-1 downto 0);
decode_shamt
:
decode_shamt
:
process
(
opcode
,
funct3
)
is
process
(
opcode
,
funct3
)
is
...
@@ -353,7 +352,13 @@ begin
...
@@ -353,7 +352,13 @@ begin
arith
<=
'0'
;
arith
<=
'0'
;
sign
<=
SIGN_UNSIGNED
;
sign
<=
SIGN_UNSIGNED
;
-- B,U,LUI,J,R-TYPEs
when
OPCODE_BEQ
=>
-- BEQ: Subtract src1 and src2, take branch if zero
alu_opcode
<=
ALUOP_ADD
;
arith
<=
ARITH_SUBTRACT
;
sign
<=
SIGN_UNSIGNED
;
-- U,LUI,J,R-TYPEs
-- Unsupported instructions
-- Unsupported instructions
when
others
=>
when
others
=>
alu_opcode
<=
(
others
=>
'0'
);
alu_opcode
<=
(
others
=>
'0'
);
...
@@ -371,6 +376,8 @@ begin
...
@@ -371,6 +376,8 @@ begin
begin
begin
if
rising_edge
(
i_clk
)
then
if
rising_edge
(
i_clk
)
then
if
i_rstn
=
'1'
and
i_flush
=
'0'
then
if
i_rstn
=
'1'
and
i_flush
=
'0'
then
o_decode_reg
.
opcode
<=
opcode
;
o_decode_reg
.
shamt
<=
shamt
;
o_decode_reg
.
shamt
<=
shamt
;
o_decode_reg
.
arith
<=
arith
;
o_decode_reg
.
arith
<=
arith
;
o_decode_reg
.
sign
<=
sign
;
o_decode_reg
.
sign
<=
sign
;
...
@@ -380,6 +387,8 @@ begin
...
@@ -380,6 +387,8 @@ begin
o_decode_reg
.
pc
<=
pc
;
o_decode_reg
.
pc
<=
pc
;
o_decode_reg
.
imm
<=
imm
;
o_decode_reg
.
imm
<=
imm
;
else
else
o_decode_reg
.
opcode
<=
(
others
=>
'0'
);
o_decode_reg
.
shamt
<=
(
others
=>
'0'
);
o_decode_reg
.
shamt
<=
(
others
=>
'0'
);
o_decode_reg
.
arith
<=
'0'
;
o_decode_reg
.
arith
<=
'0'
;
o_decode_reg
.
sign
<=
'0'
;
o_decode_reg
.
sign
<=
'0'
;
...
...
This diff is collapsed.
Click to expand it.
sources/riscv_execute.vhd
0 → 100644
+
82
−
0
View file @
8dbb2d4a
-------------------------------------------------------------------------------
-- Project ELE8304 : Circuits intégrés à très grande échelle
-------------------------------------------------------------------------------
-- File riscv_execute.vhd
-- Authors Titouan Luard <luardtitouan@gmail.com>
-- Yann Roberge <yann.roberge@polymtl.ca>
-- Lab GRM - Polytechnique Montreal
-- Date 2021-12-04
-------------------------------------------------------------------------------
-- Brief Execute stage of the pipeline
-------------------------------------------------------------------------------
library
ieee
;
use
ieee
.
std_logic_1164
.
all
;
use
ieee
.
numeric_std
.
all
;
use
ieee
.
math_real
.
all
;
library
work
;
use
work
.
riscv_pkg
.
all
;
entity
riscv_execute
is
port
(
-- Entrées de l'étage Decode
i_decode_reg
:
in
decode_reg
;
-- Sorties
o_pc_transfer
:
out
std_logic
;
o_pc_target
:
out
std_logic_vector
(
XLEN
-1
downto
0
);
o_flush
:
out
std_logic
;
-- Sorties registrées
o_execute_reg
:
out
execute_reg
);
end
entity
riscv_execute
;
architecture
beh
of
riscv_execute
is
signal
alu_src2
:
std_logic_vector
(
XLEN
-1
downto
0
);
-- Sorties
signal
alu_result
:
std_logic_vector
(
XLEN
-1
downto
0
);
signal
store_data
:
std_logic
;
alias
opcode
is
i_decode_reg
.
opcode
;
alias
jump
is
i_decode_reg
.
jump
;
alias
branch
is
i_decode_reg
.
branch
;
constant
ALL_ZEROES
:
std_logic_vector
(
XLEN
-1
downto
0
)
:
=
(
others
=>
'0'
);
begin
-- PC transfer
-- transfert si jump ou si la condition du BEQ est vraie
-- flush la pipeline dans ce même cas
-- toute la gestion de conflit se fait ici
-- ie. branch prediction
pc_transfer
:
process
(
jump
,
branch
,
alu_result
)
is
begin
if
jump
=
'1'
or
(
branch
=
'1'
and
alu_result
=
ALL_ZEROES
)
then
o_flush
<=
'1'
;
o_pc_transfer
<=
'1'
;
else
o_flush
<=
'0'
;
o_pc_transfer
<=
'0'
;
end
if
;
end
process
pc_transfer
;
-- DEBUG
o_pc_target
<=
(
others
=>
'1'
);
o_execute_reg
.
alu_result
<=
(
others
=>
'1'
);
o_execute_reg
.
store_data
<=
'1'
;
-- Résolution des opérations arithmétiques et logiques
-- TODO: the whole thing is a big mux depending on OPCODE
-- Ajustement du PC en cas de saut ou branchement
-- TODO: same here. big opcode mux
-- Écriture du registre execute
-- TODO: same as decode register write thingy
end
architecture
beh
;
This diff is collapsed.
Click to expand it.
sources/riscv_pkg.vhd
+
6
−
2
View file @
8dbb2d4a
...
@@ -159,6 +159,8 @@ package riscv_pkg is
...
@@ -159,6 +159,8 @@ package riscv_pkg is
type
decode_reg
is
record
type
decode_reg
is
record
opcode
:
std_logic_vector
(
OPCODE_WIDTH
downto
0
);
alu_opcode
:
std_logic_vector
(
ALUOP_WIDTH
-1
downto
0
);
alu_opcode
:
std_logic_vector
(
ALUOP_WIDTH
-1
downto
0
);
shamt
:
std_logic_vector
(
SHAMT_WIDTH
-1
downto
0
);
shamt
:
std_logic_vector
(
SHAMT_WIDTH
-1
downto
0
);
arith
:
std_logic
;
arith
:
std_logic
;
...
@@ -172,8 +174,10 @@ package riscv_pkg is
...
@@ -172,8 +174,10 @@ package riscv_pkg is
type
execute_reg
is
record
type
execute_reg
is
record
-- TODO
opcode
:
std_logic_vector
(
OPCODE_WIDTH
downto
0
);
debug
:
std_logic
;
alu_result
:
std_logic_vector
(
XLEN
-1
downto
0
);
store_data
:
std_logic
;
end
record
execute_reg
;
end
record
execute_reg
;
...
...
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