blob: b904795af7f696093de079420908ef26a62b075f (
plain) (
tree)
|
|
module modexpng_mmm_col_index
(
clk,
index_last,
fsm_state_next,
col_index,
col_index_done,
col_index_zero,
col_index_next,
col_index_prev
);
//
// Includes
//
//`include "modexpng_parameters.vh"
//`include "modexpng_parameters_x8.vh"
`include "modexpng_mmm_fsm.vh"
//
// Parameters
//
parameter INDEX_WIDTH = 6;
//
// Ports
//
input clk;
input [ INDEX_WIDTH-1:0] index_last;
input [FSM_STATE_WIDTH-1:0] fsm_state_next;
output [ INDEX_WIDTH-4:0] col_index;
output col_index_done;
output [ INDEX_WIDTH-4:0] col_index_zero;
output [ INDEX_WIDTH-4:0] col_index_next;
output [ INDEX_WIDTH-4:0] col_index_prev;
//
// Registers
//
reg [INDEX_WIDTH-4:0] col_index_reg;
reg [INDEX_WIDTH-4:0] col_index_last;
reg [INDEX_WIDTH-4:0] col_index_dly;
//
// Mapping
//
assign col_index = col_index_reg;
assign col_index_prev = col_index_dly;
//
// Handy Wires
//
assign col_index_done = col_index == col_index_last;
assign col_index_zero = {(INDEX_WIDTH-3){1'b0}};
assign col_index_next = col_index + 1'b1;
//
// Increment Logic
//
always @(posedge clk)
//
case (fsm_state_next)
//
FSM_STATE_MULT_SQUARE_COL_0_TRIG: begin
col_index_reg <= col_index_zero;
col_index_last <= index_last[INDEX_WIDTH-1:3];
end
//
FSM_STATE_MULT_SQUARE_COL_N_TRIG:
col_index_reg <= col_index_next;
//
endcase
//
// Delay Logic
//
always @(posedge clk)
//
col_index_dly <= col_index;
endmodule
|