You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

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

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.06 08:08:21