I am trying to code the RC6 (Rivest cipher 6) algorithm using Verilog. The algorithm requires addition, subtraction and multiplication in modulo 232. I've been told that I can use conventional +, -, * and / operators in Verilog if I define <stdint.h> in the header and use variables of type uint32_t.
I've pasted my attempt below in defining the header and the variable types, but I keep getting syntax errors. Could someone help me understand if this is the correct way to do modulo 232 arithmetic in Verilog and what is the required syntax?
#include <stdint.h>;
module RC6_encryption( in, clk, out );
input [0:127] in ;
input clk;
output reg [0:127] out;
uint32_t wire [0:31] A;
uint32_t wire [0:31] B;
uint32_t wire [0:31] C;
uint32_t wire [0:31] D;
//<statements>
assign A = in[0:31] ;
assign B = in[32:63] ;
assign C = in[64:95] ;
assign D = in[96:127] ;
endmodule
1 Answer 1
Your assign A = in[0:31];
works in fact as a modulo function.
Since the higher bits ( in[32:127] ) are truncated all you get is a reminder of the operation
in / 2^32
as you wanted.
Explore related questions
See similar questions with these tags.
#include
is illegal syntax for Verilog. If stdint.h is C code, that will also be illegal syntax. \$\endgroup\$