您将如何在 Verilog 或 VHDL 中实现该数字逻辑?

发布于 2024-07-13 06:18:58 字数 856 浏览 5 评论 0原文

我发布了答案到 < a href="https://stackoverflow.com/questions/480405/finding-the-next-in-round-robin-scheduling-by-bit-twiddling">另一个 stackoverflow 问题,需要一些数字逻辑来解决可以用 Verilog 或 VHDL 实现,以便可以编程到 FPGA 中。

如何用 Verilog、VHDL 或任何其他硬件描述语言实现以下逻辑图?

编号框代表字段中的位。 每个字段都有K位,并且当前掩码的位将由计算机系统提供(使用锁存寄存器或等效物)。 next 中的位将被读回同一计算机系统。

替代文本 http://img145.imageshack.us/img145/5125/bitshifterlogicdiagramkn7.jpg< /a>

另请参阅:此 stackoverflow问题

I posted an answer to another stackoverflow question which requires some digital logic to be implemented in Verilog or VHDL so that it can be programmed into an FPGA.

How would you implement the following logic diagram in Verilog, VHDL, or any other hardware description language?

The numbered boxes represent bits in a field. Each field has K bits, and the bits for current and mask will be provided by a computer system (using a latched register or equivalent). The bits in next will be read back into that same computer system.

alt text http://img145.imageshack.us/img145/5125/bitshifterlogicdiagramkn7.jpg

See also: this stackoverflow question

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

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

发布评论

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

评论(1

葬花如无物 2024-07-20 06:18:58

像这样的东西吗?

module scheduler
 #( parameter K = 10 )
  (
   input wire [K:1] current,
   input wire [K:1] mask,
   output reg [K:1] next
   );

   reg [K:1] a;
   reg [K:1] b;

   //'[i+1]' busses that wrap.
   // eg, for a 4-bit bus...
   // a[i]:        a[4],a[3],a[2],a[1] (obviously...)
   // a_wrap[i]:   a[1],a[4],a[3],a[2] 
   wire [K:1] mask_wrap    = { mask[1],mask[K:2] };
   wire [K:1] a_wrap       = { a[1], a[K:2] };
   wire [K:1] current_wrap = { current[1], current[K:2] };

   integer i;
   always @( * ) begin
      for( i=1; i<=K; i=i+1 ) begin
         a[i] = ~current_wrap[i] && b[i];
         b[i] = a_wrap[i] || mask_wrap[i];
         next[i] = ~a[i] && mask_wrap[i];
      end
   end


endmodule

(免责声明:有缺陷但不是模拟)

Something like this?

module scheduler
 #( parameter K = 10 )
  (
   input wire [K:1] current,
   input wire [K:1] mask,
   output reg [K:1] next
   );

   reg [K:1] a;
   reg [K:1] b;

   //'[i+1]' busses that wrap.
   // eg, for a 4-bit bus...
   // a[i]:        a[4],a[3],a[2],a[1] (obviously...)
   // a_wrap[i]:   a[1],a[4],a[3],a[2] 
   wire [K:1] mask_wrap    = { mask[1],mask[K:2] };
   wire [K:1] a_wrap       = { a[1], a[K:2] };
   wire [K:1] current_wrap = { current[1], current[K:2] };

   integer i;
   always @( * ) begin
      for( i=1; i<=K; i=i+1 ) begin
         a[i] = ~current_wrap[i] && b[i];
         b[i] = a_wrap[i] || mask_wrap[i];
         next[i] = ~a[i] && mask_wrap[i];
      end
   end


endmodule

(Disclaimer: linted but not simulated)

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文