Xilinx Simulink 中的时序信号理解
我在理解 Simulink(Xilink 库)中定时信号的概念时遇到一些困难。
我将用一个例子来解释,
假设你有一个串行比特流,并且你想取奇数位和偶数位的和,
所以你可能会编写这样的Matlab代码:
Data_Bits=[1 2 3 0 4 5 1 2 0 9];
Sum_Bits=[];
for i=1:length(Data_Bits)/2
Sum_Bits=[Sum_Bits Data_Bits(2*i-1)+Data_Bits(2*i)]
end
假设一会儿,我们忽略所有的优化和角点除了某些情况外,此代码可能无法工作。
假设我们必须在硬件中实现这一点,Data_Bits
会连续出现, 所以你基本上要等待 2 个时钟周期来获取 2 个输入位并将其相加并生成输出。
因此,每 2 个时钟周期就有一个输出。
那么是否可以在 Xilinx 中管理定时信号,以便我们获得有效的输出。
所以我不想在输出时得到中间结果。
我们怎样才能做到这一点?我正在考虑使用某种带有自由运行时钟(计数器)的启用输入。
但是,在设计一个非常复杂的系统时,我们如何管理这个问题呢?
我在硬件设计方面没有太多经验。因此,如果我的问题危险地接近简单和愚蠢,我对我的智力感到抱歉。
感谢您阅读
基兰
I am having some trouble understanding the concept of Timing Signals in Simulink (Xilink Library).
I will explain with an example,
Suppose you have a serial Bitstream and you would like to take the sum of Odd and Even Bit,
So you would probably write Matlab Code something like this:
Data_Bits=[1 2 3 0 4 5 1 2 0 9];
Sum_Bits=[];
for i=1:length(Data_Bits)/2
Sum_Bits=[Sum_Bits Data_Bits(2*i-1)+Data_Bits(2*i)]
end
Suppose for a moment, we ignore all the optimization and corner cases aside, where this code might not work.
Assuming that we have to implement this in a hardware, the Data_Bits
is coming serially,
so you basically wait for 2 clock cycles to get 2 input bits and add it and generate the output.
So for every 2 Clock cycles, you have a an output.
So is it possible to manage the Timing Signal in Xilinx so that we have valid output.
So I donot want to have a intermediate result at the output.
How can we achieve that ? I am thinking of using some kind of an enable input with a free running Clock(Counter).
But how do we manage this while designing a really complicated system ?
I donot have so much experience with Hardware design. So if my question is dangerously bordering SIMPLE and being STUPID, I am sorry for my intelligence.
Thanks for reading
Kiran
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
如果您希望输出仅在“有效”时发生变化,则可以在输出引脚上使用启用寄存器,并将启用信号连接到与进入寄存器的值同时在单个时钟周期内保持高电平的信号是您想要在输出中呈现的内容。
在您的情况下,您的“有效”信号在交替时钟周期上在“1”和“0”之间切换,因此您可以仅使用触发器,其输出通过反相器反馈。 (在 davidd 的代码中,您可以在用
//tflipflop
注释的行上看到这一点)。如果您有一个更复杂的系统,仅在
n
周期内有效一次,则可以使用每n
周期重置一次的计数器,并将重置脉冲用作“有效”脉冲信号。If you want your output to only change when it is "valid", you use an enabled register at the output pin with the enable signal connected to something which is high for a single clock tick at the same time as the value going into the register is the one you want to present at the output.
In your case, your "valid" signal toggles between '1' and '0' on alternate clock cycles, so you can just use a flipflop with it's output fed back through an inverter. (In davidd's code, you can see this on the line commented with
//tflipflop
).If you had a more complex system which is only valid once in
n
cycles, you can use a counter which resets everyn
cycles and use the reset pulse as a "valid" signal.将输入流和延迟1个周期的输入流相加。使用 1 位计数器(或 T 触发器)来启用加法器输出上的寄存器。
这就是您要找的吗?
另外,在运行复杂系统时“管理”这个是什么意思?此构造的 verilog 或 vhdl 非常简单,可以用来代替系统生成器块。
add the input stream and the input stream delayed by 1 cycle. use a 1 bit counter (or a T-flip flop) to enable a register on the output of the adder.
Is that what you are looking for?
Also what do you mean by "managing" this while running a complex system? The verilog or vhdl for this construct would be very simple and could be used in place of system generator blocks.