The Designer's Guide Community
Forum
Welcome, Guest. Please Login or Register. Please follow the Forum guidelines.
Jul 17th, 2024, 10:23am
Pages: 1
Send Topic Print
Time as variable of array. (Read 2092 times)
Streamcx
New Member
*
Offline



Posts: 3

Time as variable of array.
Sep 01st, 2010, 5:22am
 
Time as variable of array.

How can I reazlize in Verilog this abstract code:

for k=31 to 0 //loop
for t=0 to 31  //loop in loop like C, PASCAL
if (k>(31-t-1))
x[k,t]:=1
else x[k,t]:=0;

Where t is time variable. I want to compare cariable of time. I want use value of time like number of element in 1d, 2d array.
And I need to measure time in us.

Another example on not existing language:
for j=39 to 32
for t=0 to 255
if t>m y(t):=0
m:=m+32

"t" is time variable

How can I convert time variable in integer? Will this code run slow after that transform?

I want to realize this code:

Created by PSpice
B39 B38 B37 B36 B35 B34 B33 B32 B31 B30 B29 B28 B27 B26 B25 B24 B23 B22 B21 B20 B19 B18 B17 B16 B15 B14 B13 B12 B11 B10 B9 B8 B7 B6 B5 B4 B3 B2 B1 B0
     
0us    1111 1111 1000 0000 0000 0000 0000 0000 0000 0000
1us    1111 1111 1100 0000 0000 0000 0000 0000 0000 0000
2us    1111 1111 1110 0000 0000 0000 0000 0000 0000 0000  
3us    1111 1111 1111 0000 0000 0000 0000 0000 0000 0000  
4us    1111 1111 1111 1000 0000 0000 0000 0000 0000 0000
5us    1111 1111 1111 1100 0000 0000 0000 0000 0000 0000
6us    1111 1111 1111 1110 0000 0000 0000 0000 0000 0000
7us    1111 1111 1111 1111 0000 0000 0000 0000 0000 0000
8us    1111 1111 1111 1111 1000 0000 0000 0000 0000 0000
9us    1111 1111 1111 1111 1100 0000 0000 0000 0000 0000
10us   1111 1111 1111 1111 1110 0000 0000 0000 0000 0000
11us   1111 1111 1111 1111 1111 0000 0000 0000 0000 0000
12us   1111 1111 1111 1111 1111 1000 0000 0000 0000 0000
13us   1111 1111 1111 1111 1111 1100 0000 0000 0000 0000
14us   1111 1111 1111 1111 1111 1110 0000 0000 0000 0000
15us   1111 1111 1111 1111 1111 1111 0000 0000 0000 0000

16us   1111 1111 1111 1111 1111 1111 1000 0000 0000 0000
17us   0111 1111 1111 1111 1111 1111 1100 0000 0000 0000
18us   0111 1111 1111 1111 1111 1111 1110 0000 0000 0000  
19us   0111 1111 1111 1111 1111 1111 1111 0000 0000 0000  
20us   0111 1111 1111 1111 1111 1111 1111 1000 0000 0000
21us   0111 1111 1111 1111 1111 1111 1111 1100 0000 0000
22us   0111 1111 1111 1111 1111 1111 1111 1110 0000 0000
23us   0111 1111 1111 1111 1111 1111 1111 1111 0000 0000
24us   0111 1111 1111 1111 1111 1111 1111 1111 1000 0000
25us   0111 1111 1111 1111 1111 1111 1111 1111 1100 0000
26us   0111 1111 1111 1111 1111 1111 1111 1111 1110 0000
27us   0111 1111 1111 1111 1111 1111 1111 1111 1111 0000
28us   0111 1111 1111 1111 1111 1111 1111 1111 1111 1000
29us   0111 1111 1111 1111 1111 1111 1111 1111 1111 1100
30us   0111 1111 1111 1111 1111 1111 1111 1111 1111 1110
31us   0111 1111 1111 1111 1111 1111 1111 1111 1111 1111

32us   0111 1111 0111 1111 1111 1111 1111 1111 1111 1111  
33us   0111 1111 0011 1111 1111 1111 1111 1111 1111 1111
34us   0111 1111 0001 1111 1111 1111 1111 1111 1111 1111  
35us   0111 1111 0000 1111 1111 1111 1111 1111 1111 1111  
36us   0111 1111 0000 0111 1111 1111 1111 1111 1111 1111
37us   0111 1111 0000 0011 1111 1111 1111 1111 1111 1111
38us   0111 1111 0000 0001 1111 1111 1111 1111 1111 1111
39us   0111 1111 0000 0000 1111 1111 1111 1111 1111 1111
40us   0111 1111 0000 0000 0111 1111 1111 1111 1111 1111
41us   0111 1111 0000 0000 0011 1111 1111 1111 1111 1111
42us   0111 1111 0000 0000 0001 1111 1111 1111 1111 1111
43us   0111 1111 0000 0000 0000 1111 1111 1111 1111 1111
44us   0111 1111 0000 0000 0000 0111 1111 1111 1111 1111
45us   0111 1111 0000 0000 0000 0011 1111 1111 1111 1111
46us   0111 1111 0000 0000 0000 0001 1111 1111 1111 1111
47us   0111 1111 0000 0000 0000 0000 1111 1111 1111 1111                

48us   0111 1111 0000 0000 0000 0000 0111 1111 1111 1111
49us   0011 1111 0000 0000 0000 0000 0011 1111 1111 1111
50us   0011 1111 0000 0000 0000 0000 0001 1111 1111 1111  
51us   0011 1111 0000 0000 0000 0000 0000 1111 1111 1111  
52us   0011 1111 0000 0000 0000 0000 0000 0111 1111 1111
53us   0011 1111 0000 0000 0000 0000 0000 0011 1111 1111
54us   0011 1111 0000 0000 0000 0000 0000 0001 1111 1111
55us   0011 1111 0000 0000 0000 0000 0000 0000 1111 1111
56us   0011 1111 0000 0000 0000 0000 0000 0000 0111 1111
57us   0011 1111 0000 0000 0000 0000 0000 0000 0011 1111
58us   0011 1111 0000 0000 0000 0000 0000 0000 0001 1111
59us   0011 1111 0000 0000 0000 0000 0000 0000 0000 1111
60us   0011 1111 0000 0000 0000 0000 0000 0000 0000 0111
61us   0011 1111 0000 0000 0000 0000 0000 0000 0000 0011
62us   0011 1111 0000 0000 0000 0000 0000 0000 0000 0001
63us   0011 1111 0000 0000 0000 0000 0000 0000 0000 0000

64us   0011 1111 1000 0000 0000 0000 0000 0000 0000 0000
65us   0011 1111 1100 0000 0000 0000 0000 0000 0000 0000
66us   0011 1111 1110 0000 0000 0000 0000 0000 0000 0000  
67us   0011 1111 1111 0000 0000 0000 0000 0000 0000 0000  
68us   0011 1111 1111 1000 0000 0000 0000 0000 0000 0000
69us   0011 1111 1111 1100 0000 0000 0000 0000 0000 0000
70us   0011 1111 1111 1110 0000 0000 0000 0000 0000 0000
71us   0011 1111 1111 1111 0000 0000 0000 0000 0000 0000
72us   0011 1111 1111 1111 1000 0000 0000 0000 0000 0000
73us   0011 1111 1111 1111 1100 0000 0000 0000 0000 0000
74us   0011 1111 1111 1111 1110 0000 0000 0000 0000 0000
75us   0011 1111 1111 1111 1111 0000 0000 0000 0000 0000
76us   0011 1111 1111 1111 1111 1000 0000 0000 0000 0000
77us   0011 1111 1111 1111 1111 1100 0000 0000 0000 0000
78us   0011 1111 1111 1111 1111 1110 0000 0000 0000 0000
79us   0011 1111 1111 1111 1111 1111 0000 0000 0000 0000

80us   0011 1111 1111 1111 1111 1111 1000 0000 0000 0000
81us   0001 1111 1111 1111 1111 1111 11
Back to top
 
 
View Profile   IP Logged
Ari
Junior Member
**
Offline



Posts: 17
Israel
Re: Time as variable of array.
Reply #1 - Sep 30th, 2010, 11:30am
 
Code:
`define NUM_BITS 32
parameter real timer_period=1u from (0:inf];

genvar i;
integer time_int;

integer vout_int[`NUM_BIT-1:0];

@(timer(0,timer_period)) begin
  time_int=$abstime/2u;
	for (i=0;i<`NUM_BITS;i=i+1) begin
	  vout_int[i] = i< time_int ? 1 : 0;
	 end
end //timer

for (i=0;i<`NUM_BITS;i=i+1) begin
     V(vout)<+ transition(vout_int[i],0,1n);
end//for
 

Back to top
 
 
View Profile   IP Logged
Pages: 1
Send Topic Print
Copyright 2002-2024 Designer’s Guide Consulting, Inc. Designer’s Guide® is a registered trademark of Designer’s Guide Consulting, Inc. All rights reserved. Send comments or questions to editor@designers-guide.org. Consider submitting a paper or model.