sbox55.v
来自「用VERILOG语言实现的数据加密标准代码,在QUARTUS5.1上仿真过」· Verilog 代码 · 共 86 行
V
86 行
module sbox55(sin,sout);
input [0:5] sin;
output [0:3] sout;
reg [0:3] sout;
always @(sin)
begin
case ({sin[0],sin[5]})
2'b00:
case (sin[1:4])
4'h0: sout=4'h2;
4'h1: sout=4'hc;
4'h2: sout=4'h4;
4'h3: sout=4'h1;
4'h4: sout=4'h7;
4'h5: sout=4'ha;
4'h6: sout=4'hb;
4'h7: sout=4'h6;
4'h8: sout=4'h8;
4'h9: sout=4'h5;
4'ha: sout=4'h3;
4'hb: sout=4'hf;
4'hc: sout=4'hd;
4'hd: sout=4'h0;
4'he: sout=4'he;
4'hf: sout=4'h9;
endcase
2'b01:
case (sin[1:4])
4'h0: sout=4'he;
4'h1: sout=4'hb;
4'h2: sout=4'h2;
4'h3: sout=4'hc;
4'h4: sout=4'h4;
4'h5: sout=4'h7;
4'h6: sout=4'hd;
4'h7: sout=4'h1;
4'h8: sout=4'h5;
4'h9: sout=4'h0;
4'ha: sout=4'hf;
4'hb: sout=4'ha;
4'hc: sout=4'h3;
4'hd: sout=4'h9;
4'he: sout=4'h8;
4'hf: sout=4'h6;
endcase
2'b10:
case (sin[1:4])
4'h0: sout=4'h4;
4'h1: sout=4'h2;
4'h2: sout=4'h1;
4'h3: sout=4'hb;
4'h4: sout=4'ha;
4'h5: sout=4'hd;
4'h6: sout=4'h7;
4'h7: sout=4'h8;
4'h8: sout=4'hf;
4'h9: sout=4'h9;
4'ha: sout=4'hc;
4'hb: sout=4'h5;
4'hc: sout=4'h6;
4'hd: sout=4'h3;
4'he: sout=4'h0;
4'hf: sout=4'he;
endcase
2'b11:
case (sin[1:4])
4'h0: sout=4'hb;
4'h1: sout=4'h8;
4'h2: sout=4'hc;
4'h3: sout=4'h7;
4'h4: sout=4'h1;
4'h5: sout=4'he;
4'h6: sout=4'h2;
4'h7: sout=4'hd;
4'h8: sout=4'h6;
4'h9: sout=4'hf;
4'ha: sout=4'h0;
4'hb: sout=4'h9;
4'hc: sout=4'ha;
4'hd: sout=4'h4;
4'he: sout=4'h5;
4'hf: sout=4'h3;
endcase
endcase
end
endmodule
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?