[HDLBits] Rule90

Rule 90 is a one-dimensional cellular automaton with interesting properties.

The rules are simple. There is a one-dimensional array of cells (on or off). At each time step, the next state of each cell is the XOR of the cell's two current neighbours. A more verbose way of expressing this rule is the following table, where a cell's next state is a function of itself and its two neighbours:

Left Center Right Center's next state
1 1 1 0
1 1 0 1
1 0 1 0
1 0 0 1
0 1 1 1
0 1 0 0
0 0 1 1
0 0 0 0

(The name "Rule 90" comes from reading the "next state" column: 01011010 is decimal 90.)

In this circuit, create a 512-cell system (q[511:0]), and advance by one time step each clock cycle. The load input indicates the state of the system should be loaded with data[511:0]. Assume the boundaries (q[-1] and q[512]) are both zero (off).

复制代码
module top_module(
    input clk,
    input load,
    input [511:0] data,
    output [511:0] q ); 
    always@(posedge clk) begin
        if(load)
            q<=data;
        else
            q<={1'b0,q[511:1]}^{q[510:0],1'b0};
        //verilog最好的地方就是支持整个数组批量运算
    end
endmodule

verilog真舒服

相关推荐
cici158746 小时前
基于FPGA的任意四位除法器设计与实现
fpga开发
guygg8810 小时前
基于STM8S的FreeModbus协议移植指南
fpga开发
kanhao10011 小时前
从 Vectorless 到 SAIF 再到板级实测:HLS Kernel 功耗估计全流程实战
嵌入式硬件·fpga开发
yongui4783413 小时前
基于FPGA的频率计与串口通信系统设计与实现
fpga开发
FPGA_ADDA13 小时前
国产复旦微FPGA+DSP 6U VPX处理板
fpga开发·全国产·复旦微690t·ft6678dsp·6u vpx板卡·jfm7vx690t36
fengfuyao98515 小时前
基于FPGA的简易电子密码锁设计(Verilog实现)
fpga开发
北城笑笑16 小时前
Frontend 与 FPGA 深度融合实战解析:从技术协同到多场景落地( 前端和现场可编程门阵列 )
前端·websocket·3d·vue·fpga
hoiii18716 小时前
104键PS2接口标准键盘C语言驱动程序
c语言·fpga开发·计算机外设
jllllyuz1 天前
基于FPGA的通信信号源设计
fpga开发
Saniffer_SH1 天前
【每日一题】一台可编程的PCIe 6.0主机 + 一套自动化CTS验证平台 + 一个轻量级链路分析系统
运维·服务器·测试工具·fpga开发·自动化·计算机外设·硬件架构