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

相关推荐
沐欣工作室_lvyiyi7 小时前
基于FPGA的电容测试仪设计与实现(论文+源码)
fpga开发·毕业设计·电容测试仪·电阻电容电感测试
GateWorld13 小时前
FPGA内部模块详解之三 FPGA的“记忆细胞”——嵌入式块内存(Block RAM)
fpga开发·block ram
良许Linux14 小时前
ASIC的设计和制造
单片机·嵌入式硬件·fpga开发·程序员·嵌入式·制造
minglie114 小时前
Amaranth HDL
python·fpga开发
s090713618 小时前
保姆级教程一:ZYNQ-7030开发板安装/烧录Linux系统详细指南(小白必看)
linux·fpga开发·系统安装·zynq
lf28248143119 小时前
03 xilinx除法IP核的使用
fpga开发
智能物联网开发19 小时前
机器人电子皮肤系统开发:36通道柔性触觉阵列 + FPGA高速采集
fpga开发·计算机外设·嵌入式·fpga数据采集
沐欣工作室_lvyiyi20 小时前
基于FPGA的智能音箱设计(论文+源码)
fpga开发·毕业设计·智能音箱
我爱C编程21 小时前
【硬件片内测试】基于FPGA的4FSK扩频通信链路测试,包含帧同步,定时点,扩频伪码同步,信道,误码统计
fpga开发·帧同步·定时点·扩频通信·扩频伪码同步·4fsk
GateWorld1 天前
Lattice FPGA开发全攻略--十余种输出文件格式及其区别
fpga开发·lattice·fpga开发工具