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
83aabeee
Commit
83aabeee
authored
3 years ago
by
Yann Roberge
Browse files
Options
Downloads
Patches
Plain Diff
Temp: refactoring du decode
parent
222a9eff
No related branches found
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
sources/riscv_decode.vhd
+211
-1
211 additions, 1 deletion
sources/riscv_decode.vhd
with
211 additions
and
1 deletion
sources/riscv_decode.vhd
+
211
−
1
View file @
83aabeee
...
...
@@ -67,7 +67,9 @@ architecture beh of riscv_decode is
signal
jump
:
std_logic
;
signal
branch
:
std_logic
;
signal
alu_opcode
:
std_logic_vector
(
ALUOP_WIDTH
-1
downto
0
);
signal
sign
:
std_logic
;
signal
arith
:
std_logic
;
signal
shamt
:
std_logic_vector
(
SHAMT_WIDTH
-1
downto
0
);
signal
sign
:
std_logic
;
signal
imm
:
std_logic_vector
(
XLEN
-1
downto
0
);
alias
instruction
is
i_fetch_reg
.
instruction
;
...
...
@@ -233,6 +235,214 @@ begin
);
-- Decode
--signal jump : std_logic;
--signal branch : std_logic;
decode_jump_decode
:
process
(
funct7
,
funct3
,
opcode
)
is
begin
case
opcode
is
-- R-TYPE
when
OPCODE_JALR
=>
jump
<=
'1'
;
branch
<=
'0'
;
alu_opcode
<=
(
others
=>
'0'
);
arith
<=
'0'
;
shamt
<=
(
others
=>
'0'
);
sign
<=
SIGN_UNSIGNED
;
when
OPCODE_ALU_R_TYPE
=>
jump
<=
'0'
;
branch
<=
'0'
;
case
funct3
is
when
FUNCT3_ADD
=>
-- FUNCT7 distingue la soustraction de l'addition
-- toutes les opérations sont signées
case
funct7
is
=>
when
FUNCT7_SUB_ARITH_SH
=>
arith
<=
ARITH_SUBTRACT
;
when
others
=>
arith
<=
ARITH_ADD
;
end
case
;
shamt
<=
(
others
=>
'0'
);
alu_opcode
<=
ALUOP_ADD
;
sign
<=
SIGN_SIGNED
;
when
FUNCT3_SL
=>
jump
<=
'0'
;
branch
<=
'0'
;
alu_opcode
<=
ALUOP_SH_LEFT
;
arith
<=
'0'
;
-- le shift gauche est toujours logique
shamt
<=
(
others
=>
'0'
);
sign
<=
SIGN_UNSIGNED
;
when
FUNCT3_SLT
=>
when
FUNCT3_SLTU
=>
when
FUNCT3_XOR
=>
when
FUNCT3_SR
=>
when
FUNCT3_OR
=>
when
FUNCT3_AND
=>
when
others
=>
-- on n'arrive jamais ici parce que toutes les
-- possibilités de FUNCT3 sont couvertes par le code plus haut
alu_opcode
<=
(
others
=>
'0'
);
arith
<=
'0'
;
shamt
<=
(
others
=>
'0'
);
sign
<=
SIGN_UNSIGNED
;
end
case
;
alu_opcode
<=
(
others
=>
'0'
);
sign
<=
SIGN_UNSIGNED
;
-- I-TYPE
when
OPCODE_LW
=>
jump
<=
'0'
;
branch
<=
'0'
;
alu_opcode
<=
(
others
=>
'0'
);
sign
<=
SIGN_UNSIGNED
;
when
OPCODE_ALU_I_TYPE
=>
-- S-TYPE
when
OPCODE_SW
=>
jump
<=
'0'
;
branch
<=
'0'
;
alu_opcode
<=
(
others
=>
'0'
);
sign
<=
SIGN_UNSIGNED
;
-- B-TYPE
when
OPCODE_BEQ
=>
jump
<=
'0'
;
branch
<=
'1'
;
alu_opcode
<=
(
others
=>
'0'
);
sign
<=
SIGN_UNSIGNED
;
-- U-TYPE
when
OPCODE_LUI
=>
jump
<=
'0'
;
branch
<=
'0'
;
alu_opcode
<=
(
others
=>
'0'
);
sign
<=
SIGN_UNSIGNED
;
-- J-TYPE
when
OPCODE_JAL
=>
jump
<=
'1'
;
branch
<=
'0'
;
alu_opcode
<=
(
others
=>
'0'
);
sign
<=
SIGN_UNSIGNED
;
-- R-TYPE
-- Unsupported instructions
when
others
=>
end
case
;
end
process
decode_jump_decode
;
--signal alu_opcode : std_logic_vector(ALUOP_WIDTH-1 downto 0);
--signal arith : std_logic;
--signal shamt : std_logic_vector(SHAMT_WIDTH-1 downto 0);
--signal sign : std_logic;
decode_calc
:
process
(
funct7
,
funct3
,
opcode
)
is
begin
case
opcode
is
-- R-TYPE
when
OPCODE_JALR
=>
jump
<=
'1'
;
branch
<=
'0'
;
alu_opcode
<=
(
others
=>
'0'
);
arith
<=
'0'
;
shamt
<=
(
others
=>
'0'
);
sign
<=
SIGN_UNSIGNED
;
when
OPCODE_ALU_R_TYPE
=>
jump
<=
'0'
;
branch
<=
'0'
;
case
funct3
is
when
FUNCT3_ADD
=>
-- FUNCT7 distingue la soustraction de l'addition
-- toutes les opérations sont signées
case
funct7
is
=>
when
FUNCT7_SUB_ARITH_SH
=>
arith
<=
ARITH_SUBTRACT
;
when
others
=>
arith
<=
ARITH_ADD
;
end
case
;
shamt
<=
(
others
=>
'0'
);
alu_opcode
<=
ALUOP_ADD
;
sign
<=
SIGN_SIGNED
;
when
FUNCT3_SL
=>
jump
<=
'0'
;
branch
<=
'0'
;
alu_opcode
<=
ALUOP_SH_LEFT
;
arith
<=
'0'
;
-- le shift gauche est toujours logique
shamt
<=
(
others
=>
'0'
);
sign
<=
SIGN_UNSIGNED
;
when
FUNCT3_SLT
=>
when
FUNCT3_SLTU
=>
when
FUNCT3_XOR
=>
when
FUNCT3_SR
=>
when
FUNCT3_OR
=>
when
FUNCT3_AND
=>
when
others
=>
-- on n'arrive jamais ici parce que toutes les
-- possibilités de FUNCT3 sont couvertes par le code plus haut
alu_opcode
<=
(
others
=>
'0'
);
arith
<=
'0'
;
shamt
<=
(
others
=>
'0'
);
sign
<=
SIGN_UNSIGNED
;
end
case
;
alu_opcode
<=
(
others
=>
'0'
);
sign
<=
SIGN_UNSIGNED
;
-- I-TYPE
when
OPCODE_LW
=>
jump
<=
'0'
;
branch
<=
'0'
;
alu_opcode
<=
(
others
=>
'0'
);
sign
<=
SIGN_UNSIGNED
;
when
OPCODE_ALU_I_TYPE
=>
-- S-TYPE
when
OPCODE_SW
=>
jump
<=
'0'
;
branch
<=
'0'
;
alu_opcode
<=
(
others
=>
'0'
);
sign
<=
SIGN_UNSIGNED
;
-- B-TYPE
when
OPCODE_BEQ
=>
jump
<=
'0'
;
branch
<=
'1'
;
alu_opcode
<=
(
others
=>
'0'
);
sign
<=
SIGN_UNSIGNED
;
-- U-TYPE
when
OPCODE_LUI
=>
jump
<=
'0'
;
branch
<=
'0'
;
alu_opcode
<=
(
others
=>
'0'
);
sign
<=
SIGN_UNSIGNED
;
-- J-TYPE
when
OPCODE_JAL
=>
jump
<=
'1'
;
branch
<=
'0'
;
alu_opcode
<=
(
others
=>
'0'
);
sign
<=
SIGN_UNSIGNED
;
-- R-TYPE
-- Unsupported instructions
when
others
=>
end
case
;
end
process
decode_jump_decode
;
-- Écrire le registre ID/EX
...
...
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