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

相关推荐
luoganttcc6 小时前
Taalas 将人工智能模型蚀刻到晶体管上,以提升推理能力
人工智能·fpga开发
国科安芯7 小时前
医疗成像设备系统电源芯片国产替代可行性研究
网络·单片机·嵌入式硬件·fpga开发·硬件架构
不是AI7 小时前
【电路仿真】【Logisim】二、7408 TTL
单片机·fpga开发
江蘇的蘇8 小时前
基于FPGA开发应用SATA硬盘
fpga开发
LCMICRO-1331084774614 小时前
长芯微LDM63085完全P2P替代ADM2483,是一款基于数字隔离技术的高可靠性的半双工隔离RS-485收发器
单片机·嵌入式硬件·fpga开发·硬件工程·dsp开发
博览鸿蒙16 小时前
芯片设计过程中常见的挑战有哪些?
fpga开发
LCMICRO-1331084774616 小时前
长芯微LSC3490完全P2P替代MAX3490,3.3V 高静电防护 10M 全双工 RS485/RS422 收发器
单片机·嵌入式硬件·fpga开发·硬件工程·dsp开发
二十画~书生17 小时前
攻克BGA扇出+高速信号难题—逻辑派FPGA-G1开发板6层PCB全流程设计总结
嵌入式硬件·fpga开发·硬件工程·pcb工艺
Yyq1302086968217 小时前
实时时钟和日历电路-MS85163-替PCF8563等
单片机·嵌入式硬件·fpga开发
悲喜自渡72118 小时前
FPGA学习(自用)
fpga开发