移位寄存器使用
/*
邊緣檢測、濾波等相關模板的移位寄存器
假設在rom中文件夾下以wod中的數據存放,列加行的值作為該 數的地址
現在每次取出3列數據為一組,如第一列abc,第二例def,第三列ghi
使用shifter_register ip核來實現這種功能,可以利用這種方法實現流水線操作
*/
?
module left_right_register(input clk,input rst_n,output [7:0] shiftout0,output [7:0] shiftout1,output [7:0] shiftout2 ); wire shift_en; wire [7:0] cnt; wire [7:0] in; counter counter(.clk(clk),.rst_n(rst_n),.shift_en(shift_en),//輸出使能信號.cnt(cnt)//給rom地址信號 ); my_rom my_rom(.address(cnt),.clock(clk),.q(in)); shift_register shift_register(.clk(clk),.rst_n(rst_n),.in(in),. shift_en(shift_en),.shiftout0(shiftout0),.shiftout1(shiftout1),.shiftout2(shiftout2) );endmodule?
module counter(input clk,input rst_n,output reg shift_en,output reg [7:0]cnt);always@(posedge clk or negedge rst_n)if(!rst_n)begincnt<=0;shift_en<=0;endelse beginif(cnt>=16)//表示移位寄存器中的兩個fifo值已經移入begincnt<=cnt+1;shift_en<=1;endelsecnt<=cnt+1;endendmodule?
module shift_register(input clk,input rst_n,input [7:0] in,output shift_en,output [7:0] shiftout0,output [7:0] shiftout1,output [7:0] shiftout2 );wire [15:0] taps; assign shiftout0=shift_en?in:0; assign shiftout1=shift_en?taps[7:0]:0; assign shiftout2=shift_en?taps[15:8]:0;my_shift my_shift(.clock(clk),.shiftin(in),//rom提供的初始數據.shiftout(),.taps(taps));?
總結
- 上一篇: 总结:K8s之HPA
- 下一篇: arduino声音传感器与二极管_怎样使