diff options
author | Pavel V. Shatov (Meister) <meisterpaul1@yandex.ru> | 2019-10-21 12:56:30 +0300 |
---|---|---|
committer | Pavel V. Shatov (Meister) <meisterpaul1@yandex.ru> | 2019-10-21 12:56:30 +0300 |
commit | 9eac252242c69e51a38a9a88c87b564dd40b6257 (patch) | |
tree | ab6653950a7f2a811598c73f15116fa5c009ec5c /rtl/modexpng_microcode.vh | |
parent | 36339014ec3d3ad3bb4622392d5075d674e7dbeb (diff) |
Entire CRT signature algorithm works by now.
Moved micro-operations handler into a separate module file, this way we don't
have any synthesized stuff in the top-level module, just instantiations. This
is more consistent from the design partitioning point of view. Btw, Xilinx
claims their tools work better that way too, but who knows...
Added optional simulation-only code to assist debugging. Un-comment the
ENABLE_DEBUG `define in 'rtl/modexpng_parameters.vh' to use, but don't ever
try to synthesize the core with debugging enabled.
Diffstat (limited to 'rtl/modexpng_microcode.vh')
-rw-r--r-- | rtl/modexpng_microcode.vh | 70 |
1 files changed, 38 insertions, 32 deletions
diff --git a/rtl/modexpng_microcode.vh b/rtl/modexpng_microcode.vh index 6296e9b..9d7099e 100644 --- a/rtl/modexpng_microcode.vh +++ b/rtl/modexpng_microcode.vh @@ -5,64 +5,61 @@ localparam UOP_AUX_W = 1; localparam UOP_LADDER_W = 2; localparam UOP_SEL_W = 4 * BANK_ADDR_W; -localparam UOP_ADDR_W = 6; // 64 instructions - -localparam [UOP_ADDR_W -1:0] UOP_ADDR_OFFSET_USING_CRT = 6'd0; -localparam [UOP_ADDR_W -1:0] UOP_ADDR_OFFSET_WITHOUT_CRT = 6'd31; +localparam UOP_ADDR_W = 7; // 128 instructions +localparam [UOP_ADDR_W -1:0] UOP_ADDR_OFFSET_USING_CRT = 7'd0; +localparam [UOP_ADDR_W -1:0] UOP_ADDR_OFFSET_WITHOUT_CRT = 7'd64; // 5 1 1 1 2 4*3=12 localparam UOP_W = UOP_OPCODE_W + UOP_CRT_W + UOP_NPQ_W + UOP_AUX_W + UOP_LADDER_W + UOP_SEL_W; // [21:17] [16] [15] [14] [13:12] [11:9][8:6][5:3][2:0] +// // OPCODE -localparam [UOP_OPCODE_W -1:0] UOP_OPCODE_STOP = 5'd0; +// +localparam [UOP_OPCODE_W -1:0] UOP_OPCODE_STOP = 5'd00; /* all fields are don't care */ -localparam [UOP_OPCODE_W -1:0] UOP_OPCODE_INPUT_TO_WIDE = 5'd1; -localparam [UOP_OPCODE_W -1:0] UOP_OPCODE_INPUT_TO_NARROW = 5'd2; +localparam [UOP_OPCODE_W -1:0] UOP_OPCODE_INPUT_TO_WIDE = 5'd01; +localparam [UOP_OPCODE_W -1:0] UOP_OPCODE_INPUT_TO_NARROW = 5'd02; /* CRT tells into which of the dual MMM to write * NPQ specifies the width of the operand * AUX specifies from which INPUT to read - * LADDER is don't care - * source WIDE is always don't care - * destination NARROW is don't care for _WIDE opcode and vice versa - * -*/ + * LADDER is don't care + */ -localparam [UOP_OPCODE_W -1:0] UOP_OPCODE_OUTPUT_FROM_NARROW = 5'd3; +localparam [UOP_OPCODE_W -1:0] UOP_OPCODE_OUTPUT_FROM_NARROW = 5'd03; /* CRT tells from which of the dual MMM to read * NPQ specifies the width of the operand * AUX is don't care * LADDER is don't care - * source and destination WIDE are don't care */ -localparam [UOP_OPCODE_W -1:0] UOP_OPCODE_COPY_CRT_Y2X = 5'd4; -localparam [UOP_OPCODE_W -1:0] UOP_OPCODE_COPY_LADDERS_X2Y = 5'd5; -localparam [UOP_OPCODE_W -1:0] UOP_OPCODE_CROSS_LADDERS_X2Y = 5'd7; +localparam [UOP_OPCODE_W -1:0] UOP_OPCODE_COPY_CRT_Y2X = 5'd04; +localparam [UOP_OPCODE_W -1:0] UOP_OPCODE_COPY_LADDERS_X2Y = 5'd05; +localparam [UOP_OPCODE_W -1:0] UOP_OPCODE_CROSS_LADDERS_X2Y = 5'd06; /* CRT is don't care * NPQ specifies the width of the operand * AUX is don't care * LADDER is don't care */ -localparam [UOP_OPCODE_W -1:0] UOP_OPCODE_MODULAR_MULTIPLY = 5'd8; +localparam [UOP_OPCODE_W -1:0] UOP_OPCODE_MODULAR_MULTIPLY = 5'd07; /* CRT is don't care * NPQ specifies the width of the operand * AUX = AUX_2 forces B input to 1 (AUX_1 reads from source NARROW as usual) * LADDER specifies Montgomery ladder mode */ -localparam [UOP_OPCODE_W -1:0] UOP_OPCODE_MODULAR_SUBTRACT = 5'd9; +localparam [UOP_OPCODE_W -1:0] UOP_OPCODE_MODULAR_SUBTRACT = 5'd08; /* CRT is don't care * NPQ specifies the width of the operand * AUX is don't care * LADDER is don't care */ -localparam [UOP_OPCODE_W -1:0] UOP_OPCODE_MODULAR_REDUCE_INIT = 5'd10; -localparam [UOP_OPCODE_W -1:0] UOP_OPCODE_MODULAR_REDUCE_PROC = 5'd11; +localparam [UOP_OPCODE_W -1:0] UOP_OPCODE_MODULAR_REDUCE_INIT = 5'd09; +localparam [UOP_OPCODE_W -1:0] UOP_OPCODE_MODULAR_REDUCE_PROC = 5'd10; /* CRT * NPQ * AUX @@ -70,7 +67,7 @@ localparam [UOP_OPCODE_W -1:0] UOP_OPCODE_MODULAR_REDUCE_PROC = 5'd11; */ -localparam [UOP_OPCODE_W -1:0] UOP_OPCODE_PROPAGATE_CARRIES = 5'd12; +localparam [UOP_OPCODE_W -1:0] UOP_OPCODE_PROPAGATE_CARRIES = 5'd11; /* CRT is don't care * NPQ specifies the width of the operand * AUX is don't care @@ -78,43 +75,52 @@ localparam [UOP_OPCODE_W -1:0] UOP_OPCODE_PROPAGATE_CARRIES = 5'd12; * source and destination WIDE are don't care */ -localparam [UOP_OPCODE_W -1:0] UOP_OPCODE_MERGE_LH = 5'd13; +localparam [UOP_OPCODE_W -1:0] UOP_OPCODE_MERGE_LH = 5'd12; +/* + */ -localparam [UOP_OPCODE_W -1:0] UOP_OPCODE_REGULAR_MULTIPLY = 5'd14; +localparam [UOP_OPCODE_W -1:0] UOP_OPCODE_REGULAR_MULTIPLY = 5'd13; +/* + */ -localparam [UOP_OPCODE_W -1:0] UOP_OPCODE_REGULAR_ADD_UNEVEN = 5'd15; +localparam [UOP_OPCODE_W -1:0] UOP_OPCODE_REGULAR_ADD_UNEVEN = 5'd14; +/* + */ -localparam [UOP_OPCODE_W -1:0] UOP_OPCODE_LADDER_INIT = 5'd16; -localparam [UOP_OPCODE_W -1:0] UOP_OPCODE_LADDER_STEP = 5'd17; +localparam [UOP_OPCODE_W -1:0] UOP_OPCODE_LADDER_INIT = 5'd15; +localparam [UOP_OPCODE_W -1:0] UOP_OPCODE_LADDER_STEP = 5'd16; /* CRT is don't care * NPQ is don't care * AUX is don't care * LADDER is don't care - * WIDE and NARROW are don't care */ +// // CRT +// localparam [UOP_CRT_W -1:0] UOP_CRT_X = 1'b0; localparam [UOP_CRT_W -1:0] UOP_CRT_Y = 1'b1; localparam [UOP_CRT_W -1:0] UOP_CRT_DNC = 1'bX; +// // NPQ +// localparam [UOP_NPQ_W -1:0] UOP_NPQ_N = 1'b0; localparam [UOP_NPQ_W -1:0] UOP_NPQ_PQ = 1'b1; localparam [UOP_NPQ_W -1:0] UOP_NPQ_DNC = 1'bX; +// // AUX +// localparam [UOP_AUX_W -1:0] UOP_AUX_1 = 1'b0; localparam [UOP_AUX_W -1:0] UOP_AUX_2 = 1'b1; localparam [UOP_AUX_W -1:0] UOP_AUX_DNC = 1'bX; +// // LADDER +// localparam [UOP_LADDER_W -1:0] UOP_LADDER_00 = 2'b00; localparam [UOP_LADDER_W -1:0] UOP_LADDER_11 = 2'b11; localparam [UOP_LADDER_W -1:0] UOP_LADDER_D = 2'b01; localparam [UOP_LADDER_W -1:0] UOP_LADDER_PQ = 2'b10; localparam [UOP_LADDER_W -1:0] UOP_LADDER_DNC = 2'bXX; - - -// SEL -localparam [UOP_SEL_W -1:0] UOP_SEL_DNC_ALL = {4{BANK_DNC}}; |