aboutsummaryrefslogtreecommitdiff
path: root/src/rtl/rosc_entropy.v
diff options
context:
space:
mode:
Diffstat (limited to 'src/rtl/rosc_entropy.v')
-rw-r--r--src/rtl/rosc_entropy.v123
1 files changed, 73 insertions, 50 deletions
diff --git a/src/rtl/rosc_entropy.v b/src/rtl/rosc_entropy.v
index b407f3b..32fc3d2 100644
--- a/src/rtl/rosc_entropy.v
+++ b/src/rtl/rosc_entropy.v
@@ -40,32 +40,42 @@ module rosc_entropy(
input wire clk,
input wire reset_n,
- output wire [7 : 0] debug,
- input wire debug_update,
-
input wire cs,
input wire we,
input wire [7 : 0] address,
input wire [31 : 0] write_data,
output wire [31 : 0] read_data,
- output wire error
+ output wire error,
+
+ output wire [31 : 0] entropy_data,
+ output wire entropy_valid,
+ input wire entropy_ack,
+
+ output wire [7 : 0] debug,
+ input wire debug_update,
+
+ output wire security_error
);
//----------------------------------------------------------------
// Parameters.
//----------------------------------------------------------------
- parameter ADDR_CTRL = 8'h00;
- parameter CTRL_ENABLE_BIT = 0;
+ parameter ADDR_CTRL = 8'h00;
+ parameter CTRL_ENABLE_BIT = 0;
- parameter ADDR_STATUS = 8'h01;
- parameter STATUS_RND_VALID_BIT = 0;
+ parameter ADDR_STATUS = 8'h01;
+ parameter STATUS_ENTROPY_VALID_BIT = 0;
- parameter ADDR_OPA = 8'h08;
- parameter ADDR_OPB = 8'h09;
+ parameter ADDR_OP_A = 8'h08;
+ parameter ADDR_OP_B = 8'h09;
- parameter ADDR_ENTROPY = 8'h10;
- parameter ADDR_RND = 8'h20;
+ parameter ADDR_ENTROPY = 8'h10;
+ parameter ADDR_RAW = 8'h20;
+ parameter ADDR_ROSC_OUTPUTS = 8'h21;
+
+ parameter DEFAULT_OP_A = 8'haaaaaaaa;
+ parameter DEFAULT_OP_B = ~DEFAULT_OP_A;
//----------------------------------------------------------------
@@ -87,11 +97,14 @@ module rosc_entropy(
//----------------------------------------------------------------
// Wires.
//----------------------------------------------------------------
- wire [31 : 0] entropy;
+ wire [31 : 0] raw_entropy;
+ wire [31 : 0] rosc_outputs;
+
+ wire [31 : 0] internal_entropy_data;
+ wire internal_entropy_valid;
+ wire internal_entropy_ack;
+ reg api_entropy_ack;
- wire [31 : 0] rnd_data;
- wire rnd_valid;
- reg rnd_ack;
reg [31 : 0] tmp_read_data;
reg tmp_error;
@@ -100,8 +113,13 @@ module rosc_entropy(
//----------------------------------------------------------------
// Concurrent connectivity for ports etc.
//----------------------------------------------------------------
- assign read_data = tmp_read_data;
- assign error = tmp_error;
+ assign read_data = tmp_read_data;
+ assign error = tmp_error;
+ assign security_error = 0;
+
+ assign internal_entropy_ack = api_entropy_ack | entropy_ack;
+ assign entropy_data = internal_entropy_data;
+ assign entropy_data_valid = internal_entropy_valid;
//----------------------------------------------------------------
@@ -111,16 +129,17 @@ module rosc_entropy(
.clk(clk),
.reset_n(reset_n),
- .enable(en_reg),
+ .en(en_reg),
.opa(op_a_reg),
.opb(op_b_reg),
- .entropy(entropy),
+ .raw_entropy(raw_entropy),
+ .rosc_outputs(rosc_outputs),
- .rnd_data(rnd_data),
- .rnd_valid(rnd_valid),
- .rnd_ack(rnd_ack),
+ .entropy_data(internal_entropy_data),
+ .entropy_valid(internal_entropy_valid),
+ .entropy_ack(internal_entropy_ack),
.debug(debug),
.debug_update(debug_update)
@@ -139,8 +158,8 @@ module rosc_entropy(
if (!reset_n)
begin
en_reg <= 1;
- op_a_reg <= 32'h01010101;
- op_a_reg <= 32'h10101010;
+ op_a_reg <= DEFAULT_OP_A;
+ op_b_reg <= DEFAULT_OP_B;
end
else
begin
@@ -158,7 +177,6 @@ module rosc_entropy(
begin
op_b_reg <= op_b_new;
end
-
end
end // reg_update
@@ -171,15 +189,15 @@ module rosc_entropy(
//----------------------------------------------------------------
always @*
begin : api_logic
- en_new = 0;
- en_we = 0;
- op_a_new = 0;
- op_a_we = 0;
- op_b_new = 0;
- op_b_we = 0;
- rnd_ack = 0;
- tmp_read_data = 32'h00000000;
- tmp_error = 0;
+ en_new = 0;
+ en_we = 0;
+ op_a_new = 0;
+ op_a_we = 0;
+ op_b_new = 0;
+ op_b_we = 0;
+ api_entropy_ack = 0;
+ tmp_read_data = 32'h00000000;
+ tmp_error = 0;
if (cs)
begin
@@ -193,13 +211,13 @@ module rosc_entropy(
en_we = 1;
end
- ADDR_OPA:
+ ADDR_OP_A:
begin
op_a_new = write_data;
op_a_we = 1;
end
- ADDR_OPB:
+ ADDR_OP_B:
begin
op_b_new = write_data;
op_b_we = 1;
@@ -221,28 +239,33 @@ module rosc_entropy(
ADDR_STATUS:
begin
- tmp_read_data[STATUS_RND_VALID_BIT] = rnd_valid;
+ tmp_read_data[STATUS_ENTROPY_VALID_BIT] = entropy_valid;
end
- ADDR_OPA:
- begin
- tmp_read_data = op_a_reg;
- end
+ ADDR_OP_A:
+ begin
+ tmp_read_data = op_a_reg;
+ end
- ADDR_OPB:
- begin
- tmp_read_data = op_b_reg;
- end
+ ADDR_OP_B:
+ begin
+ tmp_read_data = op_b_reg;
+ end
ADDR_ENTROPY:
begin
- tmp_read_data = entropy;
+ tmp_read_data = entropy_data;
+ api_entropy_ack = 1;
+ end
+
+ ADDR_RAW:
+ begin
+ tmp_read_data = raw_entropy;
end
- ADDR_RND:
+ ADDR_ROSC_OUTPUTS:
begin
- tmp_read_data = rnd_data;
- rnd_ack = 1;
+ tmp_read_data = rosc_outputs;
end
default: