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
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Minyong Li
Can
Commits
ac1f3ec3
Verified
Commit
ac1f3ec3
authored
4 years ago
by
Minyong Li
Browse files
Options
Downloads
Patches
Plain Diff
core: impl QuarterRound{,Test}
parent
16824fb8
No related branches found
No related tags found
No related merge requests found
Pipeline
#7466
passed
4 years ago
Stage: test
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/main/scala/uk/ac/soton/ecs/can/core/QuarterRound.scala
+34
-0
34 additions, 0 deletions
src/main/scala/uk/ac/soton/ecs/can/core/QuarterRound.scala
src/test/scala/uk/ac/soton/ecs/can/core/QuarterRoundTest.scala
+37
-0
37 additions, 0 deletions
...est/scala/uk/ac/soton/ecs/can/core/QuarterRoundTest.scala
with
71 additions
and
0 deletions
src/main/scala/uk/ac/soton/ecs/can/core/QuarterRound.scala
0 → 100644
+
34
−
0
View file @
ac1f3ec3
package
uk.ac.soton.ecs.can.core
import
chisel3._
import
chisel3.util._
class
QuarterRound
extends
Module
{
val
io
=
IO
(
new
Bundle
{
val
in
=
Input
(
Vec
(
4
,
UInt
(
32.
W
)))
val
out
=
Output
(
Vec
(
4
,
UInt
(
32.
W
)))
})
private
def
rotateLeft
(
v
:
UInt
,
b
:
Int
)
:
UInt
=
Cat
(
v
(
31
-
b
,
0
),
v
(
31
,
32
-
b
))
val
a0
=
io
.
in
(
0
)
val
b0
=
io
.
in
(
1
)
val
c0
=
io
.
in
(
2
)
val
d0
=
io
.
in
(
3
)
val
a1
=
a0
+
b0
val
d1
=
rotateLeft
(
d0
^
a1
,
16
)
val
c1
=
c0
+
d1
val
b1
=
rotateLeft
(
b0
^
c1
,
12
)
val
a2
=
a1
+
b1
val
d2
=
rotateLeft
(
d1
^
a2
,
8
)
val
c2
=
c1
+
d2
val
b2
=
rotateLeft
(
b1
^
c2
,
7
)
io
.
out
(
0
)
:=
a2
io
.
out
(
1
)
:=
b2
io
.
out
(
2
)
:=
c2
io
.
out
(
3
)
:=
d2
}
This diff is collapsed.
Click to expand it.
src/test/scala/uk/ac/soton/ecs/can/core/QuarterRoundTest.scala
0 → 100644
+
37
−
0
View file @
ac1f3ec3
package
uk.ac.soton.ecs.can.core
import
org.scalatest._
import
chiseltest._
import
chisel3._
class
QuarterRoundTest
extends
FlatSpec
with
ChiselScalatestTester
{
it
should
"compute RFC8439 2.1.1 test vector correctly"
in
{
test
(
new
QuarterRound
)
{
c
=>
c
.
io
.
in
(
0
).
poke
(
"h11111111"
.
U
(
32.
W
))
c
.
io
.
in
(
1
).
poke
(
"h01020304"
.
U
(
32.
W
))
c
.
io
.
in
(
2
).
poke
(
"h9b8d6f43"
.
U
(
32.
W
))
c
.
io
.
in
(
3
).
poke
(
"h01234567"
.
U
(
32.
W
))
c
.
io
.
out
(
0
).
expect
(
"hea2a92f4"
.
U
(
32.
W
))
c
.
io
.
out
(
1
).
expect
(
"hcb1cf8ce"
.
U
(
32.
W
))
c
.
io
.
out
(
2
).
expect
(
"h4581472e"
.
U
(
32.
W
))
c
.
io
.
out
(
3
).
expect
(
"h5881c4bb"
.
U
(
32.
W
))
}
}
it
should
"compute RFC8439 2.2.1 test vector correctly"
in
{
test
(
new
QuarterRound
)
{
c
=>
c
.
io
.
in
(
0
).
poke
(
"h516461b1"
.
U
(
32.
W
))
c
.
io
.
in
(
1
).
poke
(
"h2a5f714c"
.
U
(
32.
W
))
c
.
io
.
in
(
2
).
poke
(
"h53372767"
.
U
(
32.
W
))
c
.
io
.
in
(
3
).
poke
(
"h3d631689"
.
U
(
32.
W
))
c
.
io
.
out
(
0
).
expect
(
"hbdb886dc"
.
U
(
32.
W
))
c
.
io
.
out
(
1
).
expect
(
"hcfacafd2"
.
U
(
32.
W
))
c
.
io
.
out
(
2
).
expect
(
"he46bea80"
.
U
(
32.
W
))
c
.
io
.
out
(
3
).
expect
(
"hccc07c79"
.
U
(
32.
W
))
}
}
}
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