new testbench
authorThomas Pietrzak <thomas.pietrzak@gmail.com>
Tue, 11 Dec 2018 15:23:54 +0000 (16:23 +0100)
committerThomas Pietrzak <thomas.pietrzak@gmail.com>
Tue, 11 Dec 2018 15:23:54 +0000 (16:23 +0100)
fpga/forcefader.srcs/sim_1/new/testbench.v [new file with mode: 0644]
fpga/forcefader.v
fpga/forcefader.xpr
fpga/forcefader_ts.wcfg

diff --git a/fpga/forcefader.srcs/sim_1/new/testbench.v b/fpga/forcefader.srcs/sim_1/new/testbench.v
new file mode 100644 (file)
index 0000000..80796d1
--- /dev/null
@@ -0,0 +1,258 @@
+`timescale 1ns / 1ns
+
+module testbench(
+    );
+    /*
+    // Input
+    reg sysclk;
+    
+    //Outputs
+    wire en;
+    wire dir;
+    wire overflow;
+
+    forcefader forcefader_instance (
+      .sysclk(sysclk),
+      .input_touch(0),
+      .en(en),
+      .dir(dir),
+      .overflow(overflow),
+      .vp_in(0),
+      .vn_in(0),
+      .xa_p(0),
+      .xa_n(0)
+    );
+    */
+    
+    // Input
+    reg sysclk;
+    reg [9:0] input_pos;
+    reg [7:0] stiffness;
+    reg [9:0] endposition;
+
+    // Temp
+    wire signed [16:0] outputforce = 0;
+    
+    //Outputs
+    wire en;
+    wire dir;
+    wire overflow;
+
+    spring test_spring(
+      .position(input_pos),
+      .endposition(endposition),
+      .stiffness(stiffness),
+      .outputforce(outputforce)
+    );
+    
+    //converts force to pwm + direction
+    forceconverter forceconverter_instance(
+      .sysclk(sysclk),
+      .input_forcevalue(outputforce),
+      .output_direction(dir),
+      .output_pwm(en),
+      .output_overflow(overflow)
+    );
+
+    
+    always
+      #83 sysclk = ~sysclk;
+
+    initial begin
+      //init
+      sysclk = 0;
+      stiffness = 8'h3;
+      endposition = 10'b0111111111;
+      input_pos = 0;
+      
+      //wait
+      #100;
+      
+      //test
+      input_pos = 10'h010;
+      #10000;
+
+      input_pos = 10'h020;
+      #10000;
+
+      input_pos = 10'h030;
+      #10000;
+
+      input_pos = 10'h040;
+      #10000;
+
+      input_pos = 10'h050;
+      #10000;
+
+      input_pos = 10'h060;
+      #10000;
+
+      input_pos = 10'h070;
+      #10000;
+
+      input_pos = 10'h080;
+      #10000;
+      
+      input_pos = 10'h090;
+      #10000;
+
+      input_pos = 10'h0a0;
+      #10000;
+
+      input_pos = 10'h0b0;
+      #10000;
+
+      input_pos = 10'h0c0;
+      #10000;
+
+      input_pos = 10'h0d0;
+      #10000;
+
+      input_pos = 10'h0e0;
+      #10000;
+
+      input_pos = 10'h0f0;
+      #10000;
+
+      input_pos = 10'h100;
+      #10000;
+
+      input_pos = 10'h110;
+      #10000;
+
+      input_pos = 10'h120;
+      #10000;
+
+      input_pos = 10'h130;
+      #10000;
+
+      input_pos = 10'h140;
+      #10000;
+
+      input_pos = 10'h150;
+      #10000;
+
+      input_pos = 10'h160;
+      #10000;
+
+      input_pos = 10'h170;
+      #10000;
+
+      input_pos = 10'h180;
+      #10000;
+      
+      input_pos = 10'h190;
+      #10000;
+
+      input_pos = 10'h1a0;
+      #10000;
+
+      input_pos = 10'h1b0;
+      #10000;
+
+      input_pos = 10'h1c0;
+      #10000;
+
+      input_pos = 10'h1d0;
+      #10000;
+
+      input_pos = 10'h1e0;
+      #10000;
+
+      input_pos = 10'h1f0;
+      #10000;
+
+      input_pos = 10'h210;
+      #10000;
+
+      input_pos = 10'h220;
+      #10000;
+
+      input_pos = 10'h230;
+      #10000;
+
+      input_pos = 10'h240;
+      #10000;
+
+      input_pos = 10'h250;
+      #10000;
+
+      input_pos = 10'h260;
+      #10000;
+
+      input_pos = 10'h270;
+      #10000;
+
+      input_pos = 10'h280;
+      #10000;
+      
+      input_pos = 10'h290;
+      #10000;
+
+      input_pos = 10'h2a0;
+      #10000;
+
+      input_pos = 10'h2b0;
+      #10000;
+
+      input_pos = 10'h2c0;
+      #10000;
+
+      input_pos = 10'h2d0;
+      #10000;
+
+      input_pos = 10'h2e0;
+      #10000;
+
+      input_pos = 10'h2f0;
+      #10000;
+
+      input_pos = 10'h310;
+      #10000;
+
+      input_pos = 10'h320;
+      #100;
+
+      input_pos = 10'h330;
+      #100;
+
+      input_pos = 10'h340;
+      #100;
+
+      input_pos = 10'h350;
+      #100;
+
+      input_pos = 10'h360;
+      #100;
+
+      input_pos = 10'h370;
+      #100;
+
+      input_pos = 10'h380;
+      #100;
+      
+      input_pos = 10'h390;
+      #100;
+
+      input_pos = 10'h3a0;
+      #100;
+
+      input_pos = 10'h3b0;
+      #100;
+
+      input_pos = 10'h3c0;
+      #100;
+
+      input_pos = 10'h3d0;
+      #100;
+
+      input_pos = 10'h3e0;
+      #100;
+
+      input_pos = 10'h3f0;
+      #100;
+
+      input_pos = 10'h3ff;
+      #100;
+    end
+endmodule
index 9a8a5ca949ed377253b99b66167b0521cb61c74f..b5cbb8846c45ae49606170dd7a39a76e111c1e8c 100644 (file)
@@ -18,7 +18,10 @@ module forcefader (
   wire enable;
   reg [6:0] address_in = 7'h14;
   wire ready;
-  wire [11:0] input_pos;
+  wire [9:0] input_pos;
+  wire [15:0] data;
+  
+  assign input_pos = data[15:6];
   
   adc adc_instance (
     .daddr_in(address_in),
@@ -30,7 +33,7 @@ module forcefader (
     .vauxn4(xa_n),
     .busy_out(),
     .channel_out(),
-    .do_out(input_pos),
+    .do_out(data),
     .drdy_out(ready),
     .eoc_out(enable),
     .eos_out(),
@@ -43,7 +46,7 @@ module forcefader (
   
   //compute spring force
   spring spring_instance(
-    .position(input_pos[11:2]),
+    .position(input_pos),
     .endposition(10'b0111111111),
     .stiffness(8'b00000011),
     .outputforce(outputforce)
index d999f87be3196aed6409640dd5fd1c9d66bd2e1c..e44a6a586d8c273faa7d567b8aa0fb1b68c6f2e5 100644 (file)
@@ -32,7 +32,7 @@
     <Option Name="DSAVendor" Val="xilinx"/>
     <Option Name="DSABoardId" Val="cmod_a7-35t"/>
     <Option Name="DSANumComputeUnits" Val="60"/>
-    <Option Name="WTXSimLaunchSim" Val="58"/>
+    <Option Name="WTXSimLaunchSim" Val="84"/>
     <Option Name="WTModelSimLaunchSim" Val="0"/>
     <Option Name="WTQuestaLaunchSim" Val="0"/>
     <Option Name="WTIesLaunchSim" Val="0"/>
@@ -69,6 +69,7 @@
       </File>
       <File Path="$PSRCDIR/sources_1/new/spring.v">
         <FileInfo>
+          <Attr Name="AutoDisabled" Val="1"/>
           <Attr Name="UsedIn" Val="synthesis"/>
           <Attr Name="UsedIn" Val="implementation"/>
           <Attr Name="UsedIn" Val="simulation"/>
@@ -76,6 +77,7 @@
       </File>
       <File Path="$PPRDIR/forcefader.v">
         <FileInfo>
+          <Attr Name="UserDisabled" Val="1"/>
           <Attr Name="UsedIn" Val="synthesis"/>
           <Attr Name="UsedIn" Val="implementation"/>
           <Attr Name="UsedIn" Val="simulation"/>
@@ -83,7 +85,7 @@
       </File>
       <Config>
         <Option Name="DesignMode" Val="RTL"/>
-        <Option Name="TopModule" Val="forcefader"/>
+        <Option Name="TopModule" Val="forceconverter"/>
         <Option Name="TopAutoSet" Val="TRUE"/>
       </Config>
     </FileSet>
     <FileSet Name="adc" Type="BlockSrcs" RelSrcDir="$PSRCDIR/adc">
       <File Path="$PSRCDIR/sources_1/ip/adc/adc.xci">
         <FileInfo>
+          <Attr Name="AutoDisabled" Val="1"/>
           <Attr Name="UsedIn" Val="synthesis"/>
           <Attr Name="UsedIn" Val="implementation"/>
           <Attr Name="UsedIn" Val="simulation"/>
index d90501d7118cde46d5d5e5a6328c348af29ac6e8..873c386939934f559c31728d8495aaf8278612da 100644 (file)
    </db_ref_list>
    <zoom_setting>
       <ZoomStartTime time="0fs"></ZoomStartTime>
-      <ZoomEndTime time="14550000000001fs"></ZoomEndTime>
+      <ZoomEndTime time="294200000001fs"></ZoomEndTime>
       <Cursor1Time time="0fs"></Cursor1Time>
    </zoom_setting>
    <column_width_setting>
       <NameColumnWidth column_width="219"></NameColumnWidth>
-      <ValueColumnWidth column_width="126"></ValueColumnWidth>
+      <ValueColumnWidth column_width="110"></ValueColumnWidth>
    </column_width_setting>
-   <WVObjectSize size="7" />
+   <WVObjectSize size="12" />
    <wvobject type="group" fp_name="group25">
       <obj_property name="label">ADC</obj_property>
       <obj_property name="DisplayName">label</obj_property>
       <obj_property name="label">Force</obj_property>
       <obj_property name="DisplayName">label</obj_property>
       <obj_property name="isExpanded"></obj_property>
+      <wvobject type="array" fp_name="/testbench/stiffness">
+         <obj_property name="ElementShortName">stiffness[7:0]</obj_property>
+         <obj_property name="ObjectShortName">stiffness[7:0]</obj_property>
+      </wvobject>
+      <wvobject type="array" fp_name="/testbench/test_spring/position">
+         <obj_property name="ElementShortName">position[9:0]</obj_property>
+         <obj_property name="ObjectShortName">position[9:0]</obj_property>
+      </wvobject>
+      <wvobject type="array" fp_name="/testbench/endposition">
+         <obj_property name="ElementShortName">endposition[9:0]</obj_property>
+         <obj_property name="ObjectShortName">endposition[9:0]</obj_property>
+      </wvobject>
+      <wvobject type="array" fp_name="/testbench/test_spring/outputforce">
+         <obj_property name="ElementShortName">outputforce[16:0]</obj_property>
+         <obj_property name="ObjectShortName">outputforce[16:0]</obj_property>
+      </wvobject>
    </wvobject>
    <wvobject type="group" fp_name="group24">
       <obj_property name="label">PWM</obj_property>
       <obj_property name="DisplayName">label</obj_property>
-      <obj_property name="isExpanded"></obj_property>
+      <wvobject type="logic" fp_name="/testbench/forceconverter_instance/sysclk">
+         <obj_property name="ElementShortName">sysclk</obj_property>
+         <obj_property name="ObjectShortName">sysclk</obj_property>
+      </wvobject>
+      <wvobject type="array" fp_name="/testbench/forceconverter_instance/input_forcevalue">
+         <obj_property name="ElementShortName">input_forcevalue[16:0]</obj_property>
+         <obj_property name="ObjectShortName">input_forcevalue[16:0]</obj_property>
+      </wvobject>
+      <wvobject type="logic" fp_name="/testbench/forceconverter_instance/output_direction">
+         <obj_property name="ElementShortName">output_direction</obj_property>
+         <obj_property name="ObjectShortName">output_direction</obj_property>
+      </wvobject>
+      <wvobject type="logic" fp_name="/testbench/forceconverter_instance/output_pwm">
+         <obj_property name="ElementShortName">output_pwm</obj_property>
+         <obj_property name="ObjectShortName">output_pwm</obj_property>
+      </wvobject>
+      <wvobject type="logic" fp_name="/testbench/forceconverter_instance/output_overflow">
+         <obj_property name="ElementShortName">output_overflow</obj_property>
+         <obj_property name="ObjectShortName">output_overflow</obj_property>
+      </wvobject>
+      <wvobject type="array" fp_name="/testbench/forceconverter_instance/absforce">
+         <obj_property name="ElementShortName">absforce[15:0]</obj_property>
+         <obj_property name="ObjectShortName">absforce[15:0]</obj_property>
+      </wvobject>
+      <wvobject type="array" fp_name="/testbench/forceconverter_instance/slowclkcounter">
+         <obj_property name="ElementShortName">slowclkcounter[3:0]</obj_property>
+         <obj_property name="ObjectShortName">slowclkcounter[3:0]</obj_property>
+      </wvobject>
+      <wvobject type="logic" fp_name="/testbench/forceconverter_instance/prescale">
+         <obj_property name="ElementShortName">prescale</obj_property>
+         <obj_property name="ObjectShortName">prescale</obj_property>
+      </wvobject>
+      <wvobject type="array" fp_name="/testbench/forceconverter_instance/currentamplitude">
+         <obj_property name="ElementShortName">currentamplitude[7:0]</obj_property>
+         <obj_property name="ObjectShortName">currentamplitude[7:0]</obj_property>
+      </wvobject>
+      <wvobject type="array" fp_name="/testbench/forceconverter_instance/forcecnt">
+         <obj_property name="ElementShortName">forcecnt[7:0]</obj_property>
+         <obj_property name="ObjectShortName">forcecnt[7:0]</obj_property>
+      </wvobject>
    </wvobject>
    <wvobject type="logic" fp_name="/testbench/sysclk">
       <obj_property name="ElementShortName">sysclk</obj_property>
       <obj_property name="ObjectShortName">sysclk</obj_property>
    </wvobject>
+   <wvobject fp_name="divider23" type="divider">
+      <obj_property name="label">Force</obj_property>
+      <obj_property name="DisplayName">label</obj_property>
+   </wvobject>
+   <wvobject type="array" fp_name="/testbench/input_pos">
+      <obj_property name="ElementShortName">input_pos[9:0]</obj_property>
+      <obj_property name="ObjectShortName">input_pos[9:0]</obj_property>
+   </wvobject>
+   <wvobject type="array" fp_name="/testbench/stiffness">
+      <obj_property name="ElementShortName">stiffness[7:0]</obj_property>
+      <obj_property name="ObjectShortName">stiffness[7:0]</obj_property>
+   </wvobject>
+   <wvobject type="array" fp_name="/testbench/endposition">
+      <obj_property name="ElementShortName">endposition[9:0]</obj_property>
+      <obj_property name="ObjectShortName">endposition[9:0]</obj_property>
+   </wvobject>
+   <wvobject type="array" fp_name="/testbench/outputforce">
+      <obj_property name="ElementShortName">outputforce[16:0]</obj_property>
+      <obj_property name="ObjectShortName">outputforce[16:0]</obj_property>
+   </wvobject>
    <wvobject type="logic" fp_name="/testbench/en">
       <obj_property name="ElementShortName">en</obj_property>
       <obj_property name="ObjectShortName">en</obj_property>