aboutsummaryrefslogtreecommitdiff
path: root/src/rtl/chacha_qr.v
diff options
context:
space:
mode:
authorJoachim StroĢˆmbergson <joachim@secworks.se>2018-08-23 09:53:03 +0200
committerJoachim StroĢˆmbergson <joachim@secworks.se>2018-08-23 09:53:03 +0200
commit1721ef5b165aee52554675f6ceb1e3a1fc2fb031 (patch)
treee6eea49996ef1ceaa7059259e5f4eb128045fd62 /src/rtl/chacha_qr.v
parentf4731e83511a3b35f05e4a6222ba27af5920fcd8 (diff)
(1) Updated qr interface to include clock and reset needed for internal pipeline registers. (2) Added testbench for the qr module. (3) Added qr simulation target. (4) Added lint support.
Diffstat (limited to 'src/rtl/chacha_qr.v')
-rw-r--r--src/rtl/chacha_qr.v29
1 files changed, 29 insertions, 0 deletions
diff --git a/src/rtl/chacha_qr.v b/src/rtl/chacha_qr.v
index 42e644c..e1ddbd8 100644
--- a/src/rtl/chacha_qr.v
+++ b/src/rtl/chacha_qr.v
@@ -40,6 +40,9 @@
//======================================================================
module chacha_qr(
+ input wire clk,
+ input wire reset_n,
+
input wire [31 : 0] a,
input wire [31 : 0] b,
input wire [31 : 0] c,
@@ -52,6 +55,13 @@ module chacha_qr(
);
//----------------------------------------------------------------
+ // Registers including update variables and write enable.
+ //----------------------------------------------------------------
+ reg [31 : 0] a0_reg;
+ reg [31 : 0] a0_new;
+
+
+ //----------------------------------------------------------------
// Wires.
//----------------------------------------------------------------
reg [31 : 0] internal_a_prim;
@@ -70,6 +80,23 @@ module chacha_qr(
//----------------------------------------------------------------
+ // reg_update
+ //----------------------------------------------------------------
+ always @ (posedge clk)
+ begin : reg_update
+ if (!reset_n)
+ begin
+ a0_reg <= 32'h0;
+ end
+
+ else
+ begin
+ a0_reg <= a0_new;
+ end
+ end // reg_update
+
+
+ //----------------------------------------------------------------
// qr
//
// The actual quarterround function.
@@ -93,6 +120,8 @@ module chacha_qr(
reg [31 : 0] d3;
a0 = a + b;
+ a0_new = a + b;
+
d0 = d ^ a0;
d1 = {d0[15 : 0], d0[31 : 16]};
c0 = c + d1;