Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
C
Can
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Minyong Li
Can
Commits
ea5e3f9f
Verified
Commit
ea5e3f9f
authored
4 years ago
by
Minyong Li
Browse files
Options
Downloads
Patches
Plain Diff
core.QuarterRoundTest: add test for 1,2,8-stage QRs
parent
e34a97d1
No related branches found
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/test/scala/uk/ac/soton/ecs/can/core/QuarterRoundTest.scala
+79
-0
79 additions, 0 deletions
...est/scala/uk/ac/soton/ecs/can/core/QuarterRoundTest.scala
with
79 additions
and
0 deletions
src/test/scala/uk/ac/soton/ecs/can/core/QuarterRoundTest.scala
0 → 100644
+
79
−
0
View file @
ea5e3f9f
// SPDX-FileCopyrightText: 2021 Minyong Li <ml10g20@soton.ac.uk>
// SPDX-License-Identifier: GPL-3.0-or-later
package
uk.ac.soton.ecs.can.core
import
chisel3._
import
chiseltest._
import
org.scalatest._
class
QuarterRoundTest
extends
FlatSpec
with
ChiselScalatestTester
{
private
type
TestVector
=
Seq
[(
UInt
,
UInt
)]
private
val
testVectorRFC8439211
:
TestVector
=
Seq
(
"h11111111"
.
U
(
32.
W
)
->
"hea2a92f4"
.
U
(
32.
W
),
"h01020304"
.
U
(
32.
W
)
->
"hcb1cf8ce"
.
U
(
32.
W
),
"h9b8d6f43"
.
U
(
32.
W
)
->
"h4581472e"
.
U
(
32.
W
),
"h01234567"
.
U
(
32.
W
)
->
"h5881c4bb"
.
U
(
32.
W
)
)
private
val
testVectorRFC8439221
:
TestVector
=
Seq
(
"h516461b1"
.
U
(
32.
W
)
->
"hbdb886dc"
.
U
(
32.
W
),
"h2a5f714c"
.
U
(
32.
W
)
->
"hcfacafd2"
.
U
(
32.
W
),
"h53372767"
.
U
(
32.
W
)
->
"he46bea80"
.
U
(
32.
W
),
"h3d631689"
.
U
(
32.
W
)
->
"hccc07c79"
.
U
(
32.
W
)
)
private
def
poke
[
C
<:
BaseQuarterRound
](
c
:
C
,
tv
:
TestVector
)
=
c
.
in
.
zip
(
tv
).
foreach
{
case
(
i
,
(
p
,
_
))
=>
i
.
poke
(
p
)
}
private
def
expect
[
C
<:
BaseQuarterRound
](
c
:
C
,
tv
:
TestVector
)
=
c
.
out
.
zip
(
tv
).
foreach
{
case
(
o
,
(
_
,
e
))
=>
o
.
expect
(
e
)
}
behavior
of
"The Combinational Quarter Round"
private
def
testCombinationalQuarterRound
(
testVector
:
Seq
[(
UInt
,
UInt
)]
)
:
Unit
=
test
(
new
CombinationalQuarterRound
)
{
c
=>
poke
(
c
,
testVectorRFC8439211
)
expect
(
c
,
testVectorRFC8439211
)
}
it
should
"pass RFC8439 2.1.1 test vector"
in
testCombinationalQuarterRound
(
testVectorRFC8439211
)
it
should
"pass RFC8439 2.2.1 test vector"
in
testCombinationalQuarterRound
(
testVectorRFC8439221
)
behavior
of
"The 2-Stage Pipelined Quarter Round"
private
def
testTwoStageQuarterRound
(
tv
:
TestVector
)
:
Unit
=
test
(
new
TwoStageQuarterRound
)
{
c
=>
poke
(
c
,
tv
)
c
.
clock
.
step
()
expect
(
c
,
tv
)
}
it
should
"pass RFC8439 2.1.1 test vector"
in
testTwoStageQuarterRound
(
testVectorRFC8439211
)
it
should
"pass RFC8439 2.2.1 test vector"
in
testTwoStageQuarterRound
(
testVectorRFC8439221
)
behavior
of
"The 8-Stage Pipelined Quarter Round"
private
def
testEightStageQuarterRound
(
tv
:
TestVector
)
:
Unit
=
test
(
new
EightStageQuarterRound
)
{
c
=>
poke
(
c
,
tv
)
c
.
clock
.
step
(
8
)
expect
(
c
,
tv
)
}
it
should
"pass RFC8439 2.1.1 test vector"
in
testEightStageQuarterRound
(
testVectorRFC8439211
)
it
should
"pass RFC8439 2.2.1 test vector"
in
testEightStageQuarterRound
(
testVectorRFC8439221
)
}
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