Reputation: 63
I have this few code lines in my Verilog/SystemVerilog,
parameter DATA_SZ=45;
reg [DATA_SZ-1:0] r_data;
initial r_data = 45'h1F_A4A3A2A1A0;
// How to replace it by 'initial r_data = (DATA_SZ)'h1F_A4A3A2A1A0;?
Now how can I make it more scalable by replace 45 by DATA_SZ? Looks like it fails the syntax. Could anybody suggest some good method? Thanks!
Upvotes: 0
Views: 1303
Reputation: 42748
There is no need to do this. You can just write
initial r_data = 'h1F_A4A3A2A1A0;
And the literal will be implicitly 0 padded on the right before being assigned to r_data
. If you want to be pedantic, you can write an explicit cast
initial r_data = DATA_SZ'('h1F_A4A3A2A1A0);
Upvotes: 0