Uwe Bonnes
2007-03-02 14:44:33 UTC
Hello,
is there an easier way to initialize an verilog array of registers with the
values from a string define.
At least the way I do it below compiles in cver and icarus:
`define CNT_RST_COOKIE "CNT_RST"
module test();
reg [7:0] rst_cookie[0:6];
reg [55:0] string;
integer i, j;
initial
begin
string = `CNT_RST_COOKIE;
for (i=0; i < 7; i = i+1)
begin
rst_cookie[i] = 8'h0;
for (j=0; j<8; j = j+1)
rst_cookie[i] =rst_cookie[i] <<1 |string[8*(i+i)-1+j];
end
end
endmodule // test
Thanks
is there an easier way to initialize an verilog array of registers with the
values from a string define.
At least the way I do it below compiles in cver and icarus:
`define CNT_RST_COOKIE "CNT_RST"
module test();
reg [7:0] rst_cookie[0:6];
reg [55:0] string;
integer i, j;
initial
begin
string = `CNT_RST_COOKIE;
for (i=0; i < 7; i = i+1)
begin
rst_cookie[i] = 8'h0;
for (j=0; j<8; j = j+1)
rst_cookie[i] =rst_cookie[i] <<1 |string[8*(i+i)-1+j];
end
end
endmodule // test
Thanks
--
Uwe Bonnes ***@elektron.ikp.physik.tu-darmstadt.de
Institut fuer Kernphysik Schlossgartenstrasse 9 64289 Darmstadt
--------- Tel. 06151 162516 -------- Fax. 06151 164321 ----------
Uwe Bonnes ***@elektron.ikp.physik.tu-darmstadt.de
Institut fuer Kernphysik Schlossgartenstrasse 9 64289 Darmstadt
--------- Tel. 06151 162516 -------- Fax. 06151 164321 ----------