Commit 120e7a0a authored by Rpi petit robot's avatar Rpi petit robot
Browse files

Merge branch 'master' of https://git.eleves.ens.fr/hackens/coupe2017 into deployPetitRobot

parents 8a27add6 183d5e12
......@@ -21,7 +21,7 @@
module init(
input CLK,
input avrReady,
input ramperActive,
input ramperActive,
output reg ARD_RESET=0,
output reg fpgaReady=0,
output reg start=0
......@@ -34,7 +34,7 @@ always @(posedge CLK) begin
timeSincePowerUp <= timeSincePowerUp+1;
end
always @(posedge timeSincePowerUp[2]) begin
always @(posedge timeSincePowerUp[4]) begin
if (timeSincePowerUp >= 32000 && ARD_RESET==0) begin //1ms
ARD_RESET=1;
fpgaReady=1;
......
......@@ -21,12 +21,12 @@
module ramper(
input CLK,
input start,
input [7:0] l, //0.1 Revolutions (0.1 revolution = 200 steps)
input [63:0] ticksDone,
input pause,
input [15:0] l, //in approx millimeters (1mm = 40 steps)
input [63:0] ticksDone,
input pause,
output reg [24:0] ticksPS = 0,
output reg ramperActive=0
);
output reg ramperActive=0
);
// invVM = 32000000/(VM en steps/s)
parameter invVM = 32000000/4000; // tick/step
......@@ -36,10 +36,10 @@ parameter invVM = 32000000/4000; // tick/step
// AM = VM/(durée de rampe en s)
// vmOverAM = 32000000 * (durée de rampe en s)
parameter vmOverAm = 4*32000000;
parameter vmOverAm = 1*32000000;
// inv32MTimesAM = 1/(32000000*AM)
parameter inv32MTimesAM = 4*32000000/4000;
parameter inv32MTimesAM = 1*32000000/4000;
reg [63:0] l_copy;
......@@ -56,7 +56,7 @@ always @(posedge CLK) begin
if (~pause) begin
if (start && ~prev_start) begin
prev_start=1;
l_copy=l*200;
l_copy=l*40;
t1=vmOverAm;
t2=invVM*l_copy;
mode = (t2<t1);
......@@ -72,17 +72,15 @@ always @(posedge CLK) begin
if (start & ramperActive) begin
timer = timer+1;
if (state==0) begin
ticksPS=timer/inv32MTimesAM;
end
if (state==1) begin
ticksPS=32000000/invVM;
end
if (state==2) begin
ticksPS=(t3-timer)/inv32MTimesAM;
end
//$display("1 %b %d %d",mode,state,timer);
if (mode) begin //Count-based
if (state==0) begin
ticksPS=timer/inv32MTimesAM+10;
end
if (state==2) begin
ticksPS=(t3-timer)/inv32MTimesAM+10;
end
if (state==0 & ticksDone>l_copy/2) begin
state=2;
t3=timer*2;
......@@ -94,6 +92,15 @@ always @(posedge CLK) begin
end
end
else begin //Timing-based
if (state==0) begin
ticksPS=timer/inv32MTimesAM;
end
if (state==1) begin
ticksPS=32000000/invVM;
end
if (state==2) begin
ticksPS=(t3-timer)/inv32MTimesAM;
end
if (timer>t1 & state==0) begin
state=1;
end
......
`timescale 1ns / 1ps
//////////////////////////////////////////////////////////////////////////////////
// Company:
// Engineer:
//
// Create Date: 19:29:10 01/11/2017
// Design Name:
// Module Name: serialIn
// Project Name:
// Target Devices:
// Tool versions:
// Description:
//
// Dependencies:
//
// Revision:
// Revision 0.01 - File Created
// Additional Comments:
//
//////////////////////////////////////////////////////////////////////////////////
module serialIn(
input CLK,
input [0:3] ardBus,
output [0:64] packetOut,
output outReady,
input inReady
);
endmodule
......@@ -20,44 +20,94 @@
//////////////////////////////////////////////////////////////////////////////////
module stepperRamp(
input CLK,
output Arduino_11, //FPGA->AVR ready
input Arduino_10, //AVR->FPGA ready
output Arduino_13, //Blinker
//AVR->FPGA bus
input Arduino_2,
input Arduino_3,
input Arduino_4,
output Arduino_11, //FPGA->AVR ready
//AVR->FPGA bus
input Arduino_2, // Data in
input Arduino_3, // Data advance
input Arduino_4, // Exec
input Arduino_5,
input Arduino_6,
input Arduino_7,
input Arduino_8,
input Arduino_9,
//Debug ports
input Arduino_22,
output Arduino_23,
//output Arduino_24,
output ARD_RESET
output wire Arduino_18, //Step 1
output wire Arduino_19, //Dir 1
output wire Arduino_20, //Step 2
output wire Arduino_21, //Dir 2
//Debug ports
output wire Arduino_13,
input Arduino_22,
output Arduino_23,
//output Arduino_24,
output ARD_RESET
);
wire start;
wire dataIn = Arduino_2;
wire dataAdvance = Arduino_3;
wire execIn = Arduino_4;
//Set step and dir pins
assign Arduino_19 = 0;
assign Arduino_20 = Arduino_18;
assign Arduino_21 = 0;
//Debug led
assign Arduino_13 = Arduino_18;
wire [7:0] ardBus={Arduino_2,Arduino_3,Arduino_4,Arduino_5,Arduino_6,Arduino_7,Arduino_8,Arduino_9};
reg [31:0] shiftRegister = 32'b0;
reg [31:0] shiftRegisterCopy;
reg prevDataAdvance = 0;
reg prevExec = 0;
reg exec=0;
always @(posedge CLK) begin
if (!prevDataAdvance && dataAdvance) begin
prevDataAdvance <= 1;
shiftRegister <= {shiftRegister[30:0], dataIn};
end
if (prevDataAdvance && !dataAdvance) begin
prevDataAdvance <= 0;
end
if (!prevExec && execIn) begin
prevExec <= 1;
shiftRegisterCopy <= shiftRegister;
exec = 1;
end
if (prevExec && !execIn) begin
prevExec <= 0;
// exec=0;
end
end
wire [15:0] regDistanceMm = shiftRegisterCopy[15:0];
assign dirL = shiftRegisterCopy[16];
assign dirR = shiftRegisterCopy[17];
wire start;
wire [24:0] ticksPS;
wire ramperActive;
wire [63:0] ticksDone;
always @(posedge Arduino_13)
$display("%b regDistanceMm %b exec %b a %b s %b ticksPS %d tickDone %d ramperActive %b", shiftRegisterCopy, regDistanceMm[7:0], exec, Arduino_13, start, ticksPS, ticksDone, ramperActive);
wire obstacle;
init init(.CLK(CLK),.avrReady(Arduino_10),.ramperActive(ramperActive),
init init(.CLK(CLK),.avrReady(exec),.ramperActive(ramperActive),
.ARD_RESET(ARD_RESET), .fpgaReady(Arduino_11), .start(start));
ramper ramper(.CLK(CLK), .start(start), .l(ardBus), .ticksDone(ticksDone), .pause(obstacle),
ramper ramper(.CLK(CLK), .start(start), .l(regDistanceMm), .ticksDone(ticksDone), .pause(0 /** debug **/),
.ticksPS(ticksPS),.ramperActive(ramperActive));
ticker ticker(.CLK(CLK), .ticksPS(ticksPS), .pause(obstacle),
.out(Arduino_13 /**debug**/),.ticksDone(ticksDone));
.out(Arduino_18 /**debug**/),.ticksDone(ticksDone));
sonarControl sonar(.CLK(CLK), .sonarEcho(Arduino_22), .sonarPing(Arduino_23),
.obstacle(obstacle /**debug**/));
.obstacle(obstacle));
endmodule
......@@ -134,7 +134,7 @@
<property xil_pn:name="Enable Message Filtering" xil_pn:value="false" xil_pn:valueState="default"/>
<property xil_pn:name="Enable Multi-Pin Wake-Up Suspend Mode spartan6" xil_pn:value="false" xil_pn:valueState="default"/>
<property xil_pn:name="Enable Multi-Threading" xil_pn:value="Off" xil_pn:valueState="default"/>
<property xil_pn:name="Enable Multi-Threading par spartan6" xil_pn:value="Off" xil_pn:valueState="default"/>
<property xil_pn:name="Enable Multi-Threading par spartan6" xil_pn:value="4" xil_pn:valueState="non-default"/>
<property xil_pn:name="Enable Outputs (Output Events)" xil_pn:value="Default (5)" xil_pn:valueState="default"/>
<property xil_pn:name="Enable Suspend/Wake Global Set/Reset spartan6" xil_pn:value="false" xil_pn:valueState="default"/>
<property xil_pn:name="Encrypt Bitstream spartan6" xil_pn:value="false" xil_pn:valueState="default"/>
......@@ -255,7 +255,7 @@
<property xil_pn:name="Perform Advanced Analysis" xil_pn:value="false" xil_pn:valueState="default"/>
<property xil_pn:name="Perform Advanced Analysis Post Trace" xil_pn:value="false" xil_pn:valueState="default"/>
<property xil_pn:name="Perform Timing-Driven Packing and Placement" xil_pn:value="false" xil_pn:valueState="default"/>
<property xil_pn:name="Place &amp; Route Effort Level (Overall)" xil_pn:value="High" xil_pn:valueState="default"/>
<property xil_pn:name="Place &amp; Route Effort Level (Overall)" xil_pn:value="Standard" xil_pn:valueState="non-default"/>
<property xil_pn:name="Place And Route Mode" xil_pn:value="Normal Place and Route" xil_pn:valueState="default"/>
<property xil_pn:name="Place MultiBoot Settings into Bitstream spartan6" xil_pn:value="false" xil_pn:valueState="default"/>
<property xil_pn:name="Placer Effort Level Map" xil_pn:value="High" xil_pn:valueState="default"/>
......@@ -309,8 +309,8 @@
<property xil_pn:name="Run for Specified Time Translate" xil_pn:value="true" xil_pn:valueState="default"/>
<property xil_pn:name="Safe Implementation" xil_pn:value="No" xil_pn:valueState="default"/>
<property xil_pn:name="Security" xil_pn:value="Enable Readback and Reconfiguration" xil_pn:valueState="default"/>
<property xil_pn:name="Selected Module Instance Name" xil_pn:value="/stepperramp_tb" xil_pn:valueState="non-default"/>
<property xil_pn:name="Selected Simulation Root Source Node Behavioral" xil_pn:value="work.stepperramp_tb" xil_pn:valueState="non-default"/>
<property xil_pn:name="Selected Module Instance Name" xil_pn:value="/stepperramp_tb/DUT/ramper" xil_pn:valueState="non-default"/>
<property xil_pn:name="Selected Simulation Root Source Node Behavioral" xil_pn:value="work.ramper" xil_pn:valueState="non-default"/>
<property xil_pn:name="Selected Simulation Root Source Node Post-Map" xil_pn:value="" xil_pn:valueState="default"/>
<property xil_pn:name="Selected Simulation Root Source Node Post-Route" xil_pn:value="" xil_pn:valueState="default"/>
<property xil_pn:name="Selected Simulation Root Source Node Post-Translate" xil_pn:value="" xil_pn:valueState="default"/>
......@@ -328,7 +328,7 @@
<property xil_pn:name="Simulator" xil_pn:value="ISim (VHDL/Verilog)" xil_pn:valueState="default"/>
<property xil_pn:name="Slice Utilization Ratio" xil_pn:value="100" xil_pn:valueState="default"/>
<property xil_pn:name="Specify 'define Macro Name and Value" xil_pn:value="" xil_pn:valueState="default"/>
<property xil_pn:name="Specify Top Level Instance Names Behavioral" xil_pn:value="work.stepperramp_tb" xil_pn:valueState="default"/>
<property xil_pn:name="Specify Top Level Instance Names Behavioral" xil_pn:value="work.ramper" xil_pn:valueState="default"/>
<property xil_pn:name="Specify Top Level Instance Names Post-Map" xil_pn:value="Default" xil_pn:valueState="default"/>
<property xil_pn:name="Specify Top Level Instance Names Post-Route" xil_pn:value="Default" xil_pn:valueState="default"/>
<property xil_pn:name="Specify Top Level Instance Names Post-Translate" xil_pn:value="Default" xil_pn:valueState="default"/>
......
-w
-g DebugBitstream:No
-g Binary:no
-g CRC:Enable
-g ConfigRate:1
-g ProgPin:PullUp
-g DonePin:PullUp
-g TckPin:PullUp
-g TdiPin:PullUp
-g TdoPin:PullUp
-g TmsPin:PullUp
-g UnusedPin:PullDown
-g UserID:0xFFFFFFFF
-g DCMShutdown:Disable
-g StartUpClk:CClk
-g DONE_cycle:4
-g GTS_cycle:5
-g GWE_cycle:6
-g LCK_cycle:NoWait
-g Security:None
-g DonePipe:Yes
-g DriveDone:No
-w
-g DebugBitstream:No
-g Binary:no
-g CRC:Enable
-g ConfigRate:1
-g ProgPin:PullUp
-g DonePin:PullUp
-g TckPin:PullUp
-g TdiPin:PullUp
-g TdoPin:PullUp
-g TmsPin:PullUp
-g UnusedPin:PullDown
-g UserID:0xFFFFFFFF
-g DCMShutdown:Disable
-g StartUpClk:CClk
-g DONE_cycle:4
-g GTS_cycle:5
-g GWE_cycle:6
-g LCK_cycle:NoWait
-g Security:None
-g DonePipe:Yes
-g DriveDone:No
-w
-g DebugBitstream:No
-g Binary:no
-g CRC:Enable
-g Reset_on_err:No
-g ConfigRate:2
-g ProgPin:PullUp
-g TckPin:PullUp
-g TdiPin:PullUp
-g TdoPin:PullUp
-g TmsPin:PullUp
-g UnusedPin:PullDown
-g UserID:0xFFFFFFFF
-g ExtMasterCclk_en:No
-g SPI_buswidth:1
-g TIMER_CFG:0xFFFF
-g multipin_wakeup:No
-g StartUpClk:CClk
-g DONE_cycle:4
-g GTS_cycle:5
-g GWE_cycle:6
-g LCK_cycle:NoWait
-g Security:None
-g DonePipe:Yes
-g DriveDone:No
-g en_sw_gsr:No
-g drive_awake:No
-g sw_clk:Startupclk
-g sw_gwe_cycle:5
-g sw_gts_cycle:4
-w
-g DebugBitstream:No
-g Binary:no
-g CRC:Enable
-g Reset_on_err:No
-g ConfigRate:2
-g ProgPin:PullUp
-g TckPin:PullUp
-g TdiPin:PullUp
-g TdoPin:PullUp
-g TmsPin:PullUp
-g UnusedPin:PullDown
-g UserID:0xFFFFFFFF
-g ExtMasterCclk_en:No
-g SPI_buswidth:1
-g TIMER_CFG:0xFFFF
-g multipin_wakeup:No
-g StartUpClk:CClk
-g DONE_cycle:4
-g GTS_cycle:5
-g GWE_cycle:6
-g LCK_cycle:NoWait
-g Security:None
-g DonePipe:Yes
-g DriveDone:No
-g en_sw_gsr:No
-g drive_awake:No
-g sw_clk:Startupclk
-g sw_gwe_cycle:5
-g sw_gts_cycle:4
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
<?xml version="1.0" encoding="UTF-8"?>
<drawing version="7">
<attr value="spartan6" name="DeviceFamilyName">
<trait delete="all:0" />
<trait editname="all:0" />
<trait edittrait="all:0" />
</attr>
<netlist>
<signal name="ARD_RESET" />
<signal name="DUO_SW1" />
<port polarity="Output" name="ARD_RESET" />
<port polarity="Input" name="DUO_SW1" />
<blockdef name="inv">
<timestamp>2000-1-1T10:10:10</timestamp>
<line x2="64" y1="-32" y2="-32" x1="0" />
<line x2="160" y1="-32" y2="-32" x1="224" />
<line x2="128" y1="-64" y2="-32" x1="64" />
<line x2="64" y1="-32" y2="0" x1="128" />
<line x2="64" y1="0" y2="-64" x1="64" />
<circle r="16" cx="144" cy="-32" />
</blockdef>
<block symbolname="inv" name="XLXI_60">
<blockpin signalname="DUO_SW1" name="I" />
<blockpin signalname="ARD_RESET" name="O" />
</block>
</netlist>
<sheet sheetnum="1" width="3520" height="2720">
<text style="fontsize:28;fontname:Arial" x="144" y="2556">Replace DUO_SW1 with a Pulldown if you want the ATmega32U4 chip to run when this circuit is loaded.</text>
<branch name="ARD_RESET">
<wire x2="656" y1="2256" y2="2256" x1="624" />
</branch>
<instance x="400" y="2288" name="XLXI_60" orien="R0" />
<branch name="DUO_SW1">
<wire x2="400" y1="2256" y2="2256" x1="368" />
</branch>
<text style="fontsize:28;fontname:Arial" x="144" y="2588">Replace DUO_SW1 with a Pullup if you want to disable the ATmega32U4 chip when this circuit is loaded.</text>
<rect width="1468" x="52" y="2220" height="472" />
<text style="fontsize:48;fontname:Arial" x="604" y="2656">Papilio DUO Reset</text>
<iomarker fontsize="28" x="656" y="2256" name="ARD_RESET" orien="R0" />
<iomarker fontsize="28" x="368" y="2256" name="DUO_SW1" orien="R180" />
</sheet>
</drawing>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<drawing version="7">
<attr value="spartan3e" name="DeviceFamilyName">
<trait delete="all:0" />
<trait editname="all:0" />
<trait edittrait="all:0" />
</attr>
<netlist>
</netlist>
<sheet sheetnum="1" width="3520" height="2720">
</sheet>
</drawing>
\ No newline at end of file
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment