EmbDev.net

Forum: FPGA, VHDL & Verilog multiplier a matrice


von Mohammad M. (mohammadmother)


Rate this post
useful
not useful
Hi every one
my working is to implement a circuit in FPGA ,i get the admittance 
matric of circuit that be multiply it into current vector(value of 
current vector changing with control signal state)
when the clock rise(posedge), elements of inverse admittance matric 
(G11,G12,G21,G22) multiply into vector of current and when the clock 
down(negedge), the vector of current be updated.
the code has been written in verilog.
the problems that ISE gives is that:

Line 29: r1 is not a constant
Line 30: y11 is not a constant
Line 31: y22 is not a constant
Line 21: Module <scircuit> ignored due to previous errors.

1
`timescale 1ns / 1ps
2
//////////////////////////////////////////////////////////////////////////////////
3
// Company: 
4
// Engineer: 
5
// 
6
// Create Date:    17:21:30 10/24/2014 
7
// Design Name: 
8
// Module Name:    scircuit 
9
// Project Name: 
10
// Target Devices: 
11
// Tool versions: 
12
// Description: 
13
//
14
// Dependencies: 
15
//
16
// Revision: 
17
// Revision 0.01 - File Created
18
// Additional Comments: 
19
//
20
//////////////////////////////////////////////////////////////////////////////////
21
module scircuit(
22
    input control,
23
    input clk,
24
    input reset,
25
    output reg [15:0] v1,v2
26
    );
27
28
reg  [15:0] r1=1'b1, G1=1'b1 , R=4'b1010, vdc=8'b100100;
29
reg signed [15:0] y11=(1/r1)+G1 ,y12=-G1 ,y21=-G1 ,y22=R+G1;
30
reg signed [15:0] yy=(1/((y11*y22)-(y12*y21)));
31
reg signed [15:0] G11=(y22/yy) ,G12=(-y12/yy) ,G21=(-y21/yy) ,G22=(y11/yy);
32
reg signed [15:0] j1=0000000000000000;
33
reg signed [15:0] j2=0000000000000000;
34
reg signed [15:0] v11,v22,i1,i2;
35
always @(posedge clk)
36
  if (reset == 1)
37
       begin     
38
          v1 <= 16'b0000000000000000;
39
    v2 <= 16'b0000000000000000;
40
       end  //end if(reset ==1)
41
   else
42
       begin
43
        i1 <=(vdc/r1)+j1;
44
        i2 <= -j1;
45
        v11 <= (G11*i1) + (G12*i2) ;
46
        v22 <= (G21*i2) + (G22*i2) ;
47
      v1 <= v11;
48
      v2 <= v22;
49
      end
50
      always @(negedge clk)
51
          case(control)
52
           1'b1:
53
            j1 <=-G1*(v1-v2);
54
         1'b0:
55
               j1 <= G1*(v1-v2);
56
                
57
   endcase
58
59
endmodule

: Edited by User
von Duke Scarring (Guest)


Rate this post
useful
not useful
Mohammad Mothermohammad wrote:
> i1 <=(vdc/r1)+j1;
> Line 29: r1 is not a constant

ISE (and I belive other synthesis tools too) support only division by 
2**n.

You can change your divisior to fullfill this constrain or use IP core 
for division or write your own code/FSM for division.

Duke

von Mohammad M. (mohammadmother)


Rate this post
useful
not useful
thanks Duke
i change my code i want to define this parameter ,as input .
when program be run the values(G11,G12,G21,G22) get take from memory
the problem is how write code to access elements from memory
 the new code is:

1
`timescale 1ns / 1ps
2
//////////////////////////////////////////////////////////////////////////////////
3
// Company: 
4
// Engineer: 
5
// 
6
// Create Date:    17:21:30 10/24/2014 
7
// Design Name: 
8
// Module Name:    scircuit 
9
// Project Name: 
10
// Target Devices: 
11
// Tool versions: 
12
// Description: 
13
//
14
// Dependencies: 
15
//
16
// Revision: 
17
// Revision 0.01 - File Created
18
// Additional Comments: 
19
//
20
//////////////////////////////////////////////////////////////////////////////////
21
module scircuit(
22
    input control,
23
    input clk,
24
    input reset,
25
    input G11,G12,G21,G22;
26
    output reg [15:0] v1,v2
27
    );
28
29
reg signed [15:0]  j1,j2;
30
reg signed [15:0] v11,v22,i1,i2;
31
always @(posedge clk)
32
  if (reset == 1)
33
       begin     
34
     v1 <= 16'b0000000000000000;
35
    v2 <= 16'b0000000000000000;
36
     end  //end if(reset ==1)
37
   else
38
       begin
39
        i1 <=(vdc/r1)+j1;
40
        i2 <= -j1;
41
        v11 <= (G11*i1) + (G12*i2) ;
42
        v22 <= (G21*i2) + (G22*i2) ;
43
      v1 <= v11;
44
      v2 <= v22;
45
      end
46
      always @(negedge clk)
47
          case(control)
48
           1'b1:
49
            j1 <=-G1*(v11-v22);
50
         1'b0:
51
              j1 <= G1*(v11-v22);
52
                
53
   endcase
54
55
endmodule

von Duke Scarring (Guest)


Rate this post
useful
not useful
Mohammad Mothermohammad wrote:
> the problem is how write code to access elements from memory
Take a look in the synthesis guide of your tool.

For Xilinx you can use the XST user guide (UG627). There you can find 
a lot of (working) coding examples.

Duke

Please log in before posting. Registration is free and takes only a minute.
Existing account
Do you have a Google/GoogleMail account? No registration required!
Log in with Google account
No account? Register here.