[syntax=vhdl]
[VHDL]
`timescale 1ns / 1ps
//////////////////////////////////////////////////////////////////////////////////
// Company:
// Engineer:
//
// Create Date: 17:21:30 10/24/2014
// Design Name:
// Module Name: scircuit
// Project Name:
// Target Devices:
// Tool versions:
// Description:
//
// Dependencies:
//
// Revision:
// Revision 0.01 - File Created
// Additional Comments:
//
//////////////////////////////////////////////////////////////////////////////////
module scircuit(
input control,
input clk,
input reset,
inout reg [15:0] v1,v2
);
parameter r1=1, G1=1 , R=1010, vdc=1100100;
parameter y11=(1/r1)+G1 ,y12=-G1 ,y21=-G1 ,y22=R+G1;
parameter yy=1/((y11*y22)-(y12*y21));
parameter G11=y22/yy ,G12=-y12/yy ,G21=-y21/yy ,G22=y11/yy;
reg signed [15:0] j1,j2;
always @(posedge clk)
if (reset == 1)
begin
v1 <= 16'b0000000000000000;
v2 <= 16'b0000000000000000;
end //end if(reset ==1)
else
begin
i1 <=(vdc/r1)+j1;
i2 <= -j1;
v1 <= (G11*i1) + (G12*i2) ;
v2 <= (G21*i2) + (G22*i2) ;
end
always @(negedge clk)
case(control)
1'b1:
begin
j1 <=-G1*(v1-v2);
end
1'b0:
begin
j1 <= G1*(v1-v2);
end
end case
endmodule
[/VHDL][/syntax]