aboutsummaryrefslogtreecommitdiff
path: root/src/rtl
diff options
context:
space:
mode:
authorJoachim StroĢˆmbergson <joachim@secworks.se>2014-09-16 17:21:09 +0200
committerJoachim StroĢˆmbergson <joachim@secworks.se>2014-09-16 17:21:09 +0200
commitf2a4ea70dbee4c50b10045636dd91c3ef47386f1 (patch)
tree49a037916e570e17693ffc8d9775631ec7b115ee /src/rtl
parent3e5ec06bd7779ee6546ffa4a921b5b8a0e1859fb (diff)
More debug fixes. We add one extra wait cycle to allow the mixer to detect that we want more seed.
Diffstat (limited to 'src/rtl')
-rw-r--r--src/rtl/trng_csprng.v34
1 files changed, 25 insertions, 9 deletions
diff --git a/src/rtl/trng_csprng.v b/src/rtl/trng_csprng.v
index 4d472d2..1bdc737 100644
--- a/src/rtl/trng_csprng.v
+++ b/src/rtl/trng_csprng.v
@@ -42,18 +42,18 @@ module trng_csprng(
input wire reset_n,
// Control, config and status.
+ input wire enable,
input debug_mode,
input wire [4 : 0] num_rounds,
input wire [63 : 0] num_blocks,
input wire seed,
- input wire enable,
output wire more_seed,
output wire ready,
output wire error,
// Seed input
- input wire seed_syn,
input [511 : 0] seed_data,
+ input wire seed_syn,
output wire seed_ack,
// Random data output
@@ -71,12 +71,13 @@ module trng_csprng(
parameter CTRL_IDLE = 4'h0;
parameter CTRL_SEED0 = 4'h1;
- parameter CTRL_SEED1 = 4'h2;
- parameter CTRL_INIT0 = 4'h3;
- parameter CTRL_INIT1 = 4'h4;
- parameter CTRL_NEXT0 = 4'h5;
- parameter CTRL_NEXT1 = 4'h6;
- parameter CTRL_MORE = 4'h7;
+ parameter CTRL_NSYN = 4'h2;
+ parameter CTRL_SEED1 = 4'h3;
+ parameter CTRL_INIT0 = 4'h4;
+ parameter CTRL_INIT1 = 4'h5;
+ parameter CTRL_NEXT0 = 4'h6;
+ parameter CTRL_NEXT1 = 4'h7;
+ parameter CTRL_MORE = 4'h8;
parameter CTRL_CANCEL = 4'hf;
@@ -133,6 +134,7 @@ module trng_csprng(
wire [511 : 0] cipher_data_out;
wire cipher_data_out_valid;
+ wire cipher_ready;
reg discard_outputs;
@@ -354,10 +356,24 @@ module trng_csprng(
end
else if (seed_syn)
begin
- more_seed_new = 1;
seed_ack_new = 1;
cipher_block_new = seed_data;
cipher_block_we = 1;
+ csprng_ctrl_new = CTRL_NSYN;
+ csprng_ctrl_we = 1;
+ end
+ end
+
+ CTRL_NSYN:
+ begin
+ if ((!enable) || (seed))
+ begin
+ csprng_ctrl_new = CTRL_CANCEL;
+ csprng_ctrl_we = 1;
+ end
+ else
+ begin
+ more_seed_new = 1;
csprng_ctrl_new = CTRL_SEED1;
csprng_ctrl_we = 1;
end