Это аналогично скажем модулю расчетчика - вот его код на верилоге:
`define REV(x) { x[31],x[30],x[29],x[28],x[27],x[26],x[25],x[24],x[23],x[22],x[21],x[20],x[19],x[18],x[17],x[16],x[15],x[14],x[13],x[12],x[11],x[10],x[9],x[8],x[7],x[6],x[5],x[4],x[3],x[2],x[1],x[0] }
`define REVO(x) { x[0],x[1],x[2],x[3],x[4],x[5],x[6],x[7],x[8],x[9],x[10],x[11],x[12],x[13],x[14],x[15],x[16],x[17],x[18],x[19],x[20],x[21],x[22],x[23],x[24],x[25],x[26],x[27],x[28],x[29],x[30],x[31] }
`define E0(x) ( {x[1:0],x[31:2]} ^ {x[12:0],x[31:13]} ^ {x[21:0],x[31:22]} )
`define E1(x) ( {x[5:0],x[31:6]} ^ {x[10:0],x[31:11]} ^ {x[24:0],x[31:25]} )
`define S0(x) ( { x[6:4] ^ x[17:15], {x[3:0], x[31:7]} ^ {x[14:0],x[31:18]} ^ x[31:3] } )
`define S1(x) ( { x[16:7] ^ x[18:9], {x[6:0], x[31:17]} ^ {x[8:0],x[31:19]} ^ x[31:10] } )
`define CH(x,y,z) ( (z) ^ ((x) & ((y) ^ (z))) )
`define MAJ(x,y,z) ( ((x) & (y)) | ((z) & ((x) | (y))) )
module bitcmos__hkern32(clk, al, el, k, s, s5, s5n, s8, s8n, scanen, scanenn,
scanin, vmog, win, a, e);
input [0:6] clk;
input [0:31] al;
input [0:31] el;
input [0:31] k;
input [0:5] s;
input [0:4] s5;
input [0:4] s5n;
input [0:7] s8;
input [0:7] s8n;
input scanen;
input scanenn;
input scanin;
input [0:3] vmog;
input [0:31] win;
output [0:31] a;
output [0:31] e;
wire [0:31] w;
reg [31:0] w0, w1, w2, w3, w4, w5, w6, w7, w8, w9, w10, w11, w12, w13, w14, w15;
reg [31:0] ar, br, cr, dr, er, fr, gr, hr, agwk, ds, kr;
initial begin
w0 = 32'h00000000; w1 = 32'h00000000; w2 = 32'h00000000; w3 = 32'h00000000; w4 = 32'h00000000; w5 = 32'h00000000; w6 = 32'h00000000; w7 = 32'h00000000;
w8 = 32'h00000000; w9 = 32'h00000000; w10 = 32'h00000000; w11 = 32'h00000000; w12 = 32'h00000000; w13 = 32'h00000000; w14 = 32'h00000000; w15 = 32'h00000000
;
ar = 32'h00000000; br = 32'h00000000; cr = 32'h00000000; dr = 32'h00000000; er = 32'h00000000; fr = 32'h00000000; gr = 32'h00000000; hr = 32'h00000000;
agwk = 32'h00000000; ds = 32'h00000000; kr = 32'h00000000;
end
always @(posedge clk) begin
/* Compute round expander values */
w0 <= w1; w1 <= w2; w2 <= w3; w3 <= w4; w4 <= w5; w5 <= w6; w6 <= w7; w7 <= w8; w8 <= w9; w9 <= w10; w10 <= w11; w11 <= w12; w12 <= w13; w13 <= w14; w14 <= w15;
if (s[0]) w15 <= `REV(win); else w15 <= w0 + `S0(w1) + w9 + `S1(w14);
/* Compute HGFE */
hr <= gr; gr <= fr; fr <= er;
if (s[2]) er <= `REV(el); else er <= `E1(er) + `CH(er, fr, gr) + agwk;
/* Compute ABCD */
dr <= cr; cr <= br; br <= ar;
if (s[4]) ar <= `REV(al); else ar <= `E0(ar) + `MAJ(ar, br, cr) + ds;
/* PREPARE */
kr <= `REV(k);
ds <= er - cr;
agwk <= w15 + ar + gr + kr;
end
assign a = `REVO(ar);
assign e = `REVO(er);
endmodule /* bitcmos__hkern32 */
Какая красота с вычитанием! А код заквочу целиком, чтобы не пропал с форума случайно