Xilinx Simulink 中的时序信号理解

发布于 2024-11-06 12:54:08 字数 694 浏览 3 评论 0原文

我在理解 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

╭⌒浅淡时光〆 2024-11-13 12:54:08

如果您希望输出仅在“有效”时发生变化,则可以在输出引脚上使用启用寄存器,并将启用信号连接到与进入寄存器的值同时在单个时钟周期内保持高电平的信号是您想要在输出中呈现的内容。

在您的情况下,您的“有效”信号在交替时钟周期上在“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 every n cycles and use the reset pulse as a "valid" signal.

仅此而已 2024-11-13 12:54:08
Input stream -------------> AddSub -> register -> output stream
Input stream -> register -> AddSub    register
                                      register
                           counter -> register(enable)

将输入流和延迟1个周期的输入流相加。使用 1 位计数器(或 T 触发器)来启用加法器输出上的寄存器。

这就是您要找的吗?

另外,在运行复杂系统时“管理”这个是什么意思?此构造的 verilog 或 vhdl 非常简单,可以用来代替系统生成器块。

//note: initialization/reset and limit handling is not included and would need to be considered.
always@(posedge clk)
begin
    databits_1dly <= databits;  //create a once cycle delayed version of databits
    sum <= databits_1dly + databits; //adder
    every_other <= !every_other //t flip flop.
    if (every_other)  //invert if you want the other every_other
       sum_every_other <= sum
end
Input stream -------------> AddSub -> register -> output stream
Input stream -> register -> AddSub    register
                                      register
                           counter -> register(enable)

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.

//note: initialization/reset and limit handling is not included and would need to be considered.
always@(posedge clk)
begin
    databits_1dly <= databits;  //create a once cycle delayed version of databits
    sum <= databits_1dly + databits; //adder
    every_other <= !every_other //t flip flop.
    if (every_other)  //invert if you want the other every_other
       sum_every_other <= sum
end
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文