Simulink 2015a实现SHA256:循环迭代变量复用方案求解
Simulink 2015a实现SHA256哈希函数的循环迭代问题
我需要在Simulink 2015a中实现SHA256哈希函数,且尽可能避免使用自定义函数。此前尝试用Delay模块,但该模块会导致a-h初始化变量出现延迟(例如T1变为0)。目前首次迭代可输出正确结果,但不知道如何让循环使用新赋值的变量重启迭代。
对应的MATLAB参考代码如下:
% H = 1x8 const % constK = 1x64 const a = H(1); b = H(2); c = H(3); d = H(4); e = H(5); f = H(6); g = H(7); h = H(8); % Calc H1 subsystem in Simulink for t = 1:64 K = constK(t); temp1 = addMsgSch(h, cSigma1(e), choice(e, f, g), K, W(t)); temp2 = addMsgSch(cSigma0(a), majority(a, b, c)); h = g; g = f; f = e; e = addMsgSch(d, temp1); d = c; c = b; b = a; a = addMsgSch(temp1, temp2); end % addMsgSch(a, b... z) = a + b + ... + z;
相关模块说明:
- For循环模块:占位常量设置为1
- 用于获取a...g的子系统模块
- 首次迭代输出结果正确的模块
我的核心问题:如何让循环使用新赋值的变量(重新)启动迭代?
内容的提问来源于stack exchange,提问作者simulinkquestion
相关产品推荐
相关产品推荐

