| |
|
|
 |

Many of you already received communications about the move of the Cadence user community into cadence.com. And many of you have already joined, with over 4000 registrations in the first two weeks.The new Cadence Community enhances the ability of Cadence users to connect and collaborate. In addition to moving the community into cadence.com -- enabling single sign-on for community, Sourcelink and Cadence events -- the new site is organized around nine technology segments, giving you easy access to product information, training, forums and blogs. Some of the new features include: - Ability to respond to posts via e-mail
- Technology-specific blogs
- Latest Web 2.0 social networking capabilities
- Public profile options
- Private messaging
- Friends lists
Visit the new Cadence Community today at www.cadence.com/community and join the discussions! Registration note: Due to the scope of the enhancements and the new SSO registration system, we were not able to migrate existing cdnusers.org member accounts. So new registrations are required, but this enables a broader set of functionality we think you'll enjoy. Forum note: Under the guidance of forum moderators, we have taken the 20+ cdnusers.org forums and consolidated them into 11 forums on the new site. Posts have been brought over so you can leverage that posting history. CDNusers forums will be set to read only starting 7/30, and cdnusers.org will be redirected to the new community on 8/4.Best regards, Mike and Tom Michael A. Catrambone - Steering Committee Chairman Distinguished Engineer PCB/Mechanical UTStarcom, Inc. Tom Diederich Cadence Community Manager
|
|
|
| Home |
 |
 |
 |
|
 |
 |
Posting to forums is available to community members only. Login or Register |
|
| Author |
Messages |
|
sebastian Posts: 20 Online:
 |
| 1/02/2008 6:31 AM |
|
Hi @all,
I wish you a happy new year.
I have a question concerning dynamic array. I have to write a class method, which gets an integer (the CRC type, e.g. 8, 16, 32 ...) and a dynamic array, which contains the polynomial (binary). It should be possible to change the CRC type in each single testcase, for example:
[code] testclass tc; tc = new; tc.set_crc(8, 'b11110000); [/code]
The first problem was, that it was not possible to give the function a dynamic array, but I think I have solved the problem with the ref keyword in order to call it by reference. My whole function is listed below:
[code] function void Layer4::set_crc_properties(int crc_type, ref bit crc_polynomial[]); if ( crc_type + 1 != crc_polynomial.size() ) begin $display("crc_type and dimension of polynomial does not match!"); $display("Not assigning any value"); return; end this.crc_type = crc_type; this.crc_polynomial = new[this.crc_type+1](crc_polynomial); endfunction : set_crc_properties [/code]
Within this function it seems to work (but I'm not quite sure). The problem ist the code in the constructor-function, where I simple do the following:
[code] this.crc_polynomial = new⎝]('b0); [/code]
Here I get the following error message: [code] this.crc_polynomial = new⎝]('b0); | ncvlog: *E,TYPEERR (cc1100.sv,108|28): assignment operator type check failed. this.crc_polynomial = new⎝]('b0); | ncvlog: *E,DYNINI (cc1100.sv,108|36): is not a dynamic array. program worklib.cc1100 errors: 2, warnings: 0 [/code]
Without the ('b0) it works. Can you help me and tell me, whats going wrong here? Thank you very much for your help! Sebastian
|
|
|
|
sebastian Posts: 20 Online:
 |
| 1/02/2008 6:35 AM |
|
Me again. Sorry for the bad legibility! |
|
|
|
tpylant Posts: 87 Online:
 |
| 1/02/2008 8:06 AM |
|
First of all, I believe the formatting only works when you use the "Reply" button and not in the "Quick Reply".
As for your problem, what are you trying to do by passing the ('b0) to the DA constructor? According to LRM 5.6.1, The argument in the ( ) must be "a dynamic array of a data type equivalent to the array on the left-hand side, but it need not have the same size".
I assume you're trying to initialize the array to be 'b0. If that is the case, you don't have to do anything, since the type bit will initialize to 0 by default.
Tim |
|
|
|
sebastian Posts: 20 Online:
 |
| 1/03/2008 12:47 AM |
|
Thanks for your reply. I think this is the problem, but I'm not sure yet how to solve the problem. I want to set the array with a function called:
set_crc (16, 'b1111000011110000);
But the compiler tolds me, that only dynamic arrays are allowed as parameter in this context. So, I have to look for another solution. If somebody has a good idea, I would be very thankful.
Sebastian
|
|
|
|
tpylant Posts: 87 Online:
 |
| 1/03/2008 6:24 AM |
|
Here is a testcase I used:
module test;<br>
<br>
class testclass;<br>
<br> int crc_type;<br>
bit crc_polynomial[]<br>
<br>
function void set_crc(int crc_type, ref bit crc_polynomial[]);<br>
if ( crc_type != crc_polynomial.size() )<br>
begin<br>
$display("crc_type (%0d) and dimension of polynomial (%0d) does not match!", crc_type, crc_polynomial.size());<br>
$display("Not assigning any value");<br>
return;<br>
end<br>
this.crc_type = crc_type;<br>
this.crc_polynomial = new[this.crc_type+1](crc_polynomial);<br>&
nbsp; endfunction<br>
<br>
function void print();<br>
$write("type = %0d value = ", crc_type);<br>
for (int i=crc_polynomial.size()-1; i>=0; i--)<br>
$write(crc_polynomial[i]);<br>
$display();<br>
endfunction<br>
endclass<br>
<br>
testclass tc;<br>
bit poly[]<br>
<br>
initial begin<br>
tc = new;<br>
set_poly(8, 'b11110000);<br>
tc.set_crc(8, poly);<br> tc.print();<br>
end<br>
<br>
function void set_poly(int size, longint vect);<br>
poly = new[size]<br>
for (int i=0; i<size; i++)<br>
poly[i] = vect[i]<br>
$display("%0b ", vect);<br>
for (int i=poly.size()-1; i>=0; i--)<br>
$write(poly[i]);<br>
$display();<br>
endfunction<br>
<br>
endmodule
Tim
|
|
|
|
sebastian Posts: 20 Online:
 |
| 1/03/2008 7:06 AM |
|
Hi Tim,
thank you very much for your source file, I will try it immediately.
Sebastian |
|
|
|
sebastian Posts: 20 Online:
 |
| 1/08/2008 7:37 AM |
|
Hey, me again,
I have know developed a new idea, which should work, but before implementing this, I would ask you, if it can work.
I save the crc_checksum (in this example CRC16) in an array looking like this: bit Ε:0] crc_checksum ΐ]. During calculation, this sum has to be left shifted. If it would be an integer (like in C) it would be: crc_checksum = crc_checksum << 1;
Does this work with an array of this type too? The reason, why I cannot use an integer is, because I do not know, which type of CRC, it could be 8, 16, 32 or 64.
Thanks for your help! Sebastian |
|
|
|
TAM Posts: 56 Online:
 |
| 1/08/2008 12:56 PM |
|
You can do it if you are using packed arrays. Packed arrays can be read and loaded in parallel as if all their bits are concatenated into a single large vector. This code works for me in IUS 6.11 (I had to try it since I don't write code using this capability every day and I wanted to see if it actually worked).
module testit;
reg Ώ:0] Ε:0] a;
initial begin $display("Packed array testcase"); aΏ] = 8'b10; aΎ] = 8'b01; #10 $displayb ( aΏ], , aΎ] ); #10 a = a << 3; #10 $displayb ( aΏ], , aΎ] ); #100 $finish; end endmodule
|
|
|
|
TAM Posts: 56 Online:
 |
| 1/08/2008 12:59 PM |
|
| In my previous post, the omega symbol should be "[ 1" , the epsilon symbol should be "[ 7", and the Y (ypsilon?) symbol should be "[ 0". |
|
|
|
|
Posting to forums is available to community members only. Login or Register |
|
|
|
ActiveForums 3.6
|
|
|
|
 |
| |
|
|
|