在Verilog中,我有一個module name(input data,..., output...);
數據只是一個位輸入,我需要它顯示到reg [288:0] data_tmp;
來比較這些位。如何將數據(輸入)傳輸到reg?Verilog:讀取1位輸入並將其寫入288位寄存器
我試圖處理它類似於C的陣列使用for循環像這樣:
for(i=0; i<288; i=i+1) begin
data_tmp[i]=data;
end
但是它似乎沒有采取任何值從數據或它覆蓋它們。
實際代碼:
module inspector (
input rst_n, data, clk,
output total_cnt, skype_cnt, ftp_cnt, https_cnt, telnet_cnt, ssh_cnt, snmp_cnt, smtp_cnt,
nntp_cnt, telnet_session, skype_session, ssh_session
);
output [31:0] total_cnt;
output [7:0] skype_cnt;
output [7:0] ftp_cnt;
output [7:0] https_cnt;
output [7:0] telnet_cnt;
output [7:0] ssh_cnt;
output [7:0] snmp_cnt;
output [7:0] smtp_cnt;
output [7:0] nntp_cnt;
output [7:0] telnet_session;
output [7:0] skype_session;
output [7:0] ssh_session;
localparam INIT = 0;
localparam DATA = 1;
localparam PORT = 2;
localparam TOTAL = 3;
reg [287:0] data_tmp;
reg [3:0] Start_sequence = 32'hA5A5A5A5;
reg [1:0] state;
integer i;
always @(posedge clk)
if (rst_n) begin
total_cnt_tmp = 8'h00;
....
ssh_session_tmp = 8'h00;
end else begin
case (state)
INIT : begin
for(i=0; i<288; i=i+1) begin
data_tmp[i]=data;
end
if (data_tmp[31:0] == Start_sequence) begin
state <= DATA;
end else begin
state <= INIT;
end
end
.....
你是如何植入的?請再展示一些代碼。 for-loop應該可以工作。複製器('data_tmp = {288 {data}};')和SystemVerilog'foreach'是其他選項。 – Greg