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
9a73508e
Commit
9a73508e
authored
3 years ago
by
Yann Roberge
Browse files
Options
Downloads
Patches
Plain Diff
Avancé le TB du module decode
parent
56408c9a
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
sources/riscv_decode.vhd
+1
-1
1 addition, 1 deletion
sources/riscv_decode.vhd
sources/riscv_decode_tb.vhd
+83
-37
83 additions, 37 deletions
sources/riscv_decode_tb.vhd
with
84 additions
and
38 deletions
sources/riscv_decode.vhd
+
1
−
1
View file @
9a73508e
...
...
@@ -28,7 +28,7 @@ entity riscv_decode is
-- Entrées provenant de l'étage WRITE-BACK
i_wr_addr
:
in
std_logic_vector
(
REG_WIDTH
-1
downto
0
);
i_wr_data
:
in
std_logic_vector
(
REG_WIDTH
-1
downto
0
);
i_wr_data
:
in
std_logic_vector
(
XLEN
-1
downto
0
);
i_we
:
in
std_logic
;
-- Entrée provenant de l'étage EXECUTE
...
...
This diff is collapsed.
Click to expand it.
sources/riscv_decode_tb.vhd
+
83
−
37
View file @
9a73508e
...
...
@@ -27,7 +27,7 @@ architecture tb of riscv_decode_tb is
signal
instruction
:
std_logic_vector
(
XLEN
-1
downto
0
);
signal
pc_i
:
std_logic_vector
(
XLEN
-1
downto
0
);
signal
wr_addr
:
std_logic_vector
(
REG_WIDTH
-1
downto
0
);
signal
wr_data
:
std_logic_vector
(
REG_WIDTH
-1
downto
0
);
signal
wr_data
:
std_logic_vector
(
XLEN
-1
downto
0
);
signal
we
:
std_logic
;
signal
flush
:
std_logic
;
signal
rstn
:
std_logic
;
...
...
@@ -45,21 +45,21 @@ architecture tb of riscv_decode_tb is
-- Write to a register, no checking of what's coming out
-- TODO: Adapter
procedure
write_reg
(
signal
addr
_w
:
out
std_logic_vector
(
REG_WIDTH
-1
downto
0
);
signal
data
_w
:
out
std_logic_vector
(
XLEN
-1
downto
0
);
signal
wr_
addr
:
out
std_logic_vector
(
REG_WIDTH
-1
downto
0
);
signal
wr_
data
:
out
std_logic_vector
(
XLEN
-1
downto
0
);
signal
we
:
out
std_logic
;
constant
test_addr
_w
:
in
std_logic_vector
(
REG_WIDTH
-1
downto
0
);
constant
test_data
_w
:
in
std_logic_vector
(
XLEN
-1
downto
0
);
constant
test_
wr_
addr
:
in
std_logic_vector
(
REG_WIDTH
-1
downto
0
);
constant
test_
wr_
data
:
in
std_logic_vector
(
XLEN
-1
downto
0
);
constant
period
:
in
time
)
is
begin
addr
_w
<=
test_addr
_w
;
data
_w
<=
test_data
_w
;
wr_
addr
<=
test_
wr_
addr
;
wr_
data
<=
test_
wr_
data
;
we
<=
'1'
;
wait
for
period
;
report
"Wrote "
&
to_string
(
data
_w
)
&
" to reg "
&
to_string
(
addr
_w
);
report
"Wrote "
&
to_string
(
wr_
data
)
&
" to reg "
&
to_string
(
wr_
addr
);
end
procedure
write_reg
;
...
...
@@ -69,7 +69,7 @@ architecture tb of riscv_decode_tb is
signal
instruction
:
out
std_logic_vector
(
XLEN
-1
downto
0
);
signal
pc_i
:
out
std_logic_vector
(
XLEN
-1
downto
0
);
signal
wr_addr
:
out
std_logic_vector
(
REG_WIDTH
-1
downto
0
);
signal
wr_data
:
out
std_logic_vector
(
REG_WIDTH
-1
downto
0
);
signal
wr_data
:
out
std_logic_vector
(
XLEN
-1
downto
0
);
signal
we
:
out
std_logic
;
signal
flush
:
out
std_logic
;
...
...
@@ -83,12 +83,12 @@ architecture tb of riscv_decode_tb is
signal
pc_o
:
in
std_logic_vector
(
XLEN
-1
downto
0
);
signal
imm
:
in
std_logic_vector
(
XLEN
-1
downto
0
);
signal
test_instruction
:
in
std_logic_vector
(
XLEN
-1
downto
0
);
signal
test_pc_i
:
in
std_logic_vector
(
XLEN
-1
downto
0
);
signal
test_wr_addr
:
in
std_logic_vector
(
REG_WIDTH
-1
downto
0
);
signal
test_wr_data
:
in
std_logic_vector
(
REG_WIDTH
-1
downto
0
);
signal
test_we
:
in
std_logic
;
signal
test_flush
:
in
std_logic
;
constant
test_instruction
:
in
std_logic_vector
(
XLEN
-1
downto
0
);
constant
test_pc_i
:
in
std_logic_vector
(
XLEN
-1
downto
0
);
constant
test_wr_addr
:
in
std_logic_vector
(
REG_WIDTH
-1
downto
0
);
constant
test_wr_data
:
in
std_logic_vector
(
XLEN
-1
downto
0
);
constant
test_we
:
in
std_logic
;
constant
test_flush
:
in
std_logic
;
constant
expected_rs1_data
:
in
std_logic_vector
(
XLEN
-1
downto
0
);
constant
expected_rs2_data
:
in
std_logic_vector
(
XLEN
-1
downto
0
);
...
...
@@ -173,6 +173,7 @@ begin
-- Main TB process
p_main
:
process
is
constant
DUMMY_DATA
:
std_logic_vector
(
XLEN
-1
downto
0
)
:
=
(
3
downto
0
=>
"1010"
,
others
=>
'1'
);
constant
DUMMY_REG_ADDR
:
std_logic_vector
(
REG_WIDTH
-1
downto
0
)
:
=
(
others
=>
'1'
);
constant
EXAMPLE_PC
:
std_logic_vector
(
XLEN
-1
downto
0
)
:
=
(
3
downto
0
=>
"1010"
,
others
=>
'1'
);
begin
...
...
@@ -193,12 +194,12 @@ begin
report
"Write all registers except 0x00"
;
for
i
in
1
to
2
**
(
REG_WIDTH
)
-1
loop
write_reg
(
addr
_w
=>
addr
_w
,
data
_w
=>
data
_w
,
wr_
addr
=>
wr_
addr
,
wr_
data
=>
wr_
data
,
we
=>
we
,
test_addr
_w
=>
std_logic_vector
(
to_unsigned
(
i
,
addr
_w
)),
test_data
_w
=>
std_logic_vector
(
to_unsigned
(
i
+
3
,
data
_w
)),
test_
wr_
addr
=>
std_logic_vector
(
to_unsigned
(
i
,
wr_
addr
'length
)),
test_
wr_
data
=>
std_logic_vector
(
to_unsigned
(
i
+
3
,
wr_
data
'length
)),
period
=>
PERIOD
);
...
...
@@ -212,7 +213,7 @@ begin
instruction
,
pc_i
,
wr_addr
,
wr_data
,
we
,
flush
,
rs1_data
,
rs2_data
,
shamt
,
arith
,
sign
,
jump
,
branch
,
pc_o
,
imm
,
test_instruction
=>
"000000000000"
&
std_logic_vector
(
to_unsigned
(
0
,
REG_WIDTH
))
&
FUNCT3_ADD
&
OPCODE_ALU_I_TYPE
,
test_instruction
=>
"000000000000"
&
std_logic_vector
(
to_unsigned
(
0
,
REG_WIDTH
))
&
FUNCT3_ADD
&
DUMMY_REG_ADDR
&
OPCODE_ALU_I_TYPE
,
test_pc_i
=>
EXAMPLE_PC
,
test_wr_addr
=>
(
others
=>
'-'
),
test_wr_data
=>
(
others
=>
'-'
),
...
...
@@ -222,13 +223,13 @@ begin
expected_rs1_data
=>
(
others
=>
'0'
),
expected_rs2_data
=>
(
others
=>
'-'
),
expected_shamt
=>
(
others
=>
'-'
),
expected_arith
=>
(
others
=>
'-'
)
,
expected_sign
=>
(
others
=>
'-'
)
,
expected_jump
=>
(
others
=>
'-'
)
,
expected_branch
=>
(
others
=>
'-'
)
,
expected_arith
=>
'-'
,
expected_sign
=>
'-'
,
expected_jump
=>
'-'
,
expected_branch
=>
'-'
,
expected_pc_o
=>
EXAMPLE_PC
,
expected_imm
=>
(
others
=>
'0'
),
PERIOD
period
=>
PERIOD
);
for
i
in
1
to
2
**
(
REG_WIDTH
)
-2
loop
...
...
@@ -237,7 +238,7 @@ begin
instruction
,
pc_i
,
wr_addr
,
wr_data
,
we
,
flush
,
rs1_data
,
rs2_data
,
shamt
,
arith
,
sign
,
jump
,
branch
,
pc_o
,
imm
,
test_instruction
=>
"000000000000"
&
std_logic_vector
(
to_unsigned
(
i
,
REG_WIDTH
))
&
FUNCT3_ADD
&
OPCODE_ALU_I_TYPE
,
test_instruction
=>
"000000000000"
&
std_logic_vector
(
to_unsigned
(
i
,
REG_WIDTH
))
&
FUNCT3_ADD
&
DUMMY_REG_ADDR
&
OPCODE_ALU_I_TYPE
,
test_pc_i
=>
EXAMPLE_PC
,
test_wr_addr
=>
(
others
=>
'-'
),
test_wr_data
=>
(
others
=>
'-'
),
...
...
@@ -247,13 +248,13 @@ begin
expected_rs1_data
=>
std_logic_vector
(
to_unsigned
(
i
+
3
,
rs1_data
'length
)),
expected_rs2_data
=>
(
others
=>
'-'
),
expected_shamt
=>
(
others
=>
'-'
),
expected_arith
=>
(
others
=>
'-'
)
,
expected_sign
=>
(
others
=>
'-'
)
,
expected_jump
=>
(
others
=>
'-'
)
,
expected_branch
=>
(
others
=>
'-'
)
,
expected_arith
=>
'-'
,
expected_sign
=>
'-'
,
expected_jump
=>
'-'
,
expected_branch
=>
'-'
,
expected_pc_o
=>
EXAMPLE_PC
,
expected_imm
=>
(
others
=>
'0'
),
PERIOD
period
=>
PERIOD
);
end
loop
;
...
...
@@ -264,7 +265,7 @@ begin
instruction
,
pc_i
,
wr_addr
,
wr_data
,
we
,
flush
,
rs1_data
,
rs2_data
,
shamt
,
arith
,
sign
,
jump
,
branch
,
pc_o
,
imm
,
test_instruction
=>
"11110000111100001111"
&
"00011"
&
OPCODE_LUI
,
test_instruction
=>
"11110000111100001111"
&
DUMMY_REG_ADDR
&
OPCODE_LUI
,
test_pc_i
=>
EXAMPLE_PC
,
test_wr_addr
=>
(
others
=>
'-'
),
test_wr_data
=>
(
others
=>
'-'
),
...
...
@@ -274,18 +275,63 @@ begin
expected_rs1_data
=>
(
others
=>
'-'
),
expected_rs2_data
=>
(
others
=>
'-'
),
expected_shamt
=>
(
others
=>
'-'
),
expected_arith
=>
(
others
=>
'-'
)
,
expected_sign
=>
(
others
=>
'-'
)
,
expected_jump
=>
(
others
=>
'-'
)
,
expected_branch
=>
(
others
=>
'-'
)
,
expected_arith
=>
'0'
,
expected_sign
=>
'0'
,
expected_jump
=>
'0'
,
expected_branch
=>
'0'
,
expected_pc_o
=>
EXAMPLE_PC
,
expected_imm
=>
(
XLEN
-1
downto
12
=>
"11110000111100001111"
,
others
=>
'0'
),
PERIOD
period
=>
PERIOD
);
-- JAL
test_vector
(
instruction
,
pc_i
,
wr_addr
,
wr_data
,
we
,
flush
,
rs1_data
,
rs2_data
,
shamt
,
arith
,
sign
,
jump
,
branch
,
pc_o
,
imm
,
test_instruction
=>
"11110000111100001111"
&
DUMMY_DEST_REG
&
OPCODE_JAL
,
test_pc_i
=>
EXAMPLE_PC
,
test_wr_addr
=>
(
others
=>
'-'
),
test_wr_data
=>
(
others
=>
'-'
),
test_we
=>
'0'
,
test_flush
=>
'0'
,
expected_rs1_data
=>
(
others
=>
'-'
),
expected_rs2_data
=>
(
others
=>
'-'
),
expected_shamt
=>
(
others
=>
'-'
),
expected_arith
=>
'0'
,
expected_sign
=>
'0'
,
expected_jump
=>
'1'
,
expected_branch
=>
'0'
,
expected_pc_o
=>
EXAMPLE_PC
,
expected_imm
=>
(
XLEN
-1
downto
12
=>
"11110000111100001111"
,
others
=>
'0'
),
period
=>
PERIOD
);
-- JALR
test_vector
(
instruction
,
pc_i
,
wr_addr
,
wr_data
,
we
,
flush
,
rs1_data
,
rs2_data
,
shamt
,
arith
,
sign
,
jump
,
branch
,
pc_o
,
imm
,
test_instruction
=>
"111100001111"
&
DUMMY_REG_ADDR
&
FUNCT3_JALR
&
DUMMY_DEST_REG
&
OPCODE_JALR
,
test_pc_i
=>
EXAMPLE_PC
,
test_wr_addr
=>
(
others
=>
'-'
),
test_wr_data
=>
(
others
=>
'-'
),
test_we
=>
'0'
,
test_flush
=>
'0'
,
expected_rs1_data
=>
(
others
=>
'-'
),
expected_rs2_data
=>
(
others
=>
'-'
),
expected_shamt
=>
(
others
=>
'-'
),
expected_arith
=>
'-'
,
expected_sign
=>
'-'
,
expected_jump
=>
'-'
,
expected_branch
=>
'-'
,
expected_pc_o
=>
EXAMPLE_PC
,
expected_imm
=>
(
XLEN
-1
downto
12
=>
"111100001111"
,
others
=>
'0'
),
period
=>
PERIOD
);
-- BEQ
...
...
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