[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真舒服

相关推荐
晓晓暮雨潇潇1 小时前
Serdes专题(1)Serdes综述
fpga开发·serdes·diamond·latticeecp3
XINVRY-FPGA1 小时前
XCKU15P-2FFVA1760I AMD 赛灵思 Xilinx Kintex UltraScale+ FPGA
arm开发·嵌入式硬件·阿里云·fpga开发·云计算·硬件工程·fpga
嵌入式-老费10 小时前
Zynq开发实践(FPGA之第一个vivado工程)
fpga开发
贝塔实验室10 小时前
两种常用的抗单粒子翻转动态刷新方法
论文阅读·经验分享·笔记·科技·学习·程序人生·fpga开发
minglie120 小时前
zynq arm全局计时器和私有定时器
fpga开发
章咸鱼121381 天前
nios simple soket tcp在面对arp洪流时崩溃的处理
fpga开发·tcp
望获linux1 天前
望获实时Linux:亚微秒级时间控制
linux·运维·服务器·计算机·fpga开发·嵌入式软件·飞腾
嵌入式-老费2 天前
Zynq开发实践(FPGA之spi实现)
fpga开发
太爱学习了2 天前
FPGA雷达信号处理之:自适应门限阈值
fpga开发·信号处理
国科安芯2 天前
前沿探索:RISC-V 架构 MCU 在航天级辐射环境下的可靠性测试
网络·单片机·嵌入式硬件·fpga开发·硬件架构·risc-v