Transform() 함수 내부에서 동작하는 여러 모듈 중 하나.
* RTL
// rotate right
module calc_RR(
input wire [8*8-1:0] x,
input wire [4:0] n,
output wire [8*8-1:0] calc_x
);
assign calc_x = (x>>n) | (x<<(64-n)); // 64bit
endmodule
(x>>13) | (x<<(64-13))
= (x>>13) | (x<<51)
* TestBench
`timescale 1ns/1ps
module tb_define;
reg [8*8-1:0] i_msg;
reg [4:0] i_cnt;
wire [8*8-1:0] o_result;
calc_RR U0_RR (
.x ( i_msg ),
.n ( i_cnt ),
.calc_x ( o_result )
);
// Generate inputs
initial begin
i_msg = 'b1100_1100;
i_cnt = 'd13;
#(50);
$finish;
end
endmodule
출력 결과
13회 오른쪽으로 회전 이동을 한 결과이다.
입력값: 0000_0000_0000_0000__0000_0000_0000_0000__0000_0000_0000_0000_0000_0000_1100_1100
출력값: 0000_0110_0110_0000__0000_0000_0000_0000__0000_0000_0000_0000__0000_0000_0000_0000
x>>13 : 0000_0000_0000_0000__0000_0000_0000_0000__0000_0000_0000_0000__0000_0000_0000_0000
x<<51 : 0000_0110_0110_0000__0000_0000_0000_0000__0000_0000_0000_0000__0000_0000_0000_0000
---------------------------------------------------------------------------------------------------------------------
or연산 : 0000_0110_0110_0000__0000_0000_0000_0000__0000_0000_0000_0000__0000_0000_0000_0000
'Hardware Security' 카테고리의 다른 글
[SHA256] FF 모듈 (0) | 2022.02.23 |
---|---|
FF 구성 모듈 (0) | 2022.02.17 |
[SHA256] FF() 구성 모듈 - (1): RR, Sigma0, Sigma1 (0) | 2022.02.04 |
[SHA256][Verilog HDL] 코드 만들기 (0) | 2021.11.18 |